CC26xx Driver Library
[gpio.h] General Purpose I/O

Functions

static uint32_t GPIO_readDio (uint32_t dioNumber)
 Reads a specific DIO. More...
 
static uint32_t GPIO_readMultiDio (uint32_t dioMask)
 Reads the input value for the specified DIOs. More...
 
static void GPIO_writeDio (uint32_t dioNumber, uint32_t value)
 Writes a value to a specific DIO. More...
 
static void GPIO_writeMultiDio (uint32_t dioMask, uint32_t bitVectoredValue)
 Writes masked data to the specified DIOs. More...
 
static void GPIO_setDio (uint32_t dioNumber)
 Sets a specific DIO to 1 (high). More...
 
static void GPIO_setMultiDio (uint32_t dioMask)
 Sets the specified DIOs to 1 (high). More...
 
static void GPIO_clearDio (uint32_t dioNumber)
 Clears a specific DIO to 0 (low). More...
 
static void GPIO_clearMultiDio (uint32_t dioMask)
 Clears the specified DIOs to 0 (low). More...
 
static void GPIO_toggleDio (uint32_t dioNumber)
 Toggles a specific DIO. More...
 
static void GPIO_toggleMultiDio (uint32_t dioMask)
 Toggles the specified DIOs. More...
 
static uint32_t GPIO_getOutputEnableDio (uint32_t dioNumber)
 Gets the output enable status of a specific DIO. More...
 
static uint32_t GPIO_getOutputEnableMultiDio (uint32_t dioMask)
 Gets the output enable setting of the specified DIOs. More...
 
static void GPIO_setOutputEnableDio (uint32_t dioNumber, uint32_t outputEnableValue)
 Sets output enable of a specific DIO. More...
 
static void GPIO_setOutputEnableMultiDio (uint32_t dioMask, uint32_t bitVectoredOutputEnable)
 Configures the output enable setting for all specified DIOs. More...
 
static uint32_t GPIO_getEventDio (uint32_t dioNumber)
 Gets the event status of a specific DIO. More...
 
static uint32_t GPIO_getEventMultiDio (uint32_t dioMask)
 Gets the event status of the specified DIOs. More...
 
static void GPIO_clearEventDio (uint32_t dioNumber)
 Clears the IO event status of a specific DIO. More...
 
static void GPIO_clearEventMultiDio (uint32_t dioMask)
 Clears the IO event status on the specified DIOs. More...
 

Detailed Description

Introduction

The GPIO module allows software to control the pins of the device directly if the IOC module has been configured to route the GPIO signal to a physical pin (called DIO). Alternatively, pins can be hardware controlled by other peripheral modules. For more information about the IOC module, how to configure physical pins, and how to select between software controlled and hardware controlled, see the IOC API.

The System CPU can access the GPIO module to read the value of any DIO of the device and if the IOC module has been configured such that one or more DIOs are GPIO controlled (software controlled) the System CPU can write these DIOs through the GPIO module.

The IOC module can also be configured to generate events on edge detection and these events can be read and cleared in the GPIO module by the System CPU.

API

The API functions can be grouped like this:

Set and get direction of DIO (output enable):

Write DIO (requires IOC to be configured for GPIO usage):

Set, clear, or toggle DIO (requires IOC to be configured for GPIO usage):

Read DIO (even if IOC is NOT configured for GPIO usage; however, the DIO must be configured for input enable in IOC):

Read or clear events (even if IOC is NOT configured for GPIO usage; however, the DIO must be configured for input enable in IOC):

The IOC API provides two functions for easy configuration of DIOs as GPIO enabled using typical settings. They also serve as examples on how to configure the IOC and GPIO modules for GPIO usage:

Function Documentation

static void GPIO_clearDio ( uint32_t  dioNumber)
inlinestatic

Clears a specific DIO to 0 (low).

