File syn_ioexp.c¶
FileList > drivers > syn_ioexp.c
Go to the source code of this file
Generic I2C GPIO Expander Driver (MCP23017, MCP23008, PCF8574, TCA9555).
#include "syn_ioexp.h"#include "../util/syn_assert.h"#include <string.h>
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 Static Functions¶
| Type | Name |
|---|---|
| void | write_i2c_bytes (SYN_SoftI2C * i2c, uint8_t dev_addr, const uint8_t * buf, size_t len) |
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.
Public Static Functions Documentation¶
function write_i2c_bytes¶
static void write_i2c_bytes (
SYN_SoftI2C * i2c,
uint8_t dev_addr,
const uint8_t * buf,
size_t len
)
The documentation for this class was generated from the following file src/syntropic/drivers/syn_ioexp.c