Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_uart

Driver for UART (universal asynchronous receiver/transmitter) More...

Enumerations

enum  bc_uart_channel_t {
  BC_UART_UART0 = 0,
  BC_UART_UART1 = 1,
  BC_UART_UART2 = 2
}
 UART channels. More...
 
enum  bc_uart_baudrate_t {
  BC_UART_BAUDRATE_9600 = 0,
  BC_UART_BAUDRATE_19200 = 1,
  BC_UART_BAUDRATE_38400 = 2,
  BC_UART_BAUDRATE_57600 = 3,
  BC_UART_BAUDRATE_115200 = 4,
  BC_UART_BAUDRATE_921600 = 5
}
 UART baudrate. More...
 
enum  bc_uart_setting_t {
  BC_UART_SETTING_8N1 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_1,
  BC_UART_SETTING_8E1 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_EVEN | _BC_UART_SETTING_STOP_BIT_1,
  BC_UART_SETTING_8O1 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_ODD | _BC_UART_SETTING_STOP_BIT_1,
  BC_UART_SETTING_8N2 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_2,
  BC_UART_SETTING_8E2 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_EVEN | _BC_UART_SETTING_STOP_BIT_2,
  BC_UART_SETTING_8O2 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_2,
  BC_UART_SETTING_8N1_5 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_15,
  BC_UART_SETTING_8E1_5 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_EVEN | _BC_UART_SETTING_STOP_BIT_15,
  BC_UART_SETTING_8O1_5 = _BC_UART_SETTING_DATA_BITS_8 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_15,
  BC_UART_SETTING_7N1 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_1,
  BC_UART_SETTING_7E1 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_EVEN | _BC_UART_SETTING_STOP_BIT_1,
  BC_UART_SETTING_7O1 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_ODD | _BC_UART_SETTING_STOP_BIT_1,
  BC_UART_SETTING_7N2 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_2,
  BC_UART_SETTING_7E2 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_EVEN | _BC_UART_SETTING_STOP_BIT_2,
  BC_UART_SETTING_7O2 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_2,
  BC_UART_SETTING_7N1_5 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_15,
  BC_UART_SETTING_7E1_5 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_EVEN | _BC_UART_SETTING_STOP_BIT_15,
  BC_UART_SETTING_7O1_5 = _BC_UART_SETTING_DATA_BITS_7 | _BC_UART_SETTING_PARITY_NONE | _BC_UART_SETTING_STOP_BIT_15
}
 UART setting. More...
 
enum  bc_uart_event_t {
  BC_UART_EVENT_ASYNC_WRITE_DONE = 0,
  BC_UART_EVENT_ASYNC_READ_DATA = 1,
  BC_UART_EVENT_ASYNC_READ_TIMEOUT = 2
}
 Callback events. More...
 

Functions

void bc_uart_init (bc_uart_channel_t channel, bc_uart_baudrate_t baudrate, bc_uart_setting_t setting)
 Initialize UART channel. More...
 
void bc_uart_deinit (bc_uart_channel_t channel)
 Deinitialize UART channel. More...
 
size_t bc_uart_write (bc_uart_channel_t channel, const void *buffer, size_t length)
 Write data to UART channel (blocking call) More...
 
size_t bc_uart_read (bc_uart_channel_t channel, void *buffer, size_t length, bc_tick_t timeout)
 Read data from UART channel (blocking call) More...
 
