XMC Peripheral Library for XMC4000 Family
General Purpose Input Output (GPIO)

Data Structures

struct  XMC_GPIO_CONFIG_t
 
struct  XMC_GPIO_PORT_t
 

Enumerations

enum  XMC_GPIO_HWCTRL_t
 
enum  XMC_GPIO_MODE_t
 
enum  XMC_GPIO_OUTPUT_LEVEL_t
 
enum  XMC_GPIO_OUTPUT_STRENGTH_t
 

Functions

void XMC_GPIO_DisableDigitalInput (XMC_GPIO_PORT_t *const port, const uint8_t pin)
 
void XMC_GPIO_DisablePowerSaveMode (XMC_GPIO_PORT_t *const port, const uint8_t pin)
 
void XMC_GPIO_EnableDigitalInput (XMC_GPIO_PORT_t *const port, const uint8_t pin)
 
void XMC_GPIO_EnablePowerSaveMode (XMC_GPIO_PORT_t *const port, const uint8_t pin)
 
uint32_t XMC_GPIO_GetInput (XMC_GPIO_PORT_t *const port, const uint8_t pin)
 
void XMC_GPIO_Init (XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_CONFIG_t *const config)
 
void XMC_GPIO_SetHardwareControl (XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_HWCTRL_t hwctrl)
 
void XMC_GPIO_SetMode (XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_MODE_t mode)
 
void XMC_GPIO_SetOutputHigh (XMC_GPIO_PORT_t *const port, const uint8_t pin)
 
void XMC_GPIO_SetOutputLevel (XMC_GPIO_PORT_t *const port, const uint8_t pin, const XMC_GPIO_OUTPUT_LEVEL_t level)
 
void XMC_GPIO_SetOutputLow (XMC_GPIO_PORT_t *const port, const uint8_t pin)
 
void XMC_GPIO_SetOutputStrength (XMC_GPIO_PORT_t *const port, const uint8_t pin, XMC_GPIO_OUTPUT_STRENGTH_t strength)
 
void XMC_GPIO_ToggleOutput (XMC_GPIO_PORT_t *const port, const uint8_t pin)
 

Detailed Description

GPIO driver provide a generic and very flexible software interface for all standard digital I/O port pins. Each port slice has individual interfaces for the operation as General Purpose I/O and it further provides the connectivity to the on-chip periphery and the control for the pad characteristics.

The driver is divided into Input and Output mode.

Input mode features:

  1. Configuration structure XMC_GPIO_CONFIG_t and initialization function XMC_GPIO_Init()
  2. Allows the selection of weak pull-up or pull-down device. Configuration structure XMC_GPIO_MODE_t and function XMC_GPIO_SetMode()

Output mode features:

  1. Allows the selection of push pull/open drain and Alternate output. Configuration structure XMC_GPIO_MODE_t and function XMC_GPIO_SetMode()
  2. Allows the selection of pad driver strength. Configuration structure XMC_GPIO_OUTPUT_STRENGTH_t and function XMC_GPIO_SetOutputStrength()
  3. Allows the selection of initial output level. Configuration structure XMC_GPIO_OUTPUT_LEVEL_t and function XMC_GPIO_SetOutputLevel()

Enumeration Type Documentation

◆ XMC_GPIO_HWCTRL_t

Defines direct hardware control characteristics of the pin . Use type XMC_GPIO_HWCTRL_t for this enum.

Enumerator
XMC_GPIO_HWCTRL_DISABLED 

Software control only

XMC_GPIO_HWCTRL_PERIPHERAL1 

HWI0/HWO0 control path can override the software configuration

XMC_GPIO_HWCTRL_PERIPHERAL2 

HWI1/HWO1 control path can override the software configuration

◆ XMC_GPIO_MODE_t

Defines the direction and characteristics of a pin. Use type XMC_GPIO_MODE_t for this enum. For the operation with alternate functions, the port pins are directly connected to input or output functions of the on-chip periphery.

Enumerator
XMC_GPIO_MODE_INPUT_TRISTATE 

No internal pull device active

XMC_GPIO_MODE_INPUT_PULL_DOWN 

Internal pull-down device active

XMC_GPIO_MODE_INPUT_PULL_UP 

Internal pull-up device active

XMC_GPIO_MODE_INPUT_SAMPLING 

No internal pull device active;Pn_OUTx continuously samples the input value

XMC_GPIO_MODE_INPUT_INVERTED_TRISTATE 

Inverted no internal pull device active

XMC_GPIO_MODE_INPUT_INVERTED_PULL_DOWN 

Inverted internal pull-down device active

XMC_GPIO_MODE_INPUT_INVERTED_PULL_UP 

Inverted internal pull-up device active

XMC_GPIO_MODE_INPUT_INVERTED_SAMPLING 

Inverted no internal pull device active; Pn_OUTx continuously samples the input value

XMC_GPIO_MODE_OUTPUT_PUSH_PULL 

Push-pull general-purpose output

XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN 

Open-drain general-purpose output

XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1 

Push-pull alternate output function 1

XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2 

Push-pull alternate output function 2

XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT3 

Push-pull alternate output function 3

XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT4 

Push-pull alternate output function 4

XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT1 

Open drain alternate output function 1

XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2 

Open drain alternate output function 2

XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT3 

Open drain alternate output function 3

XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT4 

Open drain alternate output function 4

◆ XMC_GPIO_OUTPUT_LEVEL_t

Defines output level of a pin. Use type XMC_GPIO_OUTPUT_LEVEL_t for this enum.

Enumerator
XMC_GPIO_OUTPUT_LEVEL_LOW 

Reset bit

XMC_GPIO_OUTPUT_LEVEL_HIGH 

Set bit

◆ XMC_GPIO_OUTPUT_STRENGTH_t

Defines output strength and slew rate of a pin. Use type XMC_GPIO_OUTPUT_STRENGTH_t for this enum.

Enumerator
XMC_GPIO_OUTPUT_STRENGTH_STRONG_SHARP_EDGE 

Defines pad driver mode, for high speed 3.3V LVTTL outputs

XMC_GPIO_OUTPUT_STRENGTH_STRONG_MEDIUM_EDGE 

Defines pad driver mode, for high speed 3.3V LVTTL outputs

XMC_GPIO_OUTPUT_STRENGTH_STRONG_SOFT_EDGE 

Defines pad driver mode, medium speed 3.3V LVTTL outputs

XMC_GPIO_OUTPUT_STRENGTH_STRONG_SLOW_EDGE 

Defines pad driver mode, medium speed 3.3V LVTTL outputs

XMC_GPIO_OUTPUT_STRENGTH_MEDIUM 

Defines pad driver mode, for low speed 3.3V LVTTL outputs

XMC_GPIO_OUTPUT_STRENGTH_WEAK 

Defines pad driver mode, low speed 3.3V LVTTL outputs

Function Documentation

◆ XMC_GPIO_DisableDigitalInput()

void XMC_GPIO_DisableDigitalInput ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_PDISC.
pinport pin number.
Returns
None
Related APIs:
None
Description:
Disable digital input path for analog pins and configures Pn_PDISC register.This configuration is applicable only for analog port pins.

◆ XMC_GPIO_DisablePowerSaveMode()

void XMC_GPIO_DisablePowerSaveMode ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_PPS.
pinport pin number.
Returns
None
Description:
Disables pin power save mode and configures Pn_PPS register.This configuration is useful when the controller enters Deep Sleep mode. This configuration enables input Schmitt-Trigger and output driver stage(if pin is enabled power save mode previously). By default port pin does not react to power save mode request.
Related APIs:
XMC_GPIO_EnablePowerSaveMode()
Note:
Do not enable the Pin Power Save function for pins configured for Hardware Control (Pn_HWSEL.HWx != 00B). Doing so may result in an undefined behavior of the pin when the device enters the Deep Sleep state.

◆ XMC_GPIO_EnableDigitalInput()

void XMC_GPIO_EnableDigitalInput ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_PDISC.
pinport pin number.
Returns
None
Related APIs:
None
Description:
Enable digital input path for analog pins and configures Pn_PDISC register.This configuration is applicable only for analog port pins.

◆ XMC_GPIO_EnablePowerSaveMode()

void XMC_GPIO_EnablePowerSaveMode ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_PPS.
pinport pin number.
Returns
None
Description:
Enables pin power save mode and configures Pn_PPS register.This configuration is useful when the controller enters Deep Sleep mode.Port pin enabled with power save mode option are set to a defined state and the input Schmitt-Trigger as well as the output driver stage are switched off. By default port pin does not react to power save mode request.
Related APIs:
XMC_GPIO_DisablePowerSaveMode()

Note:
Do not enable the Pin Power Save function for pins configured for Hardware Control (Pn_HWSEL.HWx != 00B). Doing so may result in an undefined behavior of the pin when the device enters the Deep Sleep state.

◆ XMC_GPIO_GetInput()

uint32_t XMC_GPIO_GetInput ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_IN.
pinPort pin number.
Returns
uint32_t pin logic level status.
Description:
Reads the Pn_IN register and returns the current logical value at the GPIO pin.
Related APIs:
None
Note:
Prior to this api, user has to configure port pin to input mode using XMC_GPIO_SetMode().

◆ XMC_GPIO_Init()

void XMC_GPIO_Init ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin,
const XMC_GPIO_CONFIG_t *const  config 
)
Parameters
portConstant pointer pointing to GPIO port, to access port registers like Pn_OUT,Pn_OMR,Pn_IOCR etc.
pinPort pin number.
configGPIO configuration data structure. Refer data structure XMC_GPIO_CONFIG_t for details.
Returns
None
Description:
Initializes input / output mode settings like, pull up / pull down devices,push pull /open drain, and pad driver mode. Also configures alternate function outputs and clears hardware port control for selected port and pin . It configures hardware registers Pn_IOCR,Pn_OUT,Pn_OMR,Pn_PDISC and Pn_PDR.
Related APIs:
None
Note:
This API is called in definition of DAVE_init by code generation and therefore should not be explicitly called for the normal operation. Use other APIs only after DAVE_init is called successfully (returns DAVE_STATUS_SUCCESS).

