CoX Peripheral Interface V2.1
API Reference
xGPIO API

xGPIO API Reference. More...

Collaboration diagram for xGPIO API:

Defines

#define xGPIOSPinToPeripheralId(eShortPin)
 Get the GPIO port from a Pin.
#define xGPIOSPinToPort(eShortPin)
 Get the GPIO port from a short Pin.
#define xGPIOSPinToPortPin(eShortPin)
 Get the GPIO port and Pin number from a short Pin.
#define xGPIOSPinToPin(eShortPin)
 Get the GPIO pin number from a short Pin.
#define xGPIOSPinDirModeSet(eShortPin, ulPinIO)
 Set the direction and mode of the specified pin(s).
#define xGPIOSPinIntEnable(eShortPin, ulIntType)
 Set the interrupt type and Enable interrupt for the specified pin(s).
#define xGPIOSPinIntDisable(eShortPin)
 Disables interrupts for the specified pin.
#define xGPIOSPinIntClear(eShortPin)
 Clear the interrupt for the specified pin.
#define xGPIOSPinRead(eShortPin)
 Reads the values present of the specified pin.
#define xGPIOSPinWrite(eShortPin, ucVal)
 Write a value to the specified pin.
#define xGPIOSPinTypeGPIOInput(eShortPin)
 Turn a pin to a GPIO Input pin.
#define xGPIOSPinTypeGPIOOutput(eShortPin)
 Turn a pin to a GPIO Output(push-pull) pin.
#define xGPIOSPinTypeGPIOOutputOD(eShortPin)
 Turn a pin to a GPIO Output(open drain) pin.
#define xGPIOSPinTypeGPIOOutputQB(eShortPin)
 Turn a pin to a GPIO Output(oQuasi-bidirectional) pin.
#define xSPinTypeADC(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO ADC input pin.
#define xSPinTypeCAN(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO CAN input or output pin.
#define xSPinTypeI2C(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO I2C input or output pin.
#define xSPinTypeI2S(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO I2S input or output pin.
#define xSPinTypePWM(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO PWM input or output pin.
#define xSPinTypeSPI(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO SPI input or output pin.
#define xSPinTypeTimer(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO Timer input or output pin.
#define xSPinTypeUART(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO UART input or output pin.
#define xSPinTypeACMP(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO ACMP input or output pin.
#define xSPinTypeCLKO(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO CLKO output pin.
#define xSPinTypeEXTINT(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO external interrupt pin.
#define xSPinTypeEBI(ePeripheralPin, eShortPin)
 Turn a pin to a GPIO EBI pin.

Functions

void xGPIODirModeSet (unsigned long ulPort, unsigned long ulPins, unsigned long ulPinIO)
 Set the direction and mode of the specified pin(s).
unsigned long xGPIODirModeGet (unsigned long ulPort, unsigned long ulPin)
 Get the direction and mode of a pin.
void xGPIOPinIntCallbackInit (unsigned long ulPort, unsigned long ulPin, xtEventCallback pfnCallback)
 Init the GPIO Port X Interrupt Callback function.
void xGPIOPinIntEnable (unsigned long ulPort, unsigned long ulPins, unsigned long ulIntType)
 Set the interrupt type and Enable interrupt for the specified pin(s).
void xGPIOPinIntDisable (unsigned long ulPort, unsigned long ulPins)
 Disables interrupts for the specified pin(s).
void xGPIOPinIntStatus (unsigned long ulPort)
 Get interrupt status for the specified GPIO port.
void xGPIOPinIntClear (unsigned long ulPort, unsigned long ulPins)
 Clear the interrupt for the specified pin(s).
long xGPIOPinRead (unsigned long ulPort, unsigned long ulPins)
 Reads the values present of the specified pin(s).
void xGPIOPinWrite (unsigned long ulPort, unsigned long ulPins, unsigned char ucVal)
 Write a value to the specified pin(s).
void xGPIOPinConfigure (unsigned long ulPinConfig)
 Configure the alternate function of a GPIO pin.

Detailed Description

xGPIO API Reference.

CoX Port Details

