42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55#include "drv_spi_master.h"
68#define UARTI2CSPI_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
72 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
73 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
74 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
75 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
76 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
83#define UARTI2CSPI_MASTER_I2C 0
84#define UARTI2CSPI_MASTER_SPI 1
91#define UARTI2CSPI_RETVAL uint8_t
93#define UARTI2CSPI_OK 0x00
94#define UARTI2CSPI_INIT_ERROR 0xFF
101#define UARTI2CSPI_OSCILATOR_FREQ 1843200.0
102#define UARTI2CSPI_PRESCALER_DEF 1.0
103#define UARTI2CSPI_ADDR 0x48
104#define UARTI2CSPI_RHR 0x00 << 3
105#define UARTI2CSPI_THR 0x00 << 3
106#define UARTI2CSPI_IER 0x01 << 3
107#define UARTI2CSPI_FCR 0x02 << 3
108#define UARTI2CSPI_IIR 0x02 << 3
109#define UARTI2CSPI_LCR 0x03 << 3
110#define UARTI2CSPI_MCR 0x04 << 3
111#define UARTI2CSPI_LSR 0x05 << 3
112#define UARTI2CSPI_MSR 0x06 << 3
113#define UARTI2CSPI_SPR 0x07 << 3
114#define UARTI2CSPI_TCR 0x06 << 3
115#define UARTI2CSPI_TLR 0x07 << 3
116#define UARTI2CSPI_TXLVL 0x08 << 3
117#define UARTI2CSPI_RXLVL 0x09 << 3
118#define UARTI2CSPI_EFCR 0x0F << 3
125#define UARTI2CSPI_DLL 0x00 << 3
126#define UARTI2CSPI_DLH 0x01 << 3
128#define UARTI2CSPI_EFR 0x02 << 3
129#define UARTI2CSPI_XON1 0x04 << 3
130#define UARTI2CSPI_XON2 0x05 << 3
131#define UARTI2CSPI_XOFF1 0x06 << 3
132#define UARTI2CSPI_XOFF2 0x07 << 3
139#define UARTI2CSPI_UART_5_BIT_DATA 0x00
140#define UARTI2CSPI_UART_6_BIT_DATA 0x01
141#define UARTI2CSPI_UART_7_BIT_DATA 0x02
142#define UARTI2CSPI_UART_8_BIT_DATA 0x03
143#define UARTI2CSPI_UART_NOPARITY 0x00
144#define UARTI2CSPI_UART_EVENPARITY 0x18
145#define UARTI2CSPI_UART_ODDPARITY 0x08
146#define UARTI2CSPI_UART_PARITY_ONE 0x38
147#define UARTI2CSPI_UART_PARITY_ZERO 0x28
148#define UARTI2CSPI_UART_ONE_STOPBIT 0x00
149#define UARTI2CSPI_UART_TWO_STOPBITS 0x04
156#define UARTI2CSPI_CTS_INT_EN 0x80
157#define UARTI2CSPI_RTS_INT_EN 0x40
158#define UARTI2CSPI_XOFF_INT_EN 0x20
159#define UARTI2CSPI_SLEEP_INT_EN 0x10
160#define UARTI2CSPI_MODEM_STATUS_INT_EN 0x08
161#define UARTI2CSPI_RECEIVE_LINE_STATUS_INT_EN 0x04
162#define UARTI2CSPI_THR_EMPTY_INT_EN 0x02
163#define UARTI2CSPI_RXD_INT_EN 0x01
170#define UARTI2CSPI_DATA_READY 0x01
171#define UARTI2CSPI_DATA_NOT_READY 0x00
328 uint8_t parity_mode, uint8_t stop_bits );
#define UARTI2CSPI_RETVAL
Definition uarti2cspi.h:91
void uarti2cspi_uart_write_text(uarti2cspi_t *ctx, uint8_t *w_text)
Uart write text function.
void uarti2cspi_generic_read(uarti2cspi_t *ctx, uint8_t reg, uint8_t *data_buf)
Generic read function.
void uarti2cspi_cfg_setup(uarti2cspi_cfg_t *cfg)
Config Object Initialization function.
uint8_t uarti2cspi_uart_data_ready(uarti2cspi_t *ctx)
Uart data ready function.
uint8_t uarti2cspi_uart_read(uarti2cspi_t *ctx)
Uart read function.
void uarti2cspi_generic_write(uarti2cspi_t *ctx, uint8_t reg, uint8_t data_buf)
Generic write function.
void uarti2cspi_advanced_init(uarti2cspi_t *ctx, uint32_t baud_rate, uint8_t data_bits, uint8_t parity_mode, uint8_t stop_bits)
Advanced initialization function.
UARTI2CSPI_RETVAL uarti2cspi_init(uarti2cspi_t *ctx, uarti2cspi_cfg_t *cfg)
Initialization function.
void uarti2cspi_set_reset(uarti2cspi_t *ctx, uint8_t state)
Set RST pin state function.
void uarti2cspi_uart_write(uarti2cspi_t *ctx, uint8_t w_byte)
Uart write function.
void uarti2cspi_interrupt_enable(uarti2cspi_t *ctx, uint8_t vector)
Interrupt enable function.
struct uarti2cspi_s uarti2cspi_t
Click ctx object definition.
void(* uarti2cspi_master_write_t)(struct uarti2cspi_s *, uint8_t, uint8_t)
Definition uarti2cspi.h:189
void(* uarti2cspi_master_read_t)(struct uarti2cspi_s *, uint8_t, uint8_t *)
Definition uarti2cspi.h:190
uint8_t uarti2cspi_select_t
Communication type.
Definition uarti2cspi.h:183
Click configuration structure definition.
Definition uarti2cspi.h:225
uint32_t i2c_speed
Definition uarti2cspi.h:242
spi_master_chip_select_polarity_t cs_polarity
Definition uarti2cspi.h:247
pin_name_t sck
Definition uarti2cspi.h:232
uarti2cspi_select_t sel
Definition uarti2cspi.h:249
spi_master_mode_t spi_mode
Definition uarti2cspi.h:246
pin_name_t mosi
Definition uarti2cspi.h:231
uint32_t spi_speed
Definition uarti2cspi.h:245
pin_name_t scl
Definition uarti2cspi.h:228
pin_name_t int_pin
Definition uarti2cspi.h:238
pin_name_t miso
Definition uarti2cspi.h:230
pin_name_t sda
Definition uarti2cspi.h:229
pin_name_t rst
Definition uarti2cspi.h:237
pin_name_t cs
Definition uarti2cspi.h:233
uint8_t i2c_address
Definition uarti2cspi.h:243
Click ctx object definition.
Definition uarti2cspi.h:196
digital_out_t cs
Definition uarti2cspi.h:199
spi_master_t spi
Definition uarti2cspi.h:209
uarti2cspi_master_read_t read_f
Definition uarti2cspi.h:216
uarti2cspi_select_t master_sel
Definition uarti2cspi.h:217
uarti2cspi_master_write_t write_f
Definition uarti2cspi.h:215
digital_in_t int_pin
Definition uarti2cspi.h:204
i2c_master_t i2c
Definition uarti2cspi.h:208
digital_out_t rst
Definition uarti2cspi.h:200
uint8_t slave_address
Definition uarti2cspi.h:213
pin_name_t chip_select
Definition uarti2cspi.h:214