HRI board firmware v2.1 Microcontroller firmware of the board used during the HRI labs.

uart.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2017 EPFL-LSRO (Laboratoire de Systemes Robotiques).
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef __UART_H
18 #define __UART_H
19
20 #include "../main.h"
21 #include "../lib/circular_buffer.h"
22
23 #define USART_RX_Pin GPIO_Pin_5
24 #define USART_RX_PinSource GPIO_PinSource5
25 #define USART_RX_Port GPIOD
26 #define USART_TX_Pin GPIO_Pin_6
27 #define USART_TX_PinSource GPIO_PinSource6
28 #define USART_TX_Port GPIOD
29
30 #define USART_PC_COMM USART2 // UART peripheral used for the comm with the PC.
31
54 typedef void (*uart_rxByteHandlerFunc)(uint8_t rxByte);
55
56 void uart_Init(void);
57 void uart_Step(void);
58 cb_CircularBuffer* uart_GetRxQueue(void);
59 void uart_SendByteAsync(uint8_t data);
60 void uart_SendBytesAsync(uint8_t *data, int length);
61 void uart_FlushTx(void);
62
67 #endif
uart_SendByteAsync
void uart_SendByteAsync(uint8_t data)
Asynchronously sends the given byte through the UART bus.
Definition: uart.c:224
uart_FlushTx
void uart_FlushTx(void)
Start the DMA to send the bytes waiting in the intermediate buffer.
Definition: uart.c:299
uart_GetRxQueue
cb_CircularBuffer * uart_GetRxQueue(void)
Gets the user-accessible queue of the received bytes.
Definition: uart.c:175
uart_Init
void uart_Init(void)
Initializes the UART module.
Definition: uart.c:46
cb_CircularBuffer
Circular buffer structure.
Definition: circular_buffer.h:37
uart_rxByteHandlerFunc
void(* uart_rxByteHandlerFunc)(uint8_t rxByte)
Definition: uart.h:54
uart_SendBytesAsync
void uart_SendBytesAsync(uint8_t *data, int length)
Asynchronously sends the given bytes through the UART bus.
Definition: uart.c:258
uart_Step
void uart_Step(void)
Copies the received bytes into the user-accessible queue. Reads all the available bytes in the DMA RX...
Definition: uart.c:146