Firmware SDK
twr_sc16is740

Driver for SC16IS740 single UART with I2C-bus interface, 64 bytes of transmit and receive FIFOs. More...

Enumerations

enum  twr_sc16is740_fifo_t {
  TWR_SC16IS740_FIFO_RX = 0x02 ,
  TWR_SC16IS740_FIFO_TX = 0x04
}
 Fifo type.
 
enum  twr_sc16is740_baudrate_t {
  TWR_SC16IS740_BAUDRATE_9600 = 88 ,
  TWR_SC16IS740_BAUDRATE_19200 = 44 ,
  TWR_SC16IS740_BAUDRATE_38400 = 22 ,
  TWR_SC16IS740_BAUDRATE_57600 = 15 ,
  TWR_SC16IS740_BAUDRATE_115200 = 7
}
 Baudrates.
 

Functions

bool twr_sc16is740_init (twr_sc16is740_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
 SC16IS740 instance. More...
 
bool twr_sc16is740_reset_fifo (twr_sc16is740_t *self, twr_sc16is740_fifo_t fifo)
 Reset FIFO. More...
 
bool twr_sc16is740_get_spaces_available (twr_sc16is740_t *self, size_t *spaces_available)
 Get TX FIXO space available. More...
 
size_t twr_sc16is740_write (twr_sc16is740_t *self, uint8_t *buffer, size_t length)
 Write. More...
 
bool twr_sc16is740_available (twr_sc16is740_t *self, size_t *available)
 Get RX FIXO available data. More...
 
size_t twr_sc16is740_read (twr_sc16is740_t *self, uint8_t *buffer, size_t length, twr_tick_t timeout)
 Read. More...
 
bool twr_sc16is740_set_baudrate (twr_sc16is740_t *self, twr_sc16is740_baudrate_t baudrate)
 Set baudrate. More...
 

Detailed Description

Driver for SC16IS740 single UART with I2C-bus interface, 64 bytes of transmit and receive FIFOs.

Function Documentation

◆ twr_sc16is740_available()

bool twr_sc16is740_available ( twr_sc16is740_t *  self,
size_t *  available 
)

Get RX FIXO available data.

Parameters
[in]selfInstance
[out]available
Returns
true On success
false On failure

Definition at line 136 of file twr_sc16is740.c.

Referenced by twr_module_rs485_available(), and twr_sc16is740_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_sc16is740_get_spaces_available()

bool twr_sc16is740_get_spaces_available ( twr_sc16is740_t *  self,
size_t *  spaces_available 
)

Get TX FIXO space available.

Parameters
[in]selfInstance
[out]spaces_available
Returns
true On success
false On failure

Definition at line 88 of file twr_sc16is740.c.

Referenced by twr_sc16is740_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_sc16is740_init()

bool twr_sc16is740_init ( twr_sc16is740_t *  self,
twr_i2c_channel_t  i2c_channel,
uint8_t  i2c_address 
)

SC16IS740 instance.

Initialize SC16IS740

Parameters
[in]selfInstance
[in]i2c_channelI2C channel
[in]i2c_addressI2C device address
Returns
true On success
false On failure

Definition at line 23 of file twr_sc16is740.c.

Referenced by twr_module_rs485_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_sc16is740_read()

size_t twr_sc16is740_read ( twr_sc16is740_t *  self,
uint8_t *  buffer,
size_t  length,
twr_tick_t  timeout 
)

Read.

Parameters
[in]selfInstance
[out]bufferPointer to destination buffer
[in]lengthNumber of bytes to be read
[in]timeoutWrite operation timeout in ticks
Returns
Number of bytes read

Definition at line 150 of file twr_sc16is740.c.

Referenced by twr_module_rs485_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_sc16is740_reset_fifo()

bool twr_sc16is740_reset_fifo ( twr_sc16is740_t *  self,
twr_sc16is740_fifo_t  fifo 
)

Reset FIFO.

Parameters
[in]selfInstance
[in]fifo
Returns
true On success
false On failure

Definition at line 79 of file twr_sc16is740.c.

Referenced by twr_module_rs485_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_sc16is740_set_baudrate()

bool twr_sc16is740_set_baudrate ( twr_sc16is740_t *  self,
twr_sc16is740_baudrate_t  baudrate 
)

Set baudrate.

Parameters
[in]selfInstance
[in]baudrate
Returns
true On success
false On failure

Definition at line 202 of file twr_sc16is740.c.

Referenced by twr_module_rs485_set_baudrate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_sc16is740_write()

size_t twr_sc16is740_write ( twr_sc16is740_t *  self,
uint8_t *  buffer,
size_t  length 
)

Write.

Parameters
[in]selfInstance
[in]bufferPointer to source buffer
[in]lengthNumber of bytes to be written
Returns
Number of bytes written

Definition at line 102 of file twr_sc16is740.c.

Referenced by twr_module_rs485_write().

Here is the call graph for this function:
Here is the caller graph for this function: