ChibiOS/HAL  6.1.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_EXT == TRUE) || defined(__DOXYGEN__)
84  extInit();
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_QSPI == TRUE) || defined(__DOXYGEN__)
105  qspiInit();
106 #endif
107 #if (HAL_USE_SERIAL == TRUE) || defined(__DOXYGEN__)
108  sdInit();
109 #endif
110 #if (HAL_USE_SDC == TRUE) || defined(__DOXYGEN__)
111  sdcInit();
112 #endif
113 #if (HAL_USE_SPI == TRUE) || defined(__DOXYGEN__)
114  spiInit();
115 #endif
116 #if (HAL_USE_UART == TRUE) || defined(__DOXYGEN__)
117  uartInit();
118 #endif
119 #if (HAL_USE_USB == TRUE) || defined(__DOXYGEN__)
120  usbInit();
121 #endif
122 #if (HAL_USE_MMC_SPI == TRUE) || defined(__DOXYGEN__)
123  mmcInit();
124 #endif
125 #if (HAL_USE_SERIAL_USB == TRUE) || defined(__DOXYGEN__)
126  sduInit();
127 #endif
128 #if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__)
129  rtcInit();
130 #endif
131 #if (HAL_USE_WDG == TRUE) || defined(__DOXYGEN__)
132  wdgInit();
133 #endif
134 
135  /* Community driver overlay initialization.*/
136 #if defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
137 #if (HAL_USE_COMMUNITY == TRUE) || defined(__DOXYGEN__)
138  halCommunityInit();
139 #endif
140 #endif
141 
142  /* Board specific initialization.*/
143  boardInit();
144 
145 /*
146  * The ST driver is a special case, it is only initialized if the OSAL is
147  * configured to require it.
148  */
149 #if OSAL_ST_MODE != OSAL_ST_MODE_NONE
150  stInit();
151 #endif
152 }
153 
154 /** @} */
void i2cInit(void)
I2C Driver initialization.
Definition: hal_i2c.c:59
void cryInit(void)
Cryptographic Driver initialization.
Definition: hal_crypto.c:56
void extInit(void)
EXT Driver initialization.
Definition: hal_ext.c:56
void hal_lld_init(void)
Low level HAL driver initialization.
Definition: hal_lld.c:56
void icuInit(void)
ICU Driver initialization.
Definition: hal_icu.c:56
void i2sInit(void)
I2S Driver initialization.
Definition: hal_i2s.c:56
void uartInit(void)
UART Driver initialization.
Definition: hal_uart.c:56
void dacInit(void)
DAC Driver initialization.
Definition: hal_dac.c:56
void sduInit(void)
Serial Driver initialization.
void sdInit(void)
Serial Driver initialization.
Definition: hal_serial.c:135
HAL subsystem header.
void sdcInit(void)
SDC Driver initialization.
Definition: hal_sdc.c:542
void spiInit(void)
SPI Driver initialization.
Definition: hal_spi.c:56
void gptInit(void)
GPT Driver initialization.
Definition: hal_gpt.c:56
void pwmInit(void)
PWM Driver initialization.
Definition: hal_pwm.c:56
void stInit(void)
ST Driver initialization.
Definition: hal_st.c:60
void halInit(void)
HAL initialization.
Definition: hal.c:56
void usbInit(void)
USB Driver initialization.
Definition: hal_usb.c:270
void wdgInit(void)
WDG Driver initialization.
Definition: hal_wdg.c:56
#define palInit()
PAL subsystem initialization.
Definition: hal_pal.h:372
void canInit(void)
CAN Driver initialization.
Definition: hal_can.c:56
void rtcInit(void)
RTC Driver initialization.
Definition: hal_rtc.c:67
void osalInit(void)
OSAL module initialization.
Definition: osal.c:63
void mmcInit(void)
MMC over SPI driver initialization.
Definition: hal_mmc_spi.c:383
void macInit(void)
MAC Driver initialization.
Definition: hal_mac.c:64
void qspiInit(void)
QSPI Driver initialization.
Definition: hal_qspi.c:56
void adcInit(void)
ADC Driver initialization.
Definition: hal_adc.c:56