//! +--------------------------+----------------+------------------------+
//! |xGPIO API                 |       CoX      |         NUC1xx         |
//! |--------------------------|----------------|------------------------|
//! |xGPIODirModeSet           |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinToPeripheralId   |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinToPort           |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinToPin            |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinDirModeSet       |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIODirModeGet           |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOPinIntCallbackInit   |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOPinIntEnable         |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinIntEnable        |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOPinIntDisable        |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinIntDisable       |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOPinIntStatus         |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOPinIntClear          |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinIntClear         |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOPinRead              |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinRead             |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOPinWrite             |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinWrite            |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOPinConfigure         |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinTypeGPIOInput    |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinTypeGPIOOutput   |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinTypeGPIOOutputOD |  Non-Mandatory |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xGPIOSPinTypeGPIOOutputQB |  Non-Mandatory |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeADC              |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeCAN              |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeI2C              |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeI2S              |  Non-Mandatory |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypePWM              |  Non-Mandatory |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeSPI              |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeTimer            |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeUART             |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeACMP             |    Mandatory   |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeCLKO             |  Non-Mandatory |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeEXTINT           |        N       |            Y           |
//! |--------------------------|----------------|------------------------|
//! |xSPinTypeEBI              |  Non-Mandatory |            Y           |
//! +--------------------------+----------------+------------------------+
//! 

Define Documentation

#define xGPIOSPinToPeripheralId (   eShortPin)

Get the GPIO port from a Pin.

Parameters:
eShortPinis the base address of the GPIO port
Returns:
GPIO port code which is used by xSysCtlPeripheralEnable, xSysCtlPeripheralDisable, xSysCtlPeripheralReset. Details please refer to xSysCtl Peripheral ID.

Definition at line 995 of file xgpio.h.

#define xGPIOSPinToPort (   eShortPin)

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 1008 of file xgpio.h.

#define xGPIOSPinToPortPin (   eShortPin)

Get the GPIO port and Pin number 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 1022 of file xgpio.h.

#define xGPIOSPinToPin (   eShortPin)

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 1035 of file xgpio.h.

#define xGPIOSPinDirModeSet (   eShortPin,
  ulPinIO 
)

Set the direction and mode of the specified pin(s).

Parameters:
eShortPinSpecified port and pin. Details please refer to xGPIO Short Pin ID.
ulPinIOis the pin direction and/or mode. Details please refer to xGPIO Dir Mode.

This function will set the specified pin(s) 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:

Details please refer to 2.CoX Port Details.

where xGPIO_DIR_MODE_IN specifies that the pin will be programmed as a software controlled input, xGPIO_DIR_MODE_OUT specifies that the pin will be programmed as a software controlled output, and xGPIO_DIR_MODE_HW specifies that the pin will be placed under hardware control.

The pin is specified by eShortPin, which can only be one pin. Details please refer to 2.CoX Port Details.

Note:
xGPIOPadConfigSet() must also be used to configure the corresponding pad(s) in order for them to propagate the signal to/from the GPIO.
Returns:
None.

Definition at line 1070 of file xgpio.h.

#define xGPIOSPinIntEnable (   eShortPin,
  ulIntType 
)

Set the interrupt type and Enable interrupt for the specified pin(s).

Parameters:
eShortPinSpecified port and pin. Details please refer to xGPIO Short Pin ID.
ulIntTypespecifies the type of interrupt trigger mechanism. Details please refer to xGPIO Int Type.

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:

Details please refer to 2.CoX Port Details.

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 is specified by eShortPin, which can only be one pin. Details please refer to 2.CoX Port Details.

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 1197 of file xgpio.h.

#define xGPIOSPinIntDisable (   eShortPin)

Disables interrupts for the specified pin.

Parameters:
eShortPinSpecified port and pin. Details please refer to xGPIO Short Pin ID.

Mask the interrupt for the specified pin(s).

The pin is specified by eShortPin, which can only be one pin. Details please refer to 2.CoX Port Details.

Returns:
None.

Definition at line 1236 of file xgpio.h.

#define xGPIOSPinIntClear (   eShortPin)

Clear the interrupt for the specified pin.

Parameters:
eShortPinSpecified port and pin. Details please refer to xGPIO Short Pin ID.

