ChibiOS  21.6.0
hal.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  * @file hal.c
19  * @brief HAL subsystem code.
20  *
21  * @addtogroup HAL
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 /*===========================================================================*/
28 /* Driver local definitions. */
29 /*===========================================================================*/
30 
31 /*===========================================================================*/
32 /* Driver exported variables. */
33 /*===========================================================================*/
34 
35 /*===========================================================================*/
36 /* Driver local variables and types. */
37 /*===========================================================================*/
38 
39 /*===========================================================================*/
40 /* Driver local functions. */
41 /*===========================================================================*/
42 
43 /*===========================================================================*/
44 /* Driver exported functions. */
45 /*===========================================================================*/
46 
47 /**
48  * @brief HAL initialization.
49  * @details This function invokes the low level initialization code then
50  * initializes all the drivers enabled in the HAL. Finally the
51  * board-specific initialization is performed by invoking
52  * @p boardInit() (usually defined in @p board.c).
53  *
54  * @init
55  */
56 void halInit(void) {
57 
58  /* Initializes the OS Abstraction Layer.*/
59  osalInit();
60 
61  /* Platform low level initializations.*/
62  hal_lld_init();
63 
64 #if (HAL_USE_PAL == TRUE) || defined(__DOXYGEN__)
65 #if defined(PAL_NEW_INIT)
66  palInit();
67 #else
68  palInit(&pal_default_config);
69 #endif
70 #endif
71 #if (HAL_USE_ADC == TRUE) || defined(__DOXYGEN__)
72  adcInit();
73 #endif
74 #if (HAL_USE_CAN == TRUE) || defined(__DOXYGEN__)
75  canInit();
76 #endif
77 #if (HAL_USE_CRY == TRUE) || defined(__DOXYGEN__)
78  cryInit();
79 #endif
80 #if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
81  dacInit();
82 #endif
83 #if (HAL_USE_EFL == TRUE) || defined(__DOXYGEN__)
84  eflInit();
85 #endif
86 #if (HAL_USE_GPT == TRUE) || defined(__DOXYGEN__)
87  gptInit();
88 #endif
89 #if (HAL_USE_I2C == TRUE) || defined(__DOXYGEN__)
90  i2cInit();
91 #endif
92 #if (HAL_USE_I2S == TRUE) || defined(__DOXYGEN__)
93  i2sInit();
94 #endif
95 #if (HAL_USE_ICU == TRUE) || defined(__DOXYGEN__)
96  icuInit();
97 #endif
98 #if (HAL_USE_MAC == TRUE) || defined(__DOXYGEN__)
99  macInit();
100 #endif
101 #if (HAL_USE_PWM == TRUE) || defined(__DOXYGEN__)
102  pwmInit();
103 #endif
104 #if (HAL_USE_SERIAL == TRUE) || defined(__DOXYGEN__)
105  sdInit();
106 #endif
107 #if (HAL_USE_SDC == TRUE) || defined(__DOXYGEN__)
108  sdcInit();
109 #endif
110 #if (HAL_USE_SIO == TRUE) || defined(__DOXYGEN__)
111  sioInit();
112 #endif
113 #if (HAL_USE_SPI == TRUE) || defined(__DOXYGEN__)
114  spiInit();
115 #endif
116 #if (HAL_USE_TRNG == TRUE) || defined(__DOXYGEN__)
117  trngInit();
118 #endif
119 #if (HAL_USE_UART == TRUE) || defined(__DOXYGEN__)
120  uartInit();
121 #endif
122 #if (HAL_USE_USB == TRUE) || defined(__DOXYGEN__)
123  usbInit();
124 #endif
125 #if (HAL_USE_MMC_SPI == TRUE) || defined(__DOXYGEN__)
126  mmcInit();
127 #endif
128 #if (HAL_USE_SERIAL_USB == TRUE) || defined(__DOXYGEN__)
129  sduInit();
130 #endif
131 #if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__)
132  rtcInit();
133 #endif
134 #if (HAL_USE_WDG == TRUE) || defined(__DOXYGEN__)
135  wdgInit();
136 #endif
137 #if (HAL_USE_WSPI == TRUE) || defined(__DOXYGEN__)
138  wspiInit();
139 #endif
140 
141  /* Community driver overlay initialization.*/
142 #if defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
143 #if (HAL_USE_COMMUNITY == TRUE) || defined(__DOXYGEN__)
144  halCommunityInit();
145 #endif
146 #endif
147 
148  /* Board specific initialization.*/
149  boardInit();
150 
151 /*
152  * The ST driver is a special case, it is only initialized if the OSAL is
153  * configured to require it.
154  */
155 #if OSAL_ST_MODE != OSAL_ST_MODE_NONE
156  stInit();
157 #endif
158 }
159 
160 /** @} */
stInit
void stInit(void)
ST Driver initialization.
Definition: hal_st.c:69
hal.h
HAL subsystem header.
uartInit
void uartInit(void)
UART Driver initialization.
Definition: hal_uart.c:56
sduInit
void sduInit(void)
Serial Driver initialization.
Definition: hal_serial_usb.c:210
sdInit
void sdInit(void)
Serial Driver initialization.
Definition: hal_serial.c:135
eflInit
void eflInit(void)
Embedded Flash Driver initialization.
Definition: hal_efl.c:67
macInit
void macInit(void)
MAC Driver initialization.
Definition: hal_mac.c:64
palInit
#define palInit()
PAL subsystem initialization.
Definition: hal_pal.h:375
wdgInit
void wdgInit(void)
WDG Driver initialization.
Definition: hal_wdg.c:56
spiInit
void spiInit(void)
SPI Driver initialization.
Definition: hal_spi.c:56
adcInit
void adcInit(void)
ADC Driver initialization.
Definition: hal_adc.c:56
halInit
void halInit(void)
HAL initialization.
Definition: hal.c:56
canInit
void canInit(void)
CAN Driver initialization.
Definition: hal_can.c:56
wspiInit
void wspiInit(void)
WSPI Driver initialization.
Definition: hal_wspi.c:56
rtcInit
void rtcInit(void)
RTC Driver initialization.
Definition: hal_rtc.c:71
sdcInit
void sdcInit(void)
SDC Driver initialization.
Definition: hal_sdc.c:536
hal_lld_init
void hal_lld_init(void)
Low level HAL driver initialization.
Definition: hal_lld.c:72
dacInit
void dacInit(void)
DAC Driver initialization.
Definition: hal_dac.c:56
cryInit
void cryInit(void)
Cryptographic Driver initialization.
Definition: hal_crypto.c:56
gptInit
void gptInit(void)
GPT Driver initialization.
Definition: hal_gpt.c:56
osalInit
void osalInit(void)
OSAL module initialization.
Definition: osal.c:63
trngInit
void trngInit(void)
TRNG Driver initialization.
Definition: hal_trng.c:56
sioInit
void sioInit(void)
SIO Driver initialization.
Definition: hal_sio.c:213
pwmInit
void pwmInit(void)
PWM Driver initialization.
Definition: hal_pwm.c:56
mmcInit
void mmcInit(void)
MMC over SPI driver initialization.
Definition: hal_mmc_spi.c:383
usbInit
void usbInit(void)
USB Driver initialization.
Definition: hal_usb.c:270
i2sInit
void i2sInit(void)
I2S Driver initialization.
Definition: hal_i2s.c:56
icuInit
void icuInit(void)
ICU Driver initialization.
Definition: hal_icu.c:56
i2cInit
void i2cInit(void)
I2C Driver initialization.
Definition: hal_i2c.c:59