Firmware SDK
twr_sc16is740.h
1 #ifndef _TWR_SC16IS740_H
2 #define _TWR_SC16IS740_H
3 
4 #include <twr_i2c.h>
5 #include <twr_tick.h>
6 
10 
12 
13 typedef enum
14 {
15  TWR_SC16IS740_FIFO_RX = 0x02,
16  TWR_SC16IS740_FIFO_TX = 0x04
17 
19 
21 
22 typedef enum
23 {
24  TWR_SC16IS740_BAUDRATE_9600 = 88,
25  TWR_SC16IS740_BAUDRATE_19200 = 44,
26  TWR_SC16IS740_BAUDRATE_38400 = 22,
27  TWR_SC16IS740_BAUDRATE_57600 = 15,
28  TWR_SC16IS740_BAUDRATE_115200 = 7
29 
31 
33 
35 
36 typedef struct
37 {
38  twr_i2c_channel_t _i2c_channel;
39  uint8_t _i2c_address;
40 
41 } twr_sc16is740_t;
42 
44 
51 
52 bool twr_sc16is740_init(twr_sc16is740_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address);
53 
59 
60 bool twr_sc16is740_reset_fifo(twr_sc16is740_t *self, twr_sc16is740_fifo_t fifo);
61 
67 
68 bool twr_sc16is740_get_spaces_available(twr_sc16is740_t *self, size_t *spaces_available);
69 
75 
76 size_t twr_sc16is740_write(twr_sc16is740_t *self, uint8_t *buffer, size_t length);
77 
83 
84 bool twr_sc16is740_available(twr_sc16is740_t *self, size_t *available);
85 
92 
93 size_t twr_sc16is740_read(twr_sc16is740_t *self, uint8_t *buffer, size_t length, twr_tick_t timeout);
94 
100 
101 bool twr_sc16is740_set_baudrate(twr_sc16is740_t *self, twr_sc16is740_baudrate_t baudrate);
102 
104 
105 #endif // _TWR_SC16IS740_H
twr_i2c_channel_t
I2C channels.
Definition: twr_i2c.h:16
bool twr_sc16is740_reset_fifo(twr_sc16is740_t *self, twr_sc16is740_fifo_t fifo)
Reset FIFO.
Definition: twr_sc16is740.c:79
twr_sc16is740_baudrate_t
Baudrates.
Definition: twr_sc16is740.h:23
size_t twr_sc16is740_write(twr_sc16is740_t *self, uint8_t *buffer, size_t length)
Write.
size_t twr_sc16is740_read(twr_sc16is740_t *self, uint8_t *buffer, size_t length, twr_tick_t timeout)
Read.
bool twr_sc16is740_set_baudrate(twr_sc16is740_t *self, twr_sc16is740_baudrate_t baudrate)
Set baudrate.
bool twr_sc16is740_init(twr_sc16is740_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
SC16IS740 instance.
Definition: twr_sc16is740.c:23
twr_sc16is740_fifo_t
Fifo type.
Definition: twr_sc16is740.h:14
bool twr_sc16is740_available(twr_sc16is740_t *self, size_t *available)
Get RX FIXO available data.
bool twr_sc16is740_get_spaces_available(twr_sc16is740_t *self, size_t *spaces_available)
Get TX FIXO space available.
Definition: twr_sc16is740.c:88
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16