Clear the interrupt for the specified pin.

The pin is specified by eShortPin, which can only be one pin. Details please refer to 2.CoX Port Details.

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 1308 of file xgpio.h.

#define xGPIOSPinRead (   eShortPin)

Reads the values present of the specified pin.

Parameters:
eShortPinSpecified port and pin. Details please refer to xGPIO Short Pin ID.

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

The pin is specified by eShortPin, which can only be one pin. Details please refer to 2.CoX Port Details.

Returns:
Returns the value of specified port and pin.

Definition at line 1355 of file xgpio.h.

#define xGPIOSPinWrite (   eShortPin,
  ucVal 
)

Write a value to the specified pin.

Parameters:
eShortPinSpecified port and pin. Details please refer to xGPIO Short Pin ID.
ucValis the value to write to the pin(s), 0 or 1.

Write the corresponding bit values to the output pin specified by eShortPin. Writing to a pin configured as an input pin has no effect.

The pin is specified by eShortPin, which can only be one pin. Details please refer to 2.CoX Port Details.

Returns:
None.

Definition at line 1399 of file xgpio.h.

#define xGPIOSPinTypeGPIOInput (   eShortPin)

Turn a pin to a GPIO Input pin.

Parameters:
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an GPIO Input pin device and turns the pin into a GPIO input pin.

Returns:
None.

Definition at line 1435 of file xgpio.h.

#define xGPIOSPinTypeGPIOOutput (   eShortPin)

Turn a pin to a GPIO Output(push-pull) pin.

Parameters:
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an GPIO Output pin device and turns the pin into a GPIO Output pin.

Returns:
None.

Definition at line 1450 of file xgpio.h.

#define xGPIOSPinTypeGPIOOutputOD (   eShortPin)

Turn a pin to a GPIO Output(open drain) pin.

Parameters:
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an GPIO Output pin device and turns the pin into a GPIO Output(open drain) pin.

Returns:
None.

Definition at line 1465 of file xgpio.h.

#define xGPIOSPinTypeGPIOOutputQB (   eShortPin)

Turn a pin to a GPIO Output(oQuasi-bidirectional) pin.

Parameters:
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an GPIO Output pin device and turns the pin into a GPIO Output(Quasi-bidirectional) pin.

Returns:
None.

Definition at line 1480 of file xgpio.h.

#define xSPinTypeADC (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO ADC input pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as ADC0. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an ADC function device and turns the pin into a GPIO ADC input pin.

Table shows what the ePeripheralPin and eShortPin should be, only the argument which are in the same line can be combined. For eaxmple(TI):
xSPinTypeADC(ADC0, PE7) or xSPinTypeADC(ADC1, PE6) is correct;
But xSPinTypeADC(ADC0, PE6) or xSPinTypeADC(ADC0, PE5) is error.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: ADCn         |should be: PXn          |
//! |                    |n indicate the pin      |XX indicate the GPIO    |
//! |                    |number such as          |PORT,Such as            |
//! |                    |0 1 2 3 ....            |A B C D E ...           |
//! |                    |                        |n indicate the pin      |
//! |                    |                        |number such as          |
//! |                    |                        |0 1 2 3 ....            |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    ADC0                |    PA0                 |
//! |                    |    ADC1                |    PA1                 |
//! |                    |    ADC2                |    PA2                 |
//! |                    |    ADC3                |    PA3                 |
//! |                    |    ADC4                |    PA4                 |
//! |                    |    ADC5                |    PA5                 |
//! |                    |    ADC6                |    PA6                 |
//! |                    |    ADC7                |    PA7                 |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1528 of file xgpio.h.

#define xSPinTypeCAN (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO CAN input or output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as CAN0RX. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as a CAN function and turns the pin into a GPIO CAN input or output pin.

