ASCII Serial Com
Serial communication library between computers, microcontrollers, FPGAs, etc. Uses only ASCII. Not the most efficient protocol, but meant to be easy to read
|
To be used with the USART peripherals on STM32 microcontrollers. More...
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/usart.h>
#include <stdint.h>
Go to the source code of this file.
Macros | |
#define | setup_usart(usart, baud, tx_port, tx_pin, tx_af, rx_port, rx_pin, rx_af) |
Setup a USART. | |
#define | def_usart_isr_push_rx_to_circ_buf(isr_name, usart, circular_buffer) |
Define the ISR for a USART to push rx bytes to a circular buffer. | |
To be used with the USART peripherals on STM32 microcontrollers.
Definition in file stm_usart.h.
#define def_usart_isr_push_rx_to_circ_buf | ( | isr_name, | |
usart, | |||
circular_buffer ) |
Define the ISR for a USART to push rx bytes to a circular buffer.
Defines the interrupt handler for the given USART. The interrupt handler will push all rx bytes to the back of the circular buffer the user provides.
DON'T USE A SEMICOLON AFTER THIS MACRO.
Use atomic operations to remove data from the front of the circular buffer like CM_ATOMIC_BLOCK() {}
Make sure to setup the USART and run both nvic_enable_irq(NVIC_<usart>_IRQ);
and usart_enable_rx_interrupt(<usart>);
Not sure if this works with UARTs or LPUARTs
isr_name: usart1_isr, usart2_isr, ...
usart: the USART you want to use like USART1, USART2, ...
circular_buffer: a pointer to a circular_buffer_uint8 that you want received bytes pushed_back on.
Definition at line 95 of file stm_usart.h.
#define setup_usart | ( | usart, | |
baud, | |||
tx_port, | |||
tx_pin, | |||
tx_af, | |||
rx_port, | |||
rx_pin, | |||
rx_af ) |
Setup a USART.
Setup a USART in async, 8 bit, 1 stop bit, no parity, no flow-control, tx-rx mode.
The user must setup the peripheral clocks for both this USART and the GPIO input/outpu port(s).
The user must enable the USART when ready with: usart_enable(usart);
This macro takes care of setting up the GPIO pins.
Not sure if this works with UARTs or LPUARTs
usart: the USART you want to use like USART1, USART2, ...
baud: the baud rate of the USART, uint32_t
tx_port: GPIOA, GPIOB, ...
tx_pin: GPIO0, GPIO1, ...
tx_af: alternate function for the given pin/port to hook it up to the USART, e.g. GPIO_AF0, GPIO_AF1, ...
rx_port: GPIOA, GPIOB, ...
rx_pin: GPIO0, GPIO1, ...
rx_af: alternate function for the given pin/port to hook it up to the USART, e.g. GPIO_AF0, GPIO_AF1, ...
Definition at line 52 of file stm_usart.h.