◆ XMC_GPIO_SetHardwareControl()

void XMC_GPIO_SetHardwareControl ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin,
const XMC_GPIO_HWCTRL_t  hwctrl 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_HWSEL.
pinport pin number.
hwctrldirect hardware control selection. Refer XMC_GPIO_HWCTRL_t for valid values.
Returns
None
Description:
Selects direct hard ware control and configures Pn_HWSEL register.This configuration is useful for the port pins overlaid with peripheral functions for which the connected peripheral needs hardware control.
Related APIs:
None
Note:
Do not enable the Pin Power Save function for pins configured for Hardware Control (Pn_HWSEL.HWx != 00B). Doing so may result in an undefined behavior of the pin when the device enters the Deep Sleep state.

◆ XMC_GPIO_SetMode()

void XMC_GPIO_SetMode ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin,
const XMC_GPIO_MODE_t  mode 
)
Parameters
portConstant pointer pointing to GPIO port, to access hardware register Pn_IOCR.
pinPort pin number.
modeinput / output functionality selection. Refer XMC_GPIO_MODE_t for valid values.
Returns
None
Description:
Sets digital input and output driver functionality and characteristics of a GPIO port pin. It configures hardware registers Pn_IOCR. mode is initially configured during initialization in XMC_GPIO_Init(). Call this API to alter the port direction functionality as needed later in the program.
Related APIs:
None

◆ XMC_GPIO_SetOutputHigh()

void XMC_GPIO_SetOutputHigh ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_OMR.
pinPort pin number.
Returns
None
Description:
Sets port pin output to high. It configures hardware registers Pn_OMR.
Related APIs:
XMC_GPIO_SetOutputLow()
Note:
Prior to this api, user has to configure port pin to output mode using XMC_GPIO_SetMode().
Register Pn_OMR is virtual and does not contain any flip-flop. A read action delivers the value of 0.

◆ XMC_GPIO_SetOutputLevel()

void XMC_GPIO_SetOutputLevel ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin,
const XMC_GPIO_OUTPUT_LEVEL_t  level 
)
Parameters
portConstant pointer pointing to GPIO port, to access hardware register Pn_OMR.
pinPort pin number.
leveloutput level selection. Refer XMC_GPIO_OUTPUT_LEVEL_t for valid values.
Returns
None
Description:
Set port pin output level to high or low.It configures hardware registers Pn_OMR.level is initially configured during initialization in XMC_GPIO_Init(). Call this API to alter output level as needed later in the program.
Related APIs:
XMC_GPIO_SetOutputHigh(), XMC_GPIO_SetOutputLow().
Note:
Prior to this api, user has to configure port pin to output mode using XMC_GPIO_SetMode().

◆ XMC_GPIO_SetOutputLow()

void XMC_GPIO_SetOutputLow ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_OMR.
pinport pin number.
Returns
None
Description:
Sets port pin output to low. It configures hardware registers Pn_OMR.
Related APIs:>
XMC_GPIO_SetOutputHigh()
Note:
Prior to this api, user has to configure port pin to output mode using XMC_GPIO_SetMode(). Register Pn_OMR is virtual and does not contain any flip-flop. A read action delivers the value of 0.

◆ XMC_GPIO_SetOutputStrength()

void XMC_GPIO_SetOutputStrength ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin,
XMC_GPIO_OUTPUT_STRENGTH_t  strength 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_PDR.
pinPort pin number.
strengthOutput driver mode selection. Refer data structure XMC_GPIO_OUTPUT_STRENGTH_t for details.
Returns
None
Description:
Sets port pin output strength and slew rate. It configures hardware registers Pn_PDR. strength is initially configured during initialization in XMC_GPIO_Init(). Call this API to alter output driver mode as needed later in the program.
Related APIs:
None
Note:
Prior to this api, user has to configure port pin to output mode using XMC_GPIO_SetMode().

◆ XMC_GPIO_ToggleOutput()

void XMC_GPIO_ToggleOutput ( XMC_GPIO_PORT_t *const  port,
const uint8_t  pin 
)
Parameters
portconstant pointer pointing to GPIO port, to access hardware register Pn_OMR.
pinport pin number.
Returns
None
Description:
Configures port pin output to Toggle. It configures hardware registers Pn_OMR.
Related APIs:
XMC_GPIO_SetOutputHigh(), XMC_GPIO_SetOutputLow().
Note:
Prior to this api, user has to configure port pin to output mode using XMC_GPIO_SetMode(). Register Pn_OMR is virtual and does not contain any flip-flop. A read action delivers the value of 0.