Table shows what the ePeripheralPin and eShortPin should be,only the argument which are in the same line can be combined.For eaxmple(TI):
xSPinTypeCAN(CAN0RX, PA4) or xSPinTypeCAN(CAN0RX, PB4) is correct;
But xSPinTypeCAN(CAN0RX, PA5) or xSPinTypeCAN(CAN0RX, PF0) is error.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: CANnRX       |should be: PXn          |
//! |                    |or CANnTX               |XX indicate the GPIO    |
//! |                    |n indicate the pin      |PORT,Such as            |
//! |                    |number such as          |A B C D E ...           |
//! |                    |0 1 2 3 ....            |n indicate the pin      |
//! |                    |                        |number such as          |
//! |                    |                        |0 1 2 3 ....            |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    CAN0RX              |    PD6                 |
//! |                    |    CAN0TX              |    PD7                 |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1570 of file xgpio.h.

#define xSPinTypeI2C (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO I2C input or output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an I2C function device and turns the pin into a GPIO I2C input or output pin.

Table shows what the ePeripheralPin and eShortPin should be,only the argument which are in the same line can be combined.For eaxmple(TI):
xSPinTypeI2C(CAN0RX, PA4) or xSPinTypeI2C(CAN0RX, PB4) is correct;
But xSPinTypeI2C(CAN0RX, PA5) or xSPinTypeI2C(CAN0RX, PF0) is error.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: I2CnSCK      |should be: PXn          |
//! |                    |or I2CnSDA              |XX indicate the GPIO    |
//! |                    |n indicate the pin      |PORT,Such as            |
//! |                    |number such as          |A B C D E ...           |
//! |                    |0 1 2 3 ....            |n indicate the pin      |
//! |                    |                        |number such as          |
//! |                    |                        |0 1 2 3 ....            |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    I2C0SCK             |    PA9                 |
//! |                    |    I2C0SDA             |    PA8                 |
//! |                    |    I2C1SCK             |    PA11                |
//! |                    |    I2C1SDA             |    PA10                |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1614 of file xgpio.h.

#define xSPinTypeI2S (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO I2S input or output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an I2S function device and turns the pin into a GPIO I2S input or output pin.

Table shows what the ePeripheralPin and eShortPin should be,only the argument which are in the same line can be combined.For eaxmple(TI):
xSPinTypeI2S(I2S0RXSD, PA2) or xSPinTypeI2S(I2S0RXSD, PD4) is correct;
But xSPinTypeI2S(I2S0RXSD, PD1) or xSPinTypeI2S(I2S0RXWS, PA2) is error.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: I2SnRXSCK,   |should be: PXn          |
//! |                    |I2SnRXMCLK,I2S0RXSD,    |XX indicate the GPIO    |
//! |                    |I2S0RXWS,I2S0TXSCK,     |PORT,Such as            |
//! |                    |I2S0TXMCLK,I2S0TXSD,    |A B C D E ...           |
//! |                    |or I2S0TXWS.            |n indicate the pin      |
//! |                    |n indicate the pin      |number such as          |
//! |                    |number such as          |0 1 2 3 ....            |
//! |                    |0 1 2 3 ....            |                        |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    I2S0RXMCLK          |    PA15                |
//! |                    |    I2S0RXSCK           |    PC1                 |
//! |                    |    I2S0RXSD            |    PC2                 |
//! |                    |    I2S0RXWS            |    PC0                 |
//! |                    |    I2S0TXMCLK          |    PA15                |
//! |                    |    I2S0TXSCK           |    PC1                 |
//! |                    |    I2S0TXSD            |    PC3                 |
//! |                    |    I2S0TXWS            |    PC0                 |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1663 of file xgpio.h.

#define xSPinTypePWM (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO PWM input or output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as a PWM function and turns the pin into a GPIO PWM input or output pin.

Table shows what the ePeripheralPin and eShortPin should be,only the argument which are in the same line can be combined.For eaxmple(TI):
xSPinTypePWM(PWM0, PD0) or xSPinTypePWM(PWM0, PJ0) is correct;
But xSPinTypePWM(PWM0, PD1) or xSPinTypePWM(PWM0, PD2) is error.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: PWMn,        |should be: PXn          |
//! |                    |n indicate the pin      |XX indicate the GPIO    |
//! |                    |number such as          |PORT,Such as            |
//! |                    |0 1 2 3 ....            |A B C D E ...           |
//! |                    |                        |n indicate the pin      |
//! |                    |                        |number such as          |
//! |                    |                        |0 1 2 3 ....            |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    PWM0                |    PA12                |
//! |                    |    PWM1                |    PA13                |
//! |                    |    PWM2                |    PA14                |
//! |                    |    PWM3                |    PA15                |
//! |                    |    PWM4                |    PB11                |
//! |                    |    PWM5                |    PE5                 |
//! |                    |    PWM6                |    PE0                 |
//! |                    |    PWM7                |    PE1                 |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1711 of file xgpio.h.

