drivers: flash: rram singlethreading support

Adds conditional usage of locking mechanisms to allow building
without multithreading.

Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
This commit is contained in:
Mateusz Michalek 2024-01-31 10:25:08 +01:00 committed by Carles Cufí
parent 5e313608fe
commit 517d5ce2e3

View file

@ -30,10 +30,16 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL);
#define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size)
#define ERASE_VALUE 0xFF
#ifdef CONFIG_MULTITHREADING
static struct k_sem sem_lock;
#define SYNC_INIT() k_sem_init(&sem_lock, 1, 1)
#define SYNC_LOCK() k_sem_take(&sem_lock, K_FOREVER)
#define SYNC_UNLOCK() k_sem_give(&sem_lock)
#else
#define SYNC_INIT()
#define SYNC_LOCK()
#define SYNC_UNLOCK()
#endif /* CONFIG_MULTITHREADING */
#if CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE > 0
#define WRITE_BUFFER_ENABLE 1