aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src/hal.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/src/hal.c')
-rw-r--r--os/hal/src/hal.c89
1 files changed, 12 insertions, 77 deletions
diff --git a/os/hal/src/hal.c b/os/hal/src/hal.c
index d7a088ec9..aa3eca165 100644
--- a/os/hal/src/hal.c
+++ b/os/hal/src/hal.c
@@ -26,7 +26,6 @@
* @{
*/
-#include "ch.h"
#include "hal.h"
/*===========================================================================*/
@@ -60,11 +59,12 @@
*/
void halInit(void) {
+ /* Initializes the OS Abstraction Layer.*/
+ osalInit();
+
+ /* Platform low level initializations.*/
hal_lld_init();
-#if HAL_USE_TM || defined(__DOXYGEN__)
- tmInit();
-#endif
#if HAL_USE_PAL || defined(__DOXYGEN__)
palInit(&pal_default_config);
#endif
@@ -74,9 +74,6 @@ void halInit(void) {
#if HAL_USE_CAN || defined(__DOXYGEN__)
canInit();
#endif
-#if HAL_USE_DAC || defined(__DOXYGEN__)
- dacInit();
-#endif
#if HAL_USE_EXT || defined(__DOXYGEN__)
extInit();
#endif
@@ -86,6 +83,9 @@ void halInit(void) {
#if HAL_USE_I2C || defined(__DOXYGEN__)
i2cInit();
#endif
+#if HAL_USE_I2S || defined(__DOXYGEN__)
+ i2sInit();
+#endif
#if HAL_USE_ICU || defined(__DOXYGEN__)
icuInit();
#endif
@@ -119,79 +119,14 @@ void halInit(void) {
#if HAL_USE_RTC || defined(__DOXYGEN__)
rtcInit();
#endif
+
/* Board specific initialization.*/
boardInit();
-}
-
-#if HAL_IMPLEMENTS_COUNTERS || defined(__DOXYGEN__)
-/**
- * @brief Realtime window test.
- * @details This function verifies if the current realtime counter value
- * lies within the specified range or not. The test takes care
- * of the realtime counter wrapping to zero on overflow.
- * @note When start==end then the function returns always true because the
- * whole time range is specified.
- * @note This is an optional service that could not be implemented in
- * all HAL implementations.
- * @note This function can be called from any context.
- *
- * @par Example 1
- * Example of a guarded loop using the realtime counter. The loop implements
- * a timeout after one second.
- * @code
- * halrtcnt_t start = halGetCounterValue();
- * halrtcnt_t timeout = start + S2RTT(1);
- * while (my_condition) {
- * if (!halIsCounterWithin(start, timeout)
- * return TIMEOUT;
- * // Do something.
- * }
- * // Continue.
- * @endcode
- *
- * @par Example 2
- * Example of a loop that lasts exactly 50 microseconds.
- * @code
- * halrtcnt_t start = halGetCounterValue();
- * halrtcnt_t timeout = start + US2RTT(50);
- * while (halIsCounterWithin(start, timeout)) {
- * // Do something.
- * }
- * // Continue.
- * @endcode
- *
- * @param[in] start the start of the time window (inclusive)
- * @param[in] end the end of the time window (non inclusive)
- * @retval TRUE current time within the specified time window.
- * @retval FALSE current time not within the specified time window.
- *
- * @special
- */
-bool_t halIsCounterWithin(halrtcnt_t start, halrtcnt_t end) {
- halrtcnt_t now = halGetCounterValue();
-
- return end > start ? (now >= start) && (now < end) :
- (now >= start) || (now < end);
-}
-/**
- * @brief Polled delay.
- * @note The real delays is always few cycles in excess of the specified
- * value.
- * @note This is an optional service that could not be implemented in
- * all HAL implementations.
- * @note This function can be called from any context.
- *
- * @param[in] ticks number of ticks
- *
- * @special
- */
-void halPolledDelay(halrtcnt_t ticks) {
- halrtcnt_t start = halGetCounterValue();
- halrtcnt_t timeout = start + (ticks);
- while (halIsCounterWithin(start, timeout))
- ;
+#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
+ /* System tick service if the underlying OS requires it.*/
+ stInit();
+#endif
}
-#endif /* HAL_IMPLEMENTS_COUNTERS */
/** @} */