#define xSPinTypeSPI (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO SPI input or output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as a SPI function and turns the pin into a GPIO SPI input or output pin.

Table shows what the ePeripheralPin and eShortPin should be,only the argument which are in the same line can be combined.For eaxmple(TI):
xSPinTypeSPI(SPI0CLK, PA2) or xSPinTypeSPI(SPI0MOSI, PA5) is correct;
But xSPinTypeSPI(SPI0CLK, PA5) or xSPinTypeSPI(SPI0CLK, PA4) is error.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: SPInCLK,     |should be: PXn          |
//! |                    |SPInMISO, SPInMOSI,     |XX indicate the GPIO    |
//! |                    |or SPInCS,              |PORT,Such as            |
//! |                    |n indicate the pin      |A B C D E ...           |
//! |                    |number such as          |n indicate the pin      |
//! |                    |0 1 2 3 ....            |number such as          |
//! |                    |                        |0 1 2 3 ....            |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    SPI0CLK             |    PC1                 |
//! |                    |    SPI0MOSI            |    PC5,PC3             |
//! |                    |    SPI0MISO            |    PC4,PC2             |
//! |                    |    SPI0CS              |    PC0,PB10            |
//! |                    |    SPI1CLK             |    PC9                 |
//! |                    |    SPI1MOSI            |    PC13,PC11           |
//! |                    |    SPI1MISO            |    PC12,PC10           |
//! |                    |    SPI1CS              |    PB9,PC8             |
//! |                    |    SPI2CLK             |    PD1                 |
//! |                    |    SPI2MOSI            |    PD3,PD5             |
//! |                    |    SPI2MISO            |    PD2,PD4             |
//! |                    |    SPI2CS              |    PA7,PD0             |
//! |                    |    SPI3CLK             |    PD9                 |
//! |                    |    SPI3MOSI            |    PD11,PD13           |
//! |                    |    SPI3MISO            |    PD10,PD12           |
//! |                    |    SPI3CS              |    PB14,PD8            |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1767 of file xgpio.h.

#define xSPinTypeTimer (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO Timer input or output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as a Timer function and turns the pin into a GPIO Timer input or output pin.

Table shows what the ePeripheralPin and eShortPin should be,only the argument which are in the same line can be combined.For eaxmple(TI):
xSPinTypeTimer(TIMCCP0, PD3) or xSPinTypeTimer(TIMCCP0, PJ7) is correct;
But xSPinTypeTimer(TIMCCP0, PC5) or xSPinTypeTimer(TIMCCP0, PB6) is error.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: TIMCCPn,     |should be: PXn          |
//! |                    |n indicate the pin      |XX indicate the GPIO    |
//! |                    |number such as          |PORT,Such as            |
//! |                    |0 1 2 3 ....            |A B C D E ...           |
//! |                    |                        |n indicate the pin      |
//! |                    |                        |number such as          |
//! |                    |                        |0 1 2 3 ....            |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    TIMCCP0             |    PB8                 |
//! |                    |    TIMCCP1             |    PB9                 |
//! |                    |    TIMCCP2             |    PB10                |
//! |                    |    TIMCCP3             |    PB11                |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1811 of file xgpio.h.

#define xSPinTypeUART (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO UART input or output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as a UART function and turns the pin into a GPIO UART input or output pin.

