41#ifdef PREINIT_SUPPORTED
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
51#include "drv_digital_out.h"
52#include "drv_digital_in.h"
53#include "drv_i2c_master.h"
65#define EXPAND5_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
68 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
69 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define EXPAND5_RETVAL uint8_t
78#define EXPAND5_OK 0x00
79#define EXPAND5_INIT_ERROR 0xFF
86#define EXPAND5_I2C_ADR_GND 0x22
87#define EXPAND5_I2C_ADR_VCC 0x23
94#define EXPAND5_RA_IN_0 0x00
95#define EXPAND5_RA_IN_1 0x01
96#define EXPAND5_RA_IN_2 0x02
97#define EXPAND5_RA_OUT_0 0x04
98#define EXPAND5_RA_OUT_1 0x05
99#define EXPAND5_RA_OUT_2 0x06
100#define EXPAND5_RA_POL_0 0x08
101#define EXPAND5_RA_POL_1 0x09
102#define EXPAND5_RA_POL_2 0x0A
103#define EXPAND5_RA_CFG_0 0x0C
104#define EXPAND5_RA_CFG_1 0x0D
105#define EXPAND5_RA_CFG_2 0x0E
107#define EXPAND5_AUTO_INC 0x80
110#define EXPAND5_HIGH 1
112#define EXPAND5_POL_NORMAL 0
113#define EXPAND5_POL_INVERTED 1
128#define EXPAND5_P12 10
129#define EXPAND5_P13 11
130#define EXPAND5_P14 12
131#define EXPAND5_P15 13
132#define EXPAND5_P16 14
133#define EXPAND5_P17 15
134#define EXPAND5_P20 16
135#define EXPAND5_P21 17
136#define EXPAND5_P22 18
137#define EXPAND5_P23 19
138#define EXPAND5_P24 20
139#define EXPAND5_P25 21
140#define EXPAND5_P26 22
141#define EXPAND5_P27 23
#define EXPAND5_RETVAL
Definition expand5.h:76
void expand5_generic_write(expand5_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t expand5_get_pin_dir(expand5_t *ctx, uint16_t pin)
Get a single pin's direction ( I/O ) setting function.
void expand5_set_all_dir(expand5_t *ctx, uint8_t bank0, uint8_t bank1, uint8_t bank2)
Set all pin direction ( I/O ) settings in all banks function.
void expand5_set_bank_dir(expand5_t *ctx, uint8_t bank, uint8_t direction)
Set all pin direction ( I/O ) settings in one bank function.
void expand5_read_all_banks(expand5_t *ctx, uint8_t *bank0, uint8_t *bank1, uint8_t *bank2)
Get all pins logic levels from all banks function.
uint8_t expand5_get_bank_pol(expand5_t *ctx, uint8_t bank)
Get all pin polarity ( normal/inverted ) settings from one bank function.
uint8_t expand5_read_pin(expand5_t *ctx, uint16_t pin)
Get a single INPUT pin's logic level function.
uint8_t expand5_get_bank_dir(expand5_t *ctx, uint8_t bank)
Get all pin direction ( I/O ) settings from one bank function.
void expand5_get_all_banks_pol(expand5_t *ctx, uint8_t *bank0, uint8_t *bank1, uint8_t *bank2)
Get all pin polarity ( normal/inverted ) settings from all banks function.
void expand5_write_all_banks(expand5_t *ctx, uint8_t bank0, uint8_t bank1, uint8_t bank2)
Set all OUTPUT pins' logic levels in all banks function.
void expand5_write_bit(expand5_t *ctx, uint8_t reg_adr, uint8_t bit_num, uint8_t pin_val)
Write bit function.
void expand5_write_bank(expand5_t *ctx, uint8_t bank, uint8_t value)
Set all OUTPUT pins' logic levels in one bank function.
uint8_t expand5_read_bit(expand5_t *ctx, uint8_t reg_adr, uint8_t bit_num)
Read bit function.
void expand5_get_all_dir(expand5_t *ctx, uint8_t *bank0, uint8_t *bank1, uint8_t *bank2)
Get all pin direction ( I/O ) settings from all banks function.
uint8_t expand5_get_bank_out_lvl(expand5_t *ctx, uint8_t bank)
Get all pin output settings from one bank function.
void expand5_set_pin_dir(expand5_t *ctx, uint16_t pin, uint8_t direction)
Set a single pin's direction ( I/O ) setting function.
void expand5_generic_read(expand5_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t expand5_check_int(expand5_t *ctx)
Get Interrupt state function.
uint8_t expand5_get_pin_out_lvl(expand5_t *ctx, uint16_t pin)
Get a single OUTPUT pin's setting function.
void expand5_get_all_banks_out_lvl(expand5_t *ctx, uint8_t *bank0, uint8_t *bank1, uint8_t *bank2)
Get all pin output settings from all banks function.
uint8_t expand5_get_pin_pol(expand5_t *ctx, uint16_t pin)
Get a single pin's polarity ( normal/inverted ) setting function.
void expand5_cfg_setup(expand5_cfg_t *cfg)
Config Object Initialization function.
void expand5_write_pin(expand5_t *ctx, uint16_t pin, uint8_t pin_val)
Set a single OUTPUT pin's logic level function.
uint8_t expand5_read_bank(expand5_t *ctx, uint8_t bank)
Get all pin logic levels from one bank function.
EXPAND5_RETVAL expand5_init(expand5_t *ctx, expand5_cfg_t *cfg)
Initialization function.
void expand5_set_all_banks_pol(expand5_t *ctx, uint8_t bank0, uint8_t bank1, uint8_t bank2)
Set all pin polarity ( normal/inverted ) settings in all banks function.
void expand5_set_bank_pol(expand5_t *ctx, uint8_t bank, uint8_t polarity)
Set all pin polarity ( normal/inverted ) settings in one bank function.
void expand5_reset(expand5_t *ctx)
Reset function.
void expand5_set_pin_pol(expand5_t *ctx, uint16_t pin, uint8_t polarity)
Set a single pin's polarity ( normal/inverted ) setting function.
Click configuration structure definition.
Definition expand5.h:178
uint32_t i2c_speed
Definition expand5.h:191
pin_name_t scl
Definition expand5.h:181
pin_name_t int_pin
Definition expand5.h:187
pin_name_t sda
Definition expand5.h:182
pin_name_t rst
Definition expand5.h:186
uint8_t i2c_address
Definition expand5.h:192
Click ctx object definition.
Definition expand5.h:155
digital_in_t int_pin
Definition expand5.h:162
i2c_master_t i2c
Definition expand5.h:166
digital_out_t rst
Definition expand5.h:158
uint8_t slave_address
Definition expand5.h:170