firmware
IEM Firmware Documentation
Loading...
Searching...
No Matches
stm32_lock_user.h
Go to the documentation of this file.
1
21
22#ifndef __STM32_LOCK_USER_H__
23#define __STM32_LOCK_USER_H__
24
25#ifdef __cplusplus
26extern "C" {
27#endif /* __cplusplus */
28
29#include "FreeRTOS.h"
30#include "task.h"
31
32#if STM32_LOCK_API != 1 /* Version of the implemented API */
33 #error stm32_lock_user.h not compatible with current version of stm32_lock.h
34#endif
35
36#define MAX_LOCK_NESTING_LEVEL 4
37
38#define LOCK_ASSERT(x) \
39 do { \
40 if (!(x)) { \
41 __disable_irq(); \
42 for (;;); \
43 } \
44 } while (0)
45
46/* Remove the following line when you have implemented your own thread-safe
47 * solution. */
48// #error Please implement your own thread-safe solution
49
50/* Private defines -----------------------------------------------------------*/
52#define LOCKING_DATA_INIT \
53 { \
54 { 0, 0, 0, 0 }, \
55 0, \
56 }
57
58/* Private typedef -----------------------------------------------------------*/
63
64/* Private functions ---------------------------------------------------------*/
65
70static inline void stm32_lock_init(LockingData_t *lock) {
71 LOCK_ASSERT(lock);
72 for (UBaseType_t *i = lock->interrupt_status; i < (lock->interrupt_status + MAX_LOCK_NESTING_LEVEL); i++) *i = 0;
73 lock->nesting_level = 0;
74}
75
80static inline void stm32_lock_acquire(LockingData_t *lock) {
81 LOCK_ASSERT(lock);
83 // As far as I can tell, the _FROM_ISR version is fine to call from either ISRs or tasks
85}
86
97
98#ifdef __cplusplus
99} /* extern "C" */
100#endif /* __cplusplus */
101
102#endif /* __STM32_LOCK_USER_H__ */
unsigned long UBaseType_t
Definition portmacro.h:60
static void stm32_lock_acquire(LockingData_t *lock)
Acquire STM32 lock.
Definition stm32_lock_user.h:80
#define LOCK_ASSERT(x)
Definition stm32_lock_user.h:38
static void stm32_lock_release(LockingData_t *lock)
Release STM32 lock.
Definition stm32_lock_user.h:91
static void stm32_lock_init(LockingData_t *lock)
Initialize STM32 lock.
Definition stm32_lock_user.h:70
#define MAX_LOCK_NESTING_LEVEL
Definition stm32_lock_user.h:36
Definition stm32_lock_user.h:59
UBaseType_t interrupt_status[MAX_LOCK_NESTING_LEVEL]
Definition stm32_lock_user.h:60
uint8_t nesting_level
Definition stm32_lock_user.h:61
#define taskENTER_CRITICAL_FROM_ISR()
Definition task.h:231
#define taskEXIT_CRITICAL_FROM_ISR(x)
Definition task.h:250