Table shows what the ePeripheralPin and eShortPin should be,only the argument which are in the same line can be combined.For eaxmple(TI):
xSPinTypeUART(UART0RX, PA0) or xSPinTypeUART(UART0TX, PA1) is correct;
But xSPinTypeUART(UART0RX, PA1) or xSPinTypeUART(UART0RX, PE6) is error.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: UARTnRX,     |should be: PXn          |
//! |                    |UARTnTX, UARTnCTS,      |XX indicate the GPIO    |
//! |                    |......,                 |PORT,Such as            |
//! |                    |n indicate the pin      |A B C D E ...           |
//! |                    |number such as          |n indicate the pin      |
//! |                    |0 1 2 3 ....            |number such as          |
//! |                    |                        |0 1 2 3 ....            |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    UART0RX             |    PB0                 |
//! |                    |    UART0TX             |    PB1                 |
//! |                    |    UART0RTS            |    PB2                 |
//! |                    |    UART0CTS            |    PB3                 |
//! |                    |    UART1CTS            |    PB7                 |
//! |                    |    UART1RTS            |    PB6                 |
//! |                    |    UART1RX             |    PB4                 |
//! |                    |    UART1TX             |    PB5                 |
//! |                    |    UART2RX             |    PD14                |
//! |                    |    UART2TX             |    PD15                |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1861 of file xgpio.h.

#define xSPinTypeACMP (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO ACMP input or output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an ACMP function and turns the pin into a GPIO ACMP input or output pin.

//! +--------------------+------------------------+------------------------+
//! |    manufacturer    |ePeripheralPin          |eShortPin               |
//! |--------------------|------------------------|------------------------|
//! |    CoX             |This parameter is a     |This parameter is a     |
//! |                    |mandatory.The mandatory |mandatory. the mandatory|
//! |                    |is the format of        |is the format of        |
//! |                    |Variable naming.So it   |Variable naming.So it   |
//! |                    |should be: CMPnN,       |should be: PXn          |
//! |                    |CMPnO or CMPnP          |XX indicate the GPIO    |
//! |                    |n indicate the pin      |PORT,Such as            |
//! |                    |number such as          |A B C D E ...           |
//! |                    |0 1 2 3 ....            |n indicate the pin      |
//! |                    |                        |number such as          |
//! |                    |                        |0 1 2 3 ....            |
//! |--------------------|------------------------|------------------------|
//! |       NUC1xx       |    CMP0P               |    PC6                 |
//! |                    |    CMP0N               |    PC7                 |
//! |                    |    CMP0O               |    PB12                |
//! |                    |    CMP1P               |    PC14                |
//! |                    |    CMP1N               |    PC15                |
//! |                    |    CMP1O               |    PB13                |
//! |--------------------|------------------------|------------------------|
//! 
Returns:
None.

Definition at line 1903 of file xgpio.h.

#define xSPinTypeCLKO (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO CLKO output pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as a CLKO function and turns the pin into a GPIO CLKO output pin.

Returns:
None.

Definition at line 1920 of file xgpio.h.

#define xSPinTypeEXTINT (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO external interrupt pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an GPIO interrupt function and turns the pin into a GPIO external interrupt pin.

Returns:
None.

Definition at line 1937 of file xgpio.h.

#define xSPinTypeEBI (   ePeripheralPin,
  eShortPin 
)

Turn a pin to a GPIO EBI pin.

Parameters:
ePeripheralPinis the GPIO Peripheral name such as I2C0SDA. Details please refer to xGPIO Pin Config.
eShortPinis the GPIO short pin name such as PA0. Details please refer to xGPIO Short Pin ID.

This function configures a pin for use as an GPIO EBI function and turns the pin into a GPIO EBI pin.

Returns:
None.

Definition at line 1954 of file xgpio.h.


Function Documentation

void xGPIODirModeSet ( unsigned long  ulPort,
unsigned long  ulPins,
unsigned long  ulPinIO 
)

Set the direction and mode of the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port Details please refer to xLowLayer Peripheral Memmap.
ulPinsis the bit-packed representation of the pin(s). Details please refer to xGPIO General Pin ID.
ulPinIOis the pin direction and/or mode. Details please refer to xGPIO Dir Mode.

This function will set the specified pin(s) 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:

Details please refer to 2.CoX Port Details.

Where xGPIO_DIR_MODE_IN specifies that the pin will be programmed as a software controlled input, xGPIO_DIR_MODE_OUT specifies that the pin will be programmed as a software controlled output, and xGPIO_DIR_MODE_HW specifies that the pin will be placed under hardware control.

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.

