EVE 1.0
Extended GPIO driver
Collaboration diagram for Extended GPIO driver:

Modules

 PCAL9535a GPIO driver
 
 SC16IS7x0 GPIO driver
 

Data Structures

struct  gpio_ext_state_t
 
struct  gpio_ext_init_pin_t
 
struct  gpio_ext_api_t
 
struct  gpio_ext_t
 

Typedefs

typedef void(* gpio_ext_init_t) (const struct gpio_ext_t *GpioExt)
 Virtual function initializes pins of an gpio expander to default values based on DRIVER_PORT_EXT_INIT_TABLE.
 
typedef uint16_t(* gpio_ext_inport_t) (const struct gpio_ext_t *GpioExt)
 Virtual function reads from gpio expander port.
 
typedef void(* gpio_ext_outport_t) (const struct gpio_ext_t *GpioExt, uint16_t Value)
 Virtual function writes to gpio expander port / pin direction register / pull select register / pull enable register / interrupt enable register / latch enable register.
 
typedef void(* gpio_ext_setdrive_t) (const struct gpio_ext_t *GpioExt, uint8_t Values[])
 Virtual function sets drive force to gpio expander pins.
 

Enumerations

Functions called from application programs

void GpioExtInit (const struct gpio_ext_t *GpioExt)
 Initialize IO expander driver and chip. More...
 
static void GpioExtPortWrite (const struct gpio_ext_t *GpioExt, uint16_t Value, uint16_t Mask)
 Write 16-bits data to the GPIO port. More...
 
static void GpioExtPortSet (const struct gpio_ext_t *GpioExt, uint16_t Mask)
 Set bits by mask in the GPIO port. More...
 
static void GpioExtPortClear (const struct gpio_ext_t *GpioExt, uint16_t Mask)
 Clear bits by mask in the GPIO port. More...
 
static void GpioExtPortToggle (const struct gpio_ext_t *GpioExt, uint16_t Mask)
 Invert bits by mask in the GPIO port. More...
 
static void GpioExtPinWrite (const struct gpio_ext_t *GpioExt, uint16_t Pin, uint16_t Value)
 Set/clear 1 pin in the GPIO port. More...
 
static void GpioExtPinSet (const struct gpio_ext_t *GpioExt, uint16_t Pin)
 Set 1 pin in the GPIO port. More...
 
static void GpioExtPinClear (const struct gpio_ext_t *GpioExt, uint16_t Pin)
 Clear 1 pin in the GPIO port. More...
 
static void GpioExtPinToggle (const struct gpio_ext_t *GpioExt, uint16_t Pin)
 Invert 1 pin in the GPIO port. More...
 
static uint16_t GpioExtPortRead (const struct gpio_ext_t *GpioExt)
 Read all the pins from the GPIO port. More...
 
static uint8_t GpioExtPinRead (const struct gpio_ext_t *GpioExt, uint16_t Pin)
 Read a pin value from the GPIO port. More...
 
void GpioExtPortSetup (const struct gpio_ext_t *GpioExt, uint16_t Direction, uint16_t PullSelect, uint16_t PullEnable, uint16_t Mask)
 Set IO expander ports to input or output. More...
 
static uint16_t GpioExtInterruptsClear (const struct gpio_ext_t *GpioExt, uint16_t Mask)
 
static uint16_t GpioExtInterruptsRead (const struct gpio_ext_t *GpioExt)
 
static void GpioExtInterruptsEnable (const struct gpio_ext_t *GpioExt, uint16_t Mask)
 
static void GpioExtInterruptsDisable (const struct gpio_ext_t *GpioExt, uint16_t Mask)
 
static void GpioExtSetDrive (const struct gpio_ext_t *GpioExt, uint8_t Values[])
 
static void GpioExtSetLatch (const struct gpio_ext_t *GpioExt, uint16_t Mask)
 
static uint8_t GpioExtCheckStatus (const struct gpio_ext_t *GpioExt)
 Check status of GpioExt operations and reset status to GPIO_EXT_STATUS_OK. More...
 

Detailed Description

Enumeration Type Documentation

GPIO driver SPI/I2C bus operation statuse

Enumerator
GPIO_EXT_STATUS_OK 

Operation completed successfully.

GPIO_EXT_STATUS_COMM_ERROR 

SPI/I2C bus error.

Definition at line 72 of file gpio-ext.h.

Pin direction setting

Enumerator
DIR_UNCHANGED 

Do not touch pin direction setting (leave as is)

DIR_IN 

Set pin as input.

DIR_OUT 

Set pin as output.

Definition at line 81 of file gpio-ext.h.

Pin pullup / pulldown setting

Enumerator
PULL_UNCHANGED 

Do not touch pin pullup / pulldown setting (leave as is)

PULL_NONE 

Disconnect pin pullup / pulldown.

PULL_UP 

Pullup the pin.

PULL_DOWN 

Pulldown the pin.

