furi_check - a new way to asserting (#204)

* hal-related task_is_isr_context function
* furi_check implementation
* change application to use furi_check
* add second level of assertion
* add TODO about ISR context
* Applications: refactor furi_check and furi_assert.
* Apploader: propwer widget usage. Menu: check on furi resource request.
* refactor furi_check

Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
Co-authored-by: coreglitch <mail@s3f.ru>
This commit is contained in:
DrZlo13
2020-10-29 09:27:17 +03:00
committed by GitHub
parent c9b921f6ce
commit 8aeafd8179
24 changed files with 292 additions and 136 deletions

View File

@@ -1,7 +1,6 @@
#include "gui_event.h"
#include <flipper_v2.h>
#include <assert.h>
#define GUI_EVENT_MQUEUE_SIZE 8
@@ -11,7 +10,9 @@ struct GuiEvent {
};
void gui_event_input_events_callback(const void* value, void* ctx) {
assert(ctx);
furi_assert(value);
furi_assert(ctx);
GuiEvent* gui_event = ctx;
GuiMessage message;
@@ -23,35 +24,36 @@ void gui_event_input_events_callback(const void* value, void* ctx) {
GuiEvent* gui_event_alloc() {
GuiEvent* gui_event = furi_alloc(sizeof(GuiEvent));
// Allocate message que
// Allocate message queue
gui_event->mqueue = osMessageQueueNew(GUI_EVENT_MQUEUE_SIZE, sizeof(GuiMessage), NULL);
assert(gui_event->mqueue);
furi_check(gui_event->mqueue);
// Input
gui_event->input_event_record = furi_open("input_events");
assert(gui_event->input_event_record != NULL);
furi_check(gui_event->input_event_record != NULL);
subscribe_pubsub(gui_event->input_event_record, gui_event_input_events_callback, gui_event);
return gui_event;
}
void gui_event_free(GuiEvent* gui_event) {
assert(gui_event);
assert(osMessageQueueDelete(gui_event->mqueue) == osOK);
furi_assert(gui_event);
furi_check(osMessageQueueDelete(gui_event->mqueue) == osOK);
free(gui_event);
}
void gui_event_messsage_send(GuiEvent* gui_event, GuiMessage* message) {
assert(gui_event);
assert(message);
furi_assert(gui_event);
furi_assert(message);
osMessageQueuePut(gui_event->mqueue, message, 0, 0);
}
GuiMessage gui_event_message_next(GuiEvent* gui_event) {
assert(gui_event);
furi_assert(gui_event);
GuiMessage message;
assert(osMessageQueueGet(gui_event->mqueue, &message, NULL, osWaitForever) == osOK);
furi_check(osMessageQueueGet(gui_event->mqueue, &message, NULL, osWaitForever) == osOK);
return message;
}