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 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
ATMO_GPIO_InterruptTrigger_DirectCallback 0x80u

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, uint8_t trigger, ATMO_AbilityHandle_t abilityHandle)

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

Parameter Direction Type
abilityHandle N/A ATMO_AbilityHandle_t
trigger N/A uint8_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, uint8_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 uint8_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
ATMO_GPIO_PinState_t

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

ATMO_GPIO_InterruptTrigger_t ATMO_GPIO_GetInterruptTrigger(uint8_t maskedTrigger)

Given an interrupt trigger mask (as passed into the registration functions), remove the Direct Interrupt Bit and just get the trigger.

Parameter Direction Type
maskedTrigger N/A uint8_t
Return Type
ATMO_GPIO_InterruptTrigger_t

bool ATMO_GPIO_IsDirectInterrupt(uint8_t maskedTrigger)

Given an interrupt trigger mask, get the bit indicating whether or not it’s a direct interrupt.

Parameter Direction Type
maskedTrigger N/A uint8_t
Return Type
bool