CoX Peripheral Interface(M051 Implement) V2.1.1.0
API Reference
M051 GPIO API

GPIO API Reference. More...

Collaboration diagram for M051 GPIO API:

Defines

#define GPIOSPinFunctionSet(ulFunction, eShortPin)
#define GPIOSPinIntEnable(eShortPin, ulIntType)
#define xGPIOSDirModeSet(eShortPin, ulPinIO)
#define GPIOSPinIntDisable(eShortPin)
#define GPIOSPinIntClear(eShortPin)
#define GPIOSPinRead(eShortPin)
#define GPIOSPinWrite(eShortPin, ucVal)
#define GPIOSPinToPeripheralId(eShortPin)
#define GPIOSPinToPort(eShortPin)
#define GPIOSPinToPortPin(eShortPin)
#define GPIOSPinToPin(eShortPin)
#define GPIOSPinConfigure(ePeripheralPin, eShortPin)

Functions

void GPIODirModeSet (unsigned long ulPort, unsigned long ulBit, unsigned long ulPinIO)
 Sets the direction and mode of the specified pin.
unsigned long GPIODirModeGet (unsigned long ulPort, unsigned long ulBit)
void GPIOPinIntEnable (unsigned long ulPort, unsigned long ulPins, unsigned long ulIntType)
 Sets the interrupt type and Enables interrupts for the specified pin(s).
void GPIOPinIntDisable (unsigned long ulPort, unsigned long ulPins)
 Disables interrupts for the specified pin(s).
void GPIOPinIntCallbackInit (unsigned long ulPort, unsigned long ulPin, xtEventCallback xtPortCallback)
 Init interrupts callback for the specified Port.
unsigned long GPIOPinIntStatus (unsigned long ulPort)
 Gets interrupt status for the specified GPIO port.
void GPIOPinIntClear (unsigned long ulPort, unsigned long ulPins)
 Clears the interrupt for the specified pin(s).
long GPIOPinRead (unsigned long ulPort, unsigned long ulPins)
 Reads the values present of the specified pin(s).
void GPIOPinWrite (unsigned long ulPort, unsigned long ulPins, unsigned char ucVal)
 Writes a value to the specified pin(s).
void GPIOPinDebounceEnable (unsigned long ulPort, unsigned long ulPins)
 Enable the debounce function of the specified GPIO pin(s).
void GPIOPinDebounceDisable (unsigned long ulPort, unsigned long ulPins)
 Disable the debounce function of the specified GPIO pin(s).
void GPIOPinMaskSet (unsigned long ulPort, unsigned long ulPins)
 Set GPIO port mask register of the specified GPIO pin(s).
void GPIODebounceTimeSet (unsigned long ulClockSource, unsigned long ulDebounceClk)
 Set the De-bounce sampling cycle.
long GPIODebounceTimeGet (void)
 Get the De-bounce sampling cycle.
long GPIOPortMaskGet (unsigned long ulPort)
 Get current GPIO port mask setting.
long GPIOPinPortDoutGet (unsigned long ulPort)
 Gets output data for the specified GPIO port.
void GPIOPinFunctionSet (unsigned long ulFunction, unsigned long ulPort, unsigned long ulPins)
 Initialize the multi-function pin's specified fucntion.
void GPIOPinConfigure (unsigned long ulPinConfig)
 Configures the alternate function of a GPIO pin.
unsigned long GPIOPinToPeripheralId (unsigned long ulPort, unsigned long ulPin)
 Get the GPIO Peripheral Id from a short Pin.
unsigned long GPIOPinToPort (unsigned long ulPort, unsigned long ulPin)
 Get the GPIO port from a short Pin.
unsigned long GPIOPinToPin (unsigned long ulPort, unsigned long ulPin)
 Get the GPIO pin number from a short Pin.

Detailed Description

GPIO API Reference.


Define Documentation

#define GPIOSPinFunctionSet (   ulFunction,
  eShortPin 
)

Definition at line 2328 of file xgpio.h.

#define GPIOSPinIntEnable (   eShortPin,
  ulIntType 
)

Definition at line 2331 of file xgpio.h.

#define xGPIOSDirModeSet (   eShortPin,
  ulPinIO 
)

Definition at line 2334 of file xgpio.h.

#define GPIOSPinIntDisable (   eShortPin)

Definition at line 2337 of file xgpio.h.

