Paparazzi UAS  v5.18.0_stable
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 
40 typedef struct {
41  uint32_t moder;
42  uint32_t otyper;
43  uint32_t ospeedr;
44  uint32_t pupdr;
45  uint32_t odr;
46  uint32_t afrl;
47  uint32_t afrh;
48 } gpio_setup_t;
49 
53 typedef struct {
54 #if STM32_HAS_GPIOA || defined(__DOXYGEN__)
55  gpio_setup_t PAData;
56 #endif
57 #if STM32_HAS_GPIOB || defined(__DOXYGEN__)
58  gpio_setup_t PBData;
59 #endif
60 #if STM32_HAS_GPIOC || defined(__DOXYGEN__)
61  gpio_setup_t PCData;
62 #endif
63 #if STM32_HAS_GPIOD || defined(__DOXYGEN__)
64  gpio_setup_t PDData;
65 #endif
66 #if STM32_HAS_GPIOE || defined(__DOXYGEN__)
67  gpio_setup_t PEData;
68 #endif
69 #if STM32_HAS_GPIOF || defined(__DOXYGEN__)
70  gpio_setup_t PFData;
71 #endif
72 #if STM32_HAS_GPIOG || defined(__DOXYGEN__)
73  gpio_setup_t PGData;
74 #endif
75 #if STM32_HAS_GPIOH || defined(__DOXYGEN__)
76  gpio_setup_t PHData;
77 #endif
78 #if STM32_HAS_GPIOI || defined(__DOXYGEN__)
79  gpio_setup_t PIData;
80 #endif
81 #if STM32_HAS_GPIOJ || defined(__DOXYGEN__)
82  gpio_setup_t PJData;
83 #endif
84 #if STM32_HAS_GPIOK || defined(__DOXYGEN__)
85  gpio_setup_t PKData;
86 #endif
88 
93 #if STM32_HAS_GPIOA
96 #endif
97 #if STM32_HAS_GPIOB
100 #endif
101 #if STM32_HAS_GPIOC
104 #endif
105 #if STM32_HAS_GPIOD
108 #endif
109 #if STM32_HAS_GPIOE
112 #endif
113 #if STM32_HAS_GPIOF
116 #endif
117 #if STM32_HAS_GPIOG
120 #endif
121 #if STM32_HAS_GPIOH
124 #endif
125 #if STM32_HAS_GPIOI
128 #endif
129 #if STM32_HAS_GPIOJ
132 #endif
133 #if STM32_HAS_GPIOK
136 #endif
137 };
138 
139 /*===========================================================================*/
140 /* Driver local functions. */
141 /*===========================================================================*/
142 
143 static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) {
144 
145  gpiop->OTYPER = config->otyper;
146  gpiop->OSPEEDR = config->ospeedr;
147  gpiop->PUPDR = config->pupdr;
148  gpiop->ODR = config->odr;
149  gpiop->AFRL = config->afrl;
150  gpiop->AFRH = config->afrh;
151  gpiop->MODER = config->moder;
152 }
153 
154 static void stm32_gpio_init(void) {
155 
156  /* Enabling GPIO-related clocks, the mask comes from the
157  registry header file.*/
158  rccResetAHB1(STM32_GPIO_EN_MASK);
159  rccEnableAHB1(STM32_GPIO_EN_MASK, true);
160 
161  /* Initializing all the defined GPIO ports.*/
162 #if STM32_HAS_GPIOA
164 #endif
165 #if STM32_HAS_GPIOB
167 #endif
168 #if STM32_HAS_GPIOC
170 #endif
171 #if STM32_HAS_GPIOD
173 #endif
174 #if STM32_HAS_GPIOE
176 #endif
177 #if STM32_HAS_GPIOF
179 #endif
180 #if STM32_HAS_GPIOG
182 #endif
183 #if STM32_HAS_GPIOH
185 #endif
186 #if STM32_HAS_GPIOI
187  gpio_init(GPIOI, &gpio_default_config.PIData);
188 #endif
189 #if STM32_HAS_GPIOJ
190  gpio_init(GPIOJ, &gpio_default_config.PJData);
191 #endif
192 #if STM32_HAS_GPIOK
193  gpio_init(GPIOK, &gpio_default_config.PKData);
194 #endif
195 }
196 
197 /*===========================================================================*/
198 /* Driver interrupt handlers. */
199 /*===========================================================================*/
200 
201 /*===========================================================================*/
202 /* Driver exported functions. */
203 /*===========================================================================*/
204 
210 void __early_init(void) {
211 
212  stm32_gpio_init();
213  stm32_clock_init();
214 }
215 
216 #if HAL_USE_SDC || defined(__DOXYGEN__)
217 
220 bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
221  static bool last_status = false;
222 
223  (void)sdcp;
224  return !palReadLine(LINE_SDIO_DETECT);
225 }
226 
230 bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
231 
232  (void)sdcp;
233  return false;
234 }
235 #endif /* HAL_USE_SDC */
236 
237 #if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
238 
241 bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
242 
243  (void)mmcp;
244  /* TODO: Fill the implementation.*/
245  return true;
246 }
247 
251 bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
252 
253  (void)mmcp;
254  /* TODO: Fill the implementation.*/
255  return false;
256 }
257 #endif
258 
263 void boardInit(void) {
264  /*
265  * Several I/O pins are re-mapped:
266  * JTAG TRST to LED
267  */
268  AFIO->MAPR |= AFIO_MAPR_USART3_REMAP_PARTIALREMAP | AFIO_MAPR_SWJ_CFG_NOJNTRST | AFIO_MAPR_TIM3_REMAP_FULLREMAP;
269 }
VAL_GPIOG_AFRL
#define VAL_GPIOG_AFRL
Definition: board.h:1592
VAL_GPIOA_OSPEEDR
#define VAL_GPIOA_OSPEEDR
Definition: board.h:923
LINE_SDIO_DETECT
#define LINE_SDIO_DETECT
Definition: board.h:842
VAL_GPIOA_AFRH
#define VAL_GPIOA_AFRH
Definition: board.h:983
boardInit
void boardInit(void)
Board-specific initialization code.
Definition: board.c:261
VAL_GPIOD_PUPDR
#define VAL_GPIOD_PUPDR
Definition: board.h:1249
VAL_GPIOF_OTYPER
#define VAL_GPIOF_OTYPER
Definition: board.h:1421
GPIOA
#define GPIOA
Definition: gpio_arch.h:36
VAL_GPIOI_OTYPER
#define VAL_GPIOI_OTYPER
Definition: board.h:1730
VAL_GPIOJ_AFRL
#define VAL_GPIOJ_AFRL
Definition: board.h:1901
VAL_GPIOA_AFRL
#define VAL_GPIOA_AFRL
Definition: board.h:974
VAL_GPIOI_ODR
#define VAL_GPIOI_ODR
Definition: board.h:1781
gpio_init
static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config)
Definition: board.c:143
VAL_GPIOF_PUPDR
#define VAL_GPIOF_PUPDR
Definition: board.h:1455
VAL_GPIOH_PUPDR
#define VAL_GPIOH_PUPDR
Definition: board.h:1661
VAL_GPIOJ_ODR
#define VAL_GPIOJ_ODR
Definition: board.h:1884
VAL_GPIOD_OSPEEDR
#define VAL_GPIOD_OSPEEDR
Definition: board.h:1232
VAL_GPIOK_AFRH
#define VAL_GPIOK_AFRH
Definition: board.h:2013
VAL_GPIOB_AFRH
#define VAL_GPIOB_AFRH
Definition: board.h:1086
VAL_GPIOG_AFRH
#define VAL_GPIOG_AFRH
Definition: board.h:1601
VAL_GPIOE_AFRH
#define VAL_GPIOE_AFRH
Definition: board.h:1395
uint32_t
unsigned long uint32_t
Definition: types.h:18
GPIOB
#define GPIOB
Definition: gpio_arch.h:37
VAL_GPIOJ_MODER
#define VAL_GPIOJ_MODER
Definition: board.h:1816
VAL_GPIOI_AFRL
#define VAL_GPIOI_AFRL
Definition: board.h:1798
gpio_config_t
Type of STM32 GPIO initialization data.
Definition: board.c:53
VAL_GPIOE_MODER
#define VAL_GPIOE_MODER
Definition: board.h:1301
VAL_GPIOK_ODR
#define VAL_GPIOK_ODR
Definition: board.h:1987
VAL_GPIOA_PUPDR
#define VAL_GPIOA_PUPDR
Definition: board.h:940
GPIOE
#define GPIOE
Definition: gpio_arch.h:38
VAL_GPIOD_AFRL
#define VAL_GPIOD_AFRL
Definition: board.h:1283
VAL_GPIOF_ODR
#define VAL_GPIOF_ODR
Definition: board.h:1472
VAL_GPIOE_OSPEEDR
#define VAL_GPIOE_OSPEEDR
Definition: board.h:1335
VAL_GPIOK_OSPEEDR
#define VAL_GPIOK_OSPEEDR
Definition: board.h:1953
VAL_GPIOI_OSPEEDR
#define VAL_GPIOI_OSPEEDR
Definition: board.h:1747
VAL_GPIOG_ODR
#define VAL_GPIOG_ODR
Definition: board.h:1575
VAL_GPIOC_ODR
#define VAL_GPIOC_ODR
Definition: board.h:1163
VAL_GPIOJ_OSPEEDR
#define VAL_GPIOJ_OSPEEDR
Definition: board.h:1850
VAL_GPIOE_AFRL
#define VAL_GPIOE_AFRL
Definition: board.h:1386
VAL_GPIOC_PUPDR
#define VAL_GPIOC_PUPDR
Definition: board.h:1146
VAL_GPIOI_MODER
#define VAL_GPIOI_MODER
Definition: board.h:1713
VAL_GPIOA_ODR
#define VAL_GPIOA_ODR
Definition: board.h:957
VAL_GPIOC_OSPEEDR
#define VAL_GPIOC_OSPEEDR
Definition: board.h:1129
VAL_GPIOG_MODER
#define VAL_GPIOG_MODER
Definition: board.h:1507
VAL_GPIOA_MODER
#define VAL_GPIOA_MODER
Definition: board.h:889
VAL_GPIOI_PUPDR
#define VAL_GPIOI_PUPDR
Definition: board.h:1764
VAL_GPIOD_MODER
#define VAL_GPIOD_MODER
Definition: board.h:1198
VAL_GPIOH_AFRH
#define VAL_GPIOH_AFRH
Definition: board.h:1704
VAL_GPIOE_ODR
#define VAL_GPIOE_ODR
Definition: board.h:1369
VAL_GPIOH_ODR
#define VAL_GPIOH_ODR
Definition: board.h:1678
config
static const struct usb_config_descriptor config
Definition: usb_ser_hw.c:200
VAL_GPIOD_OTYPER
#define VAL_GPIOD_OTYPER
Definition: board.h:1215
VAL_GPIOB_AFRL
#define VAL_GPIOB_AFRL
Definition: board.h:1077
VAL_GPIOC_AFRH
#define VAL_GPIOC_AFRH
Definition: board.h:1189
GPIOC
#define GPIOC
Definition: gpio_arch.h:36
VAL_GPIOK_PUPDR
#define VAL_GPIOK_PUPDR
Definition: board.h:1970
GPIOG
#define GPIOG
Definition: gpio_arch.h:40
VAL_GPIOA_OTYPER
#define VAL_GPIOA_OTYPER
Definition: board.h:906
VAL_GPIOJ_PUPDR
#define VAL_GPIOJ_PUPDR
Definition: board.h:1867
VAL_GPIOC_OTYPER
#define VAL_GPIOC_OTYPER
Definition: board.h:1112
VAL_GPIOK_OTYPER
#define VAL_GPIOK_OTYPER
Definition: board.h:1936
VAL_GPIOG_OSPEEDR
#define VAL_GPIOG_OSPEEDR
Definition: board.h:1541
VAL_GPIOG_OTYPER
#define VAL_GPIOG_OTYPER
Definition: board.h:1524
VAL_GPIOD_ODR
#define VAL_GPIOD_ODR
Definition: board.h:1266
VAL_GPIOK_MODER
#define VAL_GPIOK_MODER
Definition: board.h:1919
VAL_GPIOH_MODER
#define VAL_GPIOH_MODER
Definition: board.h:1610
VAL_GPIOH_OSPEEDR
#define VAL_GPIOH_OSPEEDR
Definition: board.h:1644
VAL_GPIOB_OSPEEDR
#define VAL_GPIOB_OSPEEDR
Definition: board.h:1026
VAL_GPIOB_ODR
#define VAL_GPIOB_ODR
Definition: board.h:1060
VAL_GPIOB_MODER
#define VAL_GPIOB_MODER
Definition: board.h:992
GPIOH
#define GPIOH
Definition: gpio_arch.h:41
GPIOD
#define GPIOD
Definition: gpio_arch.h:37
VAL_GPIOJ_AFRH
#define VAL_GPIOJ_AFRH
Definition: board.h:1910
gpio_default_config
static const gpio_config_t gpio_default_config
STM32 GPIO static initialization data.
Definition: board.c:92
VAL_GPIOE_PUPDR
#define VAL_GPIOE_PUPDR
Definition: board.h:1352
VAL_GPIOC_MODER
#define VAL_GPIOC_MODER
Definition: board.h:1095
gpio_setup_t
Type of STM32 GPIO port setup.
Definition: board.c:40
VAL_GPIOH_AFRL
#define VAL_GPIOH_AFRL
Definition: board.h:1695
VAL_GPIOE_OTYPER
#define VAL_GPIOE_OTYPER
Definition: board.h:1318
VAL_GPIOJ_OTYPER
#define VAL_GPIOJ_OTYPER
Definition: board.h:1833
VAL_GPIOK_AFRL
#define VAL_GPIOK_AFRL
Definition: board.h:2004
VAL_GPIOH_OTYPER
#define VAL_GPIOH_OTYPER
Definition: board.h:1627
VAL_GPIOF_AFRH
#define VAL_GPIOF_AFRH
Definition: board.h:1498
VAL_GPIOF_OSPEEDR
#define VAL_GPIOF_OSPEEDR
Definition: board.h:1438
VAL_GPIOD_AFRH
#define VAL_GPIOD_AFRH
Definition: board.h:1292
VAL_GPIOC_AFRL
#define VAL_GPIOC_AFRL
Definition: board.h:1180
VAL_GPIOG_PUPDR
#define VAL_GPIOG_PUPDR
Definition: board.h:1558
GPIOF
#define GPIOF
Definition: gpio_arch.h:39
__early_init
void __early_init(void)
Early initialization code.
Definition: board.c:210
stm32_gpio_init
static void stm32_gpio_init(void)
Definition: board.c:154
VAL_GPIOF_MODER
#define VAL_GPIOF_MODER
Definition: board.h:1404
VAL_GPIOB_PUPDR
#define VAL_GPIOB_PUPDR
Definition: board.h:1043
VAL_GPIOB_OTYPER
#define VAL_GPIOB_OTYPER
Definition: board.h:1009
VAL_GPIOF_AFRL
#define VAL_GPIOF_AFRL
Definition: board.h:1489
VAL_GPIOI_AFRH
#define VAL_GPIOI_AFRH
Definition: board.h:1807