Details please refer to 2.CoX Port Details.

Note:
xGPIOPadConfigSet() must also be used to configure the corresponding pad(s) in order for them to propagate the signal to/from the GPIO.
Returns:
None.
unsigned long xGPIODirModeGet ( unsigned long  ulPort,
unsigned long  ulPin 
)

Get the direction and mode of a pin.

Parameters:
ulPortis the base address of the GPIO port Details please refer to xLowLayer Peripheral Memmap.
ulPinis the bit-packed representation of the pin. Details please refer to xGPIO General Pin ID.

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.

The pin 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.

Details please refer to 2.CoX Port Details.

Returns:
Returns one of the enumerated data types described for xGPIODirModeSet().Details please refer to 2.CoX Port Details.
void xGPIOPinIntCallbackInit ( unsigned long  ulPort,
unsigned long  ulPin,
xtEventCallback  pfnCallback 
)

Init the GPIO Port X Interrupt Callback function.

Parameters:
ulPortis the base address of the GPIO port. Details please refer to xLowLayer Peripheral Memmap.
ulPinis the bit-packed representation of the pin. Details please refer to xGPIO General Pin ID.
pfnCallbackis the callback function. Details please refer to xLowLayer Types.

When there is any pins interrupt occrus, Interrupt Handler will call the callback function.

param of pfnCallback

  • pvCBData not used, always 0.
  • ulEvent not used, always 0.
  • ulMsgParam is pins which have an event. Details please refer to 2.CoX Port Details.
  • pvMsgData not used, always 0.
Returns:
None.
void xGPIOPinIntEnable ( unsigned long  ulPort,
unsigned long  ulPins,
unsigned long  ulIntType 
)

Set the interrupt type and Enable interrupt for the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port Details please refer to xLowLayer Peripheral Memmap.
ulPinsis the bit-packed representation of the pin(s). Details please refer to xGPIO General Pin ID.
ulIntTypespecifies the type of interrupt trigger mechanism. Details please refer to xGPIO Int Type.

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:

Details please refer to 2.CoX Port Details.

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.

Details please refer to 2.CoX Port Details.

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.
void xGPIOPinIntDisable ( unsigned long  ulPort,
unsigned long  ulPins 
)

Disables interrupts for the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port Details please refer to xLowLayer Peripheral Memmap.
ulPinsis the bit-packed representation of the pin(s). Details please refer to xGPIO General Pin ID.

Mask 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.

Details please refer to 2.CoX Port Details.

Returns:
None.
void xGPIOPinIntStatus ( unsigned long  ulPort)

Get interrupt status for the specified GPIO port.

Parameters:
ulPortis the base address of the GPIO port. Details please refer to xLowLayer Peripheral Memmap.
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.
void xGPIOPinIntClear ( unsigned long  ulPort,
unsigned long  ulPins 
)

Clear the interrupt for the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port Details please refer to xLowLayer Peripheral Memmap.
ulPinsis the bit-packed representation of the pin(s). Details please refer to xGPIO General Pin ID.

Clear 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.

Details please refer to 2.CoX Port Details.

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.
long xGPIOPinRead ( unsigned long  ulPort,
unsigned long  ulPins 
)

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

Parameters:
ulPortis the base address of the GPIO port Details please refer to xLowLayer Peripheral Memmap.
ulPinsis the bit-packed representation of the pin(s). Details please refer to xGPIO General Pin ID.

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.

Details please refer to 2.CoX Port Details.

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:8 should be ignored.
void xGPIOPinWrite ( unsigned long  ulPort,
unsigned long  ulPins,
unsigned char  ucVal 
)

Write a value to the specified pin(s).

Parameters:
ulPortis the base address of the GPIO port Details please refer to xLowLayer Peripheral Memmap.
ulPinsis the bit-packed representation of the pin(s). Details please refer to xGPIO General Pin ID.
ucValis the value to write to the pin(s), 0 or 1.

Write 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.

Details please refer to 2.CoX Port Details.

Returns:
None.
void xGPIOPinConfigure ( unsigned long  ulPinConfig)

Configure 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:
This function is only valid on Tempest-class devices.
Returns:
None.