Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/furi/core/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <stdio.h>
#include <stdlib.h>

static const char* volatile __furi_check_message = NULL;
const char* volatile __furi_check_message = NULL;
static volatile uint32_t __furi_check_registers[13] = {0};

/** Load r12 value to __furi_check_message and store registers to __furi_check_registers */
Expand Down Expand Up @@ -76,11 +76,13 @@ static void __furi_print_stack_info(void) {

static void __furi_print_heap_info(void) {
furi_log_puts("\r\n\t heap total: ");
furi_log_putu32(xPortGetTotalHeapSize());
furi_log_putu32(configTOTAL_HEAP_SIZE);
furi_log_puts("\r\n\t heap free: ");
furi_log_putu32(xPortGetFreeHeapSize());
HeapStats_t heap_stats;
vPortGetHeapStats(&heap_stats);
furi_log_puts("\r\n\t heap watermark: ");
furi_log_putu32(xPortGetMinimumEverFreeHeapSize());
furi_log_putu32(heap_stats.xMinimumEverFreeBytesRemaining);
furi_log_puts("\r\n\n");
}

Expand Down
10 changes: 10 additions & 0 deletions lib/furi/core/core_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ extern "C" {
#define CLAMP(x, upper, lower) (MIN(upper, MAX(x, lower)))
#endif

#ifndef CLAMP_WRAPAROUND
#define CLAMP_WRAPAROUND(x, upper, lower) \
({ \
__typeof__(x) _x = (x); \
__typeof__(upper) _upper = (upper); \
__typeof__(lower) _lower = (lower); \
(_x > _upper) ? _lower : ((_x < _lower) ? _upper : _x); \
})
#endif

#ifndef COUNT_OF
#define COUNT_OF(x) (sizeof(x) / sizeof(x[0]))
#endif
Expand Down
34 changes: 23 additions & 11 deletions lib/furi/core/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ static inline void furi_event_loop_process_custom_events(FuriEventLoop* instance
}
}

static void furi_event_loop_restore_flags(FuriEventLoop* instance, uint32_t flags) {
if(flags) {
xTaskNotifyIndexed(
(TaskHandle_t)instance->thread_id, FURI_EVENT_LOOP_FLAG_NOTIFY_INDEX, flags, eSetBits);
}
}

void furi_event_loop_run(FuriEventLoop* instance) {
furi_check(instance);
furi_check(instance->thread_id == furi_thread_get_current_id());
Expand Down Expand Up @@ -236,22 +243,27 @@ void furi_event_loop_run(FuriEventLoop* instance) {
if(flags & FuriEventLoopFlagStop) {
instance->state = FuriEventLoopStateStopped;
break;
}
if(flags & FuriEventLoopFlagEvent) {

} else if(flags & FuriEventLoopFlagEvent) {
furi_event_loop_process_waiting_list(instance);
}
if(flags & FuriEventLoopFlagTimer) {
furi_event_loop_restore_flags(instance, flags & ~FuriEventLoopFlagEvent);

} else if(flags & FuriEventLoopFlagTimer) {
furi_event_loop_process_timer_queue(instance);
}
if(flags & FuriEventLoopFlagPending) {
furi_event_loop_process_pending_callbacks(instance);
}
if(flags & FuriEventLoopFlagCustom) {
furi_event_loop_restore_flags(instance, flags & ~FuriEventLoopFlagTimer);

} else if(flags & FuriEventLoopFlagCustom) {
furi_event_loop_process_custom_events(instance);
furi_event_loop_restore_flags(instance, flags & ~FuriEventLoopFlagCustom);

} else if(flags & FuriEventLoopFlagPending) {
furi_event_loop_process_pending_callbacks(instance);

} else {
furi_crash();
}
}

if(!furi_event_loop_process_expired_timers(instance)) {
} else if(!furi_event_loop_process_expired_timers(instance)) {
furi_event_loop_process_tick(instance);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/furi/core/memmgr.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "memmgr.h"
#include <string.h>
#include <furi_hal_memory.h>
#include <FreeRTOS.h>

extern void* pvPortMalloc(size_t xSize);
extern void vPortFree(void* pv);
Expand Down Expand Up @@ -51,7 +52,7 @@ size_t memmgr_get_free_heap(void) {
}

size_t memmgr_get_total_heap(void) {
return xPortGetTotalHeapSize();
return configTOTAL_HEAP_SIZE;
}

size_t memmgr_get_minimum_free_heap(void) {
Expand Down
Loading