![]() |
Paparazzi UAS
v6.3_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
UART/Serial driver implementation for ChibiOS arch. More...
#include "mcu_periph/uart_arch.h"
#include <ch.h>
#include <hal.h>
#include "mcu_periph/gpio.h"
#include <BOARD_CONFIG>
Go to the source code of this file.
Data Structures | |
struct | SerialInit |
Macros | |
#define | UART_THREAD_STACK_SIZE 512 |
#define | SERIAL_INIT_NULL { NULL, NULL, NULL, NULL, NULL, 0, 0 } |
Functions | |
static UNUSED void | handle_uart_rx (struct uart_periph *p) |
RX handler. More... | |
static UNUSED void | handle_uart_tx (struct uart_periph *p) |
TX handler. More... | |
uint8_t | uart_getch (struct uart_periph *p) |
void | uart_periph_set_baudrate (struct uart_periph *p, uint32_t baud) |
Set baudrate. 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_set_bits_stop_parity (struct uart_periph *p, uint8_t bits, uint8_t stop, uint8_t parity) |
Set parity and stop bits. More... | |
int | uart_check_free_space (struct uart_periph *p, long *fd, uint16_t len) |
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... | |
void | uart_send_message (struct uart_periph *p, long fd) |
UART/Serial driver implementation for ChibiOS arch.
ChibiOS has a high level Serial Driver, for Paparazzi it is more convenient than pure UART driver (which needs callbacks etc.). This implementation is asynchronous and the RX thread has to use event flags. See ChibiOS documen- tation.
Definition in file uart_arch.c.
struct SerialInit |
Definition at line 48 of file uart_arch.c.
Data Fields | ||
---|---|---|
SerialConfig * | conf | |
uint16_t | cts_pin | |
ioportid_t | cts_port | |
mutex_t * | rx_mtx | |
semaphore_t * | rx_sem | |
mutex_t * | tx_mtx | |
semaphore_t * | tx_sem |
#define SERIAL_INIT_NULL { NULL, NULL, NULL, NULL, NULL, 0, 0 } |
Definition at line 58 of file uart_arch.c.
#define UART_THREAD_STACK_SIZE 512 |
Definition at line 45 of file uart_arch.c.
|
static |
RX handler.
Definition at line 63 of file uart_arch.c.
References p, SerialInit::rx_mtx, SerialInit::rx_sem, and UART_RX_BUFFER_SIZE.
|
static |
TX handler.
Definition at line 84 of file uart_arch.c.
References SerialInit::cts_pin, SerialInit::cts_port, gpio_get(), p, SerialInit::tx_mtx, SerialInit::tx_sem, and UART_TX_BUFFER_SIZE.
int uart_check_free_space | ( | struct uart_periph * | p, |
long * | fd, | ||
uint16_t | len | ||
) |
Definition at line 1078 of file uart_arch.c.
References fd, p, SerialInit::tx_mtx, and UART_TX_BUFFER_SIZE.
Referenced by send_buffer_to_uart(), and tunnel_event().
uint8_t uart_getch | ( | struct uart_periph * | p | ) |
Definition at line 968 of file uart_arch.c.
References p, SerialInit::rx_mtx, 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(), jevois_event(), periodic_switch_uart(), sbus_common_decode_event(), spektrum_uart_check(), sts3032_event(), syslink_dl_event(), tunnel_event(), and vn200_read_buffer().
void uart_periph_set_baudrate | ( | struct uart_periph * | p, |
uint32_t | baud | ||
) |
Set baudrate.
Definition at line 984 of file uart_arch.c.
References SerialInit::conf, and p.
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 1014 of file uart_arch.c.
References SerialInit::conf, p, 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 1123 of file uart_arch.c.
References fd, p, SerialInit::tx_mtx, SerialInit::tx_sem, and UART_TX_BUFFER_SIZE.
Referenced by actuators_ostrich_periodic(), if(), send_message(), and sts3032_event().
void uart_put_byte | ( | struct uart_periph * | p, |
long | fd, | ||
uint8_t | data | ||
) |
Uart transmit implementation.
Definition at line 1096 of file uart_arch.c.
References fd, p, SerialInit::tx_mtx, SerialInit::tx_sem, and UART_TX_BUFFER_SIZE.
Referenced by direct_memory_logger_periodic(), drop_ball(), esc32_periodic(), esc32_send(), gps_piksi_write(), hott_send_telemetry_data(), jevois_send_string(), send_buffer_to_uart(), tunnel_event(), uart_periph_init(), and uart_put_buffer().
void uart_send_message | ( | struct uart_periph * | p, |
long | fd | ||
) |
Definition at line 1153 of file uart_arch.c.
References fd, p, SerialInit::tx_mtx, and SerialInit::tx_sem.