From 0d8a0e31c05cb7debbcf81ace153ed335bd92869 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 17 Dec 2024 09:23:19 +0100 Subject: [PATCH] optiga: implement critical section To disable interrupts when processing Optiga commands. --- src/optiga/pal/pal_os_lock.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/optiga/pal/pal_os_lock.c b/src/optiga/pal/pal_os_lock.c index 7715ab830..73d98a1f3 100644 --- a/src/optiga/pal/pal_os_lock.c +++ b/src/optiga/pal/pal_os_lock.c @@ -37,6 +37,8 @@ #include "pal_os_lock.h" +#include + void pal_os_lock_create(pal_os_lock_t* p_lock, uint8_t lock_type) { p_lock->type = lock_type; @@ -73,14 +75,16 @@ void pal_os_lock_release(pal_os_lock_t* p_lock) } } +static volatile hal_atomic_t _atomic; + void pal_os_lock_enter_critical_section(void) { - // For safety critical systems it is recommended to implement a critical section entry + atomic_enter_critical(&_atomic); } void pal_os_lock_exit_critical_section(void) { - // For safety critical systems it is recommended to implement a critical section exit + atomic_leave_critical(&_atomic); } /**