Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
board.c
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
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 /*
18  * This file has been automatically generated using ChibiStudio board
19  * generator plugin. Do not edit manually.
20  */
21 
22 #include "hal.h"
23 #include "stm32_gpio.h"
24 
25 /*===========================================================================*/
26 /* Driver local definitions. */
27 /*===========================================================================*/
28 
29 /*===========================================================================*/
30 /* Driver exported variables. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver local variables and types. */
35 /*===========================================================================*/
36 
37 #if defined(STM32F1XX)
38 
42 const PALConfig pal_default_config = {
43  {VAL_GPIOA_ODR, VAL_GPIOA_CRL, VAL_GPIOA_CRH},
44  {VAL_GPIOB_ODR, VAL_GPIOB_CRL, VAL_GPIOB_CRH},
45  {VAL_GPIOC_ODR, VAL_GPIOC_CRL, VAL_GPIOC_CRH},
46  {VAL_GPIOD_ODR, VAL_GPIOD_CRL, VAL_GPIOD_CRH},
47  {VAL_GPIOE_ODR, VAL_GPIOE_CRL, VAL_GPIOE_CRH},
48 };
49 
50 #else /* STM32F1XX */
51 
55 typedef struct {
63 } gpio_setup_t;
64 
68 typedef struct {
69 #if STM32_HAS_GPIOA || defined(__DOXYGEN__)
70  gpio_setup_t PAData;
71 #endif
72 #if STM32_HAS_GPIOB || defined(__DOXYGEN__)
73  gpio_setup_t PBData;
74 #endif
75 #if STM32_HAS_GPIOC || defined(__DOXYGEN__)
76  gpio_setup_t PCData;
77 #endif
78 #if STM32_HAS_GPIOD || defined(__DOXYGEN__)
79  gpio_setup_t PDData;
80 #endif
81 #if STM32_HAS_GPIOE || defined(__DOXYGEN__)
82  gpio_setup_t PEData;
83 #endif
84 #if STM32_HAS_GPIOF || defined(__DOXYGEN__)
85  gpio_setup_t PFData;
86 #endif
87 #if STM32_HAS_GPIOG || defined(__DOXYGEN__)
88  gpio_setup_t PGData;
89 #endif
90 #if STM32_HAS_GPIOH || defined(__DOXYGEN__)
91  gpio_setup_t PHData;
92 #endif
93 #if STM32_HAS_GPIOI || defined(__DOXYGEN__)
94  gpio_setup_t PIData;
95 #endif
96 #if STM32_HAS_GPIOJ || defined(__DOXYGEN__)
97  gpio_setup_t PJData;
98 #endif
99 #if STM32_HAS_GPIOK || defined(__DOXYGEN__)
100  gpio_setup_t PKData;
101 #endif
102 } gpio_config_t;
103 
108 #if STM32_HAS_GPIOA
109  {
112  },
113 #endif
114 #if STM32_HAS_GPIOB
115  {
118  },
119 #endif
120 #if STM32_HAS_GPIOC
121  {
124  },
125 #endif
126 #if STM32_HAS_GPIOD
127  {
130  },
131 #endif
132 #if STM32_HAS_GPIOE
133  {
136  },
137 #endif
138 #if STM32_HAS_GPIOF
139  {
142  },
143 #endif
144 #if STM32_HAS_GPIOG
145  {
148  },
149 #endif
150 #if STM32_HAS_GPIOH
151  {
154  },
155 #endif
156 #if STM32_HAS_GPIOI
157  {
160  },
161 #endif
162 #if STM32_HAS_GPIOJ
163  {
166  },
167 #endif
168 #if STM32_HAS_GPIOK
169  {
172  }
173 #endif
174 };
175 
176 /*===========================================================================*/
177 /* Driver local functions. */
178 /*===========================================================================*/
179 
180 static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config)
181 {
182 
183  gpiop->OTYPER = config->otyper;
184  gpiop->OSPEEDR = config->ospeedr;
185  gpiop->PUPDR = config->pupdr;
186  gpiop->ODR = config->odr;
187  gpiop->AFRL = config->afrl;
188  gpiop->AFRH = config->afrh;
189  gpiop->MODER = config->moder;
190 }
191 
192 static void stm32_gpio_init(void)
193 {
194 
195  /* Enabling GPIO-related clocks, the mask comes from the
196  registry header file.*/
197 #if defined(STM32H7XX)
198  rccResetAHB4(STM32_GPIO_EN_MASK);
199  rccEnableAHB4(STM32_GPIO_EN_MASK, true);
200 #elif defined(STM32F3XX)
201  rccResetAHB(STM32_GPIO_EN_MASK);
202  rccEnableAHB(STM32_GPIO_EN_MASK, true);
203 #else
204  rccResetAHB1(STM32_GPIO_EN_MASK);
205  rccEnableAHB1(STM32_GPIO_EN_MASK, true);
206 #endif
207 
208  /* Initializing all the defined GPIO ports.*/
209 #if STM32_HAS_GPIOA
211 #endif
212 #if STM32_HAS_GPIOB
214 #endif
215 #if STM32_HAS_GPIOC
217 #endif
218 #if STM32_HAS_GPIOD
220 #endif
221 #if STM32_HAS_GPIOE
223 #endif
224 #if STM32_HAS_GPIOF
226 #endif
227 #if STM32_HAS_GPIOG
229 #endif
230 #if STM32_HAS_GPIOH
232 #endif
233 #if STM32_HAS_GPIOI
234  gpio_init(GPIOI, &gpio_default_config.PIData);
235 #endif
236 #if STM32_HAS_GPIOJ
237  gpio_init(GPIOJ, &gpio_default_config.PJData);
238 #endif
239 #if STM32_HAS_GPIOK
240  gpio_init(GPIOK, &gpio_default_config.PKData);
241 #endif
242 }
243 
244 #endif /* not STM32F1XX */
245 
246 /*===========================================================================*/
247 /* Driver interrupt handlers. */
248 /*===========================================================================*/
249 
250 /*===========================================================================*/
251 /* Driver exported functions. */
252 /*===========================================================================*/
253 
259 void __early_init(void)
260 {
261  stm32_gpio_init();
262  stm32_clock_init();
263 
264 #if defined(STM32H7XX)
265  SCB->ITCMCR |= 1; // ITCM enable
266  SCB->DTCMCR |= 1; // DTCM enable
267 #endif
268 }
269 
270 #if HAL_USE_SDC || defined(__DOXYGEN__)
274 bool sdc_lld_is_card_inserted(SDCDriver *sdcp)
275 {
276  (void)sdcp;
277  return true;
278 }
279 
283 bool sdc_lld_is_write_protected(SDCDriver *sdcp)
284 {
285 
286  (void)sdcp;
287  return false;
288 }
289 #endif /* HAL_USE_SDC */
290 
291 #if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
295 bool mmc_lld_is_card_inserted(MMCDriver *mmcp)
296 {
297  (void)mmcp;
298  /* TODO: Fill the implementation.*/
299  return true;
300 }
301 
305 bool mmc_lld_is_write_protected(MMCDriver *mmcp)
306 {
307  (void)mmcp;
308  /* TODO: Fill the implementation.*/
309  return false;
310 }
311 #endif
312 
317 void boardInit(void)
318 {
319 #if defined(AFIO_MAPR_VAL)
320  AFIO->MAPR |= AFIO_MAPR_VAL;
321 #endif
322 }
#define VAL_GPIOJ_OTYPER
Definition: board.h:1771
#define VAL_GPIOJ_AFRH
Definition: board.h:1848
#define VAL_GPIOK_AFRH
Definition: board.h:1951
#define VAL_GPIOK_AFRL
Definition: board.h:1942
#define VAL_GPIOE_AFRH
Definition: board.h:1333
#define VAL_GPIOA_AFRH
Definition: board.h:921
#define VAL_GPIOF_PUPDR
Definition: board.h:1393
#define VAL_GPIOF_MODER
Definition: board.h:1342
#define VAL_GPIOG_MODER
Definition: board.h:1445
#define VAL_GPIOD_OTYPER
Definition: board.h:1153
#define VAL_GPIOF_OTYPER
Definition: board.h:1359
#define VAL_GPIOH_PUPDR
Definition: board.h:1599
#define VAL_GPIOB_OSPEEDR
Definition: board.h:964
#define VAL_GPIOB_MODER
Definition: board.h:930
#define VAL_GPIOD_MODER
Definition: board.h:1136
#define VAL_GPIOG_ODR
Definition: board.h:1513
#define VAL_GPIOI_PUPDR
Definition: board.h:1702
#define VAL_GPIOF_AFRH
Definition: board.h:1436
#define VAL_GPIOH_AFRL
Definition: board.h:1633
#define VAL_GPIOC_ODR
Definition: board.h:1101
#define VAL_GPIOK_ODR
Definition: board.h:1925
#define VAL_GPIOD_AFRL
Definition: board.h:1221
#define VAL_GPIOC_MODER
Definition: board.h:1033
#define VAL_GPIOE_ODR
Definition: board.h:1307
#define VAL_GPIOH_MODER
Definition: board.h:1548
#define VAL_GPIOJ_OSPEEDR
Definition: board.h:1788
#define VAL_GPIOB_AFRL
Definition: board.h:1015
#define VAL_GPIOK_PUPDR
Definition: board.h:1908
#define VAL_GPIOK_OSPEEDR
Definition: board.h:1891
#define VAL_GPIOC_OSPEEDR
Definition: board.h:1067
#define VAL_GPIOE_OSPEEDR
Definition: board.h:1273
#define VAL_GPIOC_AFRH
Definition: board.h:1127
#define VAL_GPIOD_ODR
Definition: board.h:1204
#define VAL_GPIOD_OSPEEDR
Definition: board.h:1170
#define VAL_GPIOA_PUPDR
Definition: board.h:878
#define VAL_GPIOC_PUPDR
Definition: board.h:1084
#define VAL_GPIOB_PUPDR
Definition: board.h:981
#define VAL_GPIOK_OTYPER
Definition: board.h:1874
#define VAL_GPIOI_AFRH
Definition: board.h:1745
#define VAL_GPIOC_OTYPER
Definition: board.h:1050
#define VAL_GPIOG_OTYPER
Definition: board.h:1462
#define VAL_GPIOI_ODR
Definition: board.h:1719
#define VAL_GPIOA_OTYPER
Definition: board.h:844
#define VAL_GPIOB_OTYPER
Definition: board.h:947
#define VAL_GPIOE_PUPDR
Definition: board.h:1290
#define VAL_GPIOA_AFRL
Definition: board.h:912
#define VAL_GPIOA_ODR
Definition: board.h:895
#define VAL_GPIOE_MODER
Definition: board.h:1239
#define VAL_GPIOH_ODR
Definition: board.h:1616
#define VAL_GPIOI_OSPEEDR
Definition: board.h:1685
#define VAL_GPIOJ_PUPDR
Definition: board.h:1805
#define VAL_GPIOI_OTYPER
Definition: board.h:1668
#define VAL_GPIOH_OSPEEDR
Definition: board.h:1582
#define VAL_GPIOE_AFRL
Definition: board.h:1324
#define VAL_GPIOG_OSPEEDR
Definition: board.h:1479
#define VAL_GPIOH_AFRH
Definition: board.h:1642
#define VAL_GPIOF_OSPEEDR
Definition: board.h:1376
#define VAL_GPIOH_OTYPER
Definition: board.h:1565
#define VAL_GPIOJ_ODR
Definition: board.h:1822
#define VAL_GPIOG_AFRL
Definition: board.h:1530
#define VAL_GPIOF_ODR
Definition: board.h:1410
#define VAL_GPIOF_AFRL
Definition: board.h:1427
#define VAL_GPIOJ_MODER
Definition: board.h:1754
#define VAL_GPIOD_PUPDR
Definition: board.h:1187
#define VAL_GPIOK_MODER
Definition: board.h:1857
#define VAL_GPIOA_OSPEEDR
Definition: board.h:861
#define VAL_GPIOI_AFRL
Definition: board.h:1736
#define VAL_GPIOI_MODER
Definition: board.h:1651
#define VAL_GPIOG_AFRH
Definition: board.h:1539
#define VAL_GPIOG_PUPDR
Definition: board.h:1496
#define VAL_GPIOA_MODER
Definition: board.h:827
#define VAL_GPIOE_OTYPER
Definition: board.h:1256
#define VAL_GPIOB_AFRH
Definition: board.h:1024
#define VAL_GPIOJ_AFRL
Definition: board.h:1839
#define VAL_GPIOC_AFRL
Definition: board.h:1118
#define VAL_GPIOB_ODR
Definition: board.h:998
#define VAL_GPIOD_AFRH
Definition: board.h:1230
uint32_t pupdr
Definition: board.c:59
uint32_t afrh
Definition: board.c:62
void __early_init(void)
Early initialization code.
Definition: board.c:259
uint32_t odr
Definition: board.c:60
void boardInit(void)
Board-specific initialization code.
Definition: board.c:317
uint32_t afrl
Definition: board.c:61
static void stm32_gpio_init(void)
Definition: board.c:192
static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config)
Definition: board.c:180
static const gpio_config_t gpio_default_config
STM32 GPIO static initialization data.
Definition: board.c:107
uint32_t moder
Definition: board.c:56
uint32_t otyper
Definition: board.c:57
uint32_t ospeedr
Definition: board.c:58
Type of STM32 GPIO initialization data.
Definition: board.c:68
Type of STM32 GPIO port setup.
Definition: board.c:55
#define AFIO_MAPR_VAL
Remap several IO pins.
Definition: board.h:185
struct SDCDriver SDCDriver
Definition: sdio.h:30
#define GPIOG
Definition: gpio_arch.h:40
#define GPIOC
Definition: gpio_arch.h:36
#define GPIOF
Definition: gpio_arch.h:39
#define GPIOB
Definition: gpio_arch.h:35
#define GPIOD
Definition: gpio_arch.h:37
#define GPIOA
Definition: gpio_arch.h:34
#define GPIOH
Definition: gpio_arch.h:41
#define GPIOE
Definition: gpio_arch.h:38
static const struct usb_config_descriptor config
Definition: usb_ser_hw.c:200
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78