#define GPIOSPinIntClear (   eShortPin)

Definition at line 2340 of file xgpio.h.

#define GPIOSPinRead (   eShortPin)

Definition at line 2343 of file xgpio.h.

#define GPIOSPinWrite (   eShortPin,
  ucVal 
)

Definition at line 2346 of file xgpio.h.

#define GPIOSPinToPeripheralId (   eShortPin)

Definition at line 2349 of file xgpio.h.

#define GPIOSPinToPort (   eShortPin)

Definition at line 2352 of file xgpio.h.

#define GPIOSPinToPortPin (   eShortPin)

Definition at line 2355 of file xgpio.h.

#define GPIOSPinToPin (   eShortPin)

Definition at line 2358 of file xgpio.h.

#define GPIOSPinConfigure (   ePeripheralPin,
  eShortPin 
)

Definition at line 2361 of file xgpio.h.


Function Documentation

void GPIODirModeSet ( unsigned long  ulPort,
unsigned long  ulBit,
unsigned long  ulPinIO 
)

Sets the direction and mode of the specified pin.

Parameters:
ulPortis the base address of the GPIO port
ulBitis the bit number of a port.
ulPinIOis the pin direction and/or mode.

This function will set the specified pin(Only 1 pin) on the selected GPIO port as either an input or output under software control, or it will set the pin to be under hardware control.

The parameter ulPinIO is an enumerated data type that can be one of the following values:

  • GPIO_DIR_MODE_IN
  • GPIO_DIR_MODE_OUT
  • GPIO_DIR_MODE_QB
  • GPIO_DIR_MODE_HW

where GPIO_DIR_MODE_IN specifies that the pin will be programmed as a software controlled input, GPIO_DIR_MODE_OUT specifies that the pin will be programmed as a software controlled output,GPIO_DIR_MODE_OD specifies that the pin will be programmed as a Open-Drain.GPIO_DIR_MODE_QB specifies that the pin will be programmed as Quasi-bidirectional.

Returns:
None.

Definition at line 482 of file xgpio.c.

References GPIO_PMD, GPIO_PMD_PMD0_M, xASSERT, xGPIO_DIR_MODE_IN, xGPIO_DIR_MODE_OD, xGPIO_DIR_MODE_OUT, xGPIO_DIR_MODE_QB, and xHWREG.

Referenced by xGPIODirModeSet().

unsigned long GPIODirModeGet ( unsigned long  ulPort,
unsigned long  ulBit 
)

Gets the direction and mode of a pin.

Parameters:
ulPortis the base address of the GPIO port.
ucBitis the pin number.

This function gets the direction and control mode for a specified pin on the selected GPIO port. The pin can be configured as either an input or output under software control, or it can be under hardware control. The type of control and direction are returned as an enumerated data type.

Returns:
Returns one of the enumerated data types described for GPIODirModeSet().

Definition at line 559 of file xgpio.c.

References GPIO_PMD, xASSERT, and xHWREG.

void GPIOPinIntEnable ( unsigned long  ulPort,
unsigned long  ulPins,
unsigned long  ulIntType 
)

Sets the interrupt type and Enables interrupts for the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).
ulIntTypespecifies the type of interrupt trigger mechanism.

This function sets up the various interrupt trigger mechanisms for the specified pin(s) on the selected GPIO port.

The parameter ulIntType is an enumerated data type that can be one of the following values:

  • GPIO_FALLING_EDGE
  • GPIO_RISING_EDGE
  • GPIO_BOTH_EDGES
  • GPIO_LOW_LEVEL
  • GPIO_HIGH_LEVEL
  • GPIO_BOTH_LEVEL

where the different values describe the interrupt detection mechanism (edge or level) and the particular triggering event (falling, rising, or both edges for edge detect, low or high for level detect).

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Note:
In order to avoid any spurious interrupts, the user must ensure that the GPIO inputs remain stable for the duration of this function.
Returns:
None.

Definition at line 610 of file xgpio.c.

References GPIO_BOTH_EDGES, GPIO_FALLING_EDGE, GPIO_HIGH_LEVEL, GPIO_IEN, GPIO_IMD, GPIO_LOW_LEVEL, GPIO_RISING_EDGE, xASSERT, and xHWREG.

void GPIOPinIntDisable ( unsigned long  ulPort,
unsigned long  ulPins 
)

Disables interrupts for the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).