Parameters
dioNumberspecifies the DIO to clear (0-31).
Returns
None
See also
GPIO_clearMultiDio(), GPIO_setDio(), GPIO_setMultiDio()
326 {
327  // Check the arguments.
328  ASSERT( dioNumberLegal( dioNumber ));
329 
330  // Clear the specified DIO.
331  HWREG( GPIO_BASE + GPIO_O_DOUTCLR31_0 ) = ( 1 << dioNumber );
332 }
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_clearEventDio ( uint32_t  dioNumber)
inlinestatic

Clears the IO event status of a specific DIO.

Parameters
dioNumberspecifies the DIO on which to clear the event status (0-31).
Returns
None
See also
GPIO_clearEventMultiDio(), GPIO_getEventDio(), GPIO_getEventMultiDio()

Referenced by IOCIntClear().

592 {
593  // Check the arguments.
594  ASSERT( dioNumberLegal( dioNumber ));
595 
596  // Clear the event status for the specified DIO.
597  HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) = ( 1 << dioNumber );
598 }
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_clearEventMultiDio ( uint32_t  dioMask)
inlinestatic

Clears the IO event status on the specified DIOs.

Parameters
dioMaskis the bit-mask representation of the DIOs on which to clear the events status. The parameter must be a bitwise OR'ed combination of the following:
Returns
None
See also
GPIO_clearEventDio(), GPIO_getEventDio(), GPIO_getEventMultiDio()
618 {
619  // Check the arguments.
620  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
621 
622  // Clear the event status for the specified DIOs.
623  HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) = dioMask;
624 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_clearMultiDio ( uint32_t  dioMask)
inlinestatic

Clears the specified DIOs to 0 (low).

Parameters
dioMaskis the bit-mask representation of the DIOs to clear. The parameter must be a bitwise OR'ed combination of the following:
Returns
None
See also
GPIO_clearDio(), GPIO_setDio(), GPIO_setMultiDio()
351 {
352  // Check the arguments.
353  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
354 
355  // Clear the DIOs.
356  HWREG( GPIO_BASE + GPIO_O_DOUTCLR31_0 ) = dioMask;
357 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73
static uint32_t GPIO_getEventDio ( uint32_t  dioNumber)
inlinestatic

Gets the event status of a specific DIO.

Parameters
dioNumberspecifies the DIO to get the event status from (0-31).
Returns
Returns the current event status on the specified DIO.
  • 0 : Non-triggered event.
  • 1 : Triggered event.
See also
GPIO_getEventMultiDio(), GPIO_clearEventDio(), GPIO_clearEventMultiDio()

Referenced by IOCIntStatus().

540 {
541  // Check the arguments.
542  ASSERT( dioNumberLegal( dioNumber ));
543 
544  // Return the event status for the specified DIO.
545  return (( HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) >> dioNumber ) & 1 );
546 }
#define ASSERT(expr)
Definition: debug.h:73
static uint32_t GPIO_getEventMultiDio ( uint32_t  dioMask)
inlinestatic

Gets the event status of the specified DIOs.

This function returns the event status for multiple DIOs. The value returned is not shifted and hence matches the corresponding dioMask bits.

Parameters
dioMaskis the bit-mask representation of the DIOs to get the event status from (0-31). The parameter must be a bitwise OR'ed combination of the following:
Returns
Returns a bit vector with the current event status corresponding to the specified DIOs.
  • 0 : Corresponding DIO has no triggered event.
  • 1 : Corresponding DIO has a triggered event.
See also
GPIO_getEventDio(), GPIO_clearEventDio(), GPIO_clearEventMultiDio()

Referenced by SysCtrlShutdownWithAbort().

571 {
572  // Check the arguments.
573  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
574 
575  // Return the event status for the specified DIO.
576  return ( HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) & dioMask );
577 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73
static uint32_t GPIO_getOutputEnableDio ( uint32_t  dioNumber)
inlinestatic

Gets the output enable status of a specific DIO.

