File syn_ioexp.h¶
FileList > drivers > syn_ioexp.h
Go to the source code of this file
Generic I2C GPIO Expander Driver (MCP23017, MCP23008, PCF8574, TCA9555).
#include "../common/syn_defs.h"#include "../drivers/syn_soft_i2c.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_IOExp Generic I2C GPIO Expander Instance Context. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_IOExpType I2C GPIO Expander IC Type. |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_ioexp_init (SYN_IOExp * ioexp, SYN_GPIO_Pin scl, SYN_GPIO_Pin sda, uint8_t i2c_addr, SYN_IOExpType type) Initialize an I2C GPIO Expander instance. |
| SYN_GPIO_State | syn_ioexp_read_pin (SYN_IOExp * ioexp, uint8_t pin) Read digital input state from a pin. |
| uint16_t | syn_ioexp_read_port (SYN_IOExp * ioexp) Read entire 16-bit input port mask. |
| void | syn_ioexp_set_pin_mode (SYN_IOExp * ioexp, uint8_t pin, SYN_GPIO_Mode mode) Set pin mode (input vs output). |
| void | syn_ioexp_write_pin (SYN_IOExp * ioexp, uint8_t pin, SYN_GPIO_State state) Write digital output state to a pin. |
| void | syn_ioexp_write_port (SYN_IOExp * ioexp, uint16_t mask) Write entire 16-bit output port mask. |
Public Types Documentation¶
enum SYN_IOExpType¶
I2C GPIO Expander IC Type.
enum SYN_IOExpType {
SYN_IOEXP_MCP23017 = 0,
SYN_IOEXP_MCP23008 = 1,
SYN_IOEXP_PCF8574 = 2,
SYN_IOEXP_TCA9555 = 3
};
Public Functions Documentation¶
function syn_ioexp_init¶
Initialize an I2C GPIO Expander instance.
SYN_Status syn_ioexp_init (
SYN_IOExp * ioexp,
SYN_GPIO_Pin scl,
SYN_GPIO_Pin sda,
uint8_t i2c_addr,
SYN_IOExpType type
)
Parameters:
ioexpExpander context.sclI2C SCL pin.sdaI2C SDA pin.i2c_addrI2C slave address (e.g. 0x20 or 0x27).typeExpander IC type (MCP23017, MCP23008, PCF8574, TCA9555).
Returns:
SYN_OK on success.
function syn_ioexp_read_pin¶
Read digital input state from a pin.
Parameters:
ioexpExpander context.pinPin index (0 to num_pins-1).
Returns:
SYN_GPIO_HIGH or SYN_GPIO_LOW.
function syn_ioexp_read_port¶
Read entire 16-bit input port mask.
Parameters:
ioexpExpander context.
Returns:
16-bit port value.
function syn_ioexp_set_pin_mode¶
Set pin mode (input vs output).
Parameters:
ioexpExpander context.pinPin index (0 to num_pins-1).modeMode (SYN_GPIO_INPUT, SYN_GPIO_OUTPUT, SYN_GPIO_INPUT_PULLUP).
function syn_ioexp_write_pin¶
Write digital output state to a pin.
Parameters:
ioexpExpander context.pinPin index (0 to num_pins-1).stateState (SYN_GPIO_HIGH or SYN_GPIO_LOW).
function syn_ioexp_write_port¶
Write entire 16-bit output port mask.
Parameters:
ioexpExpander context.mask16-bit port value.
The documentation for this class was generated from the following file src/syntropic/drivers/syn_ioexp.h