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:
@@ -30,10 +30,12 @@ uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8
|
||||
uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app);
|
||||
|
||||
void notification_message_save_settings(NotificationApp* app) {
|
||||
NotificationAppMessage m = {.type = SaveSettingsMessage, .back_event = osEventFlagsNew(NULL)};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
osEventFlagsWait(m.back_event, NOTIFICATION_EVENT_COMPLETE, osFlagsWaitAny, osWaitForever);
|
||||
osEventFlagsDelete(m.back_event);
|
||||
NotificationAppMessage m = {
|
||||
.type = SaveSettingsMessage, .back_event = furi_event_flag_alloc()};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
|
||||
// internal layer
|
||||
@@ -112,7 +114,7 @@ void notification_reset_notification_layer(NotificationApp* app, uint8_t reset_m
|
||||
notification_sound_off();
|
||||
}
|
||||
if(reset_mask & reset_display_mask) {
|
||||
osTimerStart(app->display_timer, notification_settings_display_off_delay_ticks(app));
|
||||
furi_timer_start(app->display_timer, notification_settings_display_off_delay_ticks(app));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +135,9 @@ uint8_t notification_settings_get_rgb_led_brightness(NotificationApp* app, uint8
|
||||
}
|
||||
|
||||
uint32_t notification_settings_display_off_delay_ticks(NotificationApp* app) {
|
||||
return ((float)(app->settings.display_off_delay_ms) / (1000.0f / osKernelGetTickFreq()));
|
||||
return (
|
||||
(float)(app->settings.display_off_delay_ms) /
|
||||
(1000.0f / furi_kernel_get_tick_frequency()));
|
||||
}
|
||||
|
||||
// generics
|
||||
@@ -189,8 +193,8 @@ void notification_process_notification_message(
|
||||
notification_message->data.led.value * display_brightness_setting);
|
||||
} else {
|
||||
notification_reset_notification_led_layer(&app->display);
|
||||
if(osTimerIsRunning(app->display_timer)) {
|
||||
osTimerStop(app->display_timer);
|
||||
if(furi_timer_is_running(app->display_timer)) {
|
||||
furi_timer_stop(app->display_timer);
|
||||
}
|
||||
}
|
||||
reset_mask |= reset_display_mask;
|
||||
@@ -280,7 +284,7 @@ void notification_process_notification_message(
|
||||
if(led_active) {
|
||||
if(notification_is_any_led_layer_internal_and_not_empty(app)) {
|
||||
notification_apply_notification_leds(app, led_off_values);
|
||||
furi_hal_delay_ms(minimal_delay);
|
||||
furi_delay_ms(minimal_delay);
|
||||
}
|
||||
|
||||
led_active = false;
|
||||
@@ -291,7 +295,7 @@ void notification_process_notification_message(
|
||||
reset_mask |= reset_blue_mask;
|
||||
}
|
||||
|
||||
furi_hal_delay_ms(notification_message->data.delay.length);
|
||||
furi_delay_ms(notification_message->data.delay.length);
|
||||
break;
|
||||
case NotificationMessageTypeDoNotReset:
|
||||
reset_notifications = false;
|
||||
@@ -334,7 +338,7 @@ void notification_process_notification_message(
|
||||
|
||||
if((need_minimal_delay) && (reset_notifications)) {
|
||||
notification_apply_notification_leds(app, led_off_values);
|
||||
furi_hal_delay_ms(minimal_delay);
|
||||
furi_delay_ms(minimal_delay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,9 +420,9 @@ static bool notification_load_settings(NotificationApp* app) {
|
||||
FURI_LOG_E(
|
||||
TAG, "version(%d != %d) mismatch", settings.version, NOTIFICATION_SETTINGS_VERSION);
|
||||
} else {
|
||||
osKernelLock();
|
||||
furi_kernel_lock();
|
||||
memcpy(&app->settings, &settings, settings_size);
|
||||
osKernelUnlock();
|
||||
furi_kernel_unlock();
|
||||
}
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "load failed, %s", storage_file_get_error_desc(file));
|
||||
@@ -438,9 +442,9 @@ static bool notification_save_settings(NotificationApp* app) {
|
||||
|
||||
FURI_LOG_I(TAG, "saving settings to \"%s\"", NOTIFICATION_SETTINGS_PATH);
|
||||
|
||||
osKernelLock();
|
||||
furi_kernel_lock();
|
||||
memcpy(&settings, &app->settings, settings_size);
|
||||
osKernelUnlock();
|
||||
furi_kernel_unlock();
|
||||
|
||||
bool fs_result =
|
||||
storage_file_open(file, NOTIFICATION_SETTINGS_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS);
|
||||
@@ -476,8 +480,8 @@ static void input_event_callback(const void* value, void* context) {
|
||||
// App alloc
|
||||
static NotificationApp* notification_app_alloc() {
|
||||
NotificationApp* app = malloc(sizeof(NotificationApp));
|
||||
app->queue = osMessageQueueNew(8, sizeof(NotificationAppMessage), NULL);
|
||||
app->display_timer = osTimerNew(notification_display_timer, osTimerOnce, app, NULL);
|
||||
app->queue = furi_message_queue_alloc(8, sizeof(NotificationAppMessage));
|
||||
app->display_timer = furi_timer_alloc(notification_display_timer, FuriTimerTypeOnce, app);
|
||||
|
||||
app->settings.speaker_volume = 1.0f;
|
||||
app->settings.display_brightness = 1.0f;
|
||||
@@ -535,7 +539,7 @@ int32_t notification_srv(void* p) {
|
||||
|
||||
NotificationAppMessage message;
|
||||
while(1) {
|
||||
furi_check(osMessageQueueGet(app->queue, &message, NULL, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_get(app->queue, &message, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
switch(message.type) {
|
||||
case NotificationLayerMessage:
|
||||
@@ -550,7 +554,7 @@ int32_t notification_srv(void* p) {
|
||||
}
|
||||
|
||||
if(message.back_event != NULL) {
|
||||
osEventFlagsSet(message.back_event, NOTIFICATION_EVENT_COMPLETE);
|
||||
furi_event_flag_set(message.back_event, NOTIFICATION_EVENT_COMPLETE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ typedef enum {
|
||||
typedef struct {
|
||||
const NotificationSequence* sequence;
|
||||
NotificationAppMessageType type;
|
||||
osEventFlagsId_t back_event;
|
||||
FuriEventFlag* back_event;
|
||||
} NotificationAppMessage;
|
||||
|
||||
typedef enum {
|
||||
@@ -44,9 +44,9 @@ typedef struct {
|
||||
} NotificationSettings;
|
||||
|
||||
struct NotificationApp {
|
||||
osMessageQueueId_t queue;
|
||||
FuriMessageQueue* queue;
|
||||
FuriPubSub* event_record;
|
||||
osTimerId_t display_timer;
|
||||
FuriTimer* display_timer;
|
||||
|
||||
NotificationLedLayer display;
|
||||
NotificationLedLayer led[NOTIFICATION_LED_COUNT];
|
||||
|
@@ -7,31 +7,33 @@
|
||||
void notification_message(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
NotificationAppMessage m = {
|
||||
.type = NotificationLayerMessage, .sequence = sequence, .back_event = NULL};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
};
|
||||
|
||||
void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
NotificationAppMessage m = {
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = NULL};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
};
|
||||
|
||||
void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) {
|
||||
NotificationAppMessage m = {
|
||||
.type = NotificationLayerMessage,
|
||||
.sequence = sequence,
|
||||
.back_event = osEventFlagsNew(NULL)};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
osEventFlagsWait(m.back_event, NOTIFICATION_EVENT_COMPLETE, osFlagsWaitAny, osWaitForever);
|
||||
osEventFlagsDelete(m.back_event);
|
||||
.back_event = furi_event_flag_alloc()};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
|
||||
void notification_internal_message_block(
|
||||
NotificationApp* app,
|
||||
const NotificationSequence* sequence) {
|
||||
NotificationAppMessage m = {
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = osEventFlagsNew(NULL)};
|
||||
furi_check(osMessageQueuePut(app->queue, &m, 0, osWaitForever) == osOK);
|
||||
osEventFlagsWait(m.back_event, NOTIFICATION_EVENT_COMPLETE, osFlagsWaitAny, osWaitForever);
|
||||
osEventFlagsDelete(m.back_event);
|
||||
.type = InternalLayerMessage, .sequence = sequence, .back_event = furi_event_flag_alloc()};
|
||||
furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk);
|
||||
furi_event_flag_wait(
|
||||
m.back_event, NOTIFICATION_EVENT_COMPLETE, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_event_flag_free(m.back_event);
|
||||
};
|
||||
|
Reference in New Issue
Block a user