Masks the interrupt for the specified pin(s).

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Returns:
None.

Definition at line 652 of file xgpio.c.

References GPIO_IEN, xASSERT, and xHWREG.

void GPIOPinIntCallbackInit ( unsigned long  ulPort,
unsigned long  ulPin,
xtEventCallback  xtPortCallback 
)

Init interrupts callback for the specified Port.

Parameters:
ulPortis the base address of the GPIO port.
ulPinis the bit-packed representation of the pin.
xtPortCallbackis callback for the specified Port.

Init interrupts callback for the specified Port.

Returns:
None.

Definition at line 680 of file xgpio.c.

References tGPIOPinIntAsssign::pfnGPIOPinHandlerCallback, tGPIOPinIntAsssign::ulpinID, xASSERT, and xGPIO_INT_NUMBER.

unsigned long GPIOPinIntStatus ( unsigned long  ulPort)

Gets interrupt status for the specified GPIO port.

Parameters:
ulPortis the base address of the GPIO port.
bMaskedspecifies whether masked or raw interrupt status is returned.
Returns:
Returns a bit-packed byte, where each bit that is set identifies an active masked or raw interrupt, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. Bits 31:8 should be ignored.

Definition at line 733 of file xgpio.c.

References GPIO_ISRC, xASSERT, and xHWREG.

void GPIOPinIntClear ( unsigned long  ulPort,
unsigned long  ulPins 
)

Clears the interrupt for the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).

Clears the interrupt for the specified pin(s).

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Note:
Because there is a write buffer in the Cortex-M0 processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns:
None.

Definition at line 773 of file xgpio.c.

References GPIO_ISRC, xASSERT, and xHWREG.

long GPIOPinRead ( unsigned long  ulPort,
unsigned long  ulPins 
)

Reads the values present of the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).

The values at the specified pin(s) are read, as specified by ucPins. Values are returned for both input and output pin(s), and the value for pin(s) that are not specified by ucPins are set to 0.

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Returns:
Returns a bit-packed byte providing the state of the specified pin, where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. Any bit that is not specified by ucPins is returned as a 0. Bits 31:16 should be ignored.

Definition at line 808 of file xgpio.c.

References GPIO_PIN, xASSERT, and xHWREG.

void GPIOPinWrite ( unsigned long  ulPort,
unsigned long  ulPins,
unsigned char  ucVal 
)

Writes a value to the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).
ucValis the value to write to the pin(s).

Writes the corresponding bit values to the output pin(s) specified by ucPins. Writing to a pin configured as an input pin has no effect.

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Returns:
None.

Definition at line 840 of file xgpio.c.

References GPIO_DOUT, xASSERT, and xHWREG.

void GPIOPinDebounceEnable ( unsigned long  ulPort,
unsigned long  ulPins 
)

Enable the debounce function of the specified GPIO pin(s).

Parameters:
ulPortis the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).

Enable the corresponding bit debounce function to pin(s) specified by ucPins.

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Returns:
None.

Definition at line 873 of file xgpio.c.

References GPIO_DBEN, xASSERT, and xHWREG.

void GPIOPinDebounceDisable ( unsigned long  ulPort,
unsigned long  ulPins 
)

Disable the debounce function of the specified GPIO pin(s).

Parameters:
ulPortis the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).

Disable the corresponding bit debounce function to pin(s) specified by ucPins.

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Returns:
None.

Definition at line 905 of file xgpio.c.

References GPIO_DBEN, xASSERT, and xHWREG.

void GPIOPinMaskSet ( unsigned long  ulPort,
unsigned long  ulPins 
)

Set GPIO port mask register of the specified GPIO pin(s).

Parameters:
ulPortis the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).

Set GPIO port mask register of the specified GPIO pin(s) specified by ucPins.

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Returns:
None.

Definition at line 936 of file xgpio.c.

References GPIO_DMASK, and xHWREG.

void GPIODebounceTimeSet ( unsigned long  ulClockSource,
unsigned long  ulDebounceClk 
)

Set the De-bounce sampling cycle.

Parameters:
ulClockSourceis the De-bounce sampling clock source.
ulDebounceClkis the De-bounce sampling clock.

Set the De-bounce sampling cycle.

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Returns:
None.

Definition at line 967 of file xgpio.c.

