F7 optimizations (#5674)
[betaflight.git] / src / main / platform.h
blob671a35a0df6dd885cb3197e2f842e9a514be6d80
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #define NOINLINE __attribute__((noinline))
22 #if !defined(UNIT_TEST) && !defined(SITL) && !(USBD_DEBUG_LEVEL > 0)
23 #pragma GCC poison sprintf snprintf
24 #endif
26 #if defined(STM32F745xx) || defined(STM32F746xx) || defined(STM32F722xx)
27 #include "stm32f7xx.h"
28 #include "stm32f7xx_hal.h"
29 #include "system_stm32f7xx.h"
31 #include "stm32f7xx_ll_spi.h"
32 #include "stm32f7xx_ll_gpio.h"
33 #include "stm32f7xx_ll_dma.h"
34 #include "stm32f7xx_ll_rcc.h"
35 #include "stm32f7xx_ll_bus.h"
36 #include "stm32f7xx_ll_tim.h"
38 // Chip Unique ID on F7
39 #if defined(STM32F722xx)
40 #define U_ID_0 (*(uint32_t*)0x1ff07a10)
41 #define U_ID_1 (*(uint32_t*)0x1ff07a14)
42 #define U_ID_2 (*(uint32_t*)0x1ff07a18)
43 #else
44 #define U_ID_0 (*(uint32_t*)0x1ff0f420)
45 #define U_ID_1 (*(uint32_t*)0x1ff0f424)
46 #define U_ID_2 (*(uint32_t*)0x1ff0f428)
47 #endif
49 #ifndef STM32F7
50 #define STM32F7
51 #endif
53 #elif defined(STM32F40_41xxx) || defined (STM32F411xE) || defined (STM32F446xx)
55 #include "stm32f4xx.h"
57 // Chip Unique ID on F405
58 #define U_ID_0 (*(uint32_t*)0x1fff7a10)
59 #define U_ID_1 (*(uint32_t*)0x1fff7a14)
60 #define U_ID_2 (*(uint32_t*)0x1fff7a18)
62 #ifndef STM32F4
63 #define STM32F4
64 #endif
66 #elif defined(STM32F303xC)
67 #include "stm32f30x_conf.h"
68 #include "stm32f30x_rcc.h"
69 #include "stm32f30x_gpio.h"
70 #include "core_cm4.h"
72 // Chip Unique ID on F303
73 #define U_ID_0 (*(uint32_t*)0x1FFFF7AC)
74 #define U_ID_1 (*(uint32_t*)0x1FFFF7B0)
75 #define U_ID_2 (*(uint32_t*)0x1FFFF7B4)
77 #ifndef STM32F3
78 #define STM32F3
79 #endif
81 #elif defined(STM32F10X)
83 #include "stm32f10x_conf.h"
84 #include "stm32f10x_gpio.h"
85 #include "core_cm3.h"
87 // Chip Unique ID on F103
88 #define U_ID_0 (*(uint32_t*)0x1FFFF7E8)
89 #define U_ID_1 (*(uint32_t*)0x1FFFF7EC)
90 #define U_ID_2 (*(uint32_t*)0x1FFFF7F0)
92 #ifndef STM32F1
93 #define STM32F1
94 #endif
96 #elif defined(SITL)
98 // Nop
100 #else // STM32F10X
101 #error "Invalid chipset specified. Update platform.h"
102 #endif
104 #ifdef USE_OSD_SLAVE
105 #include "target/common_osd_slave.h"
106 #include "target.h"
107 #else
108 #include "target/common_fc_pre.h"
109 #include "target.h"
110 #include "target/common_fc_post.h"
111 #endif