GPIO Driver

The GPIO driver is used for access and control of an end device’s basic general purpose input/output (GPIO) functionality. This includes reading and writing GPIO pins and configuring a GPIO pin as an input or output.

Data Structures

ATMO_GPIO_Config_t

GPIO pin configuration structure.

Member Name Type Description
pinMode ATMO_GPIO_PinMode_t Pin mode
initialState ATMO_GPIO_PinState_t Initial pin state. Only relevant for output modes.

Type Definitions

Name Definition Description
ATMO_GPIO_Device_Pin_t typedef uint32_t ATMO_GPIO_Device_Pin_t Generic typedef for a device pin
ATMO_GPIO_DriverInstance_t typedef struct ATMO_GPIO_DriverInstance_t  

Enumerations

enum ATMO_GPIO_PinMode_t

GPIO pin mode.

Name Value
ATMO_GPIO_PinMode_Disabled 0x0000u
ATMO_GPIO_PinMode_Input_HighImpedance 0x0001u
ATMO_GPIO_PinMode_Input_PullUp 0x0101u
ATMO_GPIO_PinMode_Input_PullDown 0x0201u
ATMO_GPIO_PinMode_Output_PushPull 0x0002u
ATMO_GPIO_PinMode_Output_OpenDrain 0x0003u
ATMO_GPIO_PinMode_Output_OpenDrainPullUp 0x0103u

enum ATMO_GPIO_PinState_t

GPIO pin state.

Name Value
ATMO_GPIO_PinState_Low 0x00u
ATMO_GPIO_PinState_High 0x01u
ATMO_GPIO_PinState_Error 0xFFu

enum ATMO_GPIO_InterruptTrigger_t

GPIO interrupt trigger.

Name Value
ATMO_GPIO_InterruptTrigger_None 0x00u
ATMO_GPIO_InterruptTrigger_RisingEdge 0x01u
ATMO_GPIO_InterruptTrigger_FallingEdge 0x02u
ATMO_GPIO_InterruptTrigger_BothEdges 0x03u
ATMO_GPIO_InterruptTrigger_LogicZero 0x04u
ATMO_GPIO_InterruptTrigger_LogicOne 0x05u

enum ATMO_GPIO_Status_t

GPIO driver return enumerations.

Name Value Description
ATMO_GPIO_Status_Success 0x00u Operation was successful
ATMO_GPIO_Status_Fail 0x01u Operation failed
ATMO_GPIO_Status_Initialized 0x02u Peripheral already initialized
ATMO_GPIO_Status_Invalid 0x03u Invalid operation
ATMO_GPIO_Status_NotSupported 0x04u Feature not supported by platform
ATMO_GPIO_Status_Unspecified 0x05u Some other status not defined

Functions

ATMO_Status_t ATMO_GPIO_AddDriverInstance(const ATMO_GPIO_DriverInstance_t *driverInstance, ATMO_DriverInstanceData_t *driverInstanceData, ATMO_DriverInstanceHandle_t *instanceNumber)

This routine will add an instance of a driver for GPIO into the GPIO driver handler.

Parameter Direction Type
instanceNumber N/A ATMO_DriverInstanceHandle_t *
driverInstanceData N/A ATMO_DriverInstanceData_t *
driverInstance N/A const ATMO_GPIO_DriverInstance_t *
Return Type
ATMO_Status_t

ATMO_GPIO_Status_t ATMO_GPIO_Init(ATMO_DriverInstanceHandle_t instance)

Initialize GPIO driver.

Parameter Direction Type
instance in ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t

ATMO_GPIO_Status_t ATMO_GPIO_DeInit(ATMO_DriverInstanceHandle_t instance)

This routine de-initializes a pin by setting its configuration back to the default after reset.

Parameter Direction Type
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t

ATMO_GPIO_Status_t ATMO_GPIO_SetPinConfiguration(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, const ATMO_GPIO_Config_t *config)

This routine configures a GPIO pin.

Parameter Direction Type
config N/A const ATMO_GPIO_Config_t *
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t

ATMO_GPIO_Status_t ATMO_GPIO_GetPinConfiguration(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, ATMO_GPIO_Config_t *config)

This routine gets a GPIO pin configuration.

Parameter Direction Type
config N/A ATMO_GPIO_Config_t *
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t

ATMO_GPIO_Status_t ATMO_GPIO_RegisterInterruptAbilityHandle(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, ATMO_GPIO_InterruptTrigger_t trigger, unsigned int abilityHandle)

This routine will register or unregister a user-defined callback function for the specified pin.

Parameter Direction Type
abilityHandle N/A unsigned int
trigger N/A ATMO_GPIO_InterruptTrigger_t
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t

ATMO_GPIO_Status_t ATMO_GPIO_RegisterInterruptCallback(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, ATMO_GPIO_InterruptTrigger_t trigger, ATMO_Callback_t cb)

This routine will register or unregister a user-defined callback function for the specified pin.

Parameter Direction Type
cb N/A ATMO_Callback_t
trigger N/A ATMO_GPIO_InterruptTrigger_t
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t

ATMO_GPIO_Status_t ATMO_GPIO_SetPinState(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, ATMO_GPIO_PinState_t state)

This routine sets the output value of a pin.

Parameter Direction Type
state N/A ATMO_GPIO_PinState_t
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t

ATMO_GPIO_Status_t ATMO_GPIO_GetPinState(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin, ATMO_GPIO_PinState_t *state)

This routine gets the current value of a pin.

Parameter Direction Type
state N/A ATMO_GPIO_PinState_t *
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t

ATMO_GPIO_PinState_t ATMO_GPIO_Read(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin)

This routine gets the current value of a pin.

Parameter Direction Type
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type Description
ATMO_GPIO_PinState_t The current pin state.

ATMO_GPIO_Status_t ATMO_GPIO_Toggle(ATMO_DriverInstanceHandle_t instance, ATMO_GPIO_Device_Pin_t pin)

This routine toggles the output value of a pin.

Parameter Direction Type
pin N/A ATMO_GPIO_Device_Pin_t
instance N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_GPIO_Status_t