void bc_uart_set_event_handler (bc_uart_channel_t channel, void(*event_handler)(bc_uart_channel_t, bc_uart_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_uart_set_async_fifo (bc_uart_channel_t channel, bc_fifo_t *write_fifo, bc_fifo_t *read_fifo)
 Set buffers for async transfers. More...
 
size_t bc_uart_async_write (bc_uart_channel_t channel, const void *buffer, size_t length)
 Add data to be transmited in async mode. More...
 
bool bc_uart_async_read_start (bc_uart_channel_t channel, bc_tick_t timeout)
 Start async reading. More...
 
bool bc_uart_async_read_cancel (bc_uart_channel_t channel)
 Cancel async reading. More...
 
size_t bc_uart_async_read (bc_uart_channel_t channel, void *buffer, size_t length)
 Get data that has been received in async mode. More...
 

Detailed Description

Driver for UART (universal asynchronous receiver/transmitter)

Enumeration Type Documentation

UART baudrate.

Enumerator
BC_UART_BAUDRATE_9600 

UART baudrat 9600 bps.

BC_UART_BAUDRATE_19200 

UART baudrat 19200 bps.

BC_UART_BAUDRATE_38400 

UART baudrat 38400 bps.

BC_UART_BAUDRATE_57600 

UART baudrat 57600 bps.

BC_UART_BAUDRATE_115200 

UART baudrat 115200 bps.

BC_UART_BAUDRATE_921600 

UART baudrat 921600 bps.

Definition at line 28 of file bc_uart.h.

UART channels.

Enumerator
BC_UART_UART0 

UART channel UART0.

BC_UART_UART1 

UART channel UART1.

BC_UART_UART2 

UART channel UART2.

Definition at line 13 of file bc_uart.h.

Callback events.

Enumerator
BC_UART_EVENT_ASYNC_WRITE_DONE 

Event is writting done.

BC_UART_EVENT_ASYNC_READ_DATA 

Event is reading done.

BC_UART_EVENT_ASYNC_READ_TIMEOUT 

Event is timeout.

Definition at line 127 of file bc_uart.h.

UART setting.

Enumerator
BC_UART_SETTING_8N1 

8N1: 8 data bits, none parity bit, 1 stop bit

BC_UART_SETTING_8E1 

8E1: 8 data bits, even parity bit, 1 stop bit

BC_UART_SETTING_8O1 

8O1: 8 data bits, odd parity bit, 1 stop bit

BC_UART_SETTING_8N2 

8N2: 8 data bits, none parity bit, 2 stop bits

BC_UART_SETTING_8E2 

8E2: 8 data bits, even parity bit, 2 stop bit

BC_UART_SETTING_8O2 

8O2: 8 data bits, odd parity bit, 2 stop bit

BC_UART_SETTING_8N1_5 

8N1_5: 8 data bits, none parity bit, 1.5 stop bits

BC_UART_SETTING_8E1_5 

8E1_5: 8 data bits, even parity bit, 1.5 stop bit

BC_UART_SETTING_8O1_5 

8O1_5: 8 data bits, odd parity bit, 1.5 stop bit

BC_UART_SETTING_7N1 

7N1: 7 data bits, none parity bit, 1 stop bit

BC_UART_SETTING_7E1 

7E1: 7 data bits, even parity bit, 1 stop bit

BC_UART_SETTING_7O1 

7O1: 7 data bits, odd parity bit, 1 stop bit

BC_UART_SETTING_7N2 

7N2: 7 data bits, none parity bit, 2 stop bits

BC_UART_SETTING_7E2 

7E2: 7 data bits, even parity bit, 2 stop bit

BC_UART_SETTING_7O2 

7O2: 7 data bits, odd parity bit, 2 stop bit

BC_UART_SETTING_7N1_5 

7N1_5: 7 data bits, none parity bit, 1.5 stop bits

BC_UART_SETTING_7E1_5 

7E1_5: 7 data bits, even parity bit, 1.5 stop bit

BC_UART_SETTING_7O1_5 

7O1_5: 7 data bits, odd parity bit, 1.5 stop bit

Definition at line 67 of file bc_uart.h.

Function Documentation

size_t bc_uart_async_read ( bc_uart_channel_t  channel,
void *  buffer,
size_t  length 
)

Get data that has been received in async mode.

Parameters
[in]channelUART channel
[in]bufferPointer to buffer
[in]lengthMaximum length of received data
Returns
Number of received bytes

Definition at line 571 of file bc_uart.c.

Here is the call graph for this function:

bool bc_uart_async_read_cancel ( bc_uart_channel_t  channel)

Cancel async reading.

Parameters
[in]channelUART channel
Returns
true On success
false On failure

Definition at line 531 of file bc_uart.c.

Referenced by bc_uart_deinit().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_uart_async_read_start ( bc_uart_channel_t  channel,
bc_tick_t  timeout 
)

Start async reading.

Parameters
[in]channelUART channel
[in]timeoutMaximum timeout in ms
Returns
true On success
false On failure

Definition at line 475 of file bc_uart.c.

Referenced by bc_cmwx1zzabz_init(), bc_esp8266_init(), bc_td1207r_init(), and bc_wssfm10r1at_init().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t bc_uart_async_write ( bc_uart_channel_t  channel,
const void *  buffer,
size_t  length 
)

Add data to be transmited in async mode.

Parameters
[in]channelUART channel
[in]bufferPointer to buffer
[in]lengthLength of data to be added
Returns
Number of bytes added

Definition at line 428 of file bc_uart.c.

Here is the call graph for this function:

void bc_uart_deinit ( bc_uart_channel_t  channel)

Deinitialize UART channel.

Parameters
[in]channelUART channel

Definition at line 248 of file bc_uart.c.

Here is the call graph for this function:

void bc_uart_init ( bc_uart_channel_t  channel,
bc_uart_baudrate_t  baudrate,
bc_uart_setting_t  setting 
)

Initialize UART channel.

Parameters
[in]channelUART channel
[in]configUART configuration

Definition at line 53 of file bc_uart.c.

Referenced by bc_cmwx1zzabz_init(), bc_esp8266_init(), bc_log_init(), bc_td1207r_init(), and bc_wssfm10r1at_init().

Here is the caller graph for this function:

size_t bc_uart_read ( bc_uart_channel_t  channel,
void *  buffer,
size_t  length,
bc_tick_t  timeout 
)

Read data from UART channel (blocking call)

Parameters
[in]channelUART channel
[in]bufferPointer to destination buffer
[in]lengthNumber of bytes to be read
[in]timeoutRead operation timeout in ticks
Returns
Number of bytes read

Definition at line 372 of file bc_uart.c.

Here is the call graph for this function:

void bc_uart_set_async_fifo ( bc_uart_channel_t  channel,
bc_fifo_t write_fifo,
bc_fifo_t read_fifo 
)

Set buffers for async transfers.

Parameters
[in]channelUART channel
[in]write_fifoPointer to writing fifo
[in]read_fifoPointer to reader fifo

Definition at line 422 of file bc_uart.c.

Referenced by bc_cmwx1zzabz_init(), bc_esp8266_init(), bc_td1207r_init(), and bc_wssfm10r1at_init().

Here is the caller graph for this function:

void bc_uart_set_event_handler ( bc_uart_channel_t  channel,
void(*)(bc_uart_channel_t, bc_uart_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]channelUART channel
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 416 of file bc_uart.c.

Referenced by bc_cmwx1zzabz_init(), and bc_esp8266_init().

Here is the caller graph for this function:

size_t bc_uart_write ( bc_uart_channel_t  channel,
const void *  buffer,
size_t  length 
)

Write data to UART channel (blocking call)

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

Definition at line 330 of file bc_uart.c.

Referenced by bc_atci_printf(), bc_atci_write_error(), bc_atci_write_ok(), bc_log_dump(), and bc_log_init().

Here is the caller graph for this function: