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:
@@ -33,7 +33,7 @@ static void storage_app_sd_icon_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
Storage* storage_app_alloc() {
|
||||
Storage* app = malloc(sizeof(Storage));
|
||||
app->message_queue = osMessageQueueNew(8, sizeof(StorageMessage), NULL);
|
||||
app->message_queue = furi_message_queue_alloc(8, sizeof(StorageMessage));
|
||||
app->pubsub = furi_pubsub_alloc();
|
||||
|
||||
for(uint8_t i = 0; i < STORAGE_COUNT; i++) {
|
||||
@@ -106,7 +106,7 @@ int32_t storage_srv(void* p) {
|
||||
|
||||
StorageMessage message;
|
||||
while(1) {
|
||||
if(osMessageQueueGet(app->message_queue, &message, NULL, STORAGE_TICK) == osOK) {
|
||||
if(furi_message_queue_get(app->message_queue, &message, STORAGE_TICK) == FuriStatusOk) {
|
||||
storage_process_message(app, &message);
|
||||
} else {
|
||||
storage_tick(app);
|
||||
|
@@ -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);
|
||||
|
@@ -31,7 +31,7 @@ void storage_file_clear(StorageFile* obj) {
|
||||
/****************** storage data ******************/
|
||||
|
||||
void storage_data_init(StorageData* storage) {
|
||||
storage->mutex = osMutexNew(NULL);
|
||||
storage->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
furi_check(storage->mutex != NULL);
|
||||
storage->data = NULL;
|
||||
storage->status = StorageStatusNotReady;
|
||||
@@ -39,11 +39,11 @@ void storage_data_init(StorageData* storage) {
|
||||
}
|
||||
|
||||
bool storage_data_lock(StorageData* storage) {
|
||||
return (osMutexAcquire(storage->mutex, osWaitForever) == osOK);
|
||||
return (furi_mutex_acquire(storage->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
bool storage_data_unlock(StorageData* storage) {
|
||||
return (osMutexRelease(storage->mutex) == osOK);
|
||||
return (furi_mutex_release(storage->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
StorageStatus storage_data_status(StorageData* storage) {
|
||||
|
@@ -56,7 +56,7 @@ struct StorageData {
|
||||
const FS_Api* fs_api;
|
||||
StorageApi api;
|
||||
void* data;
|
||||
osMutexId_t mutex;
|
||||
FuriMutex* mutex;
|
||||
StorageStatus status;
|
||||
StorageFileList_t files;
|
||||
};
|
||||
|
@@ -17,7 +17,7 @@ typedef struct {
|
||||
} StorageSDGui;
|
||||
|
||||
struct Storage {
|
||||
osMessageQueueId_t message_queue;
|
||||
FuriMessageQueue* message_queue;
|
||||
StorageData storage[STORAGE_COUNT];
|
||||
StorageSDGui sd_gui;
|
||||
FuriPubSub* pubsub;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <furi/record.h>
|
||||
#include <core/record.h>
|
||||
#include <m-string.h>
|
||||
#include "storage.h"
|
||||
#include <toolbox/tar/tar_archive.h>
|
||||
|
@@ -123,7 +123,7 @@ typedef enum {
|
||||
} StorageCommand;
|
||||
|
||||
typedef struct {
|
||||
osSemaphoreId_t semaphore;
|
||||
FuriSemaphore* semaphore;
|
||||
StorageCommand command;
|
||||
SAData* data;
|
||||
SAReturn* return_data;
|
||||
|
@@ -573,7 +573,7 @@ void storage_process_message_internal(Storage* app, StorageMessage* message) {
|
||||
break;
|
||||
}
|
||||
|
||||
osSemaphoreRelease(message->semaphore);
|
||||
furi_semaphore_release(message->semaphore);
|
||||
}
|
||||
|
||||
void storage_process_message(Storage* app, StorageMessage* message) {
|
||||
|
@@ -335,7 +335,7 @@ int32_t storage_test_app(void* p) {
|
||||
do_test_end(api, "/ext");
|
||||
|
||||
while(true) {
|
||||
furi_hal_delay_ms(1000);
|
||||
furi_delay_ms(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@@ -84,7 +84,7 @@ static bool sd_mount_card(StorageData* storage, bool notify) {
|
||||
}
|
||||
|
||||
if(!result) {
|
||||
furi_hal_delay_ms(1000);
|
||||
furi_delay_ms(1000);
|
||||
FURI_LOG_E(
|
||||
TAG, "init cycle %d, error: %s", counter, storage_data_status_text(storage));
|
||||
counter--;
|
||||
|
Reference in New Issue
Block a user