diff options
author | あく <alleteam@gmail.com> | 2022-07-20 13:56:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-20 13:56:33 +0300 |
commit | e3c7201a2065677ad3c96f0bb1f47f7b58cdb819 (patch) | |
tree | b08f7e8d2e339da831164be7b115fb81790facb5 /lib | |
parent | f9c2287ea7dabb0e8275d9a635c4b941516f59bc (diff) |
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>
Diffstat (limited to 'lib')
45 files changed, 116 insertions, 1862 deletions
diff --git a/lib/FreeRTOS-glue/cmsis_os2.c b/lib/FreeRTOS-glue/cmsis_os2.c deleted file mode 100644 index bee37572..00000000 --- a/lib/FreeRTOS-glue/cmsis_os2.c +++ /dev/null @@ -1,1120 +0,0 @@ -/* -------------------------------------------------------------------------- - * Copyright (c) 2013-2021 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Name: cmsis_os2.c - * Purpose: CMSIS RTOS2 wrapper for FreeRTOS - * - *---------------------------------------------------------------------------*/ - -#include <string.h> - -#include <furi/common_defines.h> - -#include "cmsis_os2.h" // ::CMSIS:RTOS2 -#include "cmsis_compiler.h" // Compiler agnostic definitions - -#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core -#include "timers.h" // ARM.FreeRTOS::RTOS:Timers -#include "queue.h" - -#include "freertos_os2.h" // Configuration check and setup - -#include CMSIS_device_header - -#ifndef CMSIS_TASK_NOTIFY_INDEX -#define CMSIS_TASK_NOTIFY_INDEX 0 -#endif - -/*---------------------------------------------------------------------------*/ -#ifndef __ARM_ARCH_6M__ - #define __ARM_ARCH_6M__ 0 -#endif -#ifndef __ARM_ARCH_7M__ - #define __ARM_ARCH_7M__ 0 -#endif -#ifndef __ARM_ARCH_7EM__ - #define __ARM_ARCH_7EM__ 0 -#endif -#ifndef __ARM_ARCH_8M_MAIN__ - #define __ARM_ARCH_8M_MAIN__ 0 -#endif -#ifndef __ARM_ARCH_7A__ - #define __ARM_ARCH_7A__ 0 -#endif - -#if ((__ARM_ARCH_7M__ == 1U) || \ - (__ARM_ARCH_7EM__ == 1U) || \ - (__ARM_ARCH_8M_MAIN__ == 1U)) -#define IS_IRQ_MASKED() ((__get_PRIMASK() != 0U) || (__get_BASEPRI() != 0U)) -#elif (__ARM_ARCH_6M__ == 1U) -#define IS_IRQ_MASKED() (__get_PRIMASK() != 0U) -#elif (__ARM_ARCH_7A__ == 1U) -/* CPSR mask bits */ -#define CPSR_MASKBIT_I 0x80U - -#define IS_IRQ_MASKED() ((__get_CPSR() & CPSR_MASKBIT_I) != 0U) -#else -#define IS_IRQ_MASKED() (__get_PRIMASK() != 0U) -#endif - -#if (__ARM_ARCH_7A__ == 1U) -/* CPSR mode bitmasks */ -#define CPSR_MODE_USER 0x10U -#define CPSR_MODE_SYSTEM 0x1FU - -#define IS_IRQ_MODE() ((__get_mode() != CPSR_MODE_USER) && (__get_mode() != CPSR_MODE_SYSTEM)) -#else -#define IS_IRQ_MODE() (__get_IPSR() != 0U) -#endif - -/* Limits */ -#define MAX_BITS_TASK_NOTIFY 31U - -#define THREAD_FLAGS_INVALID_BITS (~((1UL << MAX_BITS_TASK_NOTIFY) - 1U)) - -/* Kernel version and identification string definition (major.minor.rev: mmnnnrrrr dec) */ -#define KERNEL_VERSION (((uint32_t)tskKERNEL_VERSION_MAJOR * 10000000UL) | \ - ((uint32_t)tskKERNEL_VERSION_MINOR * 10000UL) | \ - ((uint32_t)tskKERNEL_VERSION_BUILD * 1UL)) - -#define KERNEL_ID ("FreeRTOS " tskKERNEL_VERSION_NUMBER) - -/* Timer callback information structure definition */ -typedef struct { - osTimerFunc_t func; - void *arg; -} TimerCallback_t; - -/* Kernel initialization state */ -static osKernelState_t KernelState = osKernelInactive; - -/* - Heap region definition used by heap_5 variant - - Define configAPPLICATION_ALLOCATED_HEAP as nonzero value in FreeRTOSConfig.h if - heap regions are already defined and vPortDefineHeapRegions is called in application. - - Otherwise vPortDefineHeapRegions will be called by osKernelInitialize using - definition configHEAP_5_REGIONS as parameter. Overriding configHEAP_5_REGIONS - is possible by defining it globally or in FreeRTOSConfig.h. -*/ -#if defined(USE_FreeRTOS_HEAP_5) -#if (configAPPLICATION_ALLOCATED_HEAP == 0) - /* - FreeRTOS heap is not defined by the application. - Single region of size configTOTAL_HEAP_SIZE (defined in FreeRTOSConfig.h) - is provided by default. Define configHEAP_5_REGIONS to provide custom - HeapRegion_t array. - */ - #define HEAP_5_REGION_SETUP 1 - - #ifndef configHEAP_5_REGIONS - #define configHEAP_5_REGIONS xHeapRegions - - static uint8_t ucHeap[configTOTAL_HEAP_SIZE]; - - static HeapRegion_t xHeapRegions[] = { - { ucHeap, configTOTAL_HEAP_SIZE }, - { NULL, 0 } - }; - #else - /* Global definition is provided to override default heap array */ - extern HeapRegion_t configHEAP_5_REGIONS[]; - #endif -#else - /* - The application already defined the array used for the FreeRTOS heap and - called vPortDefineHeapRegions to initialize heap. - */ - #define HEAP_5_REGION_SETUP 0 -#endif /* configAPPLICATION_ALLOCATED_HEAP */ -#endif /* USE_FreeRTOS_HEAP_5 */ - -/* - Setup SVC to reset value. -*/ -__STATIC_INLINE void SVC_Setup (void) { -#if (__ARM_ARCH_7A__ == 0U) - /* Service Call interrupt might be configured before kernel start */ - /* and when its priority is lower or equal to BASEPRI, svc intruction */ - /* causes a Hard Fault. */ - NVIC_SetPriority (SVCall_IRQn, 0U); -#endif -} - -/* - Function macro used to retrieve semaphore count from ISR -*/ -#ifndef uxSemaphoreGetCountFromISR -#define uxSemaphoreGetCountFromISR( xSemaphore ) uxQueueMessagesWaitingFromISR( ( QueueHandle_t ) ( xSemaphore ) ) -#endif - -/* - Determine if CPU executes from interrupt context or if interrupts are masked. -*/ -__STATIC_INLINE uint32_t IRQ_Context (void) { - uint32_t irq; - BaseType_t state; - - irq = 0U; - - if (IS_IRQ_MODE()) { - /* Called from interrupt context */ - irq = 1U; - } - else { - /* Get FreeRTOS scheduler state */ - state = xTaskGetSchedulerState(); - - if (state != taskSCHEDULER_NOT_STARTED) { - /* Scheduler was started */ - if (IS_IRQ_MASKED()) { - /* Interrupts are masked */ - irq = 1U; - } - } - } - - /* Return context, 0: thread context, 1: IRQ context */ - return (irq); -} - - -/* ==== Kernel Management Functions ==== */ - -/* - Initialize the RTOS Kernel. -*/ -osStatus_t osKernelInitialize (void) { - osStatus_t stat; - BaseType_t state; - - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else { - state = xTaskGetSchedulerState(); - - /* Initialize if scheduler not started and not initialized before */ - if ((state == taskSCHEDULER_NOT_STARTED) && (KernelState == osKernelInactive)) { - #if defined(USE_TRACE_EVENT_RECORDER) - /* Initialize the trace macro debugging output channel */ - EvrFreeRTOSSetup(0U); - #endif - #if defined(USE_FreeRTOS_HEAP_5) && (HEAP_5_REGION_SETUP == 1) - /* Initialize the memory regions when using heap_5 variant */ - vPortDefineHeapRegions (configHEAP_5_REGIONS); - #endif - KernelState = osKernelReady; - stat = osOK; - } else { - stat = osError; - } - } - - /* Return execution status */ - return (stat); -} - -/* - Get RTOS Kernel Information. -*/ -osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size) { - - if (version != NULL) { - /* Version encoding is major.minor.rev: mmnnnrrrr dec */ - version->api = KERNEL_VERSION; - version->kernel = KERNEL_VERSION; - } - - if ((id_buf != NULL) && (id_size != 0U)) { - /* Buffer for retrieving identification string is provided */ - if (id_size > sizeof(KERNEL_ID)) { - id_size = sizeof(KERNEL_ID); - } - /* Copy kernel identification string into provided buffer */ - memcpy(id_buf, KERNEL_ID, id_size); - } - - /* Return execution status */ - return (osOK); -} - -/* - Get the current RTOS Kernel state. -*/ -osKernelState_t osKernelGetState (void) { - osKernelState_t state; - - switch (xTaskGetSchedulerState()) { - case taskSCHEDULER_RUNNING: - state = osKernelRunning; - break; - - case taskSCHEDULER_SUSPENDED: - state = osKernelLocked; - break; - - case taskSCHEDULER_NOT_STARTED: - default: - if (KernelState == osKernelReady) { - /* Ready, osKernelInitialize was already called */ - state = osKernelReady; - } else { - /* Not initialized */ - state = osKernelInactive; - } - break; - } - - /* Return current state */ - return (state); -} - -/* - Start the RTOS Kernel scheduler. -*/ -osStatus_t osKernelStart (void) { - osStatus_t stat; - BaseType_t state; - - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else { - state = xTaskGetSchedulerState(); - - /* Start scheduler if initialized and not started before */ - if ((state == taskSCHEDULER_NOT_STARTED) && (KernelState == osKernelReady)) { - /* Ensure SVC priority is at the reset value */ - SVC_Setup(); - /* Change state to ensure correct API flow */ - KernelState = osKernelRunning; - /* Start the kernel scheduler */ - vTaskStartScheduler(); - stat = osOK; - } else { - stat = osError; - } - } - - /* Return execution status */ - return (stat); -} - -/* - Lock the RTOS Kernel scheduler. -*/ -int32_t osKernelLock (void) { - int32_t lock; - - if (IRQ_Context() != 0U) { - lock = (int32_t)osErrorISR; - } - else { - switch (xTaskGetSchedulerState()) { - case taskSCHEDULER_SUSPENDED: - lock = 1; - break; - - case taskSCHEDULER_RUNNING: - vTaskSuspendAll(); - lock = 0; - break; - - case taskSCHEDULER_NOT_STARTED: - default: - lock = (int32_t)osError; - break; - } - } - - /* Return previous lock state */ - return (lock); -} - -/* - Unlock the RTOS Kernel scheduler. -*/ -int32_t osKernelUnlock (void) { - int32_t lock; - - if (IRQ_Context() != 0U) { - lock = (int32_t)osErrorISR; - } - else { - switch (xTaskGetSchedulerState()) { - case taskSCHEDULER_SUSPENDED: - lock = 1; - - if (xTaskResumeAll() != pdTRUE) { - if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) { - lock = (int32_t)osError; - } - } - break; - - case taskSCHEDULER_RUNNING: - lock = 0; - break; - - case taskSCHEDULER_NOT_STARTED: - default: - lock = (int32_t)osError; - break; - } - } - - /* Return previous lock state */ - return (lock); -} - -/* - Restore the RTOS Kernel scheduler lock state. -*/ -int32_t osKernelRestoreLock (int32_t lock) { - - if (IRQ_Context() != 0U) { - lock = (int32_t)osErrorISR; - } - else { - switch (xTaskGetSchedulerState()) { - case taskSCHEDULER_SUSPENDED: - case taskSCHEDULER_RUNNING: - if (lock == 1) { - vTaskSuspendAll(); - } - else { - if (lock != 0) { - lock = (int32_t)osError; - } - else { - if (xTaskResumeAll() != pdTRUE) { - if (xTaskGetSchedulerState() != taskSCHEDULER_RUNNING) { - lock = (int32_t)osError; - } - } - } - } - break; - - case taskSCHEDULER_NOT_STARTED: - default: - lock = (int32_t)osError; - break; - } - } - - /* Return new lock state */ - return (lock); -} - -/* - Get the RTOS kernel tick count. -*/ -uint32_t osKernelGetTickCount (void) { - TickType_t ticks; - - if (IRQ_Context() != 0U) { - ticks = xTaskGetTickCountFromISR(); - } else { - ticks = xTaskGetTickCount(); - } - - /* Return kernel tick count */ - return (ticks); -} - -/* - Get the RTOS kernel tick frequency. -*/ -uint32_t osKernelGetTickFreq (void) { - /* Return frequency in hertz */ - return (configTICK_RATE_HZ); -} - -/* - Get the RTOS kernel system timer frequency. -*/ -uint32_t osKernelGetSysTimerFreq (void) { - /* Return frequency in hertz */ - return (configCPU_CLOCK_HZ); -} - -/* ==== Generic Wait Functions ==== */ - -/* - Wait for Timeout (Time Delay). -*/ -osStatus_t osDelay (uint32_t ticks) { - osStatus_t stat; - - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else { - stat = osOK; - - if (ticks != 0U) { - vTaskDelay(ticks); - } - } - - /* Return execution status */ - return (stat); -} - -/* - Wait until specified time. -*/ -osStatus_t osDelayUntil (uint32_t ticks) { - TickType_t tcnt, delay; - osStatus_t stat; - - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else { - stat = osOK; - tcnt = xTaskGetTickCount(); - - /* Determine remaining number of ticks to delay */ - delay = (TickType_t)ticks - tcnt; - - /* Check if target tick has not expired */ - if((delay != 0U) && (0 == (delay >> (8 * sizeof(TickType_t) - 1)))) { - if (xTaskDelayUntil (&tcnt, delay) == pdFALSE) { - /* Did not delay */ - stat = osError; - } - } - else - { - /* No delay or already expired */ - stat = osErrorParameter; - } - } - - /* Return execution status */ - return (stat); -} - - -/* ==== Timer Management Functions ==== */ - -#if (configUSE_OS2_TIMER == 1) - -static void TimerCallback (TimerHandle_t hTimer) { - TimerCallback_t *callb; - - /* Retrieve pointer to callback function and argument */ - callb = (TimerCallback_t *)pvTimerGetTimerID (hTimer); - - /* Remove dynamic allocation flag */ - callb = (TimerCallback_t *)((uint32_t)callb & ~1U); - - if (callb != NULL) { - callb->func (callb->arg); - } -} - -/* - Create and Initialize a timer. -*/ -osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr) { - const char *name; - TimerHandle_t hTimer; - TimerCallback_t *callb; - UBaseType_t reload; - int32_t mem; - uint32_t callb_dyn; - - hTimer = NULL; - - if ((IRQ_Context() == 0U) && (func != NULL)) { - callb = NULL; - callb_dyn = 0U; - - #if (configSUPPORT_STATIC_ALLOCATION == 1) - /* Static memory allocation is available: check if memory for control block */ - /* is provided and if it also contains space for callback and its argument */ - if ((attr != NULL) && (attr->cb_mem != NULL)) { - if (attr->cb_size >= (sizeof(StaticTimer_t) + sizeof(TimerCallback_t))) { - callb = (TimerCallback_t *)((uint32_t)attr->cb_mem + sizeof(StaticTimer_t)); - } - } - #endif - - #if (configSUPPORT_DYNAMIC_ALLOCATION == 1) - /* Dynamic memory allocation is available: if memory for callback and */ - /* its argument is not provided, allocate it from dynamic memory pool */ - if (callb == NULL) { - callb = (TimerCallback_t *)pvPortMalloc (sizeof(TimerCallback_t)); - - if (callb != NULL) { - /* Callback memory was allocated from dynamic pool, set flag */ - callb_dyn = 1U; - } - } - #endif - - if (callb != NULL) { - callb->func = func; - callb->arg = argument; - - if (type == osTimerOnce) { - reload = pdFALSE; - } else { - reload = pdTRUE; - } - - mem = -1; - name = NULL; - - if (attr != NULL) { - if (attr->name != NULL) { - name = attr->name; - } - - if ((attr->cb_mem != NULL) && (attr->cb_size >= sizeof(StaticTimer_t))) { - /* The memory for control block is provided, use static object */ - mem = 1; - } - else { - if ((attr->cb_mem == NULL) && (attr->cb_size == 0U)) { - /* Control block will be allocated from the dynamic pool */ - mem = 0; - } - } - } - else { - mem = 0; - } - /* Store callback memory dynamic allocation flag */ - callb = (TimerCallback_t *)((uint32_t)callb | callb_dyn); - /* - TimerCallback function is always provided as a callback and is used to call application - specified function with its argument both stored in structure callb. - */ - if (mem == 1) { - #if (configSUPPORT_STATIC_ALLOCATION == 1) - hTimer = xTimerCreateStatic (name, 1, reload, callb, TimerCallback, (StaticTimer_t *)attr->cb_mem); - #endif - } - else { - if (mem == 0) { - #if (configSUPPORT_DYNAMIC_ALLOCATION == 1) - hTimer = xTimerCreate (name, 1, reload, callb, TimerCallback); - #endif - } - } - - #if (configSUPPORT_DYNAMIC_ALLOCATION == 1) - if ((hTimer == NULL) && (callb != NULL) && (callb_dyn == 1U)) { - /* Failed to create a timer, release allocated resources */ - callb = (TimerCallback_t *)((uint32_t)callb & ~1U); - - vPortFree (callb); - } - #endif - } - } - - /* Return timer ID */ - return ((osTimerId_t)hTimer); -} - -/* - Get name of a timer. -*/ -const char *osTimerGetName (osTimerId_t timer_id) { - TimerHandle_t hTimer = (TimerHandle_t)timer_id; - const char *p; - - if ((IRQ_Context() != 0U) || (hTimer == NULL)) { - p = NULL; - } else { - p = pcTimerGetName (hTimer); - } - - /* Return name as null-terminated string */ - return (p); -} - -/* - Start or restart a timer. -*/ -osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks) { - TimerHandle_t hTimer = (TimerHandle_t)timer_id; - osStatus_t stat; - - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else if (hTimer == NULL) { - stat = osErrorParameter; - } - else { - if (xTimerChangePeriod (hTimer, ticks, portMAX_DELAY) == pdPASS) { - stat = osOK; - } else { - stat = osErrorResource; - } - } - - /* Return execution status */ - return (stat); -} - -/* - Stop a timer. -*/ -osStatus_t osTimerStop (osTimerId_t timer_id) { - TimerHandle_t hTimer = (TimerHandle_t)timer_id; - osStatus_t stat; - - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else if (hTimer == NULL) { - stat = osErrorParameter; - } - else { - if (xTimerIsTimerActive (hTimer) == pdFALSE) { - stat = osErrorResource; - } - else { - if (xTimerStop (hTimer, portMAX_DELAY) == pdPASS) { - stat = osOK; - } else { - stat = osError; - } - } - } - - /* Return execution status */ - return (stat); -} - -/* - Check if a timer is running. -*/ -uint32_t osTimerIsRunning (osTimerId_t timer_id) { - TimerHandle_t hTimer = (TimerHandle_t)timer_id; - uint32_t running; - - if ((IRQ_Context() != 0U) || (hTimer == NULL)) { - running = 0U; - } else { - running = (uint32_t)xTimerIsTimerActive (hTimer); - } - - /* Return 0: not running, 1: running */ - return (running); -} - -/* - Delete a timer. -*/ -osStatus_t osTimerDelete (osTimerId_t timer_id) { - TimerHandle_t hTimer = (TimerHandle_t)timer_id; - osStatus_t stat; -#ifndef USE_FreeRTOS_HEAP_1 -#if (configSUPPORT_DYNAMIC_ALLOCATION == 1) - TimerCallback_t *callb; -#endif - - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else if (hTimer == NULL) { - stat = osErrorParameter; - } - else { - #if (configSUPPORT_DYNAMIC_ALLOCATION == 1) - callb = (TimerCallback_t *)pvTimerGetTimerID (hTimer); - #endif - - if (xTimerDelete (hTimer, portMAX_DELAY) == pdPASS) { - #if (configSUPPORT_DYNAMIC_ALLOCATION == 1) - if ((uint32_t)callb & 1U) { - /* Callback memory was allocated from dynamic pool, clear flag */ - callb = (TimerCallback_t *)((uint32_t)callb & ~1U); - - /* Return allocated memory to dynamic pool */ - vPortFree (callb); - } - #endif - stat = osOK; - } else { - stat = osErrorResource; - } - } -#else - stat = osError; -#endif - - /* Return execution status */ - return (stat); -} -#endif /* (configUSE_OS2_TIMER == 1) */ - - -/* ==== Message Queue Management Functions ==== */ - -/* - Create and Initialize a Message Queue object. - - Limitations: - - The memory for control block and and message data must be provided in the - osThreadAttr_t structure in order to allocate object statically. -*/ -osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr) { - QueueHandle_t hQueue; - int32_t mem; - - hQueue = NULL; - - if ((IRQ_Context() == 0U) && (msg_count > 0U) && (msg_size > 0U)) { - mem = -1; - - if (attr != NULL) { - if ((attr->cb_mem != NULL) && (attr->cb_size >= sizeof(StaticQueue_t)) && - (attr->mq_mem != NULL) && (attr->mq_size >= (msg_count * msg_size))) { - /* The memory for control block and message data is provided, use static object */ - mem = 1; - } - else { - if ((attr->cb_mem == NULL) && (attr->cb_size == 0U) && - (attr->mq_mem == NULL) && (attr->mq_size == 0U)) { - /* Control block will be allocated from the dynamic pool */ - mem = 0; - } - } - } - else { - mem = 0; - } - - if (mem == 1) { - #if (configSUPPORT_STATIC_ALLOCATION == 1) - hQueue = xQueueCreateStatic (msg_count, msg_size, attr->mq_mem, attr->cb_mem); - #endif - } - else { - if (mem == 0) { - #if (configSUPPORT_DYNAMIC_ALLOCATION == 1) - hQueue = xQueueCreate (msg_count, msg_size); - #endif - } - } - - #if (configQUEUE_REGISTRY_SIZE > 0) - if (hQueue != NULL) { - if ((attr != NULL) && (attr->name != NULL)) { - /* Only non-NULL name objects are added to the Queue Registry */ - vQueueAddToRegistry (hQueue, attr->name); - } - } - #endif - - } - - /* Return message queue ID */ - return ((osMessageQueueId_t)hQueue); -} - -/* - Put a Message into a Queue or timeout if Queue is full. - - Limitations: - - Message priority is ignored -*/ -osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) { - QueueHandle_t hQueue = (QueueHandle_t)mq_id; - osStatus_t stat; - BaseType_t yield; - - (void)msg_prio; /* Message priority is ignored */ - - stat = osOK; - - if (IRQ_Context() != 0U) { - if ((hQueue == NULL) || (msg_ptr == NULL) || (timeout != 0U)) { - stat = osErrorParameter; - } - else { - yield = pdFALSE; - - if (xQueueSendToBackFromISR (hQueue, msg_ptr, &yield) != pdTRUE) { - stat = osErrorResource; - } else { - portYIELD_FROM_ISR (yield); - } - } - } - else { - if ((hQueue == NULL) || (msg_ptr == NULL)) { - stat = osErrorParameter; - } - else { - if (xQueueSendToBack (hQueue, msg_ptr, (TickType_t)timeout) != pdPASS) { - if (timeout != 0U) { - stat = osErrorTimeout; - } else { - stat = osErrorResource; - } - } - } - } - - /* Return execution status */ - return (stat); -} - -/* - Get a Message from a Queue or timeout if Queue is empty. - - Limitations: - - Message priority is ignored -*/ -osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout) { - QueueHandle_t hQueue = (QueueHandle_t)mq_id; - osStatus_t stat; - BaseType_t yield; - - (void)msg_prio; /* Message priority is ignored */ - - stat = osOK; - - if (IRQ_Context() != 0U) { - if ((hQueue == NULL) || (msg_ptr == NULL) || (timeout != 0U)) { - stat = osErrorParameter; - } - else { - yield = pdFALSE; - - if (xQueueReceiveFromISR (hQueue, msg_ptr, &yield) != pdPASS) { - stat = osErrorResource; - } else { - portYIELD_FROM_ISR (yield); - } - } - } - else { - if ((hQueue == NULL) || (msg_ptr == NULL)) { - stat = osErrorParameter; - } - else { - if (xQueueReceive (hQueue, msg_ptr, (TickType_t)timeout) != pdPASS) { - if (timeout != 0U) { - stat = osErrorTimeout; - } else { - stat = osErrorResource; - } - } - } - } - - /* Return execution status */ - return (stat); -} - -/* - Get maximum number of messages in a Message Queue. -*/ -uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id) { - StaticQueue_t *mq = (StaticQueue_t *)mq_id; - uint32_t capacity; - - if (mq == NULL) { - capacity = 0U; - } else { - /* capacity = pxQueue->uxLength */ - capacity = mq->uxDummy4[1]; - } - - /* Return maximum number of messages */ - return (capacity); -} - -/* - Get maximum message size in a Message Queue. -*/ -uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id) { - StaticQueue_t *mq = (StaticQueue_t *)mq_id; - uint32_t size; - - if (mq == NULL) { - size = 0U; - } else { - /* size = pxQueue->uxItemSize */ - size = mq->uxDummy4[2]; - } - - /* Return maximum message size */ - return (size); -} - -/* - Get number of queued messages in a Message Queue. -*/ -uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id) { - QueueHandle_t hQueue = (QueueHandle_t)mq_id; - UBaseType_t count; - - if (hQueue == NULL) { - count = 0U; - } - else if (IRQ_Context() != 0U) { - count = uxQueueMessagesWaitingFromISR (hQueue); - } - else { - count = uxQueueMessagesWaiting (hQueue); - } - - /* Return number of queued messages */ - return ((uint32_t)count); -} - -/* - Get number of available slots for messages in a Message Queue. -*/ -uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id) { - StaticQueue_t *mq = (StaticQueue_t *)mq_id; - uint32_t space; - uint32_t isrm; - - if (mq == NULL) { - space = 0U; - } - else if (IRQ_Context() != 0U) { - isrm = taskENTER_CRITICAL_FROM_ISR(); - - /* space = pxQueue->uxLength - pxQueue->uxMessagesWaiting; */ - space = mq->uxDummy4[1] - mq->uxDummy4[0]; - - taskEXIT_CRITICAL_FROM_ISR(isrm); - } - else { - space = (uint32_t)uxQueueSpacesAvailable ((QueueHandle_t)mq); - } - - /* Return number of available slots */ - return (space); -} - -/* - Reset a Message Queue to initial empty state. -*/ -osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id) { - QueueHandle_t hQueue = (QueueHandle_t)mq_id; - osStatus_t stat; - - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else if (hQueue == NULL) { - stat = osErrorParameter; - } - else { - stat = osOK; - (void)xQueueReset (hQueue); - } - - /* Return execution status */ - return (stat); -} - -/* - Delete a Message Queue object. -*/ -osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id) { - QueueHandle_t hQueue = (QueueHandle_t)mq_id; - osStatus_t stat; - -#ifndef USE_FreeRTOS_HEAP_1 - if (IRQ_Context() != 0U) { - stat = osErrorISR; - } - else if (hQueue == NULL) { - stat = osErrorParameter; - } - else { - #if (configQUEUE_REGISTRY_SIZE > 0) - vQueueUnregisterQueue (hQueue); - #endif - - stat = osOK; - vQueueDelete (hQueue); - } -#else - stat = osError; -#endif - - /* Return execution status */ - return (stat); -} - -/* Callback function prototypes */ -extern void vApplicationIdleHook (void); -extern void vApplicationMallocFailedHook (void); -extern void vApplicationDaemonTaskStartupHook (void); - -/** - Dummy implementation of the callback function vApplicationIdleHook(). -*/ -#if (configUSE_IDLE_HOOK == 1) -__WEAK void vApplicationIdleHook (void){} -#endif - -/** - Dummy implementation of the callback function vApplicationTickHook(). -*/ -#if (configUSE_TICK_HOOK == 1) - __WEAK void vApplicationTickHook (void){} -#endif - -/** - Dummy implementation of the callback function vApplicationMallocFailedHook(). -*/ -#if (configUSE_MALLOC_FAILED_HOOK == 1) -__WEAK void vApplicationMallocFailedHook (void) { - /* Assert when malloc failed hook is enabled but no application defined function exists */ - configASSERT(0); -} -#endif - -/** - Dummy implementation of the callback function vApplicationDaemonTaskStartupHook(). -*/ -#if (configUSE_DAEMON_TASK_STARTUP_HOOK == 1) -__WEAK void vApplicationDaemonTaskStartupHook (void){} -#endif - -/** - Dummy implementation of the callback function vApplicationStackOverflowHook(). -*/ -#if (configCHECK_FOR_STACK_OVERFLOW > 0) -__WEAK void vApplicationStackOverflowHook (TaskHandle_t xTask, char *pcTaskName) { - (void)xTask; - (void)pcTaskName; - - /* Assert when stack overflow is enabled but no application defined function exists */ - configASSERT(0); -} -#endif diff --git a/lib/FreeRTOS-glue/cmsis_os2.h b/lib/FreeRTOS-glue/cmsis_os2.h deleted file mode 100644 index 044c9851..00000000 --- a/lib/FreeRTOS-glue/cmsis_os2.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2013-2020 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ---------------------------------------------------------------------- - * - * $Date: 12. June 2020 - * $Revision: V2.1.3 - * - * Project: CMSIS-RTOS2 API - * Title: cmsis_os2.h header file - * - * Version 2.1.3 - * Additional functions allowed to be called from Interrupt Service Routines: - * - osThreadGetId - * Version 2.1.2 - * Additional functions allowed to be called from Interrupt Service Routines: - * - osKernelGetInfo, osKernelGetState - * Version 2.1.1 - * Additional functions allowed to be called from Interrupt Service Routines: - * - osKernelGetTickCount, osKernelGetTickFreq - * Changed Kernel Tick type to uint32_t: - * - updated: osKernelGetTickCount, osDelayUntil - * Version 2.1.0 - * Support for critical and uncritical sections (nesting safe): - * - updated: osKernelLock, osKernelUnlock - * - added: osKernelRestoreLock - * Updated Thread and Event Flags: - * - changed flags parameter and return type from int32_t to uint32_t - * Version 2.0.0 - * Initial Release - *---------------------------------------------------------------------------*/ - -#ifndef CMSIS_OS2_H_ -#define CMSIS_OS2_H_ - -#ifndef __NO_RETURN -#if defined(__CC_ARM) -#define __NO_RETURN __declspec(noreturn) -#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) -#define __NO_RETURN __attribute__((__noreturn__)) -#elif defined(__GNUC__) -#define __NO_RETURN __attribute__((__noreturn__)) -#elif defined(__ICCARM__) -#define __NO_RETURN __noreturn -#else -#define __NO_RETURN -#endif -#endif - -#include <furi/base.h> - -#ifdef __cplusplus -extern "C" -{ -#endif - - -// ==== Enumerations, structures, defines ==== - -/// Version information. -typedef struct { - uint32_t api; ///< API version (major.minor.rev: mmnnnrrrr dec). - uint32_t kernel; ///< Kernel version (major.minor.rev: mmnnnrrrr dec). -} osVersion_t; - -/// Kernel state. -typedef enum { - osKernelInactive = 0, ///< Inactive. - osKernelReady = 1, ///< Ready. - osKernelRunning = 2, ///< Running. - osKernelLocked = 3, ///< Locked. - osKernelSuspended = 4, ///< Suspended. - osKernelError = -1, ///< Error. - osKernelReserved = 0x7FFFFFFF ///< Prevents enum down-size compiler optimization. -} osKernelState_t; - -/// Timer callback function. -typedef void (*osTimerFunc_t) (void *argument); - -/// Timer type. -typedef enum { - osTimerOnce = 0, ///< One-shot timer. - osTimerPeriodic = 1 ///< Repeating timer. -} osTimerType_t; - - -/// \details Timer ID identifies the timer. -typedef void *osTimerId_t; - -/// \details Message Queue ID identifies the message queue. -typedef void *osMessageQueueId_t; - - -#ifndef TZ_MODULEID_T -#define TZ_MODULEID_T -/// \details Data type that identifies secure software modules called by a process. -typedef uint32_t TZ_ModuleId_t; -#endif - - -/// Attributes structure for timer. -typedef struct { - const char *name; ///< name of the timer - uint32_t attr_bits; ///< attribute bits - void *cb_mem; ///< memory for control block - uint32_t cb_size; ///< size of provided memory for control block -} osTimerAttr_t; - -/// Attributes structure for message queue. -typedef struct { - const char *name; ///< name of the message queue - uint32_t attr_bits; ///< attribute bits - void *cb_mem; ///< memory for control block - uint32_t cb_size; ///< size of provided memory for control block - void *mq_mem; ///< memory for data storage - uint32_t mq_size; ///< size of provided memory for data storage -} osMessageQueueAttr_t; - - -// ==== Kernel Management Functions ==== - -/// Initialize the RTOS Kernel. -/// \return status code that indicates the execution status of the function. -osStatus_t osKernelInitialize (void); - -/// Get RTOS Kernel Information. -/// \param[out] version pointer to buffer for retrieving version information. -/// \param[out] id_buf pointer to buffer for retrieving kernel identification string. -/// \param[in] id_size size of buffer for kernel identification string. -/// \return status code that indicates the execution status of the function. -osStatus_t osKernelGetInfo (osVersion_t *version, char *id_buf, uint32_t id_size); - -/// Get the current RTOS Kernel state. -/// \return current RTOS Kernel state. -osKernelState_t osKernelGetState (void); - -/// Start the RTOS Kernel scheduler. -/// \return status code that indicates the execution status of the function. -osStatus_t osKernelStart (void); - -/// Lock the RTOS Kernel scheduler. -/// \return previous lock state (1 - locked, 0 - not locked, error code if negative). -int32_t osKernelLock (void); - -/// Unlock the RTOS Kernel scheduler. -/// \return previous lock state (1 - locked, 0 - not locked, error code if negative). -int32_t osKernelUnlock (void); - -/// Restore the RTOS Kernel scheduler lock state. -/// \param[in] lock lock state obtained by \ref osKernelLock or \ref osKernelUnlock. -/// \return new lock state (1 - locked, 0 - not locked, error code if negative). -int32_t osKernelRestoreLock (int32_t lock); - -/// Suspend the RTOS Kernel scheduler. -/// \return time in ticks, for how long the system can sleep or power-down. -uint32_t osKernelSuspend (void); - -/// Resume the RTOS Kernel scheduler. -/// \param[in] sleep_ticks time in ticks for how long the system was in sleep or power-down mode. -void osKernelResume (uint32_t sleep_ticks); - -/// Get the RTOS kernel tick count. -/// \return RTOS kernel current tick count. -uint32_t osKernelGetTickCount (void); - -/// Get the RTOS kernel tick frequency. -/// \return frequency of the kernel tick in hertz, i.e. kernel ticks per second. -uint32_t osKernelGetTickFreq (void); - -/// Get the RTOS kernel system timer frequency. -/// \return frequency of the system timer in hertz, i.e. timer ticks per second. -uint32_t osKernelGetSysTimerFreq (void); - -// ==== Generic Wait Functions ==== - -/// Wait for Timeout (Time Delay). -/// \param[in] ticks \ref CMSIS_RTOS_TimeOutValue "time ticks" value -/// \return status code that indicates the execution status of the function. -osStatus_t osDelay (uint32_t ticks); - -/// Wait until specified time. -/// \param[in] ticks absolute time in ticks -/// \return status code that indicates the execution status of the function. -osStatus_t osDelayUntil (uint32_t ticks); - - -// ==== Timer Management Functions ==== - -/// Create and Initialize a timer. -/// \param[in] func function pointer to callback function. -/// \param[in] type \ref osTimerOnce for one-shot or \ref osTimerPeriodic for periodic behavior. -/// \param[in] argument argument to the timer callback function. -/// \param[in] attr timer attributes; NULL: default values. -/// \return timer ID for reference by other functions or NULL in case of error. -osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr); - -/// Get name of a timer. -/// \param[in] timer_id timer ID obtained by \ref osTimerNew. -/// \return name as null-terminated string. -const char *osTimerGetName (osTimerId_t timer_id); - -/// Start or restart a timer. -/// \param[in] timer_id timer ID obtained by \ref osTimerNew. -/// \param[in] ticks \ref CMSIS_RTOS_TimeOutValue "time ticks" value of the timer. -/// \return status code that indicates the execution status of the function. -osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks); - -/// Stop a timer. -/// \param[in] timer_id timer ID obtained by \ref osTimerNew. -/// \return status code that indicates the execution status of the function. -osStatus_t osTimerStop (osTimerId_t timer_id); - -/// Check if a timer is running. -/// \param[in] timer_id timer ID obtained by \ref osTimerNew. -/// \return 0 not running, 1 running. -uint32_t osTimerIsRunning (osTimerId_t timer_id); - -/// Delete a timer. -/// \param[in] timer_id timer ID obtained by \ref osTimerNew. -/// \return status code that indicates the execution status of the function. -osStatus_t osTimerDelete (osTimerId_t timer_id); - -// ==== Message Queue Management Functions ==== - -/// Create and Initialize a Message Queue object. -/// \param[in] msg_count maximum number of messages in queue. -/// \param[in] msg_size maximum message size in bytes. -/// \param[in] attr message queue attributes; NULL: default values. -/// \return message queue ID for reference by other functions or NULL in case of error. -osMessageQueueId_t osMessageQueueNew (uint32_t msg_count, uint32_t msg_size, const osMessageQueueAttr_t *attr); - -/// Get name of a Message Queue object. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \return name as null-terminated string. -const char *osMessageQueueGetName (osMessageQueueId_t mq_id); - -/// Put a Message into a Queue or timeout if Queue is full. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \param[in] msg_ptr pointer to buffer with message to put into a queue. -/// \param[in] msg_prio message priority. -/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. -/// \return status code that indicates the execution status of the function. -osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout); - -/// Get a Message from a Queue or timeout if Queue is empty. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \param[out] msg_ptr pointer to buffer for message to get from a queue. -/// \param[out] msg_prio pointer to buffer for message priority or NULL. -/// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out. -/// \return status code that indicates the execution status of the function. -osStatus_t osMessageQueueGet (osMessageQueueId_t mq_id, void *msg_ptr, uint8_t *msg_prio, uint32_t timeout); - -/// Get maximum number of messages in a Message Queue. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \return maximum number of messages. -uint32_t osMessageQueueGetCapacity (osMessageQueueId_t mq_id); - -/// Get maximum message size in a Message Queue. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \return maximum message size in bytes. -uint32_t osMessageQueueGetMsgSize (osMessageQueueId_t mq_id); - -/// Get number of queued messages in a Message Queue. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \return number of queued messages. -uint32_t osMessageQueueGetCount (osMessageQueueId_t mq_id); - -/// Get number of available slots for messages in a Message Queue. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \return number of available slots for messages. -uint32_t osMessageQueueGetSpace (osMessageQueueId_t mq_id); - -/// Reset a Message Queue to initial empty state. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \return status code that indicates the execution status of the function. -osStatus_t osMessageQueueReset (osMessageQueueId_t mq_id); - -/// Delete a Message Queue object. -/// \param[in] mq_id message queue ID obtained by \ref osMessageQueueNew. -/// \return status code that indicates the execution status of the function. -osStatus_t osMessageQueueDelete (osMessageQueueId_t mq_id); - - -#ifdef __cplusplus -} -#endif - -#endif // CMSIS_OS2_H_ diff --git a/lib/FreeRTOS-glue/freertos_os2.h b/lib/FreeRTOS-glue/freertos_os2.h deleted file mode 100644 index 1e70b3fc..00000000 --- a/lib/FreeRTOS-glue/freertos_os2.h +++ /dev/null @@ -1,319 +0,0 @@ -/* -------------------------------------------------------------------------- - * Copyright (c) 2013-2021 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Name: freertos_os2.h - * Purpose: CMSIS RTOS2 wrapper for FreeRTOS - * - *---------------------------------------------------------------------------*/ - -#ifndef FREERTOS_OS2_H_ -#define FREERTOS_OS2_H_ - -#include <string.h> -#include <stdint.h> - -#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core - -#if defined(_RTE_) -#include "RTE_Components.h" // Component selection -#include CMSIS_device_header - -/* Configuration and component setup check */ -#if defined(RTE_Compiler_EventRecorder) - #if !defined(EVR_FREERTOS_DISABLE) - #define USE_TRACE_EVENT_RECORDER - /* - FreeRTOS provides functions and hooks to support execution tracing. This - functionality is only enabled if configUSE_TRACE_FACILITY == 1. - Set #define configUSE_TRACE_FACILITY 1 in FreeRTOSConfig.h to enable trace events. - */ - #if (configUSE_TRACE_FACILITY == 0) - #error "Definition configUSE_TRACE_FACILITY must equal 1 to enable FreeRTOS trace events." - #endif - #endif -#endif - -#if defined(RTE_RTOS_FreeRTOS_HEAP_1) - #define USE_FreeRTOS_HEAP_1 -#endif - -#if defined(RTE_RTOS_FreeRTOS_HEAP_5) - #define USE_FreeRTOS_HEAP_5 -#endif -#endif /* _RTE_ */ - -/* - CMSIS-RTOS2 FreeRTOS image size optimization definitions. - - Note: Definitions configUSE_OS2 can be used to optimize FreeRTOS image size when - certain functionality is not required when using CMSIS-RTOS2 API. - In general optimization decisions are left to the tool chain but in cases - when coding style prevents it to optimize the code following optional - definitions can be used. -*/ - -/* - Option to exclude CMSIS-RTOS2 functions osThreadSuspend and osThreadResume from - the application image. -*/ -#ifndef configUSE_OS2_THREAD_SUSPEND_RESUME -#define configUSE_OS2_THREAD_SUSPEND_RESUME 1 -#endif - -/* - Option to exclude CMSIS-RTOS2 function furi_thread_enumerate from the application image. -*/ -#ifndef configUSE_OS2_THREAD_ENUMERATE -#define configUSE_OS2_THREAD_ENUMERATE 1 -#endif - -/* - Option to disable CMSIS-RTOS2 function osEventFlagsSet and osEventFlagsClear - operation from ISR. -*/ -#ifndef configUSE_OS2_EVENTFLAGS_FROM_ISR -#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1 -#endif - -/* - Option to exclude CMSIS-RTOS2 Thread Flags API functions from the application image. -*/ -#ifndef configUSE_OS2_THREAD_FLAGS -#define configUSE_OS2_THREAD_FLAGS configUSE_TASK_NOTIFICATIONS -#endif - -/* - Option to exclude CMSIS-RTOS2 Timer API functions from the application image. -*/ -#ifndef configUSE_OS2_TIMER -#define configUSE_OS2_TIMER configUSE_TIMERS -#endif - -/* - Option to exclude CMSIS-RTOS2 Mutex API functions from the application image. -*/ -#ifndef configUSE_OS2_MUTEX -#define configUSE_OS2_MUTEX configUSE_MUTEXES -#endif - - -/* - CMSIS-RTOS2 FreeRTOS configuration check (FreeRTOSConfig.h). - - Note: CMSIS-RTOS API requires functions included by using following definitions. - In case if certain API function is not used compiler will optimize it away. -*/ -#if (INCLUDE_xSemaphoreGetMutexHolder == 0) - /* - CMSIS-RTOS2 function osMutexGetOwner uses FreeRTOS function xSemaphoreGetMutexHolder. In case if - osMutexGetOwner is not used in the application image, compiler will optimize it away. - Set #define INCLUDE_xSemaphoreGetMutexHolder 1 to fix this error. - */ - #error "Definition INCLUDE_xSemaphoreGetMutexHolder must equal 1 to implement Mutex Management API." -#endif -#if (INCLUDE_vTaskDelay == 0) - /* - CMSIS-RTOS2 function osDelay uses FreeRTOS function vTaskDelay. In case if - osDelay is not used in the application image, compiler will optimize it away. - Set #define INCLUDE_vTaskDelay 1 to fix this error. - */ - #error "Definition INCLUDE_vTaskDelay must equal 1 to implement Generic Wait Functions API." -#endif -#if (INCLUDE_xTaskDelayUntil == 0) - /* - CMSIS-RTOS2 function osDelayUntil uses FreeRTOS function xTaskDelayUntil. In case if - osDelayUntil is not used in the application image, compiler will optimize it away. - Set #define INCLUDE_xTaskDelayUntil 1 to fix this error. - */ - #error "Definition INCLUDE_xTaskDelayUntil must equal 1 to implement Generic Wait Functions API." -#endif -#if (INCLUDE_vTaskDelete == 0) - /* - CMSIS-RTOS2 function osThreadTerminate and osThreadExit uses FreeRTOS function - vTaskDelete. In case if they are not used in the application image, compiler - will optimize them away. - Set #define INCLUDE_vTaskDelete 1 to fix this error. - */ - #error "Definition INCLUDE_vTaskDelete must equal 1 to implement Thread Management API." -#endif -#if (INCLUDE_xTaskGetCurrentTaskHandle == 0) - /* - CMSIS-RTOS2 API uses FreeRTOS function xTaskGetCurrentTaskHandle to implement - functions osThreadGetId, furi_thread_flags_clear and furi_thread_flags_get. In case if these - functions are not used in the application image, compiler will optimize them away. - Set #define INCLUDE_xTaskGetCurrentTaskHandle 1 to fix this error. - */ - #error "Definition INCLUDE_xTaskGetCurrentTaskHandle must equal 1 to implement Thread Management API." -#endif -#if (INCLUDE_xTaskGetSchedulerState == 0) - /* - CMSIS-RTOS2 API uses FreeRTOS function xTaskGetSchedulerState to implement Kernel - tick handling and therefore it is vital that xTaskGetSchedulerState is included into - the application image. - Set #define INCLUDE_xTaskGetSchedulerState 1 to fix this error. - */ - #error "Definition INCLUDE_xTaskGetSchedulerState must equal 1 to implement Kernel Information and Control API." -#endif -#if (INCLUDE_uxTaskGetStackHighWaterMark == 0) - /* - CMSIS-RTOS2 function furi_thread_get_stack_space uses FreeRTOS function uxTaskGetStackHighWaterMark. - In case if furi_thread_get_stack_space is not used in the application image, compiler will - optimize it away. - Set #define INCLUDE_uxTaskGetStackHighWaterMark 1 to fix this error. - */ - #error "Definition INCLUDE_uxTaskGetStackHighWaterMark must equal 1 to implement Thread Management API." -#endif -#if (INCLUDE_uxTaskPriorityGet == 0) - /* - CMSIS-RTOS2 function osThreadGetPriority uses FreeRTOS function uxTaskPriorityGet. In case if - osThreadGetPriority is not used in the application image, compiler will optimize it away. - Set #define INCLUDE_uxTaskPriorityGet 1 to fix this error. - */ - #error "Definition INCLUDE_uxTaskPriorityGet must equal 1 to implement Thread Management API." -#endif -#if (INCLUDE_vTaskPrioritySet == 0) - /* - CMSIS-RTOS2 function osThreadSetPriority uses FreeRTOS function vTaskPrioritySet. In case if - osThreadSetPriority is not used in the application image, compiler will optimize it away. - Set #define INCLUDE_vTaskPrioritySet 1 to fix this error. - */ - #error "Definition INCLUDE_vTaskPrioritySet must equal 1 to implement Thread Management API." -#endif -#if (INCLUDE_eTaskGetState == 0) - /* - CMSIS-RTOS2 API uses FreeRTOS function vTaskDelayUntil to implement functions osThreadGetState - and osThreadTerminate. In case if these functions are not used in the application image, - compiler will optimize them away. - Set #define INCLUDE_eTaskGetState 1 to fix this error. - */ - #error "Definition INCLUDE_eTaskGetState must equal 1 to implement Thread Management API." -#endif -#if (INCLUDE_vTaskSuspend == 0) - /* - CMSIS-RTOS2 API uses FreeRTOS functions vTaskSuspend and vTaskResume to implement - functions osThreadSuspend and osThreadResume. In case if these functions are not - used in the application image, compiler will optimize them away. - Set #define INCLUDE_vTaskSuspend 1 to fix this error. - - Alternatively, if the application does not use osThreadSuspend and - osThreadResume they can be excluded from the image code by setting: - #define configUSE_OS2_THREAD_SUSPEND_RESUME 0 (in FreeRTOSConfig.h) - */ - #if (configUSE_OS2_THREAD_SUSPEND_RESUME == 1) - #error "Definition INCLUDE_vTaskSuspend must equal 1 to implement Kernel Information and Control API." - #endif -#endif -#if (INCLUDE_xTimerPendFunctionCall == 0) - /* - CMSIS-RTOS2 function osEventFlagsSet and osEventFlagsClear, when called from - the ISR, call FreeRTOS functions xEventGroupSetBitsFromISR and - xEventGroupClearBitsFromISR which are only enabled if timers are operational and - xTimerPendFunctionCall in enabled. - Set #define INCLUDE_xTimerPendFunctionCall 1 and #define configUSE_TIMERS 1 - to fix this error. - - Alternatively, if the application does not use osEventFlagsSet and osEventFlagsClear - from the ISR their operation from ISR can be restricted by setting: - #define configUSE_OS2_EVENTFLAGS_FROM_ISR 0 (in FreeRTOSConfig.h) - */ - #if (configUSE_OS2_EVENTFLAGS_FROM_ISR == 1) - #error "Definition INCLUDE_xTimerPendFunctionCall must equal 1 to implement Event Flags API." - #endif -#endif - -#if (configUSE_TIMERS == 0) - /* - CMSIS-RTOS2 Timer Management API functions use FreeRTOS timer functions to implement - timer management. In case if these functions are not used in the application image, - compiler will optimize them away. - Set #define configUSE_TIMERS 1 to fix this error. - - Alternatively, if the application does not use timer functions they can be - excluded from the image code by setting: - #define configUSE_OS2_TIMER 0 (in FreeRTOSConfig.h) - */ - #if (configUSE_OS2_TIMER == 1) - #error "Definition configUSE_TIMERS must equal 1 to implement Timer Management API." - #endif -#endif - -#if (configUSE_MUTEXES == 0) - /* - CMSIS-RTOS2 Mutex Management API functions use FreeRTOS mutex functions to implement - mutex management. In case if these functions are not used in the application image, - compiler will optimize them away. - Set #define configUSE_MUTEXES 1 to fix this error. - - Alternatively, if the application does not use mutex functions they can be - excluded from the image code by setting: - #define configUSE_OS2_MUTEX 0 (in FreeRTOSConfig.h) - */ - #if (configUSE_OS2_MUTEX == 1) - #error "Definition configUSE_MUTEXES must equal 1 to implement Mutex Management API." - #endif -#endif - -#if (configUSE_COUNTING_SEMAPHORES == 0) - /* - CMSIS-RTOS2 Memory Pool functions use FreeRTOS function xSemaphoreCreateCounting - to implement memory pools. In case if these functions are not used in the application image, - compiler will optimize them away. - Set #define configUSE_COUNTING_SEMAPHORES 1 to fix this error. - */ - #error "Definition configUSE_COUNTING_SEMAPHORES must equal 1 to implement Memory Pool API." -#endif -#if (configUSE_TASK_NOTIFICATIONS == 0) - /* - CMSIS-RTOS2 Thread Flags API functions use FreeRTOS Task Notification functions to implement - thread flag management. In case if these functions are not used in the application image, - compiler will optimize them away. - Set #define configUSE_TASK_NOTIFICATIONS 1 to fix this error. - - Alternatively, if the application does not use thread flags functions they can be - excluded from the image code by setting: - #define configUSE_OS2_THREAD_FLAGS 0 (in FreeRTOSConfig.h) - */ - #if (configUSE_OS2_THREAD_FLAGS == 1) - #error "Definition configUSE_TASK_NOTIFICATIONS must equal 1 to implement Thread Flags API." - #endif -#endif - -#if (configUSE_TRACE_FACILITY == 0) - /* - CMSIS-RTOS2 function furi_thread_enumerate requires FreeRTOS function uxTaskGetSystemState - which is only enabled if configUSE_TRACE_FACILITY == 1. - Set #define configUSE_TRACE_FACILITY 1 to fix this error. - - Alternatively, if the application does not use furi_thread_enumerate it can be - excluded from the image code by setting: - #define configUSE_OS2_THREAD_ENUMERATE 0 (in FreeRTOSConfig.h) - */ - #if (configUSE_OS2_THREAD_ENUMERATE == 1) - #error "Definition configUSE_TRACE_FACILITY must equal 1 to implement furi_thread_enumerate." - #endif -#endif - -#if (configUSE_16_BIT_TICKS == 1) - /* - CMSIS-RTOS2 wrapper for FreeRTOS relies on 32-bit tick timer which is also optimal on - a 32-bit CPU architectures. - Set #define configUSE_16_BIT_TICKS 0 to fix this error. - */ - #error "Definition configUSE_16_BIT_TICKS must be zero to implement CMSIS-RTOS2 API." -#endif - -#endif /* FREERTOS_OS2_H_ */ diff --git a/lib/ST25RFAL002/platform.c b/lib/ST25RFAL002/platform.c index 1facfa2a..af9dc6ff 100644 --- a/lib/ST25RFAL002/platform.c +++ b/lib/ST25RFAL002/platform.c @@ -26,7 +26,7 @@ int32_t rfal_platform_irq_thread(void* context) { UNUSED(context); while(1) { - uint32_t flags = furi_thread_flags_wait(0x1, osFlagsWaitAny, osWaitForever); + uint32_t flags = furi_thread_flags_wait(0x1, FuriFlagWaitAny, FuriWaitForever); if(flags & 0x1) { rfal_platform.callback(); } diff --git a/lib/ST25RFAL002/platform.h b/lib/ST25RFAL002/platform.h index 832e034e..d86bba73 100644 --- a/lib/ST25RFAL002/platform.h +++ b/lib/ST25RFAL002/platform.h @@ -4,7 +4,6 @@ #include <stdlib.h> #include <stdbool.h> #include <limits.h> -#include <cmsis_os2.h> #include "timer.h" #include "math.h" #include <furi_hal_gpio.h> @@ -104,10 +103,9 @@ void rfal_platform_spi_release(); timerCalculateTimer(t) /*!< Create a timer with the given time (ms) */ #define platformTimerIsExpired(timer) \ timerIsExpired(timer) /*!< Checks if the given timer is expired */ -#define platformDelay(t) osDelay(t) /*!< Performs a delay for the given time (ms) */ +#define platformDelay(t) furi_delay_ms(t) /*!< Performs a delay for the given time (ms) */ -#define platformGetSysTick() \ - osKernelGetTickCount() /*!< Get System Tick (1 tick = 1 ms) */ +#define platformGetSysTick() furi_get_tick() /*!< Get System Tick (1 tick = 1 ms) */ #define platformAssert(exp) assert_param(exp) /*!< Asserts whether the given expression is true*/ diff --git a/lib/ST25RFAL002/timer.c b/lib/ST25RFAL002/timer.c index b7fe1c28..ea0678a6 100644 --- a/lib/ST25RFAL002/timer.c +++ b/lib/ST25RFAL002/timer.c @@ -41,7 +41,7 @@ ****************************************************************************** */ #include "timer.h" -#include <furi_hal_delay.h> +#include <furi.h> /* ****************************************************************************** @@ -65,7 +65,7 @@ static uint32_t timerStopwatchTick; /*******************************************************************************/ uint32_t timerCalculateTimer(uint16_t time) { - return (furi_hal_get_tick() + time); + return (furi_get_tick() + time); } /*******************************************************************************/ @@ -73,7 +73,7 @@ bool timerIsExpired(uint32_t timer) { uint32_t uDiff; int32_t sDiff; - uDiff = (timer - furi_hal_get_tick()); /* Calculate the diff between the timers */ + uDiff = (timer - furi_get_tick()); /* Calculate the diff between the timers */ sDiff = uDiff; /* Convert the diff to a signed var */ /* Check if the given timer has expired already */ @@ -96,10 +96,10 @@ void timerDelay(uint16_t tOut) { /*******************************************************************************/ void timerStopwatchStart(void) { - timerStopwatchTick = furi_hal_get_tick(); + timerStopwatchTick = furi_get_tick(); } /*******************************************************************************/ uint32_t timerStopwatchMeasure(void) { - return (uint32_t)(furi_hal_get_tick() - timerStopwatchTick); + return (uint32_t)(furi_get_tick() - timerStopwatchTick); } diff --git a/lib/app-scened-template/record_controller.hpp b/lib/app-scened-template/record_controller.hpp index 9dfa9657..9b14274a 100644 --- a/lib/app-scened-template/record_controller.hpp +++ b/lib/app-scened-template/record_controller.hpp @@ -1,5 +1,5 @@ #pragma once -#include <furi/record.h> +#include <core/record.h> /** * @brief Class for opening, casting, holding and closing records diff --git a/lib/app-scened-template/view_controller.hpp b/lib/app-scened-template/view_controller.hpp index e74673d8..d08751c5 100644 --- a/lib/app-scened-template/view_controller.hpp +++ b/lib/app-scened-template/view_controller.hpp @@ -1,7 +1,7 @@ #pragma once #include "view_modules/generic_view_module.h" #include <map> -#include <furi/check.h> +#include <core/check.h> #include <gui/view_dispatcher.h> #include <callback-connector.h> #include "typeindex_no_rtti.hpp" @@ -15,7 +15,7 @@ template <typename TApp, typename... TViewModules> class ViewController { public: ViewController() { - event_queue = osMessageQueueNew(10, sizeof(typename TApp::Event), NULL); + event_queue = furi_message_queue_alloc(10, sizeof(typename TApp::Event)); view_dispatcher = view_dispatcher_alloc(); previous_view_callback_pointer = cbc::obtain_connector( @@ -36,7 +36,7 @@ public: } view_dispatcher_free(view_dispatcher); - osMessageQueueDelete(event_queue); + furi_message_queue_free(event_queue); } /** @@ -81,7 +81,7 @@ public: * @param event event pointer */ void receive_event(typename TApp::Event* event) { - if(osMessageQueueGet(event_queue, event, NULL, 100) != osOK) { + if(furi_message_queue_get(event_queue, event, 100) != FuriStatusOk) { event->type = TApp::EventType::Tick; } } @@ -92,8 +92,8 @@ public: * @param event event pointer */ void send_event(typename TApp::Event* event) { - osStatus_t result = osMessageQueuePut(event_queue, event, 0, osWaitForever); - furi_check(result == osOK); + FuriStatus result = furi_message_queue_put(event_queue, event, FuriWaitForever); + furi_check(result == FuriStatusOk); } private: @@ -107,7 +107,7 @@ private: * @brief App event queue * */ - osMessageQueueId_t event_queue; + FuriMessageQueue* event_queue; /** * @brief Main ViewDispatcher pointer diff --git a/lib/drivers/bq27220.c b/lib/drivers/bq27220.c index 18f3f028..f64120fa 100644 --- a/lib/drivers/bq27220.c +++ b/lib/drivers/bq27220.c @@ -1,8 +1,7 @@ #include "bq27220.h" #include "bq27220_reg.h" -#include <furi_hal_delay.h> -#include <furi/log.h> +#include <furi.h> #include <stdbool.h> #define TAG "Gauge" @@ -42,7 +41,7 @@ bool bq27220_set_parameter_u16(FuriHalI2cBusHandle* handle, uint16_t address, ui ret = furi_hal_i2c_write_mem( handle, BQ27220_ADDRESS, CommandSelectSubclass, buffer, 4, BQ27220_I2C_TIMEOUT); - furi_hal_delay_us(10000); + furi_delay_us(10000); uint8_t checksum = bq27220_get_checksum(buffer, 4); buffer[0] = checksum; @@ -50,7 +49,7 @@ bool bq27220_set_parameter_u16(FuriHalI2cBusHandle* handle, uint16_t address, ui ret &= furi_hal_i2c_write_mem( handle, BQ27220_ADDRESS, CommandMACDataSum, buffer, 2, BQ27220_I2C_TIMEOUT); - furi_hal_delay_us(10000); + furi_delay_us(10000); return ret; } @@ -96,7 +95,7 @@ bool bq27220_init(FuriHalI2cBusHandle* handle, const ParamCEDV* cedv) { bq27220_set_parameter_u16(handle, AddressEDV2, cedv->EDV2); bq27220_control(handle, Control_EXIT_CFG_UPDATE_REINIT); - furi_hal_delay_us(10000); + furi_delay_us(10000); design_cap = bq27220_get_design_capacity(handle); if(cedv->design_cap == design_cap) { FURI_LOG_I(TAG, "Battery profile update success"); diff --git a/lib/drivers/cc1101.c b/lib/drivers/cc1101.c index a0c9d44a..f28165e8 100644 --- a/lib/drivers/cc1101.c +++ b/lib/drivers/cc1101.c @@ -1,6 +1,4 @@ #include "cc1101.h" -#include <cmsis_os2.h> -#include <furi_hal_delay.h> #include <assert.h> #include <string.h> diff --git a/lib/drivers/lp5562.c b/lib/drivers/lp5562.c index 7eef2a83..f5d765fa 100644 --- a/lib/drivers/lp5562.c +++ b/lib/drivers/lp5562.c @@ -1,5 +1,5 @@ #include "lp5562.h" -#include "furi/common_defines.h" +#include <core/common_defines.h> #include "lp5562_reg.h" #include <furi_hal.h> @@ -27,7 +27,7 @@ void lp5562_enable(FuriHalI2cBusHandle* handle) { Reg00_Enable reg = {.CHIP_EN = true, .LOG_EN = true}; furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, 0x00, *(uint8_t*)®, LP5562_I2C_TIMEOUT); //>488μs delay is required after writing to 0x00 register, otherwise program engine will not work - furi_hal_delay_us(500); + furi_delay_us(500); } void lp5562_set_channel_current(FuriHalI2cBusHandle* handle, LP5562Channel channel, uint8_t value) { @@ -127,7 +127,7 @@ void lp5562_execute_program( reg_val &= ~(0x3 << bit_offset); reg_val |= (0x01 << bit_offset); // load furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, 0x01, reg_val, LP5562_I2C_TIMEOUT); - furi_hal_delay_us(100); + furi_delay_us(100); // Program load for(uint8_t i = 0; i < 16; i++) { diff --git a/lib/flipper_format/flipper_format.c b/lib/flipper_format/flipper_format.c index df848ead..846129cd 100644 --- a/lib/flipper_format/flipper_format.c +++ b/lib/flipper_format/flipper_format.c @@ -1,4 +1,4 @@ -#include <furi/check.h> +#include <core/check.h> #include <toolbox/stream/stream.h> #include <toolbox/stream/string_stream.h> #include <toolbox/stream/file_stream.h> diff --git a/lib/flipper_format/flipper_format_stream.c b/lib/flipper_format/flipper_format_stream.c index 5c210536..81189b69 100644 --- a/lib/flipper_format/flipper_format_stream.c +++ b/lib/flipper_format/flipper_format_stream.c @@ -1,6 +1,6 @@ #include <inttypes.h> #include <toolbox/hex.h> -#include <furi/check.h> +#include <core/check.h> #include "flipper_format_stream.h" #include "flipper_format_stream_i.h" diff --git a/lib/freertos.scons b/lib/freertos.scons index 992c4f87..1c5a5bf5 100644 --- a/lib/freertos.scons +++ b/lib/freertos.scons @@ -20,7 +20,6 @@ libenv.ApplyLibFlags() sources = libenv.Glob("FreeRTOS-Kernel/*.c", source=True) sources += [ "FreeRTOS-Kernel/portable/GCC/ARM_CM4F/port.c", - "FreeRTOS-glue/cmsis_os2.c", ] lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources) diff --git a/lib/infrared/encoder_decoder/common/infrared_common_decoder.c b/lib/infrared/encoder_decoder/common/infrared_common_decoder.c index 1d944285..bff4c73d 100644 --- a/lib/infrared/encoder_decoder/common/infrared_common_decoder.c +++ b/lib/infrared/encoder_decoder/common/infrared_common_decoder.c @@ -1,5 +1,5 @@ -#include "furi/check.h" -#include "furi/common_defines.h" +#include <core/check.h> +#include <core/common_defines.h> #include "infrared.h" #include "infrared_common_i.h" #include <stdbool.h> diff --git a/lib/infrared/encoder_decoder/common/infrared_common_encoder.c b/lib/infrared/encoder_decoder/common/infrared_common_encoder.c index f755222d..dcf63acc 100644 --- a/lib/infrared/encoder_decoder/common/infrared_common_encoder.c +++ b/lib/infrared/encoder_decoder/common/infrared_common_encoder.c @@ -1,4 +1,4 @@ -#include "furi/check.h" +#include <core/check.h> #include "infrared.h" #include "infrared_common_i.h" #include <stdbool.h> diff --git a/lib/infrared/encoder_decoder/infrared.c b/lib/infrared/encoder_decoder/infrared.c index 59b11d5c..71bd6bb6 100644 --- a/lib/infrared/encoder_decoder/infrared.c +++ b/lib/infrared/encoder_decoder/infrared.c @@ -1,5 +1,5 @@ #include "infrared.h" -#include "furi/check.h" +#include <core/check.h> #include "common/infrared_common_i.h" #include "infrared_protocol_defs_i.h" #include <stdbool.h> diff --git a/lib/infrared/encoder_decoder/nec/infrared_encoder_nec.c b/lib/infrared/encoder_decoder/nec/infrared_encoder_nec.c index e1afae7b..d0039c33 100644 --- a/lib/infrared/encoder_decoder/nec/infrared_encoder_nec.c +++ b/lib/infrared/encoder_decoder/nec/infrared_encoder_nec.c @@ -1,4 +1,4 @@ -#include "furi/check.h" +#include <core/check.h> #include "infrared.h" #include "common/infrared_common_i.h" #include <stdint.h> diff --git a/lib/infrared/encoder_decoder/rc5/infrared_encoder_rc5.c b/lib/infrared/encoder_decoder/rc5/infrared_encoder_rc5.c index f063f7e5..7b55cdc4 100644 --- a/lib/infrared/encoder_decoder/rc5/infrared_encoder_rc5.c +++ b/lib/infrared/encoder_decoder/rc5/infrared_encoder_rc5.c @@ -1,4 +1,4 @@ -#include "furi/memmgr.h" +#include <core/memmgr.h> #include "infrared.h" #include "common/infrared_common_i.h" #include "infrared_protocol_defs_i.h" diff --git a/lib/infrared/encoder_decoder/rc6/infrared_encoder_rc6.c b/lib/infrared/encoder_decoder/rc6/infrared_encoder_rc6.c index 7d8ff975..f1240b17 100644 --- a/lib/infrared/encoder_decoder/rc6/infrared_encoder_rc6.c +++ b/lib/infrared/encoder_decoder/rc6/infrared_encoder_rc6.c @@ -1,4 +1,4 @@ -#include "furi/memmgr.h" +#include <core/memmgr.h> #include "infrared.h" #include "common/infrared_common_i.h" #include "infrared_protocol_defs_i.h" diff --git a/lib/infrared/encoder_decoder/samsung/infrared_encoder_samsung.c b/lib/infrared/encoder_decoder/samsung/infrared_encoder_samsung.c index 88745ff5..75b037f0 100644 --- a/lib/infrared/encoder_decoder/samsung/infrared_encoder_samsung.c +++ b/lib/infrared/encoder_decoder/samsung/infrared_encoder_samsung.c @@ -1,4 +1,4 @@ -#include "furi/check.h" +#include <core/check.h> #include "common/infrared_common_i.h" #include <stdint.h> #include "../infrared_i.h" diff --git a/lib/infrared/encoder_decoder/sirc/infrared_encoder_sirc.c b/lib/infrared/encoder_decoder/sirc/infrared_encoder_sirc.c index 8ae9e371..2c2bda1a 100644 --- a/lib/infrared/encoder_decoder/sirc/infrared_encoder_sirc.c +++ b/lib/infrared/encoder_decoder/sirc/infrared_encoder_sirc.c @@ -1,4 +1,4 @@ -#include "furi/check.h" +#include <core/check.h> #include "infrared.h" #include "common/infrared_common_i.h" #include <stdint.h> diff --git a/lib/infrared/worker/infrared_transmit.c b/lib/infrared/worker/infrared_transmit.c index d4c87ce5..695be8d1 100644 --- a/lib/infrared/worker/infrared_transmit.c +++ b/lib/infrared/worker/infrared_transmit.c @@ -4,7 +4,6 @@ #include <stddef.h> #include <furi.h> #include <furi_hal_infrared.h> -#include <furi_hal_delay.h> static uint32_t infrared_tx_number_of_transmissions = 0; static uint32_t infrared_tx_raw_timings_index = 0; diff --git a/lib/infrared/worker/infrared_worker.c b/lib/infrared/worker/infrared_worker.c index b24b7480..becd8d88 100644 --- a/lib/infrared/worker/infrared_worker.c +++ b/lib/infrared/worker/infrared_worker.c @@ -1,5 +1,5 @@ -#include "furi/check.h" -#include "furi/common_defines.h" +#include <core/check.h> +#include <core/common_defines.h> #include "sys/_stdint.h" #include "infrared_worker.h" #include <infrared.h> @@ -167,7 +167,7 @@ static int32_t infrared_worker_rx_thread(void* thread_context) { TickType_t last_blink_time = 0; while(1) { - events = furi_thread_flags_wait(INFRARED_WORKER_ALL_RX_EVENTS, 0, osWaitForever); + events = furi_thread_flags_wait(INFRARED_WORKER_ALL_RX_EVENTS, 0, FuriWaitForever); furi_check(events & INFRARED_WORKER_ALL_RX_EVENTS); /* at least one caught */ if(events & INFRARED_WORKER_RX_RECEIVED) { @@ -506,7 +506,7 @@ static int32_t infrared_worker_tx_thread(void* thread_context) { break; case InfraredWorkerStateRunTx: - events = furi_thread_flags_wait(INFRARED_WORKER_ALL_TX_EVENTS, 0, osWaitForever); + events = furi_thread_flags_wait(INFRARED_WORKER_ALL_TX_EVENTS, 0, FuriWaitForever); furi_check(events & INFRARED_WORKER_ALL_TX_EVENTS); /* at least one caught */ if(events & INFRARED_WORKER_EXIT) { diff --git a/lib/nfc_protocols/emv.c b/lib/nfc_protocols/emv.c index b69675fd..935c9f63 100644 --- a/lib/nfc_protocols/emv.c +++ b/lib/nfc_protocols/emv.c @@ -1,6 +1,6 @@ #include "emv.h" -#include <furi/common_defines.h> +#include <core/common_defines.h> #define TAG "Emv" diff --git a/lib/one_wire/ibutton/encoder/encoder_cyfral.c b/lib/one_wire/ibutton/encoder/encoder_cyfral.c index f6cbe630..0b506b2b 100644 --- a/lib/one_wire/ibutton/encoder/encoder_cyfral.c +++ b/lib/one_wire/ibutton/encoder/encoder_cyfral.c @@ -2,7 +2,7 @@ #include <furi_hal.h> #define CYFRAL_DATA_SIZE sizeof(uint16_t) -#define CYFRAL_PERIOD (125 * furi_hal_delay_instructions_per_microsecond()) +#define CYFRAL_PERIOD (125 * furi_hal_cortex_instructions_per_microsecond()) #define CYFRAL_0_LOW (CYFRAL_PERIOD * 0.66f) #define CYFRAL_0_HI (CYFRAL_PERIOD * 0.33f) #define CYFRAL_1_LOW (CYFRAL_PERIOD * 0.33f) diff --git a/lib/one_wire/ibutton/encoder/encoder_metakom.c b/lib/one_wire/ibutton/encoder/encoder_metakom.c index 3b597e7c..5b978ebe 100644 --- a/lib/one_wire/ibutton/encoder/encoder_metakom.c +++ b/lib/one_wire/ibutton/encoder/encoder_metakom.c @@ -2,7 +2,7 @@ #include <furi_hal.h> #define METAKOM_DATA_SIZE sizeof(uint32_t) -#define METAKOM_PERIOD (125 * furi_hal_delay_instructions_per_microsecond()) +#define METAKOM_PERIOD (125 * furi_hal_cortex_instructions_per_microsecond()) #define METAKOM_0_LOW (METAKOM_PERIOD * 0.33f) #define METAKOM_0_HI (METAKOM_PERIOD * 0.66f) #define METAKOM_1_LOW (METAKOM_PERIOD * 0.66f) diff --git a/lib/one_wire/ibutton/ibutton_worker.c b/lib/one_wire/ibutton/ibutton_worker.c index 82c3d688..755ed32f 100644 --- a/lib/one_wire/ibutton/ibutton_worker.c +++ b/lib/one_wire/ibutton/ibutton_worker.c @@ -32,7 +32,7 @@ iButtonWorker* ibutton_worker_alloc() { worker->pulse_decoder = pulse_decoder_alloc(); worker->protocol_cyfral = protocol_cyfral_alloc(); worker->protocol_metakom = protocol_metakom_alloc(); - worker->messages = osMessageQueueNew(1, sizeof(iButtonMessage), NULL); + worker->messages = furi_message_queue_alloc(1, sizeof(iButtonMessage)); worker->mode_index = iButtonWorkerIdle; worker->last_dwt_value = 0; worker->read_cb = NULL; @@ -90,22 +90,26 @@ void ibutton_worker_emulate_set_callback( void ibutton_worker_read_start(iButtonWorker* worker, iButtonKey* key) { iButtonMessage message = {.type = iButtonMessageRead, .data.key = key}; - furi_check(osMessageQueuePut(worker->messages, &message, 0, osWaitForever) == osOK); + furi_check( + furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_write_start(iButtonWorker* worker, iButtonKey* key) { iButtonMessage message = {.type = iButtonMessageWrite, .data.key = key}; - furi_check(osMessageQueuePut(worker->messages, &message, 0, osWaitForever) == osOK); + furi_check( + furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_emulate_start(iButtonWorker* worker, iButtonKey* key) { iButtonMessage message = {.type = iButtonMessageEmulate, .data.key = key}; - furi_check(osMessageQueuePut(worker->messages, &message, 0, osWaitForever) == osOK); + furi_check( + furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_stop(iButtonWorker* worker) { iButtonMessage message = {.type = iButtonMessageStop}; - furi_check(osMessageQueuePut(worker->messages, &message, 0, osWaitForever) == osOK); + furi_check( + furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_free(iButtonWorker* worker) { @@ -123,7 +127,7 @@ void ibutton_worker_free(iButtonWorker* worker) { encoder_cyfral_free(worker->encoder_cyfral); encoder_metakom_free(worker->encoder_metakom); - osMessageQueueDelete(worker->messages); + furi_message_queue_free(worker->messages); furi_thread_free(worker->thread); free(worker->key_data); @@ -136,7 +140,8 @@ void ibutton_worker_start_thread(iButtonWorker* worker) { void ibutton_worker_stop_thread(iButtonWorker* worker) { iButtonMessage message = {.type = iButtonMessageEnd}; - furi_check(osMessageQueuePut(worker->messages, &message, 0, osWaitForever) == osOK); + furi_check( + furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); furi_thread_join(worker->thread); } @@ -148,7 +153,7 @@ void ibutton_worker_switch_mode(iButtonWorker* worker, iButtonWorkerMode mode) { void ibutton_worker_notify_emulate(iButtonWorker* worker) { iButtonMessage message = {.type = iButtonMessageNotifyEmulate}; - furi_check(osMessageQueuePut(worker->messages, &message, 0, 0) == osOK); + furi_check(furi_message_queue_put(worker->messages, &message, 0) == FuriStatusOk); } void ibutton_worker_set_key_p(iButtonWorker* worker, iButtonKey* key) { @@ -159,14 +164,14 @@ static int32_t ibutton_worker_thread(void* thread_context) { iButtonWorker* worker = thread_context; bool running = true; iButtonMessage message; - osStatus_t status; + FuriStatus status; ibutton_worker_modes[worker->mode_index].start(worker); while(running) { - status = osMessageQueueGet( - worker->messages, &message, NULL, ibutton_worker_modes[worker->mode_index].quant); - if(status == osOK) { + status = furi_message_queue_get( + worker->messages, &message, ibutton_worker_modes[worker->mode_index].quant); + if(status == FuriStatusOk) { switch(message.type) { case iButtonMessageEnd: ibutton_worker_switch_mode(worker, iButtonWorkerIdle); @@ -195,7 +200,7 @@ static int32_t ibutton_worker_thread(void* thread_context) { } break; } - } else if(status == osErrorTimeout) { + } else if(status == FuriStatusErrorTimeout) { ibutton_worker_modes[worker->mode_index].tick(worker); } else { furi_crash("iButton worker error"); diff --git a/lib/one_wire/ibutton/ibutton_worker_i.h b/lib/one_wire/ibutton/ibutton_worker_i.h index 48d03595..28588443 100644 --- a/lib/one_wire/ibutton/ibutton_worker_i.h +++ b/lib/one_wire/ibutton/ibutton_worker_i.h @@ -52,7 +52,7 @@ struct iButtonWorker { OneWireDevice* device; iButtonWriter* writer; iButtonWorkerMode mode_index; - osMessageQueueId_t messages; + FuriMessageQueue* messages; FuriThread* thread; PulseDecoder* pulse_decoder; diff --git a/lib/one_wire/ibutton/ibutton_worker_modes.c b/lib/one_wire/ibutton/ibutton_worker_modes.c index 5ee76862..78e05d0e 100644 --- a/lib/one_wire/ibutton/ibutton_worker_modes.c +++ b/lib/one_wire/ibutton/ibutton_worker_modes.c @@ -21,7 +21,7 @@ void ibutton_worker_mode_write_stop(iButtonWorker* worker); const iButtonWorkerModeType ibutton_worker_modes[] = { { - .quant = osWaitForever, + .quant = FuriWaitForever, .start = ibutton_worker_mode_idle_start, .tick = ibutton_worker_mode_idle_tick, .stop = ibutton_worker_mode_idle_stop, @@ -86,7 +86,7 @@ bool ibutton_worker_read_comparator(iButtonWorker* worker) { furi_hal_rfid_comp_start(); // TODO: rework with thread events, "pulse_decoder_get_decoded_index_with_timeout" - furi_hal_delay_ms(100); + furi_delay_ms(100); int32_t decoded_index = pulse_decoder_get_decoded_index(worker->pulse_decoder); if(decoded_index >= 0) { pulse_decoder_get_data( @@ -121,7 +121,7 @@ bool ibutton_worker_read_comparator(iButtonWorker* worker) { bool ibutton_worker_read_dallas(iButtonWorker* worker) { bool result = false; onewire_host_start(worker->host); - furi_hal_delay_ms(100); + furi_delay_ms(100); FURI_CRITICAL_ENTER(); if(onewire_host_search(worker->host, worker->key_data, NORMAL_SEARCH)) { onewire_host_reset_search(worker->host); diff --git a/lib/one_wire/ibutton/ibutton_writer.c b/lib/one_wire/ibutton/ibutton_writer.c index fe19db71..203c4fc0 100644 --- a/lib/one_wire/ibutton/ibutton_writer.c +++ b/lib/one_wire/ibutton/ibutton_writer.c @@ -11,13 +11,13 @@ struct iButtonWriter { static void writer_write_one_bit(iButtonWriter* writer, bool value, uint32_t delay) { onewire_host_write_bit(writer->host, value); - furi_hal_delay_us(delay); + furi_delay_us(delay); } static void writer_write_byte_ds1990(iButtonWriter* writer, uint8_t data) { for(uint8_t n_bit = 0; n_bit < 8; n_bit++) { onewire_host_write_bit(writer->host, data & 1); - furi_hal_delay_us(5000); + furi_delay_us(5000); data = data >> 1; } } @@ -68,7 +68,7 @@ static bool writer_write_TM2004(iButtonWriter* writer, iButtonKey* key) { // TODO: check answer CRC // pulse indicating that data is correct - furi_hal_delay_us(600); + furi_delay_us(600); writer_write_one_bit(writer, 1, 50000); // read written key byte @@ -104,7 +104,7 @@ static bool writer_write_1990_1(iButtonWriter* writer, iButtonKey* key) { // unlock onewire_host_reset(writer->host); onewire_host_write(writer->host, RW1990_1_CMD_WRITE_RECORD_FLAG); - furi_hal_delay_us(10); + furi_delay_us(10); writer_write_one_bit(writer, 0, 5000); // write key @@ -113,7 +113,7 @@ static bool writer_write_1990_1(iButtonWriter* writer, iButtonKey* key) { for(uint8_t i = 0; i < ibutton_key_get_data_size(key); i++) { // inverted key for RW1990.1 writer_write_byte_ds1990(writer, ~ibutton_key_get_data_p(key)[i]); - furi_hal_delay_us(30000); + furi_delay_us(30000); } // lock @@ -139,7 +139,7 @@ static bool writer_write_1990_2(iButtonWriter* writer, iButtonKey* key) { // unlock onewire_host_reset(writer->host); onewire_host_write(writer->host, RW1990_2_CMD_WRITE_RECORD_FLAG); - furi_hal_delay_us(10); + furi_delay_us(10); writer_write_one_bit(writer, 1, 5000); // write key @@ -147,7 +147,7 @@ static bool writer_write_1990_2(iButtonWriter* writer, iButtonKey* key) { onewire_host_write(writer->host, RW1990_2_CMD_WRITE_ROM); for(uint8_t i = 0; i < ibutton_key_get_data_size(key); i++) { writer_write_byte_ds1990(writer, ibutton_key_get_data_p(key)[i]); - furi_hal_delay_us(30000); + furi_delay_us(30000); } // lock @@ -191,7 +191,7 @@ static bool writer_write_TM01( //} else { for(uint8_t i = 0; i < key->get_type_data_size(); i++) { write_byte_ds1990(key->get_data()[i]); - furi_hal_delay_us(10000); + furi_delay_us(10000); } //} @@ -271,9 +271,9 @@ void ibutton_writer_free(iButtonWriter* writer) { iButtonWriterResult ibutton_writer_write(iButtonWriter* writer, iButtonKey* key) { iButtonWriterResult result = iButtonWriterNoDetect; - osKernelLock(); + furi_kernel_lock(); bool blank_present = onewire_host_reset(writer->host); - osKernelUnlock(); + furi_kernel_unlock(); if(blank_present) { switch(ibutton_key_get_type(key)) { diff --git a/lib/one_wire/ibutton/pulse_protocols/protocol_cyfral.c b/lib/one_wire/ibutton/pulse_protocols/protocol_cyfral.c index a992f00d..7c289790 100644 --- a/lib/one_wire/ibutton/pulse_protocols/protocol_cyfral.c +++ b/lib/one_wire/ibutton/pulse_protocols/protocol_cyfral.c @@ -1,8 +1,8 @@ #include "protocol_cyfral.h" #include <stdlib.h> #include <string.h> -#include <furi/check.h> -#include <furi_hal_delay.h> +#include <furi.h> +#include <furi_hal.h> #define CYFRAL_DATA_SIZE 2 #define CYFRAL_MAX_PERIOD_US 230 @@ -104,7 +104,7 @@ static void cyfral_reset(void* context) { cyfral->nibble = 0; cyfral->data_valid = true; - cyfral->max_period = CYFRAL_MAX_PERIOD_US * furi_hal_delay_instructions_per_microsecond(); + cyfral->max_period = CYFRAL_MAX_PERIOD_US * furi_hal_cortex_instructions_per_microsecond(); } static bool cyfral_process_bit( diff --git a/lib/one_wire/ibutton/pulse_protocols/protocol_metakom.c b/lib/one_wire/ibutton/pulse_protocols/protocol_metakom.c index d76ef886..9df9e20b 100644 --- a/lib/one_wire/ibutton/pulse_protocols/protocol_metakom.c +++ b/lib/one_wire/ibutton/pulse_protocols/protocol_metakom.c @@ -1,8 +1,7 @@ #include "protocol_metakom.h" #include <stdlib.h> #include <string.h> -#include <furi/check.h> -#include <furi_hal_delay.h> +#include <core/check.h> #define METAKOM_DATA_SIZE 4 #define METAKOM_PERIOD_SAMPLE_COUNT 10 diff --git a/lib/one_wire/one_wire_host.c b/lib/one_wire/one_wire_host.c index 1bb0a1cc..654b9e45 100644 --- a/lib/one_wire/one_wire_host.c +++ b/lib/one_wire/one_wire_host.c @@ -31,23 +31,23 @@ bool onewire_host_reset(OneWireHost* host) { furi_hal_ibutton_pin_high(); do { if(--retries == 0) return 0; - furi_hal_delay_us(2); + furi_delay_us(2); } while(!furi_hal_ibutton_pin_get_level()); // pre delay - furi_hal_delay_us(OWH_RESET_DELAY_PRE); + furi_delay_us(OWH_RESET_DELAY_PRE); // drive low furi_hal_ibutton_pin_low(); - furi_hal_delay_us(OWH_RESET_DRIVE); + furi_delay_us(OWH_RESET_DRIVE); // release furi_hal_ibutton_pin_high(); - furi_hal_delay_us(OWH_RESET_RELEASE); + furi_delay_us(OWH_RESET_RELEASE); // read and post delay r = !furi_hal_ibutton_pin_get_level(); - furi_hal_delay_us(OWH_RESET_DELAY_POST); + furi_delay_us(OWH_RESET_DELAY_POST); return r; } @@ -58,15 +58,15 @@ bool onewire_host_read_bit(OneWireHost* host) { // drive low furi_hal_ibutton_pin_low(); - furi_hal_delay_us(OWH_READ_DRIVE); + furi_delay_us(OWH_READ_DRIVE); // release furi_hal_ibutton_pin_high(); - furi_hal_delay_us(OWH_READ_RELEASE); + furi_delay_us(OWH_READ_RELEASE); // read and post delay result = furi_hal_ibutton_pin_get_level(); - furi_hal_delay_us(OWH_READ_DELAY_POST); + furi_delay_us(OWH_READ_DELAY_POST); return result; } @@ -94,19 +94,19 @@ void onewire_host_write_bit(OneWireHost* host, bool value) { if(value) { // drive low furi_hal_ibutton_pin_low(); - furi_hal_delay_us(OWH_WRITE_1_DRIVE); + furi_delay_us(OWH_WRITE_1_DRIVE); // release furi_hal_ibutton_pin_high(); - furi_hal_delay_us(OWH_WRITE_1_RELEASE); + furi_delay_us(OWH_WRITE_1_RELEASE); } else { // drive low furi_hal_ibutton_pin_low(); - furi_hal_delay_us(OWH_WRITE_0_DRIVE); + furi_delay_us(OWH_WRITE_0_DRIVE); // release furi_hal_ibutton_pin_high(); - furi_hal_delay_us(OWH_WRITE_0_RELEASE); + furi_delay_us(OWH_WRITE_0_RELEASE); } } diff --git a/lib/one_wire/one_wire_slave.c b/lib/one_wire/one_wire_slave.c index 1f389623..af04cfda 100644 --- a/lib/one_wire/one_wire_slave.c +++ b/lib/one_wire/one_wire_slave.c @@ -2,8 +2,7 @@ #include "one_wire_slave_i.h" #include "one_wire_device.h" #include <furi.h> -#include <furi_hal_delay.h> -#include <furi_hal_ibutton.h> +#include <furi_hal.h> #define OWS_RESET_MIN 270 #define OWS_RESET_MAX 960 @@ -39,14 +38,14 @@ struct OneWireSlave { uint32_t onewire_slave_wait_while_gpio_is(OneWireSlave* bus, uint32_t time, const bool pin_value) { UNUSED(bus); uint32_t start = DWT->CYCCNT; - uint32_t time_ticks = time * furi_hal_delay_instructions_per_microsecond(); + uint32_t time_ticks = time * furi_hal_cortex_instructions_per_microsecond(); uint32_t time_captured; do { time_captured = DWT->CYCCNT; if(furi_hal_ibutton_pin_get_level() != pin_value) { uint32_t remaining_time = time_ticks - (time_captured - start); - remaining_time /= furi_hal_delay_instructions_per_microsecond(); + remaining_time /= furi_hal_cortex_instructions_per_microsecond(); return remaining_time; } } while((time_captured - start) < time_ticks); @@ -60,7 +59,7 @@ bool onewire_slave_show_presence(OneWireSlave* bus) { // show presence furi_hal_ibutton_pin_low(); - furi_hal_delay_us(OWS_PRESENCE_MIN); + furi_delay_us(OWS_PRESENCE_MIN); furi_hal_ibutton_pin_high(); // somebody also can show presence @@ -127,7 +126,7 @@ bool onewire_slave_send_bit(OneWireSlave* bus, bool value) { } // hold line for ZERO or ONE time - furi_hal_delay_us(time); + furi_delay_us(time); furi_hal_ibutton_pin_high(); return true; @@ -213,7 +212,7 @@ static void exti_cb(void* context) { if(input_state) { uint32_t pulse_length = - (DWT->CYCCNT - pulse_start) / furi_hal_delay_instructions_per_microsecond(); + (DWT->CYCCNT - pulse_start) / furi_hal_cortex_instructions_per_microsecond(); if(pulse_length >= OWS_RESET_MIN) { if(pulse_length <= OWS_RESET_MAX) { // reset cycle ok diff --git a/lib/one_wire/pulse_protocols/pulse_decoder.c b/lib/one_wire/pulse_protocols/pulse_decoder.c index e8197a08..c7d3b09e 100644 --- a/lib/one_wire/pulse_protocols/pulse_decoder.c +++ b/lib/one_wire/pulse_protocols/pulse_decoder.c @@ -1,7 +1,7 @@ #include <stdlib.h> #include "pulse_decoder.h" #include <string.h> -#include <furi/check.h> +#include <core/check.h> #define MAX_PROTOCOL 5 diff --git a/lib/subghz/blocks/encoder.c b/lib/subghz/blocks/encoder.c index 3cefc2c1..f3349b5f 100644 --- a/lib/subghz/blocks/encoder.c +++ b/lib/subghz/blocks/encoder.c @@ -1,6 +1,6 @@ #include "encoder.h" #include "math.h" -#include <furi/check.h> +#include <core/check.h> #define TAG "SubGhzBlockEncoder" @@ -42,4 +42,4 @@ size_t subghz_protocol_blocks_get_upload( upload[size_upload++] = level_duration_make( subghz_protocol_blocks_get_bit_array(data_array, index_bit - 1), duration); return size_upload; -}
\ No newline at end of file +} diff --git a/lib/subghz/protocols/princeton_for_testing.c b/lib/subghz/protocols/princeton_for_testing.c index 5c3f7151..43078d2e 100644 --- a/lib/subghz/protocols/princeton_for_testing.c +++ b/lib/subghz/protocols/princeton_for_testing.c @@ -76,9 +76,8 @@ void subghz_encoder_princeton_for_testing_set( instance->count_key = instance->count_key_package + 3; - if((furi_hal_get_tick() - instance->time_stop) < instance->timeout) { - instance->time_stop = - (instance->timeout - (furi_hal_get_tick() - instance->time_stop)) * 1000; + if((furi_get_tick() - instance->time_stop) < instance->timeout) { + instance->time_stop = (instance->timeout - (furi_get_tick() - instance->time_stop)) * 1000; } else { instance->time_stop = 0; } diff --git a/lib/subghz/protocols/raw.c b/lib/subghz/protocols/raw.c index 516aa633..ebc84c11 100644 --- a/lib/subghz/protocols/raw.c +++ b/lib/subghz/protocols/raw.c @@ -287,7 +287,7 @@ static bool subghz_protocol_encoder_raw_worker_init(SubGhzProtocolEncoderRAW* in if(subghz_file_encoder_worker_start( instance->file_worker_encoder, string_get_cstr(instance->file_name))) { //the worker needs a file in order to open and read part of the file - osDelay(100); + furi_delay_ms(100); instance->is_runing = true; } else { subghz_protocol_encoder_raw_stop(instance); diff --git a/lib/subghz/subghz_file_encoder_worker.c b/lib/subghz/subghz_file_encoder_worker.c index 0ec4c861..457c8b02 100644 --- a/lib/subghz/subghz_file_encoder_worker.c +++ b/lib/subghz/subghz_file_encoder_worker.c @@ -153,19 +153,19 @@ static int32_t subghz_file_encoder_worker_thread(void* context) { break; } } - osDelay(5); + furi_delay_ms(5); } //waiting for the end of the transfer FURI_LOG_I(TAG, "End read file"); while(!furi_hal_subghz_is_async_tx_complete() && instance->worker_running) { - osDelay(5); + furi_delay_ms(5); } FURI_LOG_I(TAG, "End transmission"); while(instance->worker_running) { if(instance->worker_stoping) { if(instance->callback_end) instance->callback_end(instance->context_end); } - osDelay(50); + furi_delay_ms(50); } flipper_format_file_close(instance->flipper_format); diff --git a/lib/subghz/subghz_tx_rx_worker.c b/lib/subghz/subghz_tx_rx_worker.c index 0f687f15..74a6183c 100644 --- a/lib/subghz/subghz_tx_rx_worker.c +++ b/lib/subghz/subghz_tx_rx_worker.c @@ -68,11 +68,11 @@ bool subghz_tx_rx_worker_rx(SubGhzTxRxWorker* instance, uint8_t* data, uint8_t* if(instance->status != SubGhzTxRxWorkerStatusRx) { furi_hal_subghz_rx(); instance->status = SubGhzTxRxWorkerStatusRx; - osDelay(1); + furi_delay_tick(1); } //waiting for reception to complete while(furi_hal_gpio_read(&gpio_cc1101_g0)) { - osDelay(1); + furi_delay_tick(1); if(!--timeout) { FURI_LOG_W(TAG, "RX cc1101_g0 timeout"); furi_hal_subghz_flush_rx(); @@ -106,14 +106,14 @@ void subghz_tx_rx_worker_tx(SubGhzTxRxWorker* instance, uint8_t* data, size_t si furi_hal_subghz_tx(); //start send instance->status = SubGhzTxRxWorkerStatusTx; while(!furi_hal_gpio_read(&gpio_cc1101_g0)) { // Wait for GDO0 to be set -> sync transmitted - osDelay(1); + furi_delay_tick(1); if(!--timeout) { FURI_LOG_W(TAG, "TX !cc1101_g0 timeout"); break; } } while(furi_hal_gpio_read(&gpio_cc1101_g0)) { // Wait for GDO0 to be cleared -> end of packet - osDelay(1); + furi_delay_tick(1); if(!--timeout) { FURI_LOG_W(TAG, "TX cc1101_g0 timeout"); break; @@ -189,7 +189,7 @@ static int32_t subghz_tx_rx_worker_thread(void* context) { } if(timeout_tx) timeout_tx--; - osDelay(1); + furi_delay_tick(1); } furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate); diff --git a/lib/toolbox/stream/stream.c b/lib/toolbox/stream/stream.c index 982c4983..088996f0 100644 --- a/lib/toolbox/stream/stream.c +++ b/lib/toolbox/stream/stream.c @@ -1,8 +1,8 @@ #include "stream.h" #include "stream_i.h" #include "file_stream.h" -#include <furi/check.h> -#include <furi/common_defines.h> +#include <core/check.h> +#include <core/common_defines.h> void stream_free(Stream* stream) { furi_assert(stream); diff --git a/lib/toolbox/stream/string_stream.c b/lib/toolbox/stream/string_stream.c index 3244b7ba..f3e1364d 100644 --- a/lib/toolbox/stream/string_stream.c +++ b/lib/toolbox/stream/string_stream.c @@ -1,7 +1,7 @@ #include "stream.h" #include "stream_i.h" #include "string_stream.h" -#include <furi/common_defines.h> +#include <core/common_defines.h> typedef struct { Stream stream_base; diff --git a/lib/toolbox/tar/tar_archive.c b/lib/toolbox/tar/tar_archive.c index 91d2c812..cc107530 100644 --- a/lib/toolbox/tar/tar_archive.c +++ b/lib/toolbox/tar/tar_archive.c @@ -213,7 +213,7 @@ static int archive_extract_foreach_cb(mtar_t* tar, const mtar_header_t* header, } FURI_LOG_W(TAG, "Failed to open '%s', reties: %d", string_get_cstr(fname), n_tries); storage_file_close(out_file); - osDelay(FILE_OPEN_RETRY_DELAY); + furi_delay_ms(FILE_OPEN_RETRY_DELAY); } if(!storage_file_is_open(out_file)) { @@ -265,7 +265,7 @@ bool tar_archive_add_file( } FURI_LOG_W(TAG, "Failed to open '%s', reties: %d", fs_file_path, n_tries); storage_file_close(src_file); - osDelay(FILE_OPEN_RETRY_DELAY); + furi_delay_ms(FILE_OPEN_RETRY_DELAY); } if(!storage_file_is_open(src_file) || diff --git a/lib/u8g2/u8g2_glue.c b/lib/u8g2/u8g2_glue.c index 33d30f29..77f37f14 100644 --- a/lib/u8g2/u8g2_glue.c +++ b/lib/u8g2/u8g2_glue.c @@ -10,10 +10,10 @@ uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, vo /* HAL initialization contains all what we need so we can skip this part. */ break; case U8X8_MSG_DELAY_MILLI: - furi_hal_delay_ms(arg_int); + furi_delay_ms(arg_int); break; case U8X8_MSG_DELAY_10MICRO: - furi_hal_delay_us(10); + furi_delay_us(10); break; case U8X8_MSG_DELAY_100NANO: asm("nop"); |