2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
23 #include "drivers/dma.h" // For dmaResource_t
25 // Since serial ports can be used for any function these buffer sizes should be equal
26 // The two largest things that need to be sent are: 1, MSP responses, 2, UBLOX SVINFO packet.
28 // Size must be a power of two due to various optimizations which use 'and' instead of 'mod'
29 // Various serial routines return the buffer occupied size as uint8_t which would need to be extended in order to
30 // increase size further.
46 typedef struct uartPort_s
{
51 DMA_HandleTypeDef rxDMAHandle
;
52 DMA_HandleTypeDef txDMAHandle
;
55 dmaResource_t
*rxDMAResource
;
56 dmaResource_t
*txDMAResource
;
57 uint32_t rxDMAChannel
;
58 uint32_t txDMAChannel
;
65 uint32_t txDMAPeripheralBaseAddr
;
66 uint32_t rxDMAPeripheralBaseAddr
;
70 // All USARTs can also be used as UART, and we use them only as UART.
71 UART_HandleTypeDef Handle
;
73 USART_TypeDef
*USARTx
;
77 void uartPinConfigure(const serialPinConfig_t
*pSerialPinConfig
);
78 serialPort_t
*uartOpen(UARTDevice_e device
, serialReceiveCallbackPtr rxCallback
, void *rxCallbackData
, uint32_t baudRate
, portMode_e mode
, portOptions_e options
);