Furi: core refactoring and CMSIS removal part 2 (#1410)
* Furi: rename and move core * Furi: drop CMSIS_OS header and unused api, partially refactor and cleanup the rest * Furi: CMSIS_OS drop and refactoring. * Furi: refactoring, remove cmsis legacy * Furi: fix incorrect assert on queue deallocation, cleanup timer * Furi: improve delay api, get rid of floats * hal: dropped furi_hal_crc * Furi: move DWT based delay to cortex HAL * Furi: update core documentation Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "furi/log.h"
|
||||
#include <furi/record.h>
|
||||
#include <core/log.h>
|
||||
#include <core/record.h>
|
||||
#include <m-string.h>
|
||||
#include "storage.h"
|
||||
#include "storage_i.h"
|
||||
@@ -13,18 +13,20 @@
|
||||
|
||||
#define TAG "StorageAPI"
|
||||
|
||||
#define S_API_PROLOGUE \
|
||||
osSemaphoreId_t semaphore = osSemaphoreNew(1, 0, NULL); \
|
||||
#define S_API_PROLOGUE \
|
||||
FuriSemaphore* semaphore = furi_semaphore_alloc(1, 0); \
|
||||
furi_check(semaphore != NULL);
|
||||
|
||||
#define S_FILE_API_PROLOGUE \
|
||||
Storage* storage = file->storage; \
|
||||
furi_assert(storage);
|
||||
|
||||
#define S_API_EPILOGUE \
|
||||
furi_check(osMessageQueuePut(storage->message_queue, &message, 0, osWaitForever) == osOK); \
|
||||
osSemaphoreAcquire(semaphore, osWaitForever); \
|
||||
osSemaphoreDelete(semaphore);
|
||||
#define S_API_EPILOGUE \
|
||||
furi_check( \
|
||||
furi_message_queue_put(storage->message_queue, &message, FuriWaitForever) == \
|
||||
FuriStatusOk); \
|
||||
furi_semaphore_acquire(semaphore, FuriWaitForever); \
|
||||
furi_semaphore_free(semaphore);
|
||||
|
||||
#define S_API_MESSAGE(_command) \
|
||||
SAReturn return_data; \
|
||||
@@ -88,8 +90,8 @@ static void storage_file_close_callback(const void* message, void* context) {
|
||||
if(storage_event->type == StorageEventTypeFileClose ||
|
||||
storage_event->type == StorageEventTypeDirClose) {
|
||||
furi_assert(context);
|
||||
osEventFlagsId_t event = context;
|
||||
osEventFlagsSet(event, StorageEventFlagFileClose);
|
||||
FuriEventFlag* event = context;
|
||||
furi_event_flag_set(event, StorageEventFlagFileClose);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +101,7 @@ bool storage_file_open(
|
||||
FS_AccessMode access_mode,
|
||||
FS_OpenMode open_mode) {
|
||||
bool result;
|
||||
osEventFlagsId_t event = osEventFlagsNew(NULL);
|
||||
FuriEventFlag* event = furi_event_flag_alloc();
|
||||
FuriPubSubSubscription* subscription = furi_pubsub_subscribe(
|
||||
storage_get_pubsub(file->storage), storage_file_close_callback, event);
|
||||
|
||||
@@ -107,14 +109,15 @@ bool storage_file_open(
|
||||
result = storage_file_open_internal(file, path, access_mode, open_mode);
|
||||
|
||||
if(!result && file->error_id == FSE_ALREADY_OPEN) {
|
||||
osEventFlagsWait(event, StorageEventFlagFileClose, osFlagsWaitAny, osWaitForever);
|
||||
furi_event_flag_wait(
|
||||
event, StorageEventFlagFileClose, FuriFlagWaitAny, FuriWaitForever);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while(true);
|
||||
|
||||
furi_pubsub_unsubscribe(storage_get_pubsub(file->storage), subscription);
|
||||
osEventFlagsDelete(event);
|
||||
furi_event_flag_free(event);
|
||||
|
||||
FURI_LOG_T(
|
||||
TAG, "File %p - %p open (%s)", (uint32_t)file - SRAM_BASE, file->file_id - SRAM_BASE, path);
|
||||
@@ -258,7 +261,7 @@ static bool storage_dir_open_internal(File* file, const char* path) {
|
||||
|
||||
bool storage_dir_open(File* file, const char* path) {
|
||||
bool result;
|
||||
osEventFlagsId_t event = osEventFlagsNew(NULL);
|
||||
FuriEventFlag* event = furi_event_flag_alloc();
|
||||
FuriPubSubSubscription* subscription = furi_pubsub_subscribe(
|
||||
storage_get_pubsub(file->storage), storage_file_close_callback, event);
|
||||
|
||||
@@ -266,14 +269,15 @@ bool storage_dir_open(File* file, const char* path) {
|
||||
result = storage_dir_open_internal(file, path);
|
||||
|
||||
if(!result && file->error_id == FSE_ALREADY_OPEN) {
|
||||
osEventFlagsWait(event, StorageEventFlagFileClose, osFlagsWaitAny, osWaitForever);
|
||||
furi_event_flag_wait(
|
||||
event, StorageEventFlagFileClose, FuriFlagWaitAny, FuriWaitForever);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while(true);
|
||||
|
||||
furi_pubsub_unsubscribe(storage_get_pubsub(file->storage), subscription);
|
||||
osEventFlagsDelete(event);
|
||||
furi_event_flag_free(event);
|
||||
|
||||
FURI_LOG_T(
|
||||
TAG, "Dir %p - %p open (%s)", (uint32_t)file - SRAM_BASE, file->file_id - SRAM_BASE, path);
|
||||
|
||||
Reference in New Issue
Block a user