This function returns the output enable status for the specified DIO. The DIO can be configured as either input or output under software control.

Parameters
dioNumberspecifies the DIO to get the output enable setting from (0-31).
Returns
Returns one of the enumerated data types (0 or 1):
See also
GPIO_getOutputEnableMultiDio(), GPIO_setOutputEnableDio(), GPIO_setOutputEnableMultiDio()
423 {
424  // Check the arguments.
425  ASSERT( dioNumberLegal( dioNumber ));
426 
427  // Return the output enable status for the specified DIO.
428  return (( HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) >> dioNumber ) & 1 );
429 }
#define ASSERT(expr)
Definition: debug.h:73
static uint32_t GPIO_getOutputEnableMultiDio ( uint32_t  dioMask)
inlinestatic

Gets the output enable setting of the specified DIOs.

This function returns the output enable setting for multiple DIOs. The value returned is not shifted and hence matches the corresponding dioMask bits.

Parameters
dioMaskis the bit-mask representation of the DIOs to return the output enable settings from. The parameter must be a bitwise OR'ed combination of the following:
Returns
Returns the output enable setting for multiple DIOs as a bit vector corresponding to the dioMask bits.
  • 0 : Corresponding DIO is configured with output disabled.
  • 1 : Corresponding DIO is configured with output enabled.
See also
GPIO_getOutputEnableDio(), GPIO_setOutputEnableDio(), GPIO_setOutputEnableMultiDio()
453 {
454  // Check the arguments.
455  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
456 
457  // Return the output enable value for the specified DIOs.
458  return ( HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) & dioMask );
459 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73
static uint32_t GPIO_readDio ( uint32_t  dioNumber)
inlinestatic

Reads a specific DIO.

Parameters
dioNumberspecifies the DIO to read (0-31).
Returns
Returns 0 or 1 reflecting the input value of the specified DIO.
See also
GPIO_readMultiDio(), GPIO_writeDio(), GPIO_writeMultiDio()
172 {
173  // Check the arguments.
174  ASSERT( dioNumberLegal( dioNumber ));
175 
176  // Return the input value from the specified DIO.
177  return (( HWREG( GPIO_BASE + GPIO_O_DIN31_0 ) >> dioNumber ) & 1 );
178 }
#define ASSERT(expr)
Definition: debug.h:73
static uint32_t GPIO_readMultiDio ( uint32_t  dioMask)
inlinestatic

Reads the input value for the specified DIOs.

This function returns the input value for multiple DIOs. The value returned is not shifted and hence matches the corresponding dioMask bits.

Parameters
dioMaskis the bit-mask representation of the DIOs to read. The parameter must be a bitwise OR'ed combination of the following:
Returns
Returns a bit vector reflecting the input value of the corresponding DIOs.
  • 0 : Corresponding DIO is low.
  • 1 : Corresponding DIO is high.
