File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 3434#define STM32_FLASH_TIMEOUT (K_MSEC(25))
3535#endif
3636
37+ #define CFG_HW_FLASH_SEMID 2
38+
3739/*
3840 * This is named flash_stm32_sem_take instead of flash_stm32_lock (and
3941 * similarly for flash_stm32_sem_give) to avoid confusion with locking
4042 * actual flash pages.
4143 */
4244static inline void flash_stm32_sem_take (struct device * dev )
4345{
46+
47+ #ifdef CONFIG_SOC_SERIES_STM32WBX
48+ while (LL_HSEM_1StepLock (HSEM , CFG_HW_FLASH_SEMID ))
49+ ;
50+ #endif /* CONFIG_SOC_SERIES_STM32WBX */
51+
4452 k_sem_take (& FLASH_STM32_PRIV (dev )-> sem , K_FOREVER );
4553}
4654
4755static inline void flash_stm32_sem_give (struct device * dev )
4856{
57+
4958 k_sem_give (& FLASH_STM32_PRIV (dev )-> sem );
59+
60+ #ifdef CONFIG_SOC_SERIES_STM32WBX
61+ LL_HSEM_ReleaseLock (HSEM , CFG_HW_FLASH_SEMID , 0 );
62+ #endif /* CONFIG_SOC_SERIES_STM32WBX */
63+
5064}
5165
5266#if !defined(CONFIG_SOC_SERIES_STM32WBX )
@@ -279,6 +293,10 @@ static int stm32_flash_init(struct device *dev)
279293 }
280294#endif
281295
296+ #ifdef CONFIG_SOC_SERIES_STM32WBX
297+ LL_AHB3_GRP1_EnableClock (LL_AHB3_GRP1_PERIPH_HSEM );
298+ #endif /* CONFIG_SOC_SERIES_STM32WBX */
299+
282300 k_sem_init (& p -> sem , 1 , 1 );
283301
284302 return flash_stm32_write_protection (dev , false);
Original file line number Diff line number Diff line change 4343#include <stm32wbxx_ll_system.h>
4444#endif /* CONFIG_CLOCK_CONTROL_STM32_CUBE */
4545
46+ #ifdef CONFIG_FLASH
47+ #include <stm32wbxx_ll_hsem.h>
48+ #endif /* CONFIG_FLASH */
49+
4650#endif /* !_ASMLANGUAGE */
4751
4852#endif /* _STM32WBX_SOC_H_ */
You can’t perform that action at this time.
0 commit comments