code style aligned
added .clang-format and updated projects Furi and NanoBake with it
This commit is contained in:
+11
-11
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <furi_config.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -17,25 +17,25 @@ typedef enum {
|
||||
FuriFlagWaitAll = 0x00000001U, ///< Wait for all flags.
|
||||
FuriFlagNoClear = 0x00000002U, ///< Do not clear flags which have been specified to wait for.
|
||||
|
||||
FuriFlagError = 0x80000000U, ///< Error indicator.
|
||||
FuriFlagErrorUnknown = 0xFFFFFFFFU, ///< FuriStatusError (-1).
|
||||
FuriFlagErrorTimeout = 0xFFFFFFFEU, ///< FuriStatusErrorTimeout (-2).
|
||||
FuriFlagErrorResource = 0xFFFFFFFDU, ///< FuriStatusErrorResource (-3).
|
||||
FuriFlagError = 0x80000000U, ///< Error indicator.
|
||||
FuriFlagErrorUnknown = 0xFFFFFFFFU, ///< FuriStatusError (-1).
|
||||
FuriFlagErrorTimeout = 0xFFFFFFFEU, ///< FuriStatusErrorTimeout (-2).
|
||||
FuriFlagErrorResource = 0xFFFFFFFDU, ///< FuriStatusErrorResource (-3).
|
||||
FuriFlagErrorParameter = 0xFFFFFFFCU, ///< FuriStatusErrorParameter (-4).
|
||||
FuriFlagErrorISR = 0xFFFFFFFAU, ///< FuriStatusErrorISR (-6).
|
||||
FuriFlagErrorISR = 0xFFFFFFFAU, ///< FuriStatusErrorISR (-6).
|
||||
} FuriFlag;
|
||||
|
||||
typedef enum {
|
||||
FuriStatusOk = 0, ///< Operation completed successfully.
|
||||
FuriStatusError =
|
||||
-1, ///< Unspecified RTOS error: run-time error but no other error message fits.
|
||||
FuriStatusErrorTimeout = -2, ///< Operation not completed within the timeout period.
|
||||
FuriStatusErrorResource = -3, ///< Resource not available.
|
||||
-1, ///< Unspecified RTOS error: run-time error but no other error message fits.
|
||||
FuriStatusErrorTimeout = -2, ///< Operation not completed within the timeout period.
|
||||
FuriStatusErrorResource = -3, ///< Resource not available.
|
||||
FuriStatusErrorParameter = -4, ///< Parameter error.
|
||||
FuriStatusErrorNoMemory =
|
||||
-5, ///< System is out of memory: it was impossible to allocate or reserve memory for the operation.
|
||||
FuriStatusErrorISR =
|
||||
-6, ///< Not allowed in ISR context: the function cannot be called from interrupt service routines.
|
||||
-6, ///< Not allowed in ISR context: the function cannot be called from interrupt service routines.
|
||||
FuriStatusReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization.
|
||||
} FuriStatus;
|
||||
|
||||
|
||||
+37
-31
@@ -6,8 +6,10 @@
|
||||
#include <freertos/task.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
PLACE_IN_SECTION("MB_MEM2") const char* __furi_check_message = NULL;
|
||||
PLACE_IN_SECTION("MB_MEM2") uint32_t __furi_check_registers[13] = {0};
|
||||
PLACE_IN_SECTION("MB_MEM2")
|
||||
const char* __furi_check_message = NULL;
|
||||
PLACE_IN_SECTION("MB_MEM2")
|
||||
uint32_t __furi_check_registers[13] = {0};
|
||||
|
||||
/** Load r12 value to __furi_check_message and store registers to __furi_check_registers */
|
||||
/*#define GET_MESSAGE_AND_STORE_REGISTERS() \
|
||||
@@ -62,7 +64,7 @@ static void __furi_put_uint32_as_hex(uint32_t data) {
|
||||
|
||||
static void __furi_print_register_info() {
|
||||
// Print registers
|
||||
for(uint8_t i = 0; i < 12; i++) {
|
||||
for (uint8_t i = 0; i < 12; i++) {
|
||||
furi_hal_console_puts("\r\n\tr");
|
||||
__furi_put_uint32_as_text(i);
|
||||
furi_hal_console_puts(" : ");
|
||||
@@ -79,22 +81,26 @@ static void __furi_print_stack_info() {
|
||||
}
|
||||
|
||||
static void __furi_print_bt_stack_info() {
|
||||
// const FuriHalBtHardfaultInfo* fault_info = furi_hal_bt_get_hardfault_info();
|
||||
// if(fault_info == NULL) {
|
||||
// furi_hal_console_puts("\r\n\tcore2: not faulted");
|
||||
// } else {
|
||||
// furi_hal_console_puts("\r\n\tcore2: hardfaulted.\r\n\tPC: ");
|
||||
// __furi_put_uint32_as_hex(fault_info->source_pc);
|
||||
// furi_hal_console_puts("\r\n\tLR: ");
|
||||
// __furi_put_uint32_as_hex(fault_info->source_lr);
|
||||
// furi_hal_console_puts("\r\n\tSP: ");
|
||||
// __furi_put_uint32_as_hex(fault_info->source_sp);
|
||||
// }
|
||||
/*
|
||||
const FuriHalBtHardfaultInfo* fault_info = furi_hal_bt_get_hardfault_info();
|
||||
if(fault_info == NULL) {
|
||||
furi_hal_console_puts("\r\n\tcore2: not faulted");
|
||||
} else {
|
||||
furi_hal_console_puts("\r\n\tcore2: hardfaulted.\r\n\tPC: ");
|
||||
__furi_put_uint32_as_hex(fault_info->source_pc);
|
||||
furi_hal_console_puts("\r\n\tLR: ");
|
||||
__furi_put_uint32_as_hex(fault_info->source_lr);
|
||||
furi_hal_console_puts("\r\n\tSP: ");
|
||||
__furi_put_uint32_as_hex(fault_info->source_sp);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
static void __furi_print_heap_info() {
|
||||
// furi_hal_console_puts("\r\n\t heap total: ");
|
||||
// __furi_put_uint32_as_text(xPortGetTotalHeapSize());
|
||||
/*
|
||||
furi_hal_console_puts("\r\n\t heap total: ");
|
||||
__furi_put_uint32_as_text(xPortGetTotalHeapSize());
|
||||
*/
|
||||
furi_hal_console_puts("\r\n\t heap free: ");
|
||||
__furi_put_uint32_as_text(xPortGetFreeHeapSize());
|
||||
furi_hal_console_puts("\r\n\t heap watermark: ");
|
||||
@@ -102,13 +108,13 @@ static void __furi_print_heap_info() {
|
||||
}
|
||||
|
||||
static void __furi_print_name(bool isr) {
|
||||
if(isr) {
|
||||
if (isr) {
|
||||
furi_hal_console_puts("[ISR ");
|
||||
__furi_put_uint32_as_text(__get_IPSR());
|
||||
furi_hal_console_puts("] ");
|
||||
} else {
|
||||
const char* name = pcTaskGetName(NULL);
|
||||
if(name == NULL) {
|
||||
if (name == NULL) {
|
||||
furi_hal_console_puts("[main] ");
|
||||
} else {
|
||||
furi_hal_console_puts("[");
|
||||
@@ -120,15 +126,15 @@ static void __furi_print_name(bool isr) {
|
||||
|
||||
FURI_NORETURN void __furi_crash_implementation() {
|
||||
__disable_irq();
|
||||
// GET_MESSAGE_AND_STORE_REGISTERS();
|
||||
// GET_MESSAGE_AND_STORE_REGISTERS();
|
||||
|
||||
bool isr = FURI_IS_IRQ_MODE();
|
||||
|
||||
if(__furi_check_message == NULL) {
|
||||
if (__furi_check_message == NULL) {
|
||||
__furi_check_message = "Fatal Error";
|
||||
} else if(__furi_check_message == (void*)__FURI_ASSERT_MESSAGE_FLAG) {
|
||||
} else if (__furi_check_message == (void*)__FURI_ASSERT_MESSAGE_FLAG) {
|
||||
__furi_check_message = "furi_assert failed";
|
||||
} else if(__furi_check_message == (void*)__FURI_CHECK_MESSAGE_FLAG) {
|
||||
} else if (__furi_check_message == (void*)__FURI_CHECK_MESSAGE_FLAG) {
|
||||
__furi_check_message = "furi_check failed";
|
||||
}
|
||||
|
||||
@@ -137,7 +143,7 @@ FURI_NORETURN void __furi_crash_implementation() {
|
||||
furi_hal_console_puts(__furi_check_message);
|
||||
|
||||
__furi_print_register_info();
|
||||
if(!isr) {
|
||||
if (!isr) {
|
||||
__furi_print_stack_info();
|
||||
}
|
||||
__furi_print_heap_info();
|
||||
@@ -147,17 +153,17 @@ FURI_NORETURN void __furi_crash_implementation() {
|
||||
// https://developer.arm.com/documentation/ddi0403/d/Debug-Architecture/ARMv7-M-Debug/Debug-register-support-in-the-SCS/Debug-Halting-Control-and-Status-Register--DHCSR?lang=en
|
||||
// bool debug = CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk;
|
||||
#ifdef FURI_NDEBUG
|
||||
if(debug) {
|
||||
if (debug) {
|
||||
#endif
|
||||
furi_hal_console_puts("\r\nSystem halted. Connect debugger for more info\r\n");
|
||||
furi_hal_console_puts("\033[0m\r\n");
|
||||
// furi_hal_debug_enable();
|
||||
// furi_hal_debug_enable();
|
||||
|
||||
esp_system_abort("crash");
|
||||
esp_system_abort("crash");
|
||||
#ifdef FURI_NDEBUG
|
||||
} else {
|
||||
uint32_t ptr = (uint32_t)__furi_check_message;
|
||||
if(ptr < FLASH_BASE || ptr > (FLASH_BASE + FLASH_SIZE)) {
|
||||
if (ptr < FLASH_BASE || ptr > (FLASH_BASE + FLASH_SIZE)) {
|
||||
ptr = (uint32_t) "Check serial logs";
|
||||
}
|
||||
furi_hal_rtc_set_fault_data(ptr);
|
||||
@@ -170,11 +176,11 @@ FURI_NORETURN void __furi_crash_implementation() {
|
||||
}
|
||||
FURI_NORETURN void __furi_halt_implementation() {
|
||||
__disable_irq();
|
||||
// GET_MESSAGE_AND_STORE_REGISTERS();
|
||||
// GET_MESSAGE_AND_STORE_REGISTERS();
|
||||
|
||||
bool isr = FURI_IS_IRQ_MODE();
|
||||
|
||||
if(__furi_check_message == NULL) {
|
||||
if (__furi_check_message == NULL) {
|
||||
__furi_check_message = "System halt requested.";
|
||||
}
|
||||
|
||||
@@ -186,8 +192,8 @@ FURI_NORETURN void __furi_halt_implementation() {
|
||||
|
||||
// Check if debug enabled by DAP
|
||||
// https://developer.arm.com/documentation/ddi0403/d/Debug-Architecture/ARMv7-M-Debug/Debug-register-support-in-the-SCS/Debug-Halting-Control-and-Status-Register--DHCSR?lang=en
|
||||
// bool debug = CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk;
|
||||
// RESTORE_REGISTERS_AND_HALT_MCU(true);
|
||||
// bool debug = CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk;
|
||||
// RESTORE_REGISTERS_AND_HALT_MCU(true);
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
+23
-23
@@ -13,8 +13,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <m-core.h>
|
||||
#include <esp_log.h>
|
||||
#include <m-core.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -35,11 +35,11 @@ FURI_NORETURN void __furi_crash_implementation();
|
||||
FURI_NORETURN void __furi_halt_implementation();
|
||||
|
||||
/** Crash system with message. */
|
||||
#define __furi_crash(message) \
|
||||
do { \
|
||||
#define __furi_crash(message) \
|
||||
do { \
|
||||
ESP_LOGE("crash", "%s\n\tat %s:%d", ((message) ? ((const char*)message) : ""), __FILE__, __LINE__); \
|
||||
__furi_crash_implementation(); \
|
||||
} while(0)
|
||||
__furi_crash_implementation(); \
|
||||
} while (0)
|
||||
|
||||
/** Crash system
|
||||
*
|
||||
@@ -48,11 +48,11 @@ FURI_NORETURN void __furi_halt_implementation();
|
||||
#define furi_crash(...) M_APPLY(__furi_crash, M_IF_EMPTY(__VA_ARGS__)((NULL), (__VA_ARGS__)))
|
||||
|
||||
/** Halt system with message. */
|
||||
#define __furi_halt(message) \
|
||||
do { \
|
||||
ESP_LOGE("halt", "%s\n\tat %s:%d", ((message) ? ((const char*)message) : ""), __FILE__, __LINE__); \
|
||||
__furi_halt_implementation(); \
|
||||
} while(0)
|
||||
#define __furi_halt(message) \
|
||||
do { \
|
||||
ESP_LOGE("halt", "%s\n\tat %s:%d", ((message) ? ((const char*)message) : ""), __FILE__, __LINE__); \
|
||||
__furi_halt_implementation(); \
|
||||
} while (0)
|
||||
|
||||
/** Halt system
|
||||
*
|
||||
@@ -61,13 +61,13 @@ FURI_NORETURN void __furi_halt_implementation();
|
||||
#define furi_halt(...) M_APPLY(__furi_halt, M_IF_EMPTY(__VA_ARGS__)((NULL), (__VA_ARGS__)))
|
||||
|
||||
/** Check condition and crash if check failed */
|
||||
#define __furi_check(__e, __m) \
|
||||
do { \
|
||||
if(!(__e)) { \
|
||||
#define __furi_check(__e, __m) \
|
||||
do { \
|
||||
if (!(__e)) { \
|
||||
ESP_LOGE("check", "%s", #__e); \
|
||||
__furi_crash(__m); \
|
||||
} \
|
||||
} while(0)
|
||||
__furi_crash(__m); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/** Check condition and crash if failed
|
||||
*
|
||||
@@ -79,19 +79,19 @@ FURI_NORETURN void __furi_halt_implementation();
|
||||
|
||||
/** Only in debug build: Assert condition and crash if assert failed */
|
||||
#ifdef FURI_DEBUG
|
||||
#define __furi_assert(__e, __m) \
|
||||
do { \
|
||||
if(!(__e)) { \
|
||||
#define __furi_assert(__e, __m) \
|
||||
do { \
|
||||
if (!(__e)) { \
|
||||
ESP_LOGE("assert", "%s", #__e); \
|
||||
__furi_crash(__m); \
|
||||
} \
|
||||
} while(0)
|
||||
__furi_crash(__m); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define __furi_assert(__e, __m) \
|
||||
do { \
|
||||
((void)(__e)); \
|
||||
((void)(__m)); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/** Assert condition and crash if failed
|
||||
|
||||
@@ -51,7 +51,7 @@ extern "C" {
|
||||
typeof(x) SWAP = x; \
|
||||
x = y; \
|
||||
y = SWAP; \
|
||||
} while(0)
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef PLACE_IN_SECTION
|
||||
@@ -84,9 +84,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef REVERSE_BYTES_U32
|
||||
#define REVERSE_BYTES_U32(x) \
|
||||
((((x)&0x000000FF) << 24) | (((x)&0x0000FF00) << 8) | (((x)&0x00FF0000) >> 8) | \
|
||||
(((x)&0xFF000000) >> 24))
|
||||
#define REVERSE_BYTES_U32(x) \
|
||||
((((x) & 0x000000FF) << 24) | (((x) & 0x0000FF00) << 8) | (((x) & 0x00FF0000) >> 8) | \
|
||||
(((x) & 0xFF000000) >> 24))
|
||||
#endif
|
||||
|
||||
#ifndef FURI_BIT
|
||||
|
||||
@@ -12,9 +12,9 @@ __FuriCriticalInfo __furi_critical_enter(void) {
|
||||
info.from_isr = FURI_IS_ISR();
|
||||
info.kernel_running = (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING);
|
||||
|
||||
if(info.from_isr) {
|
||||
if (info.from_isr) {
|
||||
info.isrm = taskENTER_CRITICAL_FROM_ISR();
|
||||
} else if(info.kernel_running) {
|
||||
} else if (info.kernel_running) {
|
||||
taskENTER_CRITICAL(&prv_critical_mutex);
|
||||
} else {
|
||||
__disable_irq();
|
||||
@@ -24,9 +24,9 @@ __FuriCriticalInfo __furi_critical_enter(void) {
|
||||
}
|
||||
|
||||
void __furi_critical_exit(__FuriCriticalInfo info) {
|
||||
if(info.from_isr) {
|
||||
if (info.from_isr) {
|
||||
taskEXIT_CRITICAL_FROM_ISR(info.isrm);
|
||||
} else if(info.kernel_running) {
|
||||
} else if (info.kernel_running) {
|
||||
taskEXIT_CRITICAL(&prv_critical_mutex);
|
||||
} else {
|
||||
__enable_irq();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "event_flag.h"
|
||||
#include "common_defines.h"
|
||||
#include "check.h"
|
||||
#include "common_defines.h"
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/event_groups.h>
|
||||
@@ -30,9 +30,9 @@ uint32_t furi_event_flag_set(FuriEventFlag* instance, uint32_t flags) {
|
||||
uint32_t rflags;
|
||||
BaseType_t yield;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
yield = pdFALSE;
|
||||
if(xEventGroupSetBitsFromISR(hEventGroup, (EventBits_t)flags, &yield) == pdFAIL) {
|
||||
if (xEventGroupSetBitsFromISR(hEventGroup, (EventBits_t)flags, &yield) == pdFAIL) {
|
||||
rflags = (uint32_t)FuriFlagErrorResource;
|
||||
} else {
|
||||
rflags = flags;
|
||||
@@ -53,10 +53,10 @@ uint32_t furi_event_flag_clear(FuriEventFlag* instance, uint32_t flags) {
|
||||
EventGroupHandle_t hEventGroup = (EventGroupHandle_t)instance;
|
||||
uint32_t rflags;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
rflags = xEventGroupGetBitsFromISR(hEventGroup);
|
||||
|
||||
if(xEventGroupClearBitsFromISR(hEventGroup, (EventBits_t)flags) == pdFAIL) {
|
||||
if (xEventGroupClearBitsFromISR(hEventGroup, (EventBits_t)flags) == pdFAIL) {
|
||||
rflags = (uint32_t)FuriStatusErrorResource;
|
||||
} else {
|
||||
/* xEventGroupClearBitsFromISR only registers clear operation in the timer command queue. */
|
||||
@@ -78,7 +78,7 @@ uint32_t furi_event_flag_get(FuriEventFlag* instance) {
|
||||
EventGroupHandle_t hEventGroup = (EventGroupHandle_t)instance;
|
||||
uint32_t rflags;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
rflags = xEventGroupGetBitsFromISR(hEventGroup);
|
||||
} else {
|
||||
rflags = xEventGroupGetBits(hEventGroup);
|
||||
@@ -92,7 +92,8 @@ uint32_t furi_event_flag_wait(
|
||||
FuriEventFlag* instance,
|
||||
uint32_t flags,
|
||||
uint32_t options,
|
||||
uint32_t timeout) {
|
||||
uint32_t timeout
|
||||
) {
|
||||
furi_assert(!FURI_IS_IRQ_MODE());
|
||||
furi_assert(instance);
|
||||
furi_assert((flags & FURI_EVENT_FLAG_INVALID_BITS) == 0U);
|
||||
@@ -102,32 +103,33 @@ uint32_t furi_event_flag_wait(
|
||||
BaseType_t exit_clr;
|
||||
uint32_t rflags;
|
||||
|
||||
if(options & FuriFlagWaitAll) {
|
||||
if (options & FuriFlagWaitAll) {
|
||||
wait_all = pdTRUE;
|
||||
} else {
|
||||
wait_all = pdFAIL;
|
||||
}
|
||||
|
||||
if(options & FuriFlagNoClear) {
|
||||
if (options & FuriFlagNoClear) {
|
||||
exit_clr = pdFAIL;
|
||||
} else {
|
||||
exit_clr = pdTRUE;
|
||||
}
|
||||
|
||||
rflags = xEventGroupWaitBits(
|
||||
hEventGroup, (EventBits_t)flags, exit_clr, wait_all, (TickType_t)timeout);
|
||||
hEventGroup, (EventBits_t)flags, exit_clr, wait_all, (TickType_t)timeout
|
||||
);
|
||||
|
||||
if(options & FuriFlagWaitAll) {
|
||||
if((flags & rflags) != flags) {
|
||||
if(timeout > 0U) {
|
||||
if (options & FuriFlagWaitAll) {
|
||||
if ((flags & rflags) != flags) {
|
||||
if (timeout > 0U) {
|
||||
rflags = (uint32_t)FuriStatusErrorTimeout;
|
||||
} else {
|
||||
rflags = (uint32_t)FuriStatusErrorResource;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if((flags & rflags) == 0U) {
|
||||
if(timeout > 0U) {
|
||||
if ((flags & rflags) == 0U) {
|
||||
if (timeout > 0U) {
|
||||
rflags = (uint32_t)FuriStatusErrorTimeout;
|
||||
} else {
|
||||
rflags = (uint32_t)FuriStatusErrorResource;
|
||||
|
||||
@@ -63,7 +63,8 @@ uint32_t furi_event_flag_wait(
|
||||
FuriEventFlag* instance,
|
||||
uint32_t flags,
|
||||
uint32_t options,
|
||||
uint32_t timeout);
|
||||
uint32_t timeout
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -2,18 +2,12 @@
|
||||
#include "common_defines.h"
|
||||
#include "furi_string.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <esp_log.h>
|
||||
#include <memory.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define TAG "FuriHalConsole"
|
||||
|
||||
#ifdef HEAP_PRINT_DEBUG
|
||||
#define CONSOLE_BAUDRATE 1843200
|
||||
#else
|
||||
#define CONSOLE_BAUDRATE 230400
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
bool alive;
|
||||
FuriHalConsoleTxCallback tx_callback;
|
||||
@@ -27,21 +21,14 @@ FuriHalConsole furi_hal_console = {
|
||||
};
|
||||
|
||||
void furi_hal_console_init() {
|
||||
// furi_hal_uart_init(FuriHalUartIdUSART1, CONSOLE_BAUDRATE);
|
||||
furi_hal_console.alive = true;
|
||||
}
|
||||
|
||||
void furi_hal_console_enable() {
|
||||
// furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, NULL, NULL);
|
||||
// while(!LL_USART_IsActiveFlag_TC(USART1))
|
||||
// ;
|
||||
// furi_hal_uart_set_br(FuriHalUartIdUSART1, CONSOLE_BAUDRATE);
|
||||
furi_hal_console.alive = true;
|
||||
}
|
||||
|
||||
void furi_hal_console_disable() {
|
||||
// while(!LL_USART_IsActiveFlag_TC(USART1))
|
||||
// ;
|
||||
furi_hal_console.alive = false;
|
||||
}
|
||||
|
||||
@@ -53,12 +40,10 @@ void furi_hal_console_set_tx_callback(FuriHalConsoleTxCallback callback, void* c
|
||||
}
|
||||
|
||||
void furi_hal_console_tx(const uint8_t* buffer, size_t buffer_size) {
|
||||
if(!furi_hal_console.alive) return;
|
||||
if (!furi_hal_console.alive) return;
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
// Transmit data
|
||||
|
||||
if(furi_hal_console.tx_callback) {
|
||||
if (furi_hal_console.tx_callback) {
|
||||
furi_hal_console.tx_callback(buffer, buffer_size, furi_hal_console.tx_callback_context);
|
||||
}
|
||||
|
||||
@@ -67,15 +52,11 @@ void furi_hal_console_tx(const uint8_t* buffer, size_t buffer_size) {
|
||||
safe_buffer[buffer_size] = 0;
|
||||
|
||||
ESP_LOGI(TAG, "%s", safe_buffer);
|
||||
// furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size);
|
||||
//// Wait for TC flag to be raised for last char
|
||||
// while(!LL_USART_IsActiveFlag_TC(USART1))
|
||||
// ;
|
||||
FURI_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
void furi_hal_console_tx_with_new_line(const uint8_t* buffer, size_t buffer_size) {
|
||||
if(!furi_hal_console.alive) return;
|
||||
if (!furi_hal_console.alive) return;
|
||||
|
||||
FURI_CRITICAL_ENTER();
|
||||
|
||||
@@ -84,13 +65,6 @@ void furi_hal_console_tx_with_new_line(const uint8_t* buffer, size_t buffer_size
|
||||
safe_buffer[buffer_size] = 0;
|
||||
ESP_LOGI(TAG, "%s", safe_buffer);
|
||||
|
||||
// Transmit data
|
||||
// furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)buffer, buffer_size);
|
||||
// Transmit new line symbols
|
||||
// furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t*)"\r\n", 2);
|
||||
// Wait for TC flag to be raised for last char
|
||||
// while(!LL_USART_IsActiveFlag_TC(USART1))
|
||||
// ;
|
||||
FURI_CRITICAL_EXIT();
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ void furi_string_replace_at(FuriString* v, size_t pos, size_t len, const char st
|
||||
}
|
||||
|
||||
size_t
|
||||
furi_string_replace(FuriString* string, FuriString* needle, FuriString* replace, size_t start) {
|
||||
furi_string_replace(FuriString* string, FuriString* needle, FuriString* replace, size_t start) {
|
||||
return string_replace(string->string, needle->string, replace->string, start);
|
||||
}
|
||||
|
||||
@@ -266,32 +266,32 @@ void furi_string_utf8_push(FuriString* str, FuriStringUnicodeValue u) {
|
||||
}
|
||||
|
||||
static m_str1ng_utf8_state_e furi_state_to_state(FuriStringUTF8State state) {
|
||||
switch(state) {
|
||||
case FuriStringUTF8StateStarting:
|
||||
return M_STR1NG_UTF8_STARTING;
|
||||
case FuriStringUTF8StateDecoding1:
|
||||
return M_STR1NG_UTF8_DECODING_1;
|
||||
case FuriStringUTF8StateDecoding2:
|
||||
return M_STR1NG_UTF8_DECODING_2;
|
||||
case FuriStringUTF8StateDecoding3:
|
||||
return M_STR1NG_UTF8_DECODING_3;
|
||||
default:
|
||||
return M_STR1NG_UTF8_ERROR;
|
||||
switch (state) {
|
||||
case FuriStringUTF8StateStarting:
|
||||
return M_STR1NG_UTF8_STARTING;
|
||||
case FuriStringUTF8StateDecoding1:
|
||||
return M_STR1NG_UTF8_DECODING_1;
|
||||
case FuriStringUTF8StateDecoding2:
|
||||
return M_STR1NG_UTF8_DECODING_2;
|
||||
case FuriStringUTF8StateDecoding3:
|
||||
return M_STR1NG_UTF8_DECODING_3;
|
||||
default:
|
||||
return M_STR1NG_UTF8_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
static FuriStringUTF8State state_to_furi_state(m_str1ng_utf8_state_e state) {
|
||||
switch(state) {
|
||||
case M_STR1NG_UTF8_STARTING:
|
||||
return FuriStringUTF8StateStarting;
|
||||
case M_STR1NG_UTF8_DECODING_1:
|
||||
return FuriStringUTF8StateDecoding1;
|
||||
case M_STR1NG_UTF8_DECODING_2:
|
||||
return FuriStringUTF8StateDecoding2;
|
||||
case M_STR1NG_UTF8_DECODING_3:
|
||||
return FuriStringUTF8StateDecoding3;
|
||||
default:
|
||||
return FuriStringUTF8StateError;
|
||||
switch (state) {
|
||||
case M_STR1NG_UTF8_STARTING:
|
||||
return FuriStringUTF8StateStarting;
|
||||
case M_STR1NG_UTF8_DECODING_1:
|
||||
return FuriStringUTF8StateDecoding1;
|
||||
case M_STR1NG_UTF8_DECODING_2:
|
||||
return FuriStringUTF8StateDecoding2;
|
||||
case M_STR1NG_UTF8_DECODING_3:
|
||||
return FuriStringUTF8StateDecoding3;
|
||||
default:
|
||||
return FuriStringUTF8StateError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <m-core.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -402,7 +402,7 @@ void furi_string_replace_at(FuriString* string, size_t pos, size_t len, const ch
|
||||
* @return size_t
|
||||
*/
|
||||
size_t
|
||||
furi_string_replace(FuriString* string, FuriString* needle, FuriString* replace, size_t start);
|
||||
furi_string_replace(FuriString* string, FuriString* needle, FuriString* replace, size_t start);
|
||||
|
||||
/**
|
||||
* @brief Replace a C string 'needle' to C string 'replace' in a string from 'start' position.
|
||||
@@ -418,7 +418,8 @@ size_t furi_string_replace_str(
|
||||
FuriString* string,
|
||||
const char needle[],
|
||||
const char replace[],
|
||||
size_t start);
|
||||
size_t start
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Replace all occurrences of 'needle' string into 'replace' string.
|
||||
@@ -429,7 +430,8 @@ size_t furi_string_replace_str(
|
||||
void furi_string_replace_all(
|
||||
FuriString* string,
|
||||
const FuriString* needle,
|
||||
const FuriString* replace);
|
||||
const FuriString* replace
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Replace all occurrences of 'needle' C string into 'replace' C string.
|
||||
@@ -569,25 +571,25 @@ void furi_string_utf8_decode(char c, FuriStringUTF8State* state, FuriStringUnico
|
||||
* @brief Select for 1 argument
|
||||
*/
|
||||
#define FURI_STRING_SELECT1(func1, func2, a) \
|
||||
_Generic((a), char* : func2, const char* : func2, FuriString* : func1, const FuriString* : func1)(a)
|
||||
_Generic((a), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)(a)
|
||||
|
||||
/**
|
||||
* @brief Select for 2 arguments
|
||||
*/
|
||||
#define FURI_STRING_SELECT2(func1, func2, a, b) \
|
||||
_Generic((b), char* : func2, const char* : func2, FuriString* : func1, const FuriString* : func1)(a, b)
|
||||
_Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)(a, b)
|
||||
|
||||
/**
|
||||
* @brief Select for 3 arguments
|
||||
*/
|
||||
#define FURI_STRING_SELECT3(func1, func2, a, b, c) \
|
||||
_Generic((b), char* : func2, const char* : func2, FuriString* : func1, const FuriString* : func1)(a, b, c)
|
||||
_Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)(a, b, c)
|
||||
|
||||
/**
|
||||
* @brief Select for 4 arguments
|
||||
*/
|
||||
#define FURI_STRING_SELECT4(func1, func2, a, b, c, d) \
|
||||
_Generic((b), char* : func2, const char* : func2, FuriString* : func1, const FuriString* : func1)(a, b, c, d)
|
||||
_Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)(a, b, c, d)
|
||||
|
||||
/**
|
||||
* @brief Allocate new FuriString and set it content to string (or C string).
|
||||
@@ -633,12 +635,13 @@ void furi_string_utf8_decode(char c, FuriStringUTF8State* state, FuriStringUnico
|
||||
* @brief Search for a string (or C string) in a string
|
||||
* (string, [c]string[, start=0])
|
||||
*/
|
||||
#define furi_string_search(...) \
|
||||
M_APPLY( \
|
||||
FURI_STRING_SELECT3, \
|
||||
furi_string_search, \
|
||||
furi_string_search_str, \
|
||||
M_DEFAULT_ARGS(3, (0), __VA_ARGS__))
|
||||
#define furi_string_search(...) \
|
||||
M_APPLY( \
|
||||
FURI_STRING_SELECT3, \
|
||||
furi_string_search, \
|
||||
furi_string_search_str, \
|
||||
M_DEFAULT_ARGS(3, (0), __VA_ARGS__) \
|
||||
)
|
||||
/**
|
||||
* @brief Search for a C string in a string
|
||||
* (string, cstring[, start=0])
|
||||
@@ -687,12 +690,13 @@ void furi_string_utf8_decode(char c, FuriStringUTF8State* state, FuriStringUnico
|
||||
* @brief Replace a string to another string (or C string to another C string) in a string.
|
||||
* (string, [c]string, [c]string[, start=0])
|
||||
*/
|
||||
#define furi_string_replace(...) \
|
||||
M_APPLY( \
|
||||
FURI_STRING_SELECT4, \
|
||||
furi_string_replace, \
|
||||
furi_string_replace_str, \
|
||||
M_DEFAULT_ARGS(4, (0), __VA_ARGS__))
|
||||
#define furi_string_replace(...) \
|
||||
M_APPLY( \
|
||||
FURI_STRING_SELECT4, \
|
||||
furi_string_replace, \
|
||||
furi_string_replace_str, \
|
||||
M_DEFAULT_ARGS(4, (0), __VA_ARGS__) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Replace a C string to another C string in a string.
|
||||
|
||||
@@ -11,16 +11,16 @@ bool furi_kernel_is_irq_or_masked() {
|
||||
bool irq = false;
|
||||
BaseType_t state;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
/* Called from interrupt context */
|
||||
irq = true;
|
||||
} else {
|
||||
/* Get FreeRTOS scheduler state */
|
||||
state = xTaskGetSchedulerState();
|
||||
|
||||
if(state != taskSCHEDULER_NOT_STARTED) {
|
||||
if (state != taskSCHEDULER_NOT_STARTED) {
|
||||
/* Scheduler was started */
|
||||
if(FURI_IS_IRQ_MASKED()) {
|
||||
if (FURI_IS_IRQ_MASKED()) {
|
||||
/* Interrupts are masked */
|
||||
irq = true;
|
||||
}
|
||||
@@ -40,20 +40,20 @@ int32_t furi_kernel_lock() {
|
||||
|
||||
int32_t lock;
|
||||
|
||||
switch(xTaskGetSchedulerState()) {
|
||||
case taskSCHEDULER_SUSPENDED:
|
||||
lock = 1;
|
||||
break;
|
||||
switch (xTaskGetSchedulerState()) {
|
||||
case taskSCHEDULER_SUSPENDED:
|
||||
lock = 1;
|
||||
break;
|
||||
|
||||
case taskSCHEDULER_RUNNING:
|
||||
vTaskSuspendAll();
|
||||
lock = 0;
|
||||
break;
|
||||
case taskSCHEDULER_RUNNING:
|
||||
vTaskSuspendAll();
|
||||
lock = 0;
|
||||
break;
|
||||
|
||||
case taskSCHEDULER_NOT_STARTED:
|
||||
default:
|
||||
lock = (int32_t)FuriStatusError;
|
||||
break;
|
||||
case taskSCHEDULER_NOT_STARTED:
|
||||
default:
|
||||
lock = (int32_t)FuriStatusError;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Return previous lock state */
|
||||
@@ -65,25 +65,25 @@ int32_t furi_kernel_unlock() {
|
||||
|
||||
int32_t lock;
|
||||
|
||||
switch(xTaskGetSchedulerState()) {
|
||||
case taskSCHEDULER_SUSPENDED:
|
||||
lock = 1;
|
||||
switch (xTaskGetSchedulerState()) {
|
||||
case taskSCHEDULER_SUSPENDED:
|
||||
lock = 1;
|
||||
|
||||
if(xTaskResumeAll() != pdTRUE) {
|
||||
if(xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) {
|
||||
lock = (int32_t)FuriStatusError;
|
||||
if (xTaskResumeAll() != pdTRUE) {
|
||||
if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) {
|
||||
lock = (int32_t)FuriStatusError;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case taskSCHEDULER_RUNNING:
|
||||
lock = 0;
|
||||
break;
|
||||
case taskSCHEDULER_RUNNING:
|
||||
lock = 0;
|
||||
break;
|
||||
|
||||
case taskSCHEDULER_NOT_STARTED:
|
||||
default:
|
||||
lock = (int32_t)FuriStatusError;
|
||||
break;
|
||||
case taskSCHEDULER_NOT_STARTED:
|
||||
default:
|
||||
lock = (int32_t)FuriStatusError;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Return previous lock state */
|
||||
@@ -93,28 +93,28 @@ int32_t furi_kernel_unlock() {
|
||||
int32_t furi_kernel_restore_lock(int32_t lock) {
|
||||
furi_assert(!furi_kernel_is_irq_or_masked());
|
||||
|
||||
switch(xTaskGetSchedulerState()) {
|
||||
case taskSCHEDULER_SUSPENDED:
|
||||
case taskSCHEDULER_RUNNING:
|
||||
if(lock == 1) {
|
||||
vTaskSuspendAll();
|
||||
} else {
|
||||
if(lock != 0) {
|
||||
lock = (int32_t)FuriStatusError;
|
||||
switch (xTaskGetSchedulerState()) {
|
||||
case taskSCHEDULER_SUSPENDED:
|
||||
case taskSCHEDULER_RUNNING:
|
||||
if (lock == 1) {
|
||||
vTaskSuspendAll();
|
||||
} else {
|
||||
if(xTaskResumeAll() != pdTRUE) {
|
||||
if(xTaskGetSchedulerState() != taskSCHEDULER_RUNNING) {
|
||||
lock = (int32_t)FuriStatusError;
|
||||
if (lock != 0) {
|
||||
lock = (int32_t)FuriStatusError;
|
||||
} else {
|
||||
if (xTaskResumeAll() != pdTRUE) {
|
||||
if (xTaskGetSchedulerState() != taskSCHEDULER_RUNNING) {
|
||||
lock = (int32_t)FuriStatusError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case taskSCHEDULER_NOT_STARTED:
|
||||
default:
|
||||
lock = (int32_t)FuriStatusError;
|
||||
break;
|
||||
case taskSCHEDULER_NOT_STARTED:
|
||||
default:
|
||||
lock = (int32_t)FuriStatusError;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Return new lock state */
|
||||
@@ -128,7 +128,7 @@ uint32_t furi_kernel_get_tick_frequency() {
|
||||
|
||||
void furi_delay_tick(uint32_t ticks) {
|
||||
furi_assert(!furi_kernel_is_irq_or_masked());
|
||||
if(ticks == 0U) {
|
||||
if (ticks == 0U) {
|
||||
taskYIELD();
|
||||
} else {
|
||||
vTaskDelay(ticks);
|
||||
@@ -148,8 +148,8 @@ FuriStatus furi_delay_until_tick(uint32_t tick) {
|
||||
delay = (TickType_t)tick - tcnt;
|
||||
|
||||
/* Check if target tick has not expired */
|
||||
if((delay != 0U) && (0 == (delay >> (8 * sizeof(TickType_t) - 1)))) {
|
||||
if(xTaskDelayUntil(&tcnt, delay) == pdFALSE) {
|
||||
if ((delay != 0U) && (0 == (delay >> (8 * sizeof(TickType_t) - 1)))) {
|
||||
if (xTaskDelayUntil(&tcnt, delay) == pdFALSE) {
|
||||
/* Did not delay */
|
||||
stat = FuriStatusError;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ FuriStatus furi_delay_until_tick(uint32_t tick) {
|
||||
uint32_t furi_get_tick() {
|
||||
TickType_t ticks;
|
||||
|
||||
if(furi_kernel_is_irq_or_masked() != 0U) {
|
||||
if (furi_kernel_is_irq_or_masked() != 0U) {
|
||||
ticks = xTaskGetTickCountFromISR();
|
||||
} else {
|
||||
ticks = xTaskGetTickCount();
|
||||
@@ -183,8 +183,8 @@ uint32_t furi_ms_to_ticks(uint32_t milliseconds) {
|
||||
}
|
||||
|
||||
void furi_delay_ms(uint32_t milliseconds) {
|
||||
if(!FURI_IS_ISR() && xTaskGetSchedulerState() == taskSCHEDULER_RUNNING) {
|
||||
if(milliseconds > 0 && milliseconds < portMAX_DELAY - 1) {
|
||||
if (!FURI_IS_ISR() && xTaskGetSchedulerState() == taskSCHEDULER_RUNNING) {
|
||||
if (milliseconds > 0 && milliseconds < portMAX_DELAY - 1) {
|
||||
milliseconds += 1;
|
||||
}
|
||||
#if configTICK_RATE_HZ_RAW == 1000
|
||||
@@ -192,7 +192,7 @@ void furi_delay_ms(uint32_t milliseconds) {
|
||||
#else
|
||||
furi_delay_tick(furi_ms_to_ticks(milliseconds));
|
||||
#endif
|
||||
} else if(milliseconds > 0) {
|
||||
} else if (milliseconds > 0) {
|
||||
furi_delay_us(milliseconds * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "kernel.h"
|
||||
#include "message_queue.h"
|
||||
#include "check.h"
|
||||
#include "kernel.h"
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/queue.h>
|
||||
@@ -22,31 +22,31 @@ void furi_message_queue_free(FuriMessageQueue* instance) {
|
||||
}
|
||||
|
||||
FuriStatus
|
||||
furi_message_queue_put(FuriMessageQueue* instance, const void* msg_ptr, uint32_t timeout) {
|
||||
furi_message_queue_put(FuriMessageQueue* instance, const void* msg_ptr, uint32_t timeout) {
|
||||
QueueHandle_t hQueue = (QueueHandle_t)instance;
|
||||
FuriStatus stat;
|
||||
BaseType_t yield;
|
||||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(furi_kernel_is_irq_or_masked() != 0U) {
|
||||
if((hQueue == NULL) || (msg_ptr == NULL) || (timeout != 0U)) {
|
||||
if (furi_kernel_is_irq_or_masked() != 0U) {
|
||||
if ((hQueue == NULL) || (msg_ptr == NULL) || (timeout != 0U)) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
yield = pdFALSE;
|
||||
|
||||
if(xQueueSendToBackFromISR(hQueue, msg_ptr, &yield) != pdTRUE) {
|
||||
if (xQueueSendToBackFromISR(hQueue, msg_ptr, &yield) != pdTRUE) {
|
||||
stat = FuriStatusErrorResource;
|
||||
} else {
|
||||
portYIELD_FROM_ISR(yield);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if((hQueue == NULL) || (msg_ptr == NULL)) {
|
||||
if ((hQueue == NULL) || (msg_ptr == NULL)) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
if(xQueueSendToBack(hQueue, msg_ptr, (TickType_t)timeout) != pdPASS) {
|
||||
if(timeout != 0U) {
|
||||
if (xQueueSendToBack(hQueue, msg_ptr, (TickType_t)timeout) != pdPASS) {
|
||||
if (timeout != 0U) {
|
||||
stat = FuriStatusErrorTimeout;
|
||||
} else {
|
||||
stat = FuriStatusErrorResource;
|
||||
@@ -66,24 +66,24 @@ FuriStatus furi_message_queue_get(FuriMessageQueue* instance, void* msg_ptr, uin
|
||||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(furi_kernel_is_irq_or_masked() != 0U) {
|
||||
if((hQueue == NULL) || (msg_ptr == NULL) || (timeout != 0U)) {
|
||||
if (furi_kernel_is_irq_or_masked() != 0U) {
|
||||
if ((hQueue == NULL) || (msg_ptr == NULL) || (timeout != 0U)) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
yield = pdFALSE;
|
||||
|
||||
if(xQueueReceiveFromISR(hQueue, msg_ptr, &yield) != pdPASS) {
|
||||
if (xQueueReceiveFromISR(hQueue, msg_ptr, &yield) != pdPASS) {
|
||||
stat = FuriStatusErrorResource;
|
||||
} else {
|
||||
portYIELD_FROM_ISR(yield);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if((hQueue == NULL) || (msg_ptr == NULL)) {
|
||||
if ((hQueue == NULL) || (msg_ptr == NULL)) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
if(xQueueReceive(hQueue, msg_ptr, (TickType_t)timeout) != pdPASS) {
|
||||
if(timeout != 0U) {
|
||||
if (xQueueReceive(hQueue, msg_ptr, (TickType_t)timeout) != pdPASS) {
|
||||
if (timeout != 0U) {
|
||||
stat = FuriStatusErrorTimeout;
|
||||
} else {
|
||||
stat = FuriStatusErrorResource;
|
||||
@@ -100,7 +100,7 @@ uint32_t furi_message_queue_get_capacity(FuriMessageQueue* instance) {
|
||||
StaticQueue_t* mq = (StaticQueue_t*)instance;
|
||||
uint32_t capacity;
|
||||
|
||||
if(mq == NULL) {
|
||||
if (mq == NULL) {
|
||||
capacity = 0U;
|
||||
} else {
|
||||
/* capacity = pxQueue->uxLength */
|
||||
@@ -115,7 +115,7 @@ uint32_t furi_message_queue_get_message_size(FuriMessageQueue* instance) {
|
||||
StaticQueue_t* mq = (StaticQueue_t*)instance;
|
||||
uint32_t size;
|
||||
|
||||
if(mq == NULL) {
|
||||
if (mq == NULL) {
|
||||
size = 0U;
|
||||
} else {
|
||||
/* size = pxQueue->uxItemSize */
|
||||
@@ -130,9 +130,9 @@ uint32_t furi_message_queue_get_count(FuriMessageQueue* instance) {
|
||||
QueueHandle_t hQueue = (QueueHandle_t)instance;
|
||||
UBaseType_t count;
|
||||
|
||||
if(hQueue == NULL) {
|
||||
if (hQueue == NULL) {
|
||||
count = 0U;
|
||||
} else if(furi_kernel_is_irq_or_masked() != 0U) {
|
||||
} else if (furi_kernel_is_irq_or_masked() != 0U) {
|
||||
count = uxQueueMessagesWaitingFromISR(hQueue);
|
||||
} else {
|
||||
count = uxQueueMessagesWaiting(hQueue);
|
||||
@@ -147,9 +147,9 @@ uint32_t furi_message_queue_get_space(FuriMessageQueue* instance) {
|
||||
uint32_t space;
|
||||
uint32_t isrm;
|
||||
|
||||
if(mq == NULL) {
|
||||
if (mq == NULL) {
|
||||
space = 0U;
|
||||
} else if(furi_kernel_is_irq_or_masked() != 0U) {
|
||||
} else if (furi_kernel_is_irq_or_masked() != 0U) {
|
||||
isrm = taskENTER_CRITICAL_FROM_ISR();
|
||||
|
||||
/* space = pxQueue->uxLength - pxQueue->uxMessagesWaiting; */
|
||||
@@ -168,9 +168,9 @@ FuriStatus furi_message_queue_reset(FuriMessageQueue* instance) {
|
||||
QueueHandle_t hQueue = (QueueHandle_t)instance;
|
||||
FuriStatus stat;
|
||||
|
||||
if(furi_kernel_is_irq_or_masked() != 0U) {
|
||||
if (furi_kernel_is_irq_or_masked() != 0U) {
|
||||
stat = FuriStatusErrorISR;
|
||||
} else if(hQueue == NULL) {
|
||||
} else if (hQueue == NULL) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
stat = FuriStatusOk;
|
||||
|
||||
@@ -37,7 +37,7 @@ void furi_message_queue_free(FuriMessageQueue* instance);
|
||||
* @return The furi status.
|
||||
*/
|
||||
FuriStatus
|
||||
furi_message_queue_put(FuriMessageQueue* instance, const void* msg_ptr, uint32_t timeout);
|
||||
furi_message_queue_put(FuriMessageQueue* instance, const void* msg_ptr, uint32_t timeout);
|
||||
|
||||
/** Get message from queue
|
||||
*
|
||||
|
||||
+16
-16
@@ -10,9 +10,9 @@ FuriMutex* furi_mutex_alloc(FuriMutexType type) {
|
||||
|
||||
SemaphoreHandle_t hMutex = NULL;
|
||||
|
||||
if(type == FuriMutexTypeNormal) {
|
||||
if (type == FuriMutexTypeNormal) {
|
||||
hMutex = xSemaphoreCreateMutex();
|
||||
} else if(type == FuriMutexTypeRecursive) {
|
||||
} else if (type == FuriMutexTypeRecursive) {
|
||||
hMutex = xSemaphoreCreateRecursiveMutex();
|
||||
} else {
|
||||
furi_crash("Programming error");
|
||||
@@ -20,7 +20,7 @@ FuriMutex* furi_mutex_alloc(FuriMutexType type) {
|
||||
|
||||
furi_check(hMutex != NULL);
|
||||
|
||||
if(type == FuriMutexTypeRecursive) {
|
||||
if (type == FuriMutexTypeRecursive) {
|
||||
/* Set LSB as 'recursive mutex flag' */
|
||||
hMutex = (SemaphoreHandle_t)((uint32_t)hMutex | 1U);
|
||||
}
|
||||
@@ -48,22 +48,22 @@ FuriStatus furi_mutex_acquire(FuriMutex* instance, uint32_t timeout) {
|
||||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
stat = FuriStatusErrorISR;
|
||||
} else if(hMutex == NULL) {
|
||||
} else if (hMutex == NULL) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
if(rmtx != 0U) {
|
||||
if(xSemaphoreTakeRecursive(hMutex, timeout) != pdPASS) {
|
||||
if(timeout != 0U) {
|
||||
if (rmtx != 0U) {
|
||||
if (xSemaphoreTakeRecursive(hMutex, timeout) != pdPASS) {
|
||||
if (timeout != 0U) {
|
||||
stat = FuriStatusErrorTimeout;
|
||||
} else {
|
||||
stat = FuriStatusErrorResource;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(xSemaphoreTake(hMutex, timeout) != pdPASS) {
|
||||
if(timeout != 0U) {
|
||||
if (xSemaphoreTake(hMutex, timeout) != pdPASS) {
|
||||
if (timeout != 0U) {
|
||||
stat = FuriStatusErrorTimeout;
|
||||
} else {
|
||||
stat = FuriStatusErrorResource;
|
||||
@@ -88,17 +88,17 @@ FuriStatus furi_mutex_release(FuriMutex* instance) {
|
||||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
stat = FuriStatusErrorISR;
|
||||
} else if(hMutex == NULL) {
|
||||
} else if (hMutex == NULL) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
if(rmtx != 0U) {
|
||||
if(xSemaphoreGiveRecursive(hMutex) != pdPASS) {
|
||||
if (rmtx != 0U) {
|
||||
if (xSemaphoreGiveRecursive(hMutex) != pdPASS) {
|
||||
stat = FuriStatusErrorResource;
|
||||
}
|
||||
} else {
|
||||
if(xSemaphoreGive(hMutex) != pdPASS) {
|
||||
if (xSemaphoreGive(hMutex) != pdPASS) {
|
||||
stat = FuriStatusErrorResource;
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ FuriThreadId furi_mutex_get_owner(FuriMutex* instance) {
|
||||
|
||||
hMutex = (SemaphoreHandle_t)((uint32_t)instance & ~1U);
|
||||
|
||||
if((FURI_IS_IRQ_MODE()) || (hMutex == NULL)) {
|
||||
if ((FURI_IS_IRQ_MODE()) || (hMutex == NULL)) {
|
||||
owner = 0;
|
||||
} else {
|
||||
owner = (FuriThreadId)xSemaphoreGetMutexHolder(hMutex);
|
||||
|
||||
@@ -40,7 +40,7 @@ void furi_pubsub_free(FuriPubSub* pubsub) {
|
||||
}
|
||||
|
||||
FuriPubSubSubscription*
|
||||
furi_pubsub_subscribe(FuriPubSub* pubsub, FuriPubSubCallback callback, void* callback_context) {
|
||||
furi_pubsub_subscribe(FuriPubSub* pubsub, FuriPubSubCallback callback, void* callback_context) {
|
||||
furi_check(furi_mutex_acquire(pubsub->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
// put uninitialized item to the list
|
||||
FuriPubSubSubscription* item = FuriPubSubSubscriptionList_push_raw(pubsub->items);
|
||||
@@ -63,12 +63,12 @@ void furi_pubsub_unsubscribe(FuriPubSub* pubsub, FuriPubSubSubscription* pubsub_
|
||||
|
||||
// iterate over items
|
||||
FuriPubSubSubscriptionList_it_t it;
|
||||
for(FuriPubSubSubscriptionList_it(it, pubsub->items); !FuriPubSubSubscriptionList_end_p(it);
|
||||
FuriPubSubSubscriptionList_next(it)) {
|
||||
for (FuriPubSubSubscriptionList_it(it, pubsub->items); !FuriPubSubSubscriptionList_end_p(it);
|
||||
FuriPubSubSubscriptionList_next(it)) {
|
||||
const FuriPubSubSubscription* item = FuriPubSubSubscriptionList_cref(it);
|
||||
|
||||
// if the iterator is equal to our element
|
||||
if(item == pubsub_subscription) {
|
||||
if (item == pubsub_subscription) {
|
||||
FuriPubSubSubscriptionList_remove(pubsub->items, it);
|
||||
result = true;
|
||||
break;
|
||||
@@ -84,8 +84,8 @@ void furi_pubsub_publish(FuriPubSub* pubsub, void* message) {
|
||||
|
||||
// iterate over subscribers
|
||||
FuriPubSubSubscriptionList_it_t it;
|
||||
for(FuriPubSubSubscriptionList_it(it, pubsub->items); !FuriPubSubSubscriptionList_end_p(it);
|
||||
FuriPubSubSubscriptionList_next(it)) {
|
||||
for (FuriPubSubSubscriptionList_it(it, pubsub->items); !FuriPubSubSubscriptionList_end_p(it);
|
||||
FuriPubSubSubscriptionList_next(it)) {
|
||||
const FuriPubSubSubscription* item = FuriPubSubSubscriptionList_cref(it);
|
||||
item->callback(message, item->callback_context);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void furi_pubsub_free(FuriPubSub* pubsub);
|
||||
* @return pointer to FuriPubSubSubscription instance
|
||||
*/
|
||||
FuriPubSubSubscription*
|
||||
furi_pubsub_subscribe(FuriPubSub* pubsub, FuriPubSubCallback callback, void* callback_context);
|
||||
furi_pubsub_subscribe(FuriPubSub* pubsub, FuriPubSubCallback callback, void* callback_context);
|
||||
|
||||
/** Unsubscribe from FuriPubSub
|
||||
*
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "record.h"
|
||||
#include "check.h"
|
||||
#include "mutex.h"
|
||||
#include "event_flag.h"
|
||||
#include "mutex.h"
|
||||
|
||||
#include <m-dict.h>
|
||||
#include "m_cstr_dup.h"
|
||||
#include <m-dict.h>
|
||||
|
||||
#define FURI_RECORD_FLAG_READY (0x1)
|
||||
|
||||
@@ -46,7 +46,7 @@ void furi_record_init() {
|
||||
static FuriRecordData* furi_record_data_get_or_create(const char* name) {
|
||||
furi_assert(furi_record);
|
||||
FuriRecordData* record_data = furi_record_get(name);
|
||||
if(!record_data) {
|
||||
if (!record_data) {
|
||||
FuriRecordData new_record;
|
||||
new_record.flags = furi_event_flag_alloc();
|
||||
new_record.data = NULL;
|
||||
@@ -101,7 +101,7 @@ bool furi_record_destroy(const char* name) {
|
||||
|
||||
FuriRecordData* record_data = furi_record_get(name);
|
||||
furi_assert(record_data);
|
||||
if(record_data->holders_count == 0) {
|
||||
if (record_data->holders_count == 0) {
|
||||
furi_record_erase(name, record_data);
|
||||
ret = true;
|
||||
}
|
||||
@@ -127,7 +127,9 @@ void* furi_record_open(const char* name) {
|
||||
record_data->flags,
|
||||
FURI_RECORD_FLAG_READY,
|
||||
FuriFlagWaitAny | FuriFlagNoClear,
|
||||
FuriWaitForever) == FURI_RECORD_FLAG_READY);
|
||||
FuriWaitForever
|
||||
) == FURI_RECORD_FLAG_READY
|
||||
);
|
||||
|
||||
return record_data->data;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "core_defines.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -18,11 +18,11 @@ extern "C" {
|
||||
* @param variable_name the name of the variable that is used in the `code`
|
||||
* @param code the code to execute: consider putting it between {}
|
||||
*/
|
||||
#define FURI_RECORD_TRANSACTION(record_name, variable_name, code) \
|
||||
{ \
|
||||
NbGui* (variable_name) = (NbGui*)furi_record_open(record_name); \
|
||||
code \
|
||||
furi_record_close(record_name); \
|
||||
#define FURI_RECORD_TRANSACTION(record_name, variable_name, code) \
|
||||
{ \
|
||||
NbGui*(variable_name) = (NbGui*)furi_record_open(record_name); \
|
||||
code; \
|
||||
furi_record_close(record_name); \
|
||||
}
|
||||
|
||||
/** Initialize record storage For internal use only.
|
||||
|
||||
@@ -10,10 +10,10 @@ FuriSemaphore* furi_semaphore_alloc(uint32_t max_count, uint32_t initial_count)
|
||||
furi_assert((max_count > 0U) && (initial_count <= max_count));
|
||||
|
||||
SemaphoreHandle_t hSemaphore = NULL;
|
||||
if(max_count == 1U) {
|
||||
if (max_count == 1U) {
|
||||
hSemaphore = xSemaphoreCreateBinary();
|
||||
if((hSemaphore != NULL) && (initial_count != 0U)) {
|
||||
if(xSemaphoreGive(hSemaphore) != pdPASS) {
|
||||
if ((hSemaphore != NULL) && (initial_count != 0U)) {
|
||||
if (xSemaphoreGive(hSemaphore) != pdPASS) {
|
||||
vSemaphoreDelete(hSemaphore);
|
||||
hSemaphore = NULL;
|
||||
}
|
||||
@@ -46,21 +46,21 @@ FuriStatus furi_semaphore_acquire(FuriSemaphore* instance, uint32_t timeout) {
|
||||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if(timeout != 0U) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
if (timeout != 0U) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
yield = pdFALSE;
|
||||
|
||||
if(xSemaphoreTakeFromISR(hSemaphore, &yield) != pdPASS) {
|
||||
if (xSemaphoreTakeFromISR(hSemaphore, &yield) != pdPASS) {
|
||||
stat = FuriStatusErrorResource;
|
||||
} else {
|
||||
portYIELD_FROM_ISR(yield);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(xSemaphoreTake(hSemaphore, (TickType_t)timeout) != pdPASS) {
|
||||
if(timeout != 0U) {
|
||||
if (xSemaphoreTake(hSemaphore, (TickType_t)timeout) != pdPASS) {
|
||||
if (timeout != 0U) {
|
||||
stat = FuriStatusErrorTimeout;
|
||||
} else {
|
||||
stat = FuriStatusErrorResource;
|
||||
@@ -81,16 +81,16 @@ FuriStatus furi_semaphore_release(FuriSemaphore* instance) {
|
||||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
yield = pdFALSE;
|
||||
|
||||
if(xSemaphoreGiveFromISR(hSemaphore, &yield) != pdTRUE) {
|
||||
if (xSemaphoreGiveFromISR(hSemaphore, &yield) != pdTRUE) {
|
||||
stat = FuriStatusErrorResource;
|
||||
} else {
|
||||
portYIELD_FROM_ISR(yield);
|
||||
}
|
||||
} else {
|
||||
if(xSemaphoreGive(hSemaphore) != pdPASS) {
|
||||
if (xSemaphoreGive(hSemaphore) != pdPASS) {
|
||||
stat = FuriStatusErrorResource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "stream_buffer.h"
|
||||
#include "base.h"
|
||||
#include "check.h"
|
||||
#include "stream_buffer.h"
|
||||
#include "common_defines.h"
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
@@ -29,10 +29,11 @@ size_t furi_stream_buffer_send(
|
||||
FuriStreamBuffer* stream_buffer,
|
||||
const void* data,
|
||||
size_t length,
|
||||
uint32_t timeout) {
|
||||
uint32_t timeout
|
||||
) {
|
||||
size_t ret;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
BaseType_t yield;
|
||||
ret = xStreamBufferSendFromISR(stream_buffer, data, length, &yield);
|
||||
portYIELD_FROM_ISR(yield);
|
||||
@@ -47,10 +48,11 @@ size_t furi_stream_buffer_receive(
|
||||
FuriStreamBuffer* stream_buffer,
|
||||
void* data,
|
||||
size_t length,
|
||||
uint32_t timeout) {
|
||||
uint32_t timeout
|
||||
) {
|
||||
size_t ret;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
BaseType_t yield;
|
||||
ret = xStreamBufferReceiveFromISR(stream_buffer, data, length, &yield);
|
||||
portYIELD_FROM_ISR(yield);
|
||||
@@ -78,7 +80,7 @@ bool furi_stream_buffer_is_empty(FuriStreamBuffer* stream_buffer) {
|
||||
};
|
||||
|
||||
FuriStatus furi_stream_buffer_reset(FuriStreamBuffer* stream_buffer) {
|
||||
if(xStreamBufferReset(stream_buffer) == pdPASS) {
|
||||
if (xStreamBufferReset(stream_buffer) == pdPASS) {
|
||||
return FuriStatusOk;
|
||||
} else {
|
||||
return FuriStatusError;
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
* interrupt that will read from the buffer (the reader).
|
||||
*/
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "base.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -72,7 +74,8 @@ size_t furi_stream_buffer_send(
|
||||
FuriStreamBuffer* stream_buffer,
|
||||
const void* data,
|
||||
size_t length,
|
||||
uint32_t timeout);
|
||||
uint32_t timeout
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Receives bytes from a stream buffer.
|
||||
@@ -93,7 +96,8 @@ size_t furi_stream_buffer_receive(
|
||||
FuriStreamBuffer* stream_buffer,
|
||||
void* data,
|
||||
size_t length,
|
||||
uint32_t timeout);
|
||||
uint32_t timeout
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Queries a stream buffer to see how much data it contains, which is equal to
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "thread.h"
|
||||
#include "kernel.h"
|
||||
#include "check.h"
|
||||
#include "common_defines.h"
|
||||
#include "furi_string.h"
|
||||
#include "kernel.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
#define THREAD_NOTIFY_INDEX 1 // Index 0 is used for stream buffers
|
||||
|
||||
// Limits
|
||||
#define MAX_BITS_TASK_NOTIFY 31U
|
||||
#define MAX_BITS_EVENT_GROUPS 24U
|
||||
|
||||
#define THREAD_FLAGS_INVALID_BITS (~((1UL << MAX_BITS_TASK_NOTIFY) - 1U))
|
||||
#define EVENT_FLAGS_INVALID_BITS (~((1UL << MAX_BITS_EVENT_GROUPS) - 1U))
|
||||
|
||||
typedef struct FuriThreadStdout FuriThreadStdout;
|
||||
|
||||
struct FuriThreadStdout {
|
||||
@@ -57,7 +64,7 @@ static int32_t __furi_thread_stdout_flush(FuriThread* thread);
|
||||
__attribute__((__noreturn__)) void furi_thread_catch() { //-V1082
|
||||
// If you're here it means you're probably doing something wrong
|
||||
// with critical sections or with scheduler state
|
||||
asm volatile("nop"); // extra magic
|
||||
asm volatile("nop"); // extra magic
|
||||
furi_crash("You are doing it wrong"); //-V779
|
||||
__builtin_unreachable();
|
||||
}
|
||||
@@ -65,7 +72,7 @@ __attribute__((__noreturn__)) void furi_thread_catch() { //-V1082
|
||||
static void furi_thread_set_state(FuriThread* thread, FuriThreadState state) {
|
||||
furi_assert(thread);
|
||||
thread->state = state;
|
||||
if(thread->state_callback) {
|
||||
if (thread->state_callback) {
|
||||
thread->state_callback(state, thread->state_context);
|
||||
}
|
||||
}
|
||||
@@ -81,32 +88,37 @@ static void furi_thread_body(void* context) {
|
||||
furi_assert(thread->state == FuriThreadStateStarting);
|
||||
furi_thread_set_state(thread, FuriThreadStateRunning);
|
||||
|
||||
// TaskHandle_t task_handle = xTaskGetCurrentTaskHandle();
|
||||
// if(thread->heap_trace_enabled == true) {
|
||||
// memmgr_heap_enable_thread_trace((FuriThreadId)task_handle);
|
||||
// }
|
||||
/*
|
||||
TaskHandle_t task_handle = xTaskGetCurrentTaskHandle();
|
||||
if(thread->heap_trace_enabled == true) {
|
||||
memmgr_heap_enable_thread_trace((FuriThreadId)task_handle);
|
||||
}
|
||||
*/
|
||||
|
||||
thread->ret = thread->callback(thread->context);
|
||||
|
||||
// if(thread->heap_trace_enabled == true) {
|
||||
// furi_delay_ms(33);
|
||||
// thread->heap_size = memmgr_heap_get_thread_memory((FuriThreadId)task_handle);
|
||||
// furi_log_print_format(
|
||||
// thread->heap_size ? FuriLogLevelError : FuriLogLevelInfo,
|
||||
// TAG,
|
||||
// "%s allocation balance: %zu",
|
||||
// thread->name ? thread->name : "Thread",
|
||||
// thread->heap_size);
|
||||
// memmgr_heap_disable_thread_trace((FuriThreadId)task_handle);
|
||||
// }
|
||||
/*
|
||||
if(thread->heap_trace_enabled == true) {
|
||||
furi_delay_ms(33);
|
||||
thread->heap_size = memmgr_heap_get_thread_memory((FuriThreadId)task_handle);
|
||||
furi_log_print_format(
|
||||
thread->heap_size ? FuriLogLevelError : FuriLogLevelInfo,
|
||||
TAG,
|
||||
"%s allocation balance: %zu",
|
||||
thread->name ? thread->name : "Thread",
|
||||
thread->heap_size);
|
||||
memmgr_heap_disable_thread_trace((FuriThreadId)task_handle);
|
||||
}
|
||||
*/
|
||||
|
||||
furi_assert(thread->state == FuriThreadStateRunning);
|
||||
|
||||
if(thread->is_service) {
|
||||
if (thread->is_service) {
|
||||
ESP_LOGI(
|
||||
TAG,
|
||||
"%s service thread TCB memory will not be reclaimed",
|
||||
thread->name ? thread->name : "<unnamed service>");
|
||||
thread->name ? thread->name : "<unnamed service>"
|
||||
);
|
||||
}
|
||||
|
||||
// flush stdout
|
||||
@@ -126,11 +138,11 @@ FuriThread* furi_thread_alloc() {
|
||||
thread->is_service = false;
|
||||
|
||||
FuriThread* parent = NULL;
|
||||
if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
|
||||
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
|
||||
// TLS is not available, if we called not from thread context
|
||||
parent = pvTaskGetThreadLocalStoragePointer(NULL, 0);
|
||||
|
||||
if(parent && parent->appid) {
|
||||
if (parent && parent->appid) {
|
||||
furi_thread_set_appid(thread, parent->appid);
|
||||
} else {
|
||||
furi_thread_set_appid(thread, "unknown");
|
||||
@@ -145,7 +157,8 @@ FuriThread* furi_thread_alloc() {
|
||||
thread->heap_trace_enabled = true;
|
||||
} else if(mode == FuriHalRtcHeapTrackModeTree && furi_thread_get_current_id()) {
|
||||
if(parent) thread->heap_trace_enabled = parent->heap_trace_enabled;
|
||||
} else */{
|
||||
} else */
|
||||
{
|
||||
thread->heap_trace_enabled = false;
|
||||
}
|
||||
|
||||
@@ -156,7 +169,8 @@ FuriThread* furi_thread_alloc_ex(
|
||||
const char* name,
|
||||
uint32_t stack_size,
|
||||
FuriThreadCallback callback,
|
||||
void* context) {
|
||||
void* context
|
||||
) {
|
||||
FuriThread* thread = furi_thread_alloc();
|
||||
furi_thread_set_name(thread, name);
|
||||
furi_thread_set_stack_size(thread, stack_size);
|
||||
@@ -172,8 +186,8 @@ void furi_thread_free(FuriThread* thread) {
|
||||
furi_assert(thread->state == FuriThreadStateStopped);
|
||||
furi_assert(thread->task_handle == NULL);
|
||||
|
||||
if(thread->name) free(thread->name);
|
||||
if(thread->appid) free(thread->appid);
|
||||
if (thread->name) free(thread->name);
|
||||
if (thread->appid) free(thread->appid);
|
||||
furi_string_free(thread->output.buffer);
|
||||
|
||||
free(thread);
|
||||
@@ -182,14 +196,14 @@ void furi_thread_free(FuriThread* thread) {
|
||||
void furi_thread_set_name(FuriThread* thread, const char* name) {
|
||||
furi_assert(thread);
|
||||
furi_assert(thread->state == FuriThreadStateStopped);
|
||||
if(thread->name) free(thread->name);
|
||||
if (thread->name) free(thread->name);
|
||||
thread->name = name ? strdup(name) : NULL;
|
||||
}
|
||||
|
||||
void furi_thread_set_appid(FuriThread* thread, const char* appid) {
|
||||
furi_assert(thread);
|
||||
furi_assert(thread->state == FuriThreadStateStopped);
|
||||
if(thread->appid) free(thread->appid);
|
||||
if (thread->appid) free(thread->appid);
|
||||
thread->appid = appid ? strdup(appid) : NULL;
|
||||
}
|
||||
|
||||
@@ -267,7 +281,7 @@ void furi_thread_start(FuriThread* thread) {
|
||||
|
||||
uint32_t stack = thread->stack_size / sizeof(StackType_t);
|
||||
UBaseType_t priority = thread->priority ? thread->priority : FuriThreadPriorityNormal;
|
||||
if(thread->is_service) {
|
||||
if (thread->is_service) {
|
||||
thread->task_handle = xTaskCreateStatic(
|
||||
furi_thread_body,
|
||||
thread->name,
|
||||
@@ -275,10 +289,12 @@ void furi_thread_start(FuriThread* thread) {
|
||||
thread,
|
||||
priority,
|
||||
malloc(sizeof(StackType_t) * stack),
|
||||
malloc(sizeof(StaticTask_t)));
|
||||
malloc(sizeof(StaticTask_t))
|
||||
);
|
||||
} else {
|
||||
BaseType_t ret = xTaskCreate(
|
||||
furi_thread_body, thread->name, stack, thread, priority, &thread->task_handle);
|
||||
furi_thread_body, thread->name, stack, thread, priority, &thread->task_handle
|
||||
);
|
||||
furi_check(ret == pdPASS);
|
||||
}
|
||||
|
||||
@@ -287,7 +303,7 @@ void furi_thread_start(FuriThread* thread) {
|
||||
|
||||
void furi_thread_cleanup_tcb_event(TaskHandle_t task) {
|
||||
FuriThread* thread = pvTaskGetThreadLocalStoragePointer(task, 0);
|
||||
if(thread) {
|
||||
if (thread) {
|
||||
// clear thread local storage
|
||||
vTaskSetThreadLocalStoragePointer(task, 0, NULL);
|
||||
furi_assert(thread->task_handle == task);
|
||||
@@ -304,7 +320,7 @@ bool furi_thread_join(FuriThread* thread) {
|
||||
//
|
||||
// If your thread exited, but your app stuck here: some other thread uses
|
||||
// all cpu time, which delays kernel from releasing task handle
|
||||
while(thread->task_handle) {
|
||||
while (thread->task_handle) {
|
||||
furi_delay_ms(10);
|
||||
}
|
||||
|
||||
@@ -354,29 +370,23 @@ void furi_thread_yield() {
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
/* Limits */
|
||||
#define MAX_BITS_TASK_NOTIFY 31U
|
||||
#define MAX_BITS_EVENT_GROUPS 24U
|
||||
|
||||
#define THREAD_FLAGS_INVALID_BITS (~((1UL << MAX_BITS_TASK_NOTIFY) - 1U))
|
||||
#define EVENT_FLAGS_INVALID_BITS (~((1UL << MAX_BITS_EVENT_GROUPS) - 1U))
|
||||
|
||||
uint32_t furi_thread_flags_set(FuriThreadId thread_id, uint32_t flags) {
|
||||
TaskHandle_t hTask = (TaskHandle_t)thread_id;
|
||||
uint32_t rflags;
|
||||
BaseType_t yield;
|
||||
|
||||
if((hTask == NULL) || ((flags & THREAD_FLAGS_INVALID_BITS) != 0U)) {
|
||||
if ((hTask == NULL) || ((flags & THREAD_FLAGS_INVALID_BITS) != 0U)) {
|
||||
rflags = (uint32_t)FuriStatusErrorParameter;
|
||||
} else {
|
||||
rflags = (uint32_t)FuriStatusError;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
yield = pdFALSE;
|
||||
|
||||
(void)xTaskNotifyIndexedFromISR(hTask, THREAD_NOTIFY_INDEX, flags, eSetBits, &yield);
|
||||
(void)xTaskNotifyAndQueryIndexedFromISR(
|
||||
hTask, THREAD_NOTIFY_INDEX, 0, eNoAction, &rflags, NULL);
|
||||
hTask, THREAD_NOTIFY_INDEX, 0, eNoAction, &rflags, NULL
|
||||
);
|
||||
|
||||
portYIELD_FROM_ISR(yield);
|
||||
} else {
|
||||
@@ -392,20 +402,20 @@ uint32_t furi_thread_flags_clear(uint32_t flags) {
|
||||
TaskHandle_t hTask;
|
||||
uint32_t rflags, cflags;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
rflags = (uint32_t)FuriStatusErrorISR;
|
||||
} else if((flags & THREAD_FLAGS_INVALID_BITS) != 0U) {
|
||||
} else if ((flags & THREAD_FLAGS_INVALID_BITS) != 0U) {
|
||||
rflags = (uint32_t)FuriStatusErrorParameter;
|
||||
} else {
|
||||
hTask = xTaskGetCurrentTaskHandle();
|
||||
|
||||
if(xTaskNotifyAndQueryIndexed(hTask, THREAD_NOTIFY_INDEX, 0, eNoAction, &cflags) ==
|
||||
pdPASS) {
|
||||
if (xTaskNotifyAndQueryIndexed(hTask, THREAD_NOTIFY_INDEX, 0, eNoAction, &cflags) ==
|
||||
pdPASS) {
|
||||
rflags = cflags;
|
||||
cflags &= ~flags;
|
||||
|
||||
if(xTaskNotifyIndexed(hTask, THREAD_NOTIFY_INDEX, cflags, eSetValueWithOverwrite) !=
|
||||
pdPASS) {
|
||||
if (xTaskNotifyIndexed(hTask, THREAD_NOTIFY_INDEX, cflags, eSetValueWithOverwrite) !=
|
||||
pdPASS) {
|
||||
rflags = (uint32_t)FuriStatusError;
|
||||
}
|
||||
} else {
|
||||
@@ -421,13 +431,13 @@ uint32_t furi_thread_flags_get(void) {
|
||||
TaskHandle_t hTask;
|
||||
uint32_t rflags;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
rflags = (uint32_t)FuriStatusErrorISR;
|
||||
} else {
|
||||
hTask = xTaskGetCurrentTaskHandle();
|
||||
|
||||
if(xTaskNotifyAndQueryIndexed(hTask, THREAD_NOTIFY_INDEX, 0, eNoAction, &rflags) !=
|
||||
pdPASS) {
|
||||
if (xTaskNotifyAndQueryIndexed(hTask, THREAD_NOTIFY_INDEX, 0, eNoAction, &rflags) !=
|
||||
pdPASS) {
|
||||
rflags = (uint32_t)FuriStatusError;
|
||||
}
|
||||
}
|
||||
@@ -441,12 +451,12 @@ uint32_t furi_thread_flags_wait(uint32_t flags, uint32_t options, uint32_t timeo
|
||||
TickType_t t0, td, tout;
|
||||
BaseType_t rval;
|
||||
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
rflags = (uint32_t)FuriStatusErrorISR;
|
||||
} else if((flags & THREAD_FLAGS_INVALID_BITS) != 0U) {
|
||||
} else if ((flags & THREAD_FLAGS_INVALID_BITS) != 0U) {
|
||||
rflags = (uint32_t)FuriStatusErrorParameter;
|
||||
} else {
|
||||
if((options & FuriFlagNoClear) == FuriFlagNoClear) {
|
||||
if ((options & FuriFlagNoClear) == FuriFlagNoClear) {
|
||||
clear = 0U;
|
||||
} else {
|
||||
clear = flags;
|
||||
@@ -459,24 +469,24 @@ uint32_t furi_thread_flags_wait(uint32_t flags, uint32_t options, uint32_t timeo
|
||||
do {
|
||||
rval = xTaskNotifyWaitIndexed(THREAD_NOTIFY_INDEX, 0, clear, &nval, tout);
|
||||
|
||||
if(rval == pdPASS) {
|
||||
if (rval == pdPASS) {
|
||||
rflags &= flags;
|
||||
rflags |= nval;
|
||||
|
||||
if((options & FuriFlagWaitAll) == FuriFlagWaitAll) {
|
||||
if((flags & rflags) == flags) {
|
||||
if ((options & FuriFlagWaitAll) == FuriFlagWaitAll) {
|
||||
if ((flags & rflags) == flags) {
|
||||
break;
|
||||
} else {
|
||||
if(timeout == 0U) {
|
||||
if (timeout == 0U) {
|
||||
rflags = (uint32_t)FuriStatusErrorResource;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if((flags & rflags) != 0) {
|
||||
if ((flags & rflags) != 0) {
|
||||
break;
|
||||
} else {
|
||||
if(timeout == 0U) {
|
||||
if (timeout == 0U) {
|
||||
rflags = (uint32_t)FuriStatusErrorResource;
|
||||
break;
|
||||
}
|
||||
@@ -486,19 +496,19 @@ uint32_t furi_thread_flags_wait(uint32_t flags, uint32_t options, uint32_t timeo
|
||||
/* Update timeout */
|
||||
td = xTaskGetTickCount() - t0;
|
||||
|
||||
if(td > tout) {
|
||||
if (td > tout) {
|
||||
tout = 0;
|
||||
} else {
|
||||
tout -= td;
|
||||
}
|
||||
} else {
|
||||
if(timeout == 0) {
|
||||
if (timeout == 0) {
|
||||
rflags = (uint32_t)FuriStatusErrorResource;
|
||||
} else {
|
||||
rflags = (uint32_t)FuriStatusErrorTimeout;
|
||||
}
|
||||
}
|
||||
} while(rval != pdFAIL);
|
||||
} while (rval != pdFAIL);
|
||||
}
|
||||
|
||||
/* Return flags before clearing */
|
||||
@@ -509,7 +519,7 @@ uint32_t furi_thread_enumerate(FuriThreadId* thread_array, uint32_t array_items)
|
||||
uint32_t i, count;
|
||||
TaskStatus_t* task;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() || (thread_array == NULL) || (array_items == 0U)) {
|
||||
if (FURI_IS_IRQ_MODE() || (thread_array == NULL) || (array_items == 0U)) {
|
||||
count = 0U;
|
||||
} else {
|
||||
vTaskSuspendAll();
|
||||
@@ -517,10 +527,10 @@ uint32_t furi_thread_enumerate(FuriThreadId* thread_array, uint32_t array_items)
|
||||
count = uxTaskGetNumberOfTasks();
|
||||
task = pvPortMalloc(count * sizeof(TaskStatus_t));
|
||||
|
||||
if(task != NULL) {
|
||||
if (task != NULL) {
|
||||
count = uxTaskGetSystemState(task, count, NULL);
|
||||
|
||||
for(i = 0U; (i < count) && (i < array_items); i++) {
|
||||
for (i = 0U; (i < count) && (i < array_items); i++) {
|
||||
thread_array[i] = (FuriThreadId)task[i].xHandle;
|
||||
}
|
||||
count = i;
|
||||
@@ -537,7 +547,7 @@ const char* furi_thread_get_name(FuriThreadId thread_id) {
|
||||
TaskHandle_t hTask = (TaskHandle_t)thread_id;
|
||||
const char* name;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() || (hTask == NULL)) {
|
||||
if (FURI_IS_IRQ_MODE() || (hTask == NULL)) {
|
||||
name = NULL;
|
||||
} else {
|
||||
name = pcTaskGetName(hTask);
|
||||
@@ -550,9 +560,9 @@ const char* furi_thread_get_appid(FuriThreadId thread_id) {
|
||||
TaskHandle_t hTask = (TaskHandle_t)thread_id;
|
||||
const char* appid = "system";
|
||||
|
||||
if(!FURI_IS_IRQ_MODE() && (hTask != NULL)) {
|
||||
if (!FURI_IS_IRQ_MODE() && (hTask != NULL)) {
|
||||
FuriThread* thread = (FuriThread*)pvTaskGetThreadLocalStoragePointer(hTask, 0);
|
||||
if(thread) {
|
||||
if (thread) {
|
||||
appid = thread->appid;
|
||||
}
|
||||
}
|
||||
@@ -564,7 +574,7 @@ uint32_t furi_thread_get_stack_space(FuriThreadId thread_id) {
|
||||
TaskHandle_t hTask = (TaskHandle_t)thread_id;
|
||||
uint32_t sz;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() || (hTask == NULL)) {
|
||||
if (FURI_IS_IRQ_MODE() || (hTask == NULL)) {
|
||||
sz = 0U;
|
||||
} else {
|
||||
sz = (uint32_t)(uxTaskGetStackHighWaterMark(hTask) * sizeof(StackType_t));
|
||||
@@ -574,7 +584,7 @@ uint32_t furi_thread_get_stack_space(FuriThreadId thread_id) {
|
||||
}
|
||||
|
||||
static size_t __furi_thread_stdout_write(FuriThread* thread, const char* data, size_t size) {
|
||||
if(thread->output.write_callback != NULL) {
|
||||
if (thread->output.write_callback != NULL) {
|
||||
thread->output.write_callback(data, size);
|
||||
} else {
|
||||
furi_hal_console_tx((const uint8_t*)data, size);
|
||||
@@ -585,7 +595,7 @@ static size_t __furi_thread_stdout_write(FuriThread* thread, const char* data, s
|
||||
static int32_t __furi_thread_stdout_flush(FuriThread* thread) {
|
||||
FuriString* buffer = thread->output.buffer;
|
||||
size_t size = furi_string_size(buffer);
|
||||
if(size > 0) {
|
||||
if (size > 0) {
|
||||
__furi_thread_stdout_write(thread, furi_string_get_cstr(buffer), size);
|
||||
furi_string_reset(buffer);
|
||||
}
|
||||
@@ -608,18 +618,18 @@ FuriThreadStdoutWriteCallback furi_thread_get_stdout_callback() {
|
||||
size_t furi_thread_stdout_write(const char* data, size_t size) {
|
||||
FuriThread* thread = furi_thread_get_current();
|
||||
furi_assert(thread);
|
||||
if(size == 0 || data == NULL) {
|
||||
if (size == 0 || data == NULL) {
|
||||
return __furi_thread_stdout_flush(thread);
|
||||
} else {
|
||||
if(data[size - 1] == '\n') {
|
||||
if (data[size - 1] == '\n') {
|
||||
// if the last character is a newline, we can flush buffer and write data as is, wo buffers
|
||||
__furi_thread_stdout_flush(thread);
|
||||
__furi_thread_stdout_write(thread, data, size);
|
||||
} else {
|
||||
// string_cat doesn't work here because we need to write the exact size data
|
||||
for(size_t i = 0; i < size; i++) {
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
furi_string_push_back(thread->output.buffer, data[i]);
|
||||
if(data[i] == '\n') {
|
||||
if (data[i] == '\n') {
|
||||
__furi_thread_stdout_flush(thread);
|
||||
}
|
||||
}
|
||||
@@ -642,7 +652,7 @@ void furi_thread_suspend(FuriThreadId thread_id) {
|
||||
|
||||
void furi_thread_resume(FuriThreadId thread_id) {
|
||||
TaskHandle_t hTask = (TaskHandle_t)thread_id;
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if (FURI_IS_IRQ_MODE()) {
|
||||
xTaskResumeFromISR(hTask);
|
||||
} else {
|
||||
vTaskResume(hTask);
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include "base.h"
|
||||
#include "common_defines.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -24,12 +24,12 @@ typedef enum {
|
||||
|
||||
/** FuriThreadPriority */
|
||||
typedef enum {
|
||||
FuriThreadPriorityNone = 0, /**< Uninitialized, choose system default */
|
||||
FuriThreadPriorityIdle = 1, /**< Idle priority */
|
||||
FuriThreadPriorityLowest = 14, /**< Lowest */
|
||||
FuriThreadPriorityLow = 15, /**< Low */
|
||||
FuriThreadPriorityNormal = 16, /**< Normal */
|
||||
FuriThreadPriorityHigh = 17, /**< High */
|
||||
FuriThreadPriorityNone = 0, /**< Uninitialized, choose system default */
|
||||
FuriThreadPriorityIdle = 1, /**< Idle priority */
|
||||
FuriThreadPriorityLowest = 14, /**< Lowest */
|
||||
FuriThreadPriorityLow = 15, /**< Low */
|
||||
FuriThreadPriorityNormal = 16, /**< Normal */
|
||||
FuriThreadPriorityHigh = 17, /**< High */
|
||||
FuriThreadPriorityHighest = 18, /**< Highest */
|
||||
FuriThreadPriorityIsr =
|
||||
(FURI_CONFIG_THREAD_MAX_PRIORITIES - 1), /**< Deferred ISR (highest possible) */
|
||||
@@ -76,7 +76,8 @@ FuriThread* furi_thread_alloc_ex(
|
||||
const char* name,
|
||||
uint32_t stack_size,
|
||||
FuriThreadCallback callback,
|
||||
void* context);
|
||||
void* context
|
||||
);
|
||||
|
||||
/** Release FuriThread
|
||||
*
|
||||
|
||||
+10
-10
@@ -19,7 +19,7 @@ static void TimerCallback(TimerHandle_t hTimer) {
|
||||
/* Remove dynamic allocation flag */
|
||||
callb = (TimerCallback_t*)((uint32_t)callb & ~1U);
|
||||
|
||||
if(callb != NULL) {
|
||||
if (callb != NULL) {
|
||||
callb->func(callb->context);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ FuriTimer* furi_timer_alloc(FuriTimerCallback func, FuriTimerType type, void* co
|
||||
callb->func = func;
|
||||
callb->context = context;
|
||||
|
||||
if(type == FuriTimerTypeOnce) {
|
||||
if (type == FuriTimerTypeOnce) {
|
||||
reload = pdFALSE;
|
||||
} else {
|
||||
reload = pdTRUE;
|
||||
@@ -68,9 +68,9 @@ void furi_timer_free(FuriTimer* instance) {
|
||||
|
||||
furi_check(xTimerDelete(hTimer, portMAX_DELAY) == pdPASS);
|
||||
|
||||
while(furi_timer_is_running(instance)) furi_delay_tick(2);
|
||||
while (furi_timer_is_running(instance)) furi_delay_tick(2);
|
||||
|
||||
if((uint32_t)callb & 1U) {
|
||||
if ((uint32_t)callb & 1U) {
|
||||
/* Callback memory was allocated from dynamic pool, clear flag */
|
||||
callb = (TimerCallback_t*)((uint32_t)callb & ~1U);
|
||||
|
||||
@@ -87,7 +87,7 @@ FuriStatus furi_timer_start(FuriTimer* instance, uint32_t ticks) {
|
||||
TimerHandle_t hTimer = (TimerHandle_t)instance;
|
||||
FuriStatus stat;
|
||||
|
||||
if(xTimerChangePeriod(hTimer, ticks, portMAX_DELAY) == pdPASS) {
|
||||
if (xTimerChangePeriod(hTimer, ticks, portMAX_DELAY) == pdPASS) {
|
||||
stat = FuriStatusOk;
|
||||
} else {
|
||||
stat = FuriStatusErrorResource;
|
||||
@@ -105,8 +105,8 @@ FuriStatus furi_timer_restart(FuriTimer* instance, uint32_t ticks) {
|
||||
TimerHandle_t hTimer = (TimerHandle_t)instance;
|
||||
FuriStatus stat;
|
||||
|
||||
if(xTimerChangePeriod(hTimer, ticks, portMAX_DELAY) == pdPASS &&
|
||||
xTimerReset(hTimer, portMAX_DELAY) == pdPASS) {
|
||||
if (xTimerChangePeriod(hTimer, ticks, portMAX_DELAY) == pdPASS &&
|
||||
xTimerReset(hTimer, portMAX_DELAY) == pdPASS) {
|
||||
stat = FuriStatusOk;
|
||||
} else {
|
||||
stat = FuriStatusErrorResource;
|
||||
@@ -148,7 +148,7 @@ uint32_t furi_timer_get_expire_time(FuriTimer* instance) {
|
||||
|
||||
void furi_timer_pending_callback(FuriTimerPendigCallback callback, void* context, uint32_t arg) {
|
||||
BaseType_t ret = pdFAIL;
|
||||
if(furi_kernel_is_irq_or_masked()) {
|
||||
if (furi_kernel_is_irq_or_masked()) {
|
||||
ret = xTimerPendFunctionCallFromISR(callback, context, arg, NULL);
|
||||
} else {
|
||||
ret = xTimerPendFunctionCall(callback, context, arg, FuriWaitForever);
|
||||
@@ -162,9 +162,9 @@ void furi_timer_set_thread_priority(FuriTimerThreadPriority priority) {
|
||||
TaskHandle_t task_handle = xTimerGetTimerDaemonTaskHandle();
|
||||
furi_check(task_handle); // Don't call this method before timer task start
|
||||
|
||||
if(priority == FuriTimerThreadPriorityNormal) {
|
||||
if (priority == FuriTimerThreadPriorityNormal) {
|
||||
vTaskPrioritySet(task_handle, configTIMER_TASK_PRIORITY);
|
||||
} else if(priority == FuriTimerThreadPriorityElevated) {
|
||||
} else if (priority == FuriTimerThreadPriorityElevated) {
|
||||
vTaskPrioritySet(task_handle, configMAX_PRIORITIES - 1);
|
||||
} else {
|
||||
furi_crash();
|
||||
|
||||
@@ -9,7 +9,7 @@ extern "C" {
|
||||
typedef void (*FuriTimerCallback)(void* context);
|
||||
|
||||
typedef enum {
|
||||
FuriTimerTypeOnce = 0, ///< One-shot timer.
|
||||
FuriTimerTypeOnce = 0, ///< One-shot timer.
|
||||
FuriTimerTypePeriodic = 1 ///< Repeating timer.
|
||||
} FuriTimerType;
|
||||
|
||||
@@ -91,7 +91,7 @@ typedef void (*FuriTimerPendigCallback)(void* context, uint32_t arg);
|
||||
void furi_timer_pending_callback(FuriTimerPendigCallback callback, void* context, uint32_t arg);
|
||||
|
||||
typedef enum {
|
||||
FuriTimerThreadPriorityNormal, /**< Lower then other threads */
|
||||
FuriTimerThreadPriorityNormal, /**< Lower then other threads */
|
||||
FuriTimerThreadPriorityElevated, /**< Same as other threads */
|
||||
} FuriTimerThreadPriority;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user