References GPIO_DBCLKSRC_10K, GPIO_DBCLKSRC_HCLK, GPIO_DBNCECON, GPIO_DBNCECON_DBCLKSEL_M, GPIO_DBNCECON_DBCLKSRC, xASSERT, and xHWREG.

long GPIODebounceTimeGet ( void  )

Get the De-bounce sampling cycle.

Parameters:
None.
Returns:
The De-bounce sampling cycle.

Definition at line 996 of file xgpio.c.

References GPIO_DBNCECON, GPIO_DBNCECON_DBCLKSEL_M, and xHWREG.

long GPIOPortMaskGet ( unsigned long  ulPort)

Get current GPIO port mask setting.

Parameters:
ulPortis the base address of the GPIO port.
Returns:
The value of Specified GPIO port mask register.

Definition at line 1014 of file xgpio.c.

References GPIO_DBEN_DBEN_M, GPIO_DMASK, and xHWREG.

long GPIOPinPortDoutGet ( unsigned long  ulPort)

Gets output data for the specified GPIO port.

Parameters:
ulPortis the base address of the GPIO port.
Returns:
Returns a bit-packed byte, where each bit that is set identifies an active masked or raw interrupt, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on. Bits 31:16 should be ignored.

Definition at line 1035 of file xgpio.c.

References GPIO_DOUT, xASSERT, and xHWREG.

void GPIOPinFunctionSet ( unsigned long  ulFunction,
unsigned long  ulPort,
unsigned long  ulPins 
)

Initialize the multi-function pin's specified fucntion.

Parameters:
\paramulPort is the base address of the GPIO port.
ulPinsis the bit-packed representation of the pin(s).

Initialize the multi-function pin's of the specified function.

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.

Returns:
None.

Definition at line 1127 of file xgpio.c.

References GCR_GPAMFP, GCR_GPBMFP, GCR_GPCMFP, GCR_GPDMFP, GCR_GPEMFP, GPIO_FUNCTION_ACMP, GPIO_FUNCTION_ADC, GPIO_FUNCTION_CLKO, GPIO_FUNCTION_EBI, GPIO_FUNCTION_EXTINT, GPIO_FUNCTION_GPIO, GPIO_FUNCTION_I2C, GPIO_FUNCTION_PWM, GPIO_FUNCTION_SPI, GPIO_FUNCTION_TIM, GPIO_FUNCTION_UART, GPIO_PORTA_BASE, GPIO_PORTB_BASE, GPIO_PORTC_BASE, GPIO_PORTD_BASE, GPIO_PORTE_BASE, xASSERT, and xHWREG.

void GPIOPinConfigure ( unsigned long  ulPinConfig)

Configures the alternate function of a GPIO pin.

Parameters:
ulPinConfigis the pin configuration value, specified as only one of the GPIO_P??_??? values.

This function configures the pin mux that selects the peripheral function associated with a particular GPIO pin. Only one peripheral function at a time can be associated with a GPIO pin, and each peripheral function should only be associated with a single GPIO pin at a time (despite the fact that many of them can be associated with more than one GPIO pin).

Note:
None.
Returns:
None.

Definition at line 1068 of file xgpio.c.

References xASSERT, and xHWREG.

unsigned long GPIOPinToPeripheralId ( unsigned long  ulPort,
unsigned long  ulPin 
)

Get the GPIO Peripheral Id from a short Pin.

Parameters:
eShortPinis the base address of the GPIO port
Note:
For M051,all GPIO port use the some Peripheral clock.
Returns:
GPIO port code which is used by xSysCtlPeripheralEnable, xSysCtlPeripheralDisable, xSysCtlPeripheralReset.

Definition at line 336 of file xgpio.c.

References SYSCTL_PERIPH_GPIO, and xASSERT.

unsigned long GPIOPinToPort ( unsigned long  ulPort,
unsigned long  ulPin 
)

Get the GPIO port from a short Pin.

Parameters:
eShortPinis the base address of the GPIO port
Note:
None.
Returns:
GPIO port address which is used by GPIO API.

Definition at line 359 of file xgpio.c.

References xASSERT.

unsigned long GPIOPinToPin ( unsigned long  ulPort,
unsigned long  ulPin 
)

Get the GPIO pin number from a short Pin.

Parameters:
eShortPinis the base address of the GPIO port
Note:
None.
Returns:
GPIO pin number which is used by GPIO API.

Definition at line 382 of file xgpio.c.

References xASSERT.