Definition at line 91 of file gpio-ext.h.

Function Documentation

void GpioExtInit ( const struct gpio_ext_t GpioExt)

Initialize IO expander driver and chip.

Parameters
GpioExtParameters for the IO port expander to be used
static void GpioExtPortWrite ( const struct gpio_ext_t GpioExt,
uint16_t  Value,
uint16_t  Mask 
)
inlinestatic

Write 16-bits data to the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
ValueData to be written to IO expander ports
MaskMask of pins in the port to be written

Definition at line 213 of file gpio-ext.h.

References gpio_ext_t::Func, gpio_ext_api_t::GpioExtOutPort, gpio_ext_state_t::OutputValues, and gpio_ext_t::State.

Referenced by GpioExtPortClear(), and GpioExtPortSet().

static void GpioExtPortSet ( const struct gpio_ext_t GpioExt,
uint16_t  Mask 
)
inlinestatic

Set bits by mask in the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
MaskMask of pins in the port to be written

Definition at line 227 of file gpio-ext.h.

References GpioExtPortWrite().

static void GpioExtPortClear ( const struct gpio_ext_t GpioExt,
uint16_t  Mask 
)
inlinestatic

Clear bits by mask in the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
MaskMask of pins in the port to be written

Definition at line 238 of file gpio-ext.h.

References GpioExtPortWrite().

static void GpioExtPortToggle ( const struct gpio_ext_t GpioExt,
uint16_t  Mask 
)
inlinestatic

Invert bits by mask in the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
MaskMask of pins in the port to be written

Definition at line 249 of file gpio-ext.h.

References atomic_xor16(), gpio_ext_t::Func, gpio_ext_api_t::GpioExtOutPort, gpio_ext_state_t::OutputValues, and gpio_ext_t::State.

static void GpioExtPinWrite ( const struct gpio_ext_t GpioExt,
uint16_t  Pin,
uint16_t  Value 
)
inlinestatic

Set/clear 1 pin in the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
PinPin number to set/clear
Value0 clears the pin, any other value sets it to 1

Definition at line 263 of file gpio-ext.h.

References gpio_ext_t::Func, gpio_ext_api_t::GpioExtOutPort, gpio_ext_state_t::OutputValues, and gpio_ext_t::State.

static void GpioExtPinSet ( const struct gpio_ext_t GpioExt,
uint16_t  Pin 
)
inlinestatic

Set 1 pin in the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
PinPin number to set

Definition at line 277 of file gpio-ext.h.

References gpio_ext_t::Func, gpio_ext_api_t::GpioExtOutPort, gpio_ext_state_t::OutputValues, and gpio_ext_t::State.

static void GpioExtPinClear ( const struct gpio_ext_t GpioExt,
uint16_t  Pin 
)
inlinestatic

Clear 1 pin in the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
PinPin number to clear

Definition at line 290 of file gpio-ext.h.

References gpio_ext_t::Func, gpio_ext_api_t::GpioExtOutPort, gpio_ext_state_t::OutputValues, and gpio_ext_t::State.

static void GpioExtPinToggle ( const struct gpio_ext_t GpioExt,
uint16_t  Pin 
)
inlinestatic

Invert 1 pin in the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
PinPin number to toggle

Definition at line 303 of file gpio-ext.h.

References atomic_xor16(), gpio_ext_t::Func, gpio_ext_api_t::GpioExtOutPort, gpio_ext_state_t::OutputValues, and gpio_ext_t::State.

static uint16_t GpioExtPortRead ( const struct gpio_ext_t GpioExt)
inlinestatic

Read all the pins from the GPIO port.

Parameters
GpioExtParameters for the IO port expander to be used
Returns
Port value

Definition at line 317 of file gpio-ext.h.

Referenced by GpioExtPinRead().

static uint8_t GpioExtPinRead ( const struct gpio_ext_t GpioExt,
uint16_t  Pin 
)
inlinestatic
void GpioExtPortSetup ( const struct gpio_ext_t GpioExt,
uint16_t  Direction,
uint16_t  PullSelect,
uint16_t  PullEnable,
uint16_t  Mask 
)

Set IO expander ports to input or output.

Parameters
GpioExtParameters for the IO port expander to be used
Direction0 = input, 1 = output
PullSelect0 = pulldown, 1 = pullup
PullEnable0 = no pull, 1 = pullup/pulldown
MaskMask of pins in the port to be changed

Referenced by GpioExtPinRead().

static uint8_t GpioExtCheckStatus ( const struct gpio_ext_t GpioExt)
inlinestatic

Check status of GpioExt operations and reset status to GPIO_EXT_STATUS_OK.

Parameters
GpioExtParameters for the IO port expander to be used
Returns
GPIO_EXT_STATUS_OK if there were no errors since the last check, errorcode otherwise.

Definition at line 401 of file gpio-ext.h.

References GPIO_EXT_STATUS_OK, and gpio_ext_t::State.