Skip to content

Commit

Permalink
optiga: implement critical section
Browse files Browse the repository at this point in the history
To disable interrupts when processing Optiga commands.
  • Loading branch information
benma committed Dec 18, 2024
1 parent 0e9ae88 commit b2058f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/optiga/pal/pal_os_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

#include "pal_os_lock.h"

#include <hal_atomic.h>

void pal_os_lock_create(pal_os_lock_t* p_lock, uint8_t lock_type)
{
p_lock->type = lock_type;
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit b2058f6

Please sign in to comment.