#include <stdio.h>
#include <aversive.h>
#include <uart_config.h>
#include <cirbuf.h>
Go to the source code of this file.
Data Structures | |
struct | uart_config |
Functions | |
void | uart_init (void) |
int8_t | uart_setconf (uint8_t num, struct uart_config *u) |
void | uart_getconf (uint8_t num, struct uart_config *u) |
int | uart_recv (uint8_t num) |
int | uart_recv_nowait (uint8_t num) |
int | uart_9bits_recv (uint8_t num) |
int | uart_9bits_recv_nowait (uint8_t num) |
int | uart_send_nowait (uint8_t num, char c) |
int | uart_send (uint8_t num, char c) |
int | uart_send_9bits_nowait (uint8_t num, int c) |
int | uart_send_9bits (uint8_t num, int c) |
void | uart_register_tx_event (uint8_t num, void(*f)(char)) |
void | uart_register_rx_event (uint8_t num, void(*f)(char)) |
void | uart_register_tx_9bits_event (uint8_t num, void(*f)(int)) |
void | uart_register_rx_9bits_event (uint8_t num, void(*f)(int)) |
int | uart0_dev_send_nowait (char c, FILE *f) |
int | uart0_dev_send (char c, FILE *f) |
int | uart0_dev_recv_nowait (FILE *f) |
int | uart0_dev_recv (FILE *f) |
int | uart1_dev_send_nowait (char c, FILE *f) |
int | uart1_dev_send (char c, FILE *f) |
int | uart1_dev_recv_nowait (FILE *f) |
int | uart1_dev_recv (FILE *f) |
int | uart2_dev_send_nowait (char c, FILE *f) |
int | uart2_dev_send (char c, FILE *f) |
int | uart2_dev_recv_nowait (FILE *f) |
int | uart2_dev_recv (FILE *f) |
int | uart3_dev_send_nowait (char c, FILE *f) |
int | uart3_dev_send (char c, FILE *f) |
int | uart3_dev_recv_nowait (FILE *f) |
int | uart3_dev_recv (FILE *f) |
This module provides :
Number of bits in frame, parity, stop bits are the same for tx and rx. TX fifo is useless if interrupts are disabled because the uart wait that all bytes are transmitted before returning.
It doesn't support some USART capabilities :
Definition in file uart.h.
int uart0_dev_recv | ( | FILE * | f | ) |
Referenced by main().
int uart0_dev_recv_nowait | ( | FILE * | f | ) |
int uart0_dev_send | ( | char | c, | |
FILE * | f | |||
) |
Referenced by main().
int uart0_dev_send_nowait | ( | char | c, | |
FILE * | f | |||
) |
int uart1_dev_recv | ( | FILE * | f | ) |
Referenced by main().
int uart1_dev_recv_nowait | ( | FILE * | f | ) |
int uart1_dev_send | ( | char | c, | |
FILE * | f | |||
) |
Referenced by main().
int uart1_dev_send_nowait | ( | char | c, | |
FILE * | f | |||
) |
int uart2_dev_recv | ( | FILE * | f | ) |
int uart2_dev_recv_nowait | ( | FILE * | f | ) |
int uart2_dev_send | ( | char | c, | |
FILE * | f | |||
) |
int uart2_dev_send_nowait | ( | char | c, | |
FILE * | f | |||
) |
int uart3_dev_recv | ( | FILE * | f | ) |
int uart3_dev_recv_nowait | ( | FILE * | f | ) |
int uart3_dev_send | ( | char | c, | |
FILE * | f | |||
) |
int uart3_dev_send_nowait | ( | char | c, | |
FILE * | f | |||
) |
int uart_9bits_recv | ( | uint8_t | num | ) |
same than uart_recv with 9 bits.
Definition at line 29 of file uart_recv9.c.
References parse_doc::elt, and uart_9bits_recv_nowait().
int uart_9bits_recv_nowait | ( | uint8_t | num | ) |
same than uart_recv_nowait() with 9 bits.
Definition at line 29 of file uart_recv9_nowait.c.
References cirbuf_del_buf_tail(), cirbuf_get_buf_tail(), CIRBUF_GET_LEN, parse_doc::elt, g_rx_fifo, IRQ_LOCK, and IRQ_UNLOCK.
Referenced by uart_9bits_recv().
void uart_getconf | ( | uint8_t | num, | |
struct uart_config * | u | |||
) |
Get the current configuration of the uart 'num'
Definition at line 123 of file uart_getconf.c.
References uart_config::baudrate, uart_config::enabled, F_CPU, uart_config::intr_enabled, IRQ_LOCK, IRQ_UNLOCK, uart_config::nbits, uart_config::parity, RXCIE, RXEN, uart_config::stop_bits, U2X, uart_getconf_nbits(), UART_HAS_U2X, UART_IS_USART, UART_PARTITY_EVEN, UART_PARTITY_NONE, UART_PARTITY_ODD, uart_regs, UART_STOP_BITS_1, UART_STOP_BITS_2, UPM0, UPM1, USBS, and uart_config::use_double_speed.
void uart_init | ( | void | ) |
Initialisation function. This function puts the registers of the microcontroler in a correct state in order to use the uart. It uses the configuration file <uart_config.h> ; this function is equivalent to call uartX_setconf(NULL) for each uart.
Definition at line 239 of file uart.c.
References uart_setconf().
Referenced by main().
int uart_recv | ( | uint8_t | num | ) |
uart_recv returns the next character, taken from the fifo (if any). If there is nothing to read, the function waits until something come on the uart.
Definition at line 47 of file uart_host.c.
References parse_doc::elt, and uart_recv_nowait().
int uart_recv_nowait | ( | uint8_t | num | ) |
uart_recv returns the next character, taken from the fifo (if any). If there is nothing to read, the function returns -1.
Definition at line 29 of file uart_recv_nowait.c.
References cirbuf_del_tail(), cirbuf_get_tail(), CIRBUF_IS_EMPTY, parse_doc::elt, g_rx_fifo, IRQ_LOCK, and IRQ_UNLOCK.
Referenced by uart_recv().
void uart_register_rx_9bits_event | ( | uint8_t | num, | |
void(*)(int) | f | |||
) |
This function is used to register another function which will be executed at each 9 bits reception. WARNING : it uses the same internal pointer that the 8 bits event, so be carreful to unregister 8 bits events when doing 9 bits and vice versa.
void uart_register_rx_event | ( | uint8_t | num, | |
void(*)(char) | f | |||
) |
This function is used to register another function which will be executed at each byte reception (5, 6 ,7 ,8 bits)
Definition at line 42 of file uart_events.c.
References parse_symbols::f, IRQ_LOCK, IRQ_UNLOCK, rx_event, and UART_HW_NUM.
void uart_register_tx_9bits_event | ( | uint8_t | num, | |
void(*)(int) | f | |||
) |
This function is used to register another function which will be executed at each 9 bits frame transmission. WARNING : it uses the same internal pointer that the 8 bits event, so be carreful to unregister 8 bits events when doing 9 bits and vice versa.
void uart_register_tx_event | ( | uint8_t | num, | |
void(*)(char) | f | |||
) |
This function is used to register another function which will be executed at each byte transmission (5, 6 ,7 ,8 bits)
Definition at line 30 of file uart_events.c.
References parse_symbols::f, IRQ_LOCK, IRQ_UNLOCK, tx_event, and UART_HW_NUM.
int uart_send | ( | uint8_t | num, | |
char | c | |||
) |
uart_send is used to send data to the uart 'num'. The data is first stored in the FIFO before beeing sent. If the FIFO is full, the function wait until the uart is ready. The function returns c.
Definition at line 57 of file uart_host.c.
References cirbuf_add_head(), g_tx_fifo, GLOBAL_IRQ_ARE_MASKED, RXCIE, uart_regs, uart_send_next_char(), uart_send_nowait(), and UDRE.
int uart_send_9bits | ( | uint8_t | num, | |
int | c | |||
) |
Definition at line 28 of file uart_send9.c.
References cirbuf_add_buf_head(), g_tx_fifo, GLOBAL_IRQ_ARE_MASKED, RXCIE, uart_regs, uart_send_9bits_nowait(), uart_send_next_char(), and UDRE.
int uart_send_9bits_nowait | ( | uint8_t | num, | |
int | c | |||
) |
uart_send_9bits is the same that uart_send but arg is 16 bits so data can be 9 bits wide.
Referenced by uart_send_9bits().
int uart_send_nowait | ( | uint8_t | num, | |
char | c | |||
) |
uart_send_nowait is used to send data to the uart 'num'. The data is first stored in the FIFO before beeing sent. If the FIFO is full, data is dropped and the function returns -1, else it returns the character c.
Definition at line 52 of file uart_host.c.
References cirbuf_add_head(), CIRBUF_IS_EMPTY, CIRBUF_IS_FULL, g_tx_fifo, IRQ_LOCK, IRQ_UNLOCK, RXCIE, sbi, uart_regs, UDRE, and UDRIE.
Referenced by uart_send().
int8_t uart_setconf | ( | uint8_t | num, | |
struct uart_config * | u | |||
) |
Configure the uart 'num' with the given configuration. Returns 0 on success.
Definition at line 38 of file uart_host.c.
Referenced by uart_init().