Create release.yml
[betaflight.git] / src / main / pg / serial_uart.c
blobb9700d5b0d4a48da877849733295b1ecfe120039
1 /*
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)
8 * any later version.
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/>.
21 #include <stdint.h>
22 #include <stdbool.h>
24 #include "platform.h"
26 #ifdef USE_UART
28 #include "common/utils.h"
30 #include "pg/pg.h"
31 #include "pg/pg_ids.h"
32 #include "pg/serial_uart.h"
34 #include "drivers/io_types.h"
35 #include "drivers/serial.h"
36 #include "drivers/serial_uart.h"
38 PG_REGISTER_ARRAY_WITH_RESET_FN(serialUartConfig_t, UARTDEV_CONFIG_MAX, serialUartConfig, PG_SERIAL_UART_CONFIG, 0);
40 typedef struct uartDmaopt_s {
41 UARTDevice_e device;
42 int8_t txDmaopt;
43 int8_t rxDmaopt;
44 } uartDmaopt_t;
46 static uartDmaopt_t uartDmaopt[] = {
47 #ifdef USE_UART1
48 { UARTDEV_1, UART1_TX_DMA_OPT, UART1_RX_DMA_OPT },
49 #endif
50 #ifdef USE_UART2
51 { UARTDEV_2, UART2_TX_DMA_OPT, UART2_RX_DMA_OPT },
52 #endif
53 #ifdef USE_UART3
54 { UARTDEV_3, UART3_TX_DMA_OPT, UART3_RX_DMA_OPT },
55 #endif
56 #ifdef USE_UART4
57 { UARTDEV_4, UART4_TX_DMA_OPT, UART4_RX_DMA_OPT },
58 #endif
59 #ifdef USE_UART5
60 { UARTDEV_5, UART5_TX_DMA_OPT, UART5_RX_DMA_OPT },
61 #endif
62 #ifdef USE_UART6
63 { UARTDEV_6, UART6_TX_DMA_OPT, UART6_RX_DMA_OPT },
64 #endif
65 #ifdef USE_UART7
66 { UARTDEV_7, UART7_TX_DMA_OPT, UART7_RX_DMA_OPT },
67 #endif
68 #ifdef USE_UART8
69 { UARTDEV_8, UART8_TX_DMA_OPT, UART8_RX_DMA_OPT },
70 #endif
71 #ifdef USE_UART9
72 { UARTDEV_9, UART9_TX_DMA_OPT, UART9_RX_DMA_OPT },
73 #endif
74 #ifdef USE_UART10
75 { UARTDEV_10, UART10_TX_DMA_OPT, UART10_RX_DMA_OPT },
76 #endif
79 void pgResetFn_serialUartConfig(serialUartConfig_t *config)
81 for (unsigned i = 0; i < UARTDEV_CONFIG_MAX; i++) {
82 config[i].txDmaopt = -1;
83 config[i].rxDmaopt = -1;
86 for (unsigned i = 0; i < ARRAYLEN(uartDmaopt); i++) {
87 UARTDevice_e device = uartDmaopt[i].device;
88 config[device].txDmaopt = uartDmaopt[i].txDmaopt;
89 config[device].rxDmaopt = uartDmaopt[i].rxDmaopt;
92 #endif