Merge branch 'dev' into astra/3746-mfp-detect

This commit is contained in:
gornekich 2024-05-30 13:04:53 +01:00 committed by GitHub
commit cdcff2faef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 38 additions and 15 deletions

View file

@ -34,12 +34,16 @@ void AccessorApp::run(void) {
AccessorApp::AccessorApp()
: text_store{0} {
notification = static_cast<NotificationApp*>(furi_record_open(RECORD_NOTIFICATION));
expansion = static_cast<Expansion*>(furi_record_open(RECORD_EXPANSION));
onewire_host = onewire_host_alloc(&gpio_ibutton);
expansion_disable(expansion);
furi_hal_power_enable_otg();
}
AccessorApp::~AccessorApp() {
furi_hal_power_disable_otg();
expansion_enable(expansion);
furi_record_close(RECORD_EXPANSION);
furi_record_close(RECORD_NOTIFICATION);
onewire_host_free(onewire_host);
}

View file

@ -6,6 +6,7 @@
#include "helpers/wiegand.h"
#include <one_wire/one_wire_host.h>
#include <notification/notification_messages.h>
#include <expansion/expansion.h>
class AccessorApp {
public:
@ -51,4 +52,5 @@ private:
OneWireHost* onewire_host;
NotificationApp* notification;
Expansion* expansion;
};

View file

@ -136,15 +136,17 @@ static void snake_game_render_callback(Canvas* const canvas, void* ctx) {
furi_mutex_release(snake_state->mutex);
}
static void snake_game_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
furi_assert(event_queue);
static void snake_game_input_callback(InputEvent* input_event, void* context) {
furi_assert(context);
FuriMessageQueue* event_queue = context;
SnakeEvent event = {.type = EventTypeKey, .input = *input_event};
furi_message_queue_put(event_queue, &event, FuriWaitForever);
}
static void snake_game_update_timer_callback(FuriMessageQueue* event_queue) {
furi_assert(event_queue);
static void snake_game_update_timer_callback(void* context) {
furi_assert(context);
FuriMessageQueue* event_queue = context;
SnakeEvent event = {.type = EventTypeTick};
furi_message_queue_put(event_queue, &event, 0);

View file

@ -5,13 +5,30 @@
#include <FreeRTOS.h>
#include <queue.h>
struct FuriMessageQueue {
// !!! Semi-Opaque type inheritance, Very Fragile, DO NOT MOVE !!!
StaticQueue_t container;
// !!! Data buffer, must be last in the structure, DO NOT MOVE !!!
uint8_t buffer[];
};
FuriMessageQueue* furi_message_queue_alloc(uint32_t msg_count, uint32_t msg_size) {
furi_check((furi_kernel_is_irq_or_masked() == 0U) && (msg_count > 0U) && (msg_size > 0U));
QueueHandle_t handle = xQueueCreate(msg_count, msg_size);
furi_check(handle);
FuriMessageQueue* instance = malloc(sizeof(FuriMessageQueue) + msg_count * msg_size);
return ((FuriMessageQueue*)handle);
// 3 things happens here:
// - create queue
// - check results
// - ensure that queue container is first in the FuriMessageQueue structure
//
// As a bonus it guarantees that FuriMessageQueue* can be casted into StaticQueue_t* or QueueHandle_t.
furi_check(
xQueueCreateStatic(msg_count, msg_size, instance->buffer, &instance->container) ==
(void*)instance);
return instance;
}
void furi_message_queue_free(FuriMessageQueue* instance) {
@ -19,6 +36,7 @@ void furi_message_queue_free(FuriMessageQueue* instance) {
furi_check(instance);
vQueueDelete((QueueHandle_t)instance);
free(instance);
}
FuriStatus
@ -102,11 +120,10 @@ FuriStatus furi_message_queue_get(FuriMessageQueue* instance, void* msg_ptr, uin
uint32_t furi_message_queue_get_capacity(FuriMessageQueue* instance) {
furi_check(instance);
StaticQueue_t* mq = (StaticQueue_t*)instance;
uint32_t capacity;
/* capacity = pxQueue->uxLength */
capacity = mq->uxDummy4[1];
capacity = instance->container.uxDummy4[1];
/* Return maximum number of messages */
return (capacity);
@ -115,11 +132,10 @@ uint32_t furi_message_queue_get_capacity(FuriMessageQueue* instance) {
uint32_t furi_message_queue_get_message_size(FuriMessageQueue* instance) {
furi_check(instance);
StaticQueue_t* mq = (StaticQueue_t*)instance;
uint32_t size;
/* size = pxQueue->uxItemSize */
size = mq->uxDummy4[2];
size = instance->container.uxDummy4[2];
/* Return maximum message size */
return (size);
@ -144,7 +160,6 @@ uint32_t furi_message_queue_get_count(FuriMessageQueue* instance) {
uint32_t furi_message_queue_get_space(FuriMessageQueue* instance) {
furi_check(instance);
StaticQueue_t* mq = (StaticQueue_t*)instance;
uint32_t space;
uint32_t isrm;
@ -152,11 +167,11 @@ uint32_t furi_message_queue_get_space(FuriMessageQueue* instance) {
isrm = taskENTER_CRITICAL_FROM_ISR();
/* space = pxQueue->uxLength - pxQueue->uxMessagesWaiting; */
space = mq->uxDummy4[1] - mq->uxDummy4[0];
space = instance->container.uxDummy4[1] - instance->container.uxDummy4[0];
taskEXIT_CRITICAL_FROM_ISR(isrm);
} else {
space = (uint32_t)uxQueueSpacesAvailable((QueueHandle_t)mq);
space = (uint32_t)uxQueueSpacesAvailable((QueueHandle_t)instance);
}
/* Return number of available slots */

View file

@ -10,7 +10,7 @@
extern "C" {
#endif
typedef void FuriMessageQueue;
typedef struct FuriMessageQueue FuriMessageQueue;
/** Allocate furi message queue
*