1 /* 2 * Copyright (c) 2025 Croxel Inc. 3 * Copyright (c) 2025 CogniPilot Foundation 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #include <zephyr/irq.h> 9 10 #include <platform/argus_irq.h> 11 12 /* We have an atomic lock count in order to only lock once and store the lock key. */ 13 static atomic_val_t lock_count; 14 static uint32_t lock; 15 IRQ_UNLOCK(void)16void IRQ_UNLOCK(void) 17 { 18 if (atomic_dec(&lock_count) == 1) { 19 irq_unlock(lock); 20 } 21 } 22 IRQ_LOCK(void)23void IRQ_LOCK(void) 24 { 25 if (atomic_inc(&lock_count) == 0) { 26 lock = irq_lock(); 27 } 28 } 29