Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
arch independent UART (Universal Asynchronous Receiver/Transmitter) API More...
#include "mcu_periph/uart_arch.h"
#include "pprzlink/pprzlink_device.h"
#include "std.h"
Go to the source code of this file.
Data Structures | |
struct | uart_periph |
UART peripheral. More... | |
Macros | |
#define | UART_RX_BUFFER_SIZE 128 |
#define | UART_TX_BUFFER_SIZE 128 |
#define | UART_DEV_NAME_SIZE 16 |
#define | UBITS_7 7 |
#define | UBITS_8 8 |
#define | USTOP_1 1 |
#define | USTOP_2 2 |
#define | UPARITY_NO 0 |
#define | UPARITY_ODD 1 |
#define | UPARITY_EVEN 2 |
Functions | |
void | uart_periph_init (struct uart_periph *p) |
void | uart_periph_set_baudrate (struct uart_periph *p, uint32_t baud) |
Set baudrate. More... | |
void | uart_periph_set_bits_stop_parity (struct uart_periph *p, uint8_t bits, uint8_t stop, uint8_t parity) |
Set parity and stop bits. More... | |
void | uart_periph_set_mode (struct uart_periph *p, bool tx_enabled, bool rx_enabled, bool hw_flow_control) |
Set mode (not necessary, or can be set by SerialConfig) More... | |
void | uart_periph_invert_data_logic (struct uart_periph *p, bool invert_rx, bool invert_tx) |
void | uart_put_byte (struct uart_periph *p, long fd, uint8_t data) |
Uart transmit implementation. More... | |
void | uart_put_buffer (struct uart_periph *p, long fd, const uint8_t *data, uint16_t len) |
Uart transmit buffer implementation. More... | |
int | uart_check_free_space (struct uart_periph *p, long *fd, uint16_t len) |
void | uart_send_message (struct uart_periph *p, long fd) |
uint8_t | uart_getch (struct uart_periph *p) |
int | uart_char_available (struct uart_periph *p) |
Check UART for available chars in receive buffer. More... | |
void | uart_arch_init (void) |
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
Definition in file uart.h.
struct uart_periph |
Data Fields | ||
---|---|---|
int | baudrate | UART Baudrate. |
char | dev[UART_DEV_NAME_SIZE] | UART Dev (linux) |
struct link_device | device | Generic device interface. |
volatile uint16_t | fe_err | framing error counter |
void * | init_struct | User init struct. |
volatile uint16_t | ne_err | noise error counter |
volatile uint16_t | ore | overrun error counter |
void * | reg_addr | UART Register. |
uint8_t | rx_buf[UART_RX_BUFFER_SIZE] | Receive buffer. |
uint16_t | rx_extract_idx | |
uint16_t | rx_insert_idx | |
uint8_t | tx_buf[UART_TX_BUFFER_SIZE] | Transmit buffer. |
uint16_t | tx_extract_idx | |
uint16_t | tx_insert_idx | |
volatile uint8_t | tx_running |
void uart_arch_init | ( | void | ) |
Definition at line 54 of file uart_arch.c.
References uart_mutex, and uart_thread().
Referenced by mcu_init().
int uart_char_available | ( | struct uart_periph * | p | ) |
Check UART for available chars in receive buffer.
Definition at line 323 of file uart_arch.c.
References p, uart_mutex, and UART_RX_BUFFER_SIZE.
Referenced by airspeed_uADC_event(), dw1000_arduino_event(), esc32_event(), gps_piksi_event(), gps_piksi_read(), high_speed_logger_direct_memory_periodic(), hott_check_serial_data(), hott_common_decode_event(), hott_send_telemetry_data(), imu_gx3_event(), imu_um6_event(), jevois_event(), periodic_switch_uart(), ReadGX3Buffer(), sbus_common_decode_event(), spektrum_uart_check(), syslink_dl_event(), tunnel_event(), uart_periph_init(), vn200_event(), and vn200_read_buffer().
int uart_check_free_space | ( | struct uart_periph * | p, |
long * | fd, | ||
uint16_t | len | ||
) |
Definition at line 1077 of file uart_arch.c.
References fd, p, SerialInit::tx_mtx, and UART_TX_BUFFER_SIZE.
Referenced by send_buffer_to_uart(), tunnel_event(), and uart_periph_init().
uint8_t uart_getch | ( | struct uart_periph * | p | ) |
Definition at line 968 of file uart_arch.c.
References p, SerialInit::rx_mtx, uart_mutex, and UART_RX_BUFFER_SIZE.
Referenced by airspeed_uADC_event(), dw1000_arduino_event(), esc32_event(), gps_piksi_read(), high_speed_logger_direct_memory_periodic(), hott_check_serial_data(), hott_common_decode_event(), hott_send_telemetry_data(), imu_um6_event(), jevois_event(), periodic_switch_uart(), ReadGX3Buffer(), sbus_common_decode_event(), spektrum_uart_check(), syslink_dl_event(), tunnel_event(), uart_periph_init(), and vn200_read_buffer().
void uart_periph_init | ( | struct uart_periph * | p | ) |
Definition at line 231 of file uart.c.
References DefaultPeriodic, p, register_periodic_telemetry(), send_uart_err(), uart_char_available(), uart_check_free_space(), uart_getch(), uart_periph_set_baudrate(), uart_put_buffer(), uart_put_byte(), and uart_send_message().
Referenced by high_speed_logger_direct_memory_init().
void uart_periph_invert_data_logic | ( | struct uart_periph * | p, |
bool | invert_rx, | ||
bool | invert_tx | ||
) |
Definition at line 299 of file uart.c.
Referenced by sbus_common_init().
void uart_periph_set_baudrate | ( | struct uart_periph * | p, |
uint32_t | baud | ||
) |
Set baudrate.
Definition at line 984 of file uart_arch.c.
References uart_periph::baudrate, SerialInit::conf, p, uart_periph::reg_addr, serial_port_set_baudrate(), uart_disable_interrupts(), uart_enable_interrupts(), uart_periph_open(), and uart_set_baudrate().
Referenced by actuators_sbus_init(), gps_ubx_ucenter_autobaud(), gps_ubx_ucenter_configure(), hott_common_init(), px4flash_event(), sbus_common_init(), and uart_periph_init().
void uart_periph_set_bits_stop_parity | ( | struct uart_periph * | p, |
uint8_t | bits, | ||
uint8_t | stop, | ||
uint8_t | parity | ||
) |
Set parity and stop bits.
Definition at line 1013 of file uart_arch.c.
References SerialInit::conf, p, uart_periph::reg_addr, serial_port_set_bits_stop_parity(), UBITS_7, UPARITY_EVEN, UPARITY_ODD, and USTOP_2.
Referenced by actuators_sbus_init(), high_speed_logger_direct_memory_init(), hott_common_init(), and sbus_common_init().
void uart_periph_set_mode | ( | struct uart_periph * | p, |
bool | tx_enabled, | ||
bool | rx_enabled, | ||
bool | hw_flow_control | ||
) |
Set mode (not necessary, or can be set by SerialConfig)
Definition at line 999 of file uart_arch.c.
Referenced by hott_enable_receiver(), and hott_enable_transmitter().
void uart_put_buffer | ( | struct uart_periph * | p, |
long | fd, | ||
const uint8_t * | data, | ||
uint16_t | len | ||
) |
Uart transmit buffer implementation.
Definition at line 1122 of file uart_arch.c.
References fd, p, SerialInit::tx_mtx, SerialInit::tx_sem, uart_put_byte(), and UART_TX_BUFFER_SIZE.
Referenced by actuators_ostrich_periodic(), if(), send_message(), and uart_periph_init().
void uart_put_byte | ( | struct uart_periph * | p, |
long | fd, | ||
uint8_t | data | ||
) |
Uart transmit implementation.
Definition at line 1095 of file uart_arch.c.
References disableIRQ(), fd, SerialPort::fd, p, uart_periph::reg_addr, restoreIRQ(), TRACE, SerialInit::tx_mtx, SerialInit::tx_sem, UART_TX_BUFFER_SIZE, and UIER_ETBEI.
Referenced by ahrs_gx3_align(), direct_memory_logger_periodic(), drop_ball(), esc32_periodic(), esc32_send(), gps_piksi_write(), hott_send_telemetry_data(), imu_gx3_init(), jevois_send_string(), send_buffer_to_uart(), tunnel_event(), uart_periph_init(), uart_put_buffer(), and UM6_send_packet().
void uart_send_message | ( | struct uart_periph * | p, |
long | fd | ||
) |
Definition at line 1152 of file uart_arch.c.
References fd, p, SerialInit::tx_mtx, and SerialInit::tx_sem.
Referenced by uart_periph_init().