1 /*
2 * Copyright (c) 2018, I-SENSE group of ICCS
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 /**
8 * @file
9 * @brief Zephyr's implementation for STM32Cube HAL core initialization
10 * functions. These functions are declared as __weak in
11 * STM32Cube HAL in order to be overwritten in case of other
12 * implementations.
13 */
14
15 #include <zephyr/kernel.h>
16 #include <soc.h>
17 /**
18 * @brief This function configures the source of stm32cube time base.
19 * Cube HAL expects a 1ms tick which matches with k_uptime_get_32.
20 * Tick interrupt priority is not used
21 * @return HAL status
22 */
HAL_GetTick(void)23 uint32_t HAL_GetTick(void)
24 {
25 return k_uptime_get_32();
26 }
27
28 /**
29 * @brief This function provides minimum delay (in milliseconds) based
30 * on variable incremented.
31 * @param Delay: specifies the delay time length, in milliseconds.
32 * @return None
33 */
HAL_Delay(__IO uint32_t Delay)34 void HAL_Delay(__IO uint32_t Delay)
35 {
36 k_msleep(Delay);
37 }
38
39 #ifdef CONFIG_USE_STM32_ASSERT
40 /**
41 * @brief Generates an assert on STM32Cube HAL/LL assert trigger.
42 * @param file: specifies the file name where assert expression failed.
43 * @param line: specifies the line number where assert expression failed.
44 * @return None
45 */
assert_failed(uint8_t * file,uint32_t line)46 void assert_failed(uint8_t *file, uint32_t line)
47 {
48 /* Assert condition have been verified at Cube level, force
49 * generation here.
50 */
51 __ASSERT(false, "Invalid value line %d @ %s\n", line, file);
52 }
53 #endif /* CONFIG_USE_STM32_ASSERT */
54