AFBR-S50 API Reference Manual v1.5.6
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
Loading...
Searching...
No Matches
IRQ: Global Interrupt Control Layer

Global Interrupt Control Layer. More...

Collaboration diagram for IRQ: Global Interrupt Control Layer:

Functions

void IRQ_UNLOCK (void)
 Enable IRQ Interrupts.
 
void IRQ_LOCK (void)
 Disable IRQ Interrupts.
 

Detailed Description

Global Interrupt Control Layer.


This module provides functionality to globally enable/disable interrupts in a nested way.

Here is a simple example implementation using the CMSIS functions "__enable_irq()" and "__disable_irq()". An integer counter is used to achieve nested interrupt disabling:

// Global lock level counter value.
static volatile int g_irq_lock_ct;
// Global unlock all interrupts using CMSIS function "__enable_irq()".
void IRQ_UNLOCK(void)
{
assert(g_irq_lock_ct > 0);
if (--g_irq_lock_ct <= 0)
{
g_irq_lock_ct = 0;
__enable_irq();
}
}
// Global lock all interrupts using CMSIS function "__disable_irq()".
void IRQ_LOCK(void)
{
__disable_irq();
g_irq_lock_ct++;
}
void IRQ_UNLOCK(void)
Enable IRQ Interrupts.
void IRQ_LOCK(void)
Disable IRQ Interrupts.
Note
The IRQ locking mechanism is used to create atomic sections (within the scope of the AFBR-S50 API) that are very few processor instruction only. It does NOT lock interrupts for considerable amounts of time.
The IRQ_LOCK might get called multiple times. Therefore, the API expects that the IRQ_UNLOCK must be called as many times as the IRQ_LOCK was called before the interrupts are enabled.
The interrupts utilized by the AFBR-S50 API can be interrupted by other, higher prioritized interrupts, e.g. some system critical interrupts. In this case, the IRQ_LOCK/IRQ_UNLOCK mechanism can be implemented such that only the interrupts required for the AFBR-S50 API are locked. The above example is dedicated to a ARM Corex-M0 architecture, where interrupts can only disabled at a global scope. Other architectures like ARM Cortex-M4 allow selective disabling of interrupts.

Function Documentation

◆ IRQ_LOCK()

void IRQ_LOCK ( void  )

Disable IRQ Interrupts.


Disables IRQ interrupts and leaves the atomic or critical section.

Note
The IRQ_LOCK might get called multiple times. Therefore, the API expects that the IRQ_UNLOCK must be called as many times as the IRQ_LOCK was called before the interrupts are enabled.
Examples
02_advanced_example.c, 02_advanced_example_with_hal_self_test.c, 03_high_speed_example.c, and 04_multi_device_example.c.

◆ IRQ_UNLOCK()

void IRQ_UNLOCK ( void  )

Enable IRQ Interrupts.


Enables IRQ interrupts and enters an atomic or critical section.

Note
The IRQ_LOCK might get called multiple times. Therefore, the API expects that the IRQ_UNLOCK must be called as many times as the IRQ_LOCK was called before the interrupts are enabled.
Examples
02_advanced_example.c, 02_advanced_example_with_hal_self_test.c, 03_high_speed_example.c, and 04_multi_device_example.c.