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

Functions

static uint32_t GPIO_readDio (uint32_t dioNumber)
 Reads a specific DIO. More...
 
static void GPIO_writeDio (uint32_t dioNumber, uint32_t value)
 Writes a value to a specific DIO. More...
 
static void GPIO_setDio (uint32_t dioNumber)
 Sets a specific DIO to 1 (high). More...
 
static void GPIO_clearDio (uint32_t dioNumber)
 Clears a specific DIO to 0 (low). More...
 
static void GPIO_toggleDio (uint32_t dioNumber)
 Toggles a specific DIO. More...
 
static uint32_t GPIO_getOutputEnableDio (uint32_t dioNumber)
 Gets the output enable status of a specific DIO. More...
 
static void GPIO_setOutputEnableDio (uint32_t dioNumber, uint32_t outputEnableValue)
 Sets output enable of a specific DIO. More...
 
static uint32_t GPIO_getEventDio (uint32_t dioNumber)
 Gets the event status of a specific DIO. More...
 
static void GPIO_clearEventDio (uint32_t dioNumber)
 Clears the IO event status of a specific DIO. 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

§ GPIO_clearDio()

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_setDio()
193 {
194  GPIO_writeDio(dioNumber, 0);
195 }
static void GPIO_writeDio(uint32_t dioNumber, uint32_t value)
Writes a value to a specific DIO.
Definition: gpio.h:153
Here is the call graph for this function:

§ GPIO_clearEventDio()

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_getEventDio()

Referenced by IOCIntClear().

307 {
308  // Check the arguments.
309  ASSERT( dioNumberLegal( dioNumber ));
310 
311  // Clear the event status for the specified DIO.
312  HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) = ( 1 << dioNumber );
313 }
#define ASSERT(expr)
Definition: debug.h:71

§ GPIO_getEventDio()

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_clearEventDio()

Referenced by IOCIntStatus(), and SysCtrlShutdownWithAbort().

286 {
287  // Check the arguments.
288  ASSERT( dioNumberLegal( dioNumber ));
289 
290  // Return the event status for the specified DIO.
291  return (( HWREG( GPIO_BASE + GPIO_O_EVFLAGS31_0 ) >> dioNumber ) & 1 );
292 }
#define ASSERT(expr)
Definition: debug.h:71

§ GPIO_getOutputEnableDio()

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_setOutputEnableDio()
234 {
235  // Check the arguments.
236  ASSERT( dioNumberLegal( dioNumber ));
237 
238  // Return the output enable status for the specified DIO.
239  return (( HWREG( GPIO_BASE + GPIO_O_DOE31_0 ) >> dioNumber ) & 1 );
240 }
#define ASSERT(expr)
Definition: debug.h:71

§ GPIO_readDio()

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_writeDio()
130 {
131  // Check the arguments.
132  ASSERT( dioNumberLegal( dioNumber ));
133 
134  // Return the input value from the specified DIO.
135  return (( HWREG( GPIO_BASE + GPIO_O_DIN31_0 ) >> dioNumber ) & 1 );
136 }
#define ASSERT(expr)
Definition: debug.h:71

§ GPIO_setDio()

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_clearDio()
176 {
177  GPIO_writeDio(dioNumber, 1);
178 }
static void GPIO_writeDio(uint32_t dioNumber, uint32_t value)
Writes a value to a specific DIO.
Definition: gpio.h:153
Here is the call graph for this function:

§ GPIO_setOutputEnableDio()

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_getOutputEnableDio()

Referenced by IOCPinTypeGpioInput(), and IOCPinTypeGpioOutput().

261 {
262  // Check the arguments.
263  ASSERT( dioNumberLegal( dioNumber ));
264  ASSERT(( outputEnableValue == GPIO_OUTPUT_DISABLE ) ||
265  ( outputEnableValue == GPIO_OUTPUT_ENABLE ) );
266 
267  // Update the output enable bit for the specified DIO.
268  HWREGBITW( GPIO_BASE + GPIO_O_DOE31_0, dioNumber ) = outputEnableValue;
269 }
#define GPIO_OUTPUT_ENABLE
Definition: gpio.h:109
#define ASSERT(expr)
Definition: debug.h:71
#define GPIO_OUTPUT_DISABLE
Definition: gpio.h:108

§ GPIO_toggleDio()

static void GPIO_toggleDio ( uint32_t  dioNumber)
inlinestatic

Toggles a specific DIO.

Parameters
dioNumberspecifies the DIO to toggle (0-31).
Returns
None
208 {
209  // Check the arguments.
210  ASSERT( dioNumberLegal( dioNumber ));
211 
212  // Toggle the specified DIO.
213  HWREG( GPIO_BASE + GPIO_O_DOUTTGL31_0 ) = ( 1 << dioNumber );
214 }
#define ASSERT(expr)
Definition: debug.h:71

§ GPIO_writeDio()

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_readDio()

Referenced by GPIO_clearDio(), and GPIO_setDio().

154 {
155  // Check the arguments.
156  ASSERT( dioNumberLegal( dioNumber ));
157  ASSERT(( value == 0 ) || ( value == 1 ));
158 
159  // Write 0 or 1 to the byte indexed DOUT map
160  HWREGB( GPIO_BASE + dioNumber ) = value;
161 }
#define ASSERT(expr)
Definition: debug.h:71

Macro Definition Documentation

§ GPIO_OUTPUT_DISABLE

#define GPIO_OUTPUT_DISABLE   0x00000000

§ GPIO_OUTPUT_ENABLE

#define GPIO_OUTPUT_ENABLE   0x00000001