33#include <libopencm3/stm32/gpio.h>
34#include <libopencm3/stm32/rcc.h>
35#include <libopencm3/stm32/usart.h>
36#include <libopencm3/cm3/nvic.h>
117 if (temp ==
p->tx_extract_idx) {
125 p->tx_buf[
p->tx_insert_idx] = data;
126 p->tx_insert_idx = temp;
128 p->tx_running =
true;
142 if (
p->tx_insert_idx !=
p->tx_extract_idx) {
147 p->tx_running =
false;
160 if (temp !=
p->rx_extract_idx) {
161 p->rx_insert_idx = temp;
198#define USE_UART1_TX TRUE
201#define USE_UART1_RX TRUE
204#ifndef UART1_HW_FLOW_CONTROL
205#define UART1_HW_FLOW_CONTROL FALSE
209#define UART1_BITS UBITS_8
213#define UART1_STOP USTOP_1
217#define UART1_PARITY UPARITY_NO
239#if UART1_HW_FLOW_CONTROL
240#warning "USING UART1 FLOW CONTROL. Make sure to pull down CTS if you are not connecting any flow-control-capable hardware."
263#define USE_UART2_TX TRUE
266#define USE_UART2_RX TRUE
269#ifndef UART2_HW_FLOW_CONTROL
270#define UART2_HW_FLOW_CONTROL FALSE
274#define UART2_BITS UBITS_8
278#define UART2_STOP USTOP_1
282#define UART2_PARITY UPARITY_NO
304#if UART2_HW_FLOW_CONTROL && defined(STM32F4)
305#warning "USING UART2 FLOW CONTROL. Make sure to pull down CTS if you are not connecting any flow-control-capable hardware."
328#define USE_UART3_TX TRUE
331#define USE_UART3_RX TRUE
334#ifndef UART3_HW_FLOW_CONTROL
335#define UART3_HW_FLOW_CONTROL FALSE
339#define UART3_BITS UBITS_8
343#define UART3_STOP USTOP_1
347#define UART3_PARITY UPARITY_NO
369#if UART3_HW_FLOW_CONTROL && defined(STM32F4)
370#warning "USING UART3 FLOW CONTROL. Make sure to pull down CTS if you are not connecting any flow-control-capable hardware."
393#define USE_UART4_TX TRUE
396#define USE_UART4_RX TRUE
400#define UART4_BITS UBITS_8
404#define UART4_STOP USTOP_1
408#define UART4_PARITY UPARITY_NO
445#define USE_UART5_TX TRUE
448#define USE_UART5_RX TRUE
452#define UART5_BITS UBITS_8
456#define UART5_STOP USTOP_1
460#define UART5_PARITY UPARITY_NO
493#if USE_UART6 && defined STM32F4
497#define USE_UART6_TX TRUE
500#define USE_UART6_RX TRUE
503#ifndef UART6_HW_FLOW_CONTROL
504#define UART6_HW_FLOW_CONTROL FALSE
508#define UART6_BITS UBITS_8
512#define UART6_STOP USTOP_1
516#define UART6_PARITY UPARITY_NO
539#if UART6_HW_FLOW_CONTROL
540#warning "USING UART6 FLOW CONTROL. Make sure to pull down CTS if you are not connecting any flow-control-capable hardware."
561#define USE_UART7_TX TRUE
564#define USE_UART7_RX TRUE
568#define UART7_BITS UBITS_8
572#define UART7_STOP USTOP_1
576#define UART7_PARITY UPARITY_NO
613#define USE_UART8_TX TRUE
616#define USE_UART8_RX TRUE
620#define UART8_BITS UBITS_8
624#define UART8_STOP USTOP_1
628#define UART8_PARITY UPARITY_NO
#define UART4_GPIO_PORT_RX
#define UART1_GPIO_PORT_TX
#define UART6_GPIO_PORT_RX
#define UART2_GPIO_PORT_RX
#define UART1_GPIO_PORT_RX
#define UART6_GPIO_PORT_TX
#define UART4_GPIO_PORT_TX
#define UART3_GPIO_PORT_TX
#define UART3_GPIO_PORT_RX
void gpio_setup_pin_af(ioportid_t port, uint16_t pin, uint8_t af, bool is_output)
Setup a gpio for input or output with alternate function.
#define UART8_GPIO_PORT_RX
#define USE_UART7_RX
SBUS / Spektrum port.
#define UART2_HW_FLOW_CONTROL
#define UART7_GPIO_PORT_RX
#define UART8_GPIO_PORT_TX
#define UART2_GPIO_PORT_TX
UART2 (with optional flow control activated by default)
#define UART1_GPIO_AF
UART defines.
#define UART6_GPIO_PORT_CTS
#define UART5_GPIO_PORT_TX
#define UART5_GPIO_PORT_RX
Some architecture independent helper functions for GPIOs.
#define USE_UART6_RX
SBUS / Spektrum port.
void uart_put_byte(struct uart_periph *periph, long fd, uint8_t data)
void uart_periph_set_bits_stop_parity(struct uart_periph *periph, uint8_t bits, uint8_t stop, uint8_t parity)
void uart_periph_set_baudrate(struct uart_periph *periph, uint32_t baud)
#define UART_TX_BUFFER_SIZE
#define UART_RX_BUFFER_SIZE
#define UART7_GPIO_PORT_TX
UART7 (Modem with optional flow control disabled by default)
#define USE_UART8_RX
SBUS / Spektrum port.
#define UART3_GPIO_PORT_CTS
#define UART2_GPIO_PORT_RTS
#define UART3_GPIO_PORT_RTS
#define UART2_GPIO_PORT_CTS
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
static void usart_enable_irq(uint8_t IRQn)
void uart_periph_set_mode(struct uart_periph *p, bool tx_enabled, bool rx_enabled, bool hw_flow_control)
static void usart_isr(struct uart_periph *p)
void uart_periph_init(struct uart_periph *p)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.