F439_CPP_TX-RX_LoRa_Project

Loading...
Searching...
No Matches
Data Structures | Macros | Functions
stm32_lock.h File Reference

STMicroelectronics lock mechanisms. More...

`#include <stdint.h>`
`#include <stddef.h>`
`#include <cmsis_compiler.h>`
Include dependency graph for stm32_lock.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | LockingData_t

## Macros
#define | STM32_THREAD_SAFE_STRATEGY 2
#define | STM32_LOCK_BLOCK()
#define | STM32_LOCK_BLOCK_IF_NULL_ARGUMENT(x)
#define | STM32_LOCK_BLOCK_IF_INTERRUPT_CONTEXT()
#define | STM32_LOCK_UNUSED(var) (void)var
#define | STM32_LOCK_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
#define | LOCKING_DATA_INIT { 0, 0 }

## Functions
void | Error_Handler (void)
| Global Error_Handler.

## Detailed Description

STMicroelectronics lock mechanisms.

Author
  STMicroelectronics

This implementation supports the following strategies for handling thread-safe locks. The strategy can be explicitly selected by defining `\STM32_THREAD_SAFE_STRATEGY = <number>` in the project. Please look at the '<toolchain/library>_lock_glue.c' file for more details.

1. User defined thread-safe implementation. User defined solution for handling thread-safety.
   NOTE: The stubs in stm32_lock_user.h needs to be implemented to gain thread-safety.
2. [DEFAULT] Allow lock usage from interrupts. This implementation will ensure thread-safety by disabling all interrupts during e.g. calls to malloc.
   NOTE: Disabling all interrupts creates interrupt latency which might not be desired for this application!
3. Deny lock usage from interrupts. This implementation assumes single thread of execution.
   NOTE: Thread-safety dependent functions will enter an infinity loop if used in interrupt context.
4. Allow lock usage from interrupts. Implemented using FreeRTOS locks. This implementation will ensure thread-safety by entering RTOS ISR capable critical sections during e.g. calls to malloc. By default this implementation supports 2 levels of recursive locking. Adding additional levels requires 4 bytes per lock per level of RAM.
   NOTE: Interrupts with high priority are not disabled. This implies that the lock is not thread-safe from high priority interrupts!
5. Deny lock usage from interrupts. Implemented using FreeRTOS locks. This implementation will ensure thread-safety by suspending all tasks during e.g. calls to malloc.
   NOTE: Thread-safety dependent functions will enter an infinity loop if used in interrupt context.

Attention

Copyright (c) 2025 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

## Macro Definition Documentation

## ◆ LOCKING_DATA_INIT

#define LOCKING_DATA_INIT { 0, 0 }

Initialize members in instance of `LockingData_t` structure

## ◆ STM32_LOCK_ARRAY_SIZE

#define STM32_LOCK_ARRAY_SIZE | ( |  | array | ) | (sizeof(array) / sizeof((array)[0]))

Size of array

## ◆ STM32_LOCK_BLOCK

#define STM32_LOCK_BLOCK | ( |  | ) |

Value:
do \
{ \
__disable_irq(); \
Error_Handler(); \
while (1); \
} while (0)

Blocks execution

## ◆ STM32_LOCK_BLOCK_IF_INTERRUPT_CONTEXT

#define STM32_LOCK_BLOCK_IF_INTERRUPT_CONTEXT | ( |  | ) |

Value:
do \
{ \
if (__get_IPSR()) \
{ \
STM32_LOCK_BLOCK(); \
} \
} while (0)

Blocks execution if in interrupt context

## ◆ STM32_LOCK_BLOCK_IF_NULL_ARGUMENT

#define STM32_LOCK_BLOCK_IF_NULL_ARGUMENT | ( |  | x | ) |

Value:
do \
{ \
if ((x) == NULL) \
{ \
STM32_LOCK_BLOCK(); \
} \
} while (0)

Blocks execution if argument is NULL

## ◆ STM32_LOCK_UNUSED

#define STM32_LOCK_UNUSED | ( |  | var | ) | (void)var

Hide unused parameter warning from compiler

## ◆ STM32_THREAD_SAFE_STRATEGY

#define STM32_THREAD_SAFE_STRATEGY 2

Assume strategy 2 if not specified

## Function Documentation

## ◆ Error_Handler()

void Error_Handler | ( | void |  | ) |

Global Error_Handler.