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:
@@ -77,7 +77,7 @@ Dolphin* dolphin_alloc() {
|
||||
Dolphin* dolphin = malloc(sizeof(Dolphin));
|
||||
|
||||
dolphin->state = dolphin_state_alloc();
|
||||
dolphin->event_queue = osMessageQueueNew(8, sizeof(DolphinEvent), NULL);
|
||||
dolphin->event_queue = furi_message_queue_alloc(8, sizeof(DolphinEvent));
|
||||
dolphin->pubsub = furi_pubsub_alloc();
|
||||
dolphin->butthurt_timer = xTimerCreate(
|
||||
NULL, HOURS_IN_TICKS(2 * 24), pdTRUE, dolphin, dolphin_butthurt_timer_callback);
|
||||
@@ -93,7 +93,7 @@ void dolphin_free(Dolphin* dolphin) {
|
||||
furi_assert(dolphin);
|
||||
|
||||
dolphin_state_free(dolphin->state);
|
||||
osMessageQueueDelete(dolphin->event_queue);
|
||||
furi_message_queue_free(dolphin->event_queue);
|
||||
|
||||
free(dolphin);
|
||||
}
|
||||
@@ -102,25 +102,28 @@ void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event) {
|
||||
furi_assert(dolphin);
|
||||
furi_assert(event);
|
||||
event->flag = NULL;
|
||||
furi_check(osMessageQueuePut(dolphin->event_queue, event, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
furi_message_queue_put(dolphin->event_queue, event, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void dolphin_event_send_wait(Dolphin* dolphin, DolphinEvent* event) {
|
||||
furi_assert(dolphin);
|
||||
furi_assert(event);
|
||||
event->flag = osEventFlagsNew(NULL);
|
||||
event->flag = furi_event_flag_alloc();
|
||||
furi_check(event->flag);
|
||||
furi_check(osMessageQueuePut(dolphin->event_queue, event, 0, osWaitForever) == osOK);
|
||||
furi_check(
|
||||
osEventFlagsWait(event->flag, DOLPHIN_LOCK_EVENT_FLAG, osFlagsWaitAny, osWaitForever) ==
|
||||
furi_message_queue_put(dolphin->event_queue, event, FuriWaitForever) == FuriStatusOk);
|
||||
furi_check(
|
||||
furi_event_flag_wait(
|
||||
event->flag, DOLPHIN_LOCK_EVENT_FLAG, FuriFlagWaitAny, FuriWaitForever) ==
|
||||
DOLPHIN_LOCK_EVENT_FLAG);
|
||||
furi_check(osEventFlagsDelete(event->flag) == osOK);
|
||||
furi_event_flag_free(event->flag);
|
||||
}
|
||||
|
||||
void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event) {
|
||||
UNUSED(dolphin);
|
||||
if(event->flag) {
|
||||
osEventFlagsSet(event->flag, DOLPHIN_LOCK_EVENT_FLAG);
|
||||
furi_event_flag_set(event->flag, DOLPHIN_LOCK_EVENT_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +164,8 @@ int32_t dolphin_srv(void* p) {
|
||||
|
||||
DolphinEvent event;
|
||||
while(1) {
|
||||
if(osMessageQueueGet(dolphin->event_queue, &event, NULL, HOURS_IN_TICKS(1)) == osOK) {
|
||||
if(furi_message_queue_get(dolphin->event_queue, &event, HOURS_IN_TICKS(1)) ==
|
||||
FuriStatusOk) {
|
||||
if(event.type == DolphinEventTypeDeed) {
|
||||
dolphin_state_on_deed(dolphin->state, event.deed);
|
||||
DolphinPubsubEvent event = DolphinPubsubEventUpdate;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "furi/pubsub.h"
|
||||
#include <core/pubsub.h>
|
||||
#include "gui/view.h"
|
||||
#include "helpers/dolphin_deed.h"
|
||||
#include <stdbool.h>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "furi/pubsub.h"
|
||||
#include <core/pubsub.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
@@ -17,7 +17,7 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
DolphinEventType type;
|
||||
osEventFlagsId_t flag;
|
||||
FuriEventFlag* flag;
|
||||
union {
|
||||
DolphinDeed deed;
|
||||
DolphinStats* stats;
|
||||
@@ -28,7 +28,7 @@ struct Dolphin {
|
||||
// State
|
||||
DolphinState* state;
|
||||
// Queue
|
||||
osMessageQueueId_t event_queue;
|
||||
FuriMessageQueue* event_queue;
|
||||
FuriPubSub* pubsub;
|
||||
TimerHandle_t butthurt_timer;
|
||||
TimerHandle_t flush_timer;
|
||||
|
@@ -1,8 +1,7 @@
|
||||
#include "assets_icons.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "dolphin/helpers/dolphin_state.h"
|
||||
#include "furi/check.h"
|
||||
#include "furi/record.h"
|
||||
#include <core/check.h>
|
||||
#include <core/record.h>
|
||||
#include <furi.h>
|
||||
#include <gui/gui.h>
|
||||
#include <furi_hal_version.h>
|
||||
@@ -28,10 +27,10 @@ static const Icon* const portrait_bad[BUTTHURT_MAX] = {
|
||||
static const Icon* const* portraits[MOODS_TOTAL] = {portrait_happy, portrait_ok, portrait_bad};
|
||||
|
||||
static void input_callback(InputEvent* input, void* ctx) {
|
||||
osSemaphoreId_t semaphore = ctx;
|
||||
FuriSemaphore* semaphore = ctx;
|
||||
|
||||
if((input->type == InputTypeShort) && (input->key == InputKeyBack)) {
|
||||
osSemaphoreRelease(semaphore);
|
||||
furi_semaphore_release(semaphore);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +90,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
|
||||
|
||||
int32_t passport_app(void* p) {
|
||||
UNUSED(p);
|
||||
osSemaphoreId_t semaphore = osSemaphoreNew(1, 0, NULL);
|
||||
FuriSemaphore* semaphore = furi_semaphore_alloc(1, 0);
|
||||
furi_assert(semaphore);
|
||||
|
||||
ViewPort* view_port = view_port_alloc();
|
||||
@@ -105,12 +104,12 @@ int32_t passport_app(void* p) {
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
view_port_update(view_port);
|
||||
|
||||
furi_check(osSemaphoreAcquire(semaphore, osWaitForever) == osOK);
|
||||
furi_check(furi_semaphore_acquire(semaphore, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
furi_record_close("gui");
|
||||
osSemaphoreDelete(semaphore);
|
||||
furi_semaphore_free(semaphore);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user