See also
GPIO_readDio(), GPIO_writeDio(), GPIO_writeMultiDio()
202 {
203  // Check the arguments.
204  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
205 
206  // Return the input value from the specified DIOs.
207  return ( HWREG( GPIO_BASE + GPIO_O_DIN31_0 ) & dioMask );
208 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_setDio ( uint32_t  dioNumber)
inlinestatic

Sets a specific DIO to 1 (high).

Parameters
dioNumberspecifies the DIO to set (0-31).
Returns
None
See also
GPIO_setMultiDio(), GPIO_clearDio(), GPIO_clearMultiDio()
280 {
281  // Check the arguments.
282  ASSERT( dioNumberLegal( dioNumber ));
283 
284  // Set the specified DIO.
285  HWREG( GPIO_BASE + GPIO_O_DOUTSET31_0 ) = ( 1 << dioNumber );
286 }
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_setMultiDio ( uint32_t  dioMask)
inlinestatic

Sets the specified DIOs to 1 (high).

Parameters
dioMaskis the bit-mask representation of the DIOs to set. The parameter must be a bitwise OR'ed combination of the following:
Returns
None
See also
GPIO_setDio(), GPIO_clearDio(), GPIO_clearMultiDio()
305 {
306  // Check the arguments.
307  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
308 
309  // Set the DIOs.
310  HWREG( GPIO_BASE + GPIO_O_DOUTSET31_0 ) = dioMask;
311 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_setOutputEnableDio ( uint32_t  dioNumber,
uint32_t  outputEnableValue 
)
inlinestatic

Sets output enable of a specific DIO.

This function sets the GPIO output enable bit for the specified DIO. The DIO can be configured as either input or output under software control.

Parameters
dioNumberspecifies the DIO to configure (0-31).
outputEnableValuespecifies the output enable setting of the specified DIO:
Returns
None
See also
GPIO_setOutputEnableMultiDio(), GPIO_getOutputEnableDio(), GPIO_getOutputEnableMultiDio()

Referenced by IOCPinTypeGpioInput(), and IOCPinTypeGpioOutput().

480 {
481  // Check the arguments.
482  ASSERT( dioNumberLegal( dioNumber ));
483  ASSERT(( outputEnableValue == GPIO_OUTPUT_DISABLE ) ||
484  ( outputEnableValue == GPIO_OUTPUT_ENABLE ) );
485 
486  // Update the output enable bit for the specified DIO.
487  HWREGBITW( GPIO_BASE + GPIO_O_DOE31_0, dioNumber ) = outputEnableValue;
488 }
#define GPIO_OUTPUT_ENABLE
Definition: gpio.h:151
#define ASSERT(expr)
Definition: debug.h:73
#define GPIO_OUTPUT_DISABLE
Definition: gpio.h:150
static void GPIO_setOutputEnableMultiDio ( uint32_t  dioMask,
uint32_t  bitVectoredOutputEnable 
)
inlinestatic

Configures the output enable setting for all specified DIOs.

This function configures the output enable setting for the specified DIOs. The output enable setting must be shifted so it matches the corresponding dioMask bits. The DIOs can be configured as either an input or output under software control.

Note
Note that this is a read-modify-write operation and hence not atomic.
Parameters
dioMaskis the bit-mask representation of the DIOs on which to configure the output enable setting. The parameter must be a bitwise OR'ed combination of the following:
bitVectoredOutputEnableholds the output enable setting the corresponding DIO-bits:
  • 0 : Corresponding DIO is configured with output disabled.
  • 1 : Corresponding DIO is configured with output enabled.
Returns
None
See also
GPIO_setOutputEnableDio(), GPIO_getOutputEnableDio(), GPIO_getOutputEnableMultiDio()
516 {
517  // Check the arguments.
518  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
519 
520  HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) =
521  ( HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) & ~dioMask ) |
522  ( bitVectoredOutputEnable & dioMask );
523 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_toggleDio ( uint32_t  dioNumber)
inlinestatic

Toggles a specific DIO.

Parameters
dioNumberspecifies the DIO to toggle (0-31).
Returns
None
See also
GPIO_toggleMultiDio()
372 {
373  // Check the arguments.
374  ASSERT( dioNumberLegal( dioNumber ));
375 
376  // Toggle the specified DIO.
377  HWREG( GPIO_BASE + GPIO_O_DOUTTGL31_0 ) = ( 1 << dioNumber );
378 }
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_toggleMultiDio ( uint32_t  dioMask)
inlinestatic

Toggles the specified DIOs.

Parameters
dioMaskis the bit-mask representation of the DIOs to toggle. The parameter must be a bitwise OR'ed combination of the following:
Returns
None
See also
GPIO_toggleDio()
397 {
398  // Check the arguments.
399  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
400 
401  // Toggle the DIOs.
402  HWREG( GPIO_BASE + GPIO_O_DOUTTGL31_0 ) = dioMask;
403 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_writeDio ( uint32_t  dioNumber,
uint32_t  value 
)
inlinestatic

Writes a value to a specific DIO.

Parameters
dioNumberspecifies the DIO to update (0-31).
valuespecifies the value to write
  • 0 : Logic zero (low)
  • 1 : Logic one (high)
Returns
None
See also
GPIO_writeMultiDio(), GPIO_readDio(), GPIO_readMultiDio()
226 {
227  // Check the arguments.
228  ASSERT( dioNumberLegal( dioNumber ));
229  ASSERT(( value == 0 ) || ( value == 1 ));
230 
231  // Write 0 or 1 to the byte indexed DOUT map
232  HWREGB( GPIO_BASE + dioNumber ) = value;
233 }
#define ASSERT(expr)
Definition: debug.h:73
static void GPIO_writeMultiDio ( uint32_t  dioMask,
uint32_t  bitVectoredValue 
)
inlinestatic

Writes masked data to the specified DIOs.

Enables for writing multiple bits simultaneously. The value to write must be shifted so it matches the corresponding dioMask bits.

Note
Note that this is a read-modify-write operation and hence not atomic.
Parameters
dioMaskis the bit-mask representation of the DIOs to write. The parameter must be a bitwise OR'ed combination of the following:
bitVectoredValueholds the value to be written to the corresponding DIO-bits.
Returns
None
See also
GPIO_writeDio(), GPIO_readDio(), GPIO_readMultiDio()
258 {
259  // Check the arguments.
260  ASSERT( dioMask & GPIO_DIO_ALL_MASK );
261 
262  HWREG( GPIO_BASE + GPIO_O_DOUT31_0 ) =
263  ( HWREG( GPIO_BASE + GPIO_O_DOUT31_0 ) & ~dioMask ) |
264  ( bitVectoredValue & dioMask );
265 }
#define GPIO_DIO_ALL_MASK
Definition: gpio.h:141
#define ASSERT(expr)
Definition: debug.h:73

Macro Definition Documentation

#define GPIO_DIO_0_MASK   0x00000001
#define GPIO_DIO_10_MASK   0x00000400
#define GPIO_DIO_11_MASK   0x00000800
#define GPIO_DIO_12_MASK   0x00001000
#define GPIO_DIO_13_MASK   0x00002000
#define GPIO_DIO_14_MASK   0x00004000
#define GPIO_DIO_15_MASK   0x00008000
#define GPIO_DIO_16_MASK   0x00010000
#define GPIO_DIO_17_MASK   0x00020000
#define GPIO_DIO_18_MASK   0x00040000
#define GPIO_DIO_19_MASK   0x00080000
#define GPIO_DIO_1_MASK   0x00000002
#define GPIO_DIO_20_MASK   0x00100000
#define GPIO_DIO_21_MASK   0x00200000
#define GPIO_DIO_22_MASK   0x00400000
#define GPIO_DIO_23_MASK   0x00800000
#define GPIO_DIO_24_MASK   0x01000000
#define GPIO_DIO_25_MASK   0x02000000
#define GPIO_DIO_26_MASK   0x04000000
#define GPIO_DIO_27_MASK   0x08000000
#define GPIO_DIO_28_MASK   0x10000000
#define GPIO_DIO_29_MASK   0x20000000
#define GPIO_DIO_2_MASK   0x00000004
#define GPIO_DIO_30_MASK   0x40000000
#define GPIO_DIO_31_MASK   0x80000000
#define GPIO_DIO_3_MASK   0x00000008
#define GPIO_DIO_4_MASK   0x00000010
#define GPIO_DIO_5_MASK   0x00000020
#define GPIO_DIO_6_MASK   0x00000040
#define GPIO_DIO_7_MASK   0x00000080
#define GPIO_DIO_8_MASK   0x00000100
#define GPIO_DIO_9_MASK   0x00000200
#define GPIO_OUTPUT_DISABLE   0x00000000
#define GPIO_OUTPUT_ENABLE   0x00000001