39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
73#define UARTTOI2C_CMD_START 'S'
74#define UARTTOI2C_CMD_STOP 'P'
75#define UARTTOI2C_CMD_READ_REG 'R'
76#define UARTTOI2C_CMD_WRITE_REG 'W'
77#define UARTTOI2C_CMD_READ_GPIO 'I'
78#define UARTTOI2C_CMD_WRITE_GPIO 'O'
79#define UARTTOI2C_CMD_READ_VERSION 'V'
80#define UARTTOI2C_CMD_POWER_DOWN 'Z'
86#define UARTTOI2C_REG_BRG0 0x00
87#define UARTTOI2C_REG_BRG1 0x01
88#define UARTTOI2C_REG_PORT_CONF_1 0x02
89#define UARTTOI2C_REG_PORT_CONF_2 0x03
90#define UARTTOI2C_REG_IO_STATE 0x04
91#define UARTTOI2C_REG_RESERVED 0x05
92#define UARTTOI2C_REG_I2C_ADR 0x06
93#define UARTTOI2C_REG_I2C_CLK_L 0x07
94#define UARTTOI2C_REG_I2C_CLK_H 0x08
95#define UARTTOI2C_REG_I2C_TO 0x09
96#define UARTTOI2C_REG_I2C_STAT 0x0A
102#define UARTTOI2C_TIMEOUT_MS 3000
108#define UARTTOI2C_POWER_UP_BYTE_0 0x4F
109#define UARTTOI2C_POWER_UP_BYTE_1 0x4B
115#define UARTTOI2C_NO_PIN_MASK 0x00
116#define UARTTOI2C_PIN_0_MASK 0x01
117#define UARTTOI2C_PIN_1_MASK 0x02
118#define UARTTOI2C_PIN_2_MASK 0x04
119#define UARTTOI2C_PIN_3_MASK 0x08
120#define UARTTOI2C_PIN_4_MASK 0x10
121#define UARTTOI2C_PIN_5_MASK 0x20
122#define UARTTOI2C_PIN_6_MASK 0x40
123#define UARTTOI2C_PIN_7_MASK 0x80
124#define UARTTOI2C_ALL_PINS_MASK 0xFF
130#define UARTTOI2C_PIN_DIR_INPUT 0x00
131#define UARTTOI2C_PIN_DIR_OUTPUT_PP 0x02
132#define UARTTOI2C_PIN_DIR_OUTPUT_OD 0x03
133#define UARTTOI2C_PIN_DIR_OUTPUT_MASK 0x03
140#define UARTTOI2C_TX_DRV_BUFFER_SIZE 100
141#define UARTTOI2C_RX_DRV_BUFFER_SIZE 300
159#define UARTTOI2C_MAP_MIKROBUS( cfg, mikrobus ) \
160 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
161 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
162 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
449 uint8_t *data_in, uint8_t in_len, uint8_t *data_out, uint8_t out_len );
#define UARTTOI2C_RX_DRV_BUFFER_SIZE
Definition uarttoi2c.h:141
#define UARTTOI2C_TX_DRV_BUFFER_SIZE
UART to I2C driver buffer size.
Definition uarttoi2c.h:140
err_t uarttoi2c_i2c_write(uarttoi2c_t *ctx, uint8_t slave_addr, uint8_t *data_in, uint8_t len)
UART to I2C i2c write function.
err_t uarttoi2c_generic_read(uarttoi2c_t *ctx, char *data_out, uint16_t len)
UART to I2C data reading function.
err_t uarttoi2c_reset_device(uarttoi2c_t *ctx)
UART to I2C reset device function.
void uarttoi2c_set_rst_pin(uarttoi2c_t *ctx, uint8_t state)
UART to I2C set rst pin function.
void uarttoi2c_cfg_setup(uarttoi2c_cfg_t *cfg)
UART to I2C configuration object setup function.
err_t uarttoi2c_default_cfg(uarttoi2c_t *ctx)
UART to I2C default configuration function.
err_t uarttoi2c_write_register(uarttoi2c_t *ctx, uint8_t reg, uint8_t data_in)
UART to I2C write register function.
err_t uarttoi2c_i2c_write_then_read(uarttoi2c_t *ctx, uint8_t slave_addr, uint8_t *data_in, uint8_t in_len, uint8_t *data_out, uint8_t out_len)
UART to I2C i2c write then read function.
err_t uarttoi2c_init(uarttoi2c_t *ctx, uarttoi2c_cfg_t *cfg)
UART to I2C initialization function.
err_t uarttoi2c_gpio_read(uarttoi2c_t *ctx, uint8_t *gpio_data)
UART to I2C gpio read function.
err_t uarttoi2c_read_version(uarttoi2c_t *ctx, uint8_t *version)
UART to I2C read version function.
void uarttoi2c_gpio_write(uarttoi2c_t *ctx, uint8_t gpio_data)
UART to I2C gpio write function.
err_t uarttoi2c_generic_write(uarttoi2c_t *ctx, char *data_in, uint16_t len)
UART to I2C data writing function.
err_t uarttoi2c_gpio_config(uarttoi2c_t *ctx, uint8_t direction, uint8_t pin_mask)
UART to I2C gpio config function.
err_t uarttoi2c_read_register(uarttoi2c_t *ctx, uint8_t reg, uint8_t *data_out)
UART to I2C read register function.
err_t uarttoi2c_i2c_read(uarttoi2c_t *ctx, uint8_t slave_addr, uint8_t *data_out, uint8_t len)
UART to I2C i2c read function.
UART to I2C Click configuration object.
Definition uarttoi2c.h:190
uint32_t baud_rate
Definition uarttoi2c.h:199
bool uart_blocking
Definition uarttoi2c.h:200
uart_data_bits_t data_bit
Definition uarttoi2c.h:201
pin_name_t tx_pin
Definition uarttoi2c.h:193
pin_name_t rx_pin
Definition uarttoi2c.h:192
uart_stop_bits_t stop_bit
Definition uarttoi2c.h:203
uart_parity_t parity_bit
Definition uarttoi2c.h:202
pin_name_t rst
Definition uarttoi2c.h:196
UART to I2C Click context object.
Definition uarttoi2c.h:172
uart_t uart
Definition uarttoi2c.h:177
digital_out_t rst
Definition uarttoi2c.h:174
uarttoi2c_return_value_t
UART to I2C Click return value data.
Definition uarttoi2c.h:212
@ UARTTOI2C_ERROR
Definition uarttoi2c.h:214
@ UARTTOI2C_TIMEOUT_ERROR
Definition uarttoi2c.h:215
@ UARTTOI2C_OK
Definition uarttoi2c.h:213