GlobLib
HAL and API libraries for MCUs and hardware.
stm32f103cb_usart.h
Go to the documentation of this file.
1 #ifndef STM32F103CB_USART_H_
2 #define STM32F103CB_USART_H_
3 
63 #include <libopencm3/stm32/usart.h>
64 #include <libopencm3/stm32/rcc.h>
65 #include <libopencm3/cm3/nvic.h>
66 #include "stm32f103cb_gpio.h"
67 #include "stm32f103cb_debug.h"
68 #include <stdint.h>
69 
73 typedef void(*v_fp_u8)(uint8_t);
74 
79 typedef enum{
80 
85 
91 typedef enum{
92 
97 
102 typedef enum{
103 
106 }usart_stop;
107 
112 typedef enum{
113 
116 }usart_data;
117 
122 typedef enum{
123 
131 }usart_baud;
132 
137 typedef enum{
138 
141 }usart_isr;
142 
143 //Default option for the usart peripheral, set by USART_setup()
144 #define USART_DEFAULT_BAUD USART_BAUD_9600
145 #define USART_DEFAULT_STOP USART_STOP_ONE
146 #define USART_DEFAULT_DATA USART_DATA_EIGHT
147 #define USART_DEFAULT_PARITY USART_PARITY_NONE
148 
149 
180 mcu_error USART_put(usart_periph peripheral, uint8_t byte);
187 uint8_t USART_get(usart_periph peripheral);
195 mcu_error USART_setStop(usart_periph peripheral, usart_stop stopBits);
226 mcu_error USART_setRxISR (usart_periph peripheral, void (*new_handler)(uint8_t received));
240 mcu_error USART_setTxISR (usart_periph peripheral, void (*new_handler)(void));
248 mcu_error USART_enableISR(usart_periph peripheral, usart_isr isr_type);
256 mcu_error USART_disableISR(usart_periph peripheral, usart_isr isr_type);
257 
260 #endif
mcu_error USART_setStop(usart_periph peripheral, usart_stop stopBits)
Set the number of stop bits for the port.
mcu_error USART_setTxISR(usart_periph peripheral, void(*new_handler)(void))
Sets the target function called when transmit ISR is triggered.
4800bps buad rate
Recieve ISR.
Header file for stm32f103cb DEBUG.
Header file for stm32f103 GPIO.
usart_isr
ISR values for the port.
115200bps baud rate
mcu_error USART_setData(usart_periph peripheral, usart_data data)
Set the data frame size for the port.
Even parity for the port.
v_fp_u8 USART_add_put(usart_periph peripheral)
Return the address of the peripheral put function.
Transmit ISR.
mcu_error USART_disableISR(usart_periph peripheral, usart_isr isr_type)
Disables the specified ISR function.
usart_data
Data frame lengths for the port.
usart_periph
Peripheral ports available on the MCU.
Two stop bits for the port.
usart_stop
Stop bit options available for the port.
mcu_error USART_enableISR(usart_periph peripheral, usart_isr isr_type)
Enables the specified ISR function.
void(* v_fp_u8)(uint8_t)
Function pointer typedef for void function with uint8_t parameter.
19200bps baud rate
mcu_error USART_setParity(usart_periph peripheral, usart_parity parity)
Set the parity for the port.
No parity for the port.
38400bps baud rate
Eight bit data frame for the port.
First peripheral port.
Odd parity for the port.
usart_baud
Baud rate options for the port.
2400bps baud rate
uint8_t USART_get(usart_periph peripheral)
Get a byte on the given peripheral (blocking).
mcu_error USART_setup(usart_periph peripheral)
Initialize USART port.
mcu_error USART_put(usart_periph peripheral, uint8_t byte)
Send a byte on the given peripheral.
Third peripheral port.
57600bps baud rate
usart_parity
Parity option available for the port.
Second peripheral port.
One stop bit for the port.
mcu_error USART_setRxISR(usart_periph peripheral, void(*new_handler)(uint8_t received))
Sets the target function called when recieve ISR is triggered.
mcu_error USART_setBaud(usart_periph peripheral, usart_baud baud)
Set the baud rate for the port.
Nine bit data frame for the port.
9600bps baud rate
mcu_error
Error enumerators for the Debug peripheral.