This module provides configuration and utils for PLC Buffered USART service interface.
#define FREQ_TIMER_POLL_USART 100 |
#define TIMER_USART_PRIO 10 |
#define USART_BUFFER_SIZE 1024 |
int8_t busart_if_close |
( |
uint8_t |
chn | ) |
|
int8_t busart_if_open |
( |
uint8_t |
chn, |
|
|
uint32_t |
bauds |
|
) |
| |
This function opens an USART.
- Note
- Opening of the specified USART implies initializing local variables and opening required hardware with the following configuration:
- bauds as specified
- 8 bits, no parity, 1 stop bit
- enable interrupts
- Parameters
-
chn | Communication channel [0, 1] |
bauds | Communication speed in bauds |
- Return values
-
true | on success. |
false | on failure. |
References sam_usart_opt_t::baudrate, sam_usart_opt_t::channel_mode, sam_usart_opt_t::char_length, NULL, sam_usart_opt_t::parity_type, pdc_enable_transfer(), pdc_rx_init(), pdc_tx_init(), pmc_enable_periph_clk(), busart_comm_data_t::puc_rq_buf, busart_comm_data_t::puc_tq_buf, sam_usart_opt_t::stop_bits, sysclk_get_peripheral_hz(), tc_start(), pdc_packet::ul_addr, pdc_packet::ul_size, UNUSED, busart_comm_data_t::us_rq_count, busart_comm_data_t::us_rq_idx, busart_comm_data_t::us_wq_idx, USART0_PRIO, USART1_PRIO, USART_BUFFER_SIZE, usart_disable_interrupt(), usart_enable_interrupt(), usart_enable_rx(), usart_enable_tx(), usart_get_pdc_base(), and usart_init_rs232().
Referenced by usi_init().
uint16_t busart_if_read |
( |
uint8_t |
chn, |
|
|
void * |
buffer, |
|
|
uint16_t |
len |
|
) |
| |
int busart_if_rx_char |
( |
uint8_t |
chn | ) |
|
Get byte from USART.
- Parameters
-
chn | Communication channel [0, 1] |
- Return values
-
Byte | received |
-1 | in case of no reception |
References busart_if_read().
uint16_t busart_if_tx_char |
( |
uint8_t |
chn, |
|
|
char |
data |
|
) |
| |
Sent byte to USART.
- Parameters
-
chn | Communication channel [0, 1] |
data | Data to sent |
- Return values
-
References busart_if_write().
uint16_t busart_if_write |
( |
uint8_t |
chn, |
|
|
const void * |
buffer, |
|
|
uint16_t |
len |
|
) |
| |
This function transmits a message.
- Note
- This function transmits characters via the specified USART. If so configured, the function waits until all characters are inserted in the transmission queue. In this case, the watchdog timer must be reloaded to avoid a program reset.
- Parameters
-
chn | Communication channel [0, 1] |
buffer | Pointer to information to transmit |
len | Number of characters to transmit |
- Return values
-
References NULL, pdc_read_tx_counter(), pdc_tx_init(), busart_comm_data_t::puc_tq_buf, pdc_packet::ul_addr, pdc_packet::ul_size, and UNUSED.
Referenced by _usi_encode_and_send(), and busart_if_tx_char().
uint8_t busart_chn_open[2] |
|
static |