安信可(云知声蜂鸟US516P6)SDK开发学习---freertos os接口函数封装管理

news/2025/1/11 2:28:58/

安信可(云知声蜂鸟US516P6)SDK开发学习—freertos os接口函数封装管理

线程,互斥锁,、延时函数,任务优先级定义,线程栈定义

#define uni_usleep(us)                    vTaskDelay(((us)/1001 + 1) / portTICK_PERIOD_MS)
#define uni_msleep(ms)                    vTaskDelay((ms) / portTICK_PERIOD_MS)
#define uni_sleep(s)                      vTaskDelay(((s) * 1000) / portTICK_PERIOD_MS)#define uni_sem_t                         SemaphoreHandle_t
int uni_sem_init(uni_sem_t *sem, unsigned int value);
#define uni_sem_post(sem_ptr)             xSemaphoreGive(sem_ptr)
#define uni_sem_post_isr(sem_ptr, ptr)    xSemaphoreGiveFromISR(sem_ptr, ptr)
#define uni_sem_isr_yield(is)             portEND_SWITCHING_ISR(is)
#define uni_sem_wait(sem_ptr)             xSemaphoreTake(sem_ptr, portMAX_DELAY)
#define uni_sem_wait_ms(sem_ptr, ms)      xSemaphoreTake(sem_ptr, (ms)/portTICK_PERIOD_MS)
#define uni_sem_destroy(sem_ptr)          vSemaphoreDelete(sem_ptr)/* THREAD STACK SIZE */
#define STACK_SIZE                        256               // 1KB (freeRTOS unit is word - 4 bytes)
#define STACK_SMALL_SIZE                  (STACK_SIZE * 1)  // 1KB
#define STACK_NORMAL_SIZE                 (STACK_SIZE * 2)  // 2kB
#define STACK_MIDDLE_SIZE                 (STACK_SIZE * 3)  // 3kB
#define STACK_LARGE_SIZE                  (STACK_SIZE * 4)  // 4kB/* TASK PRIORITY */
#define OS_PRIORITY_IDLE                  tskIDLE_PRIORITY            //idle (lowest)
#define OS_PRIORITY_LOW                   (tskIDLE_PRIORITY + 1)      //low
#define OS_PRIORITY_NORMAL                (tskIDLE_PRIORITY + 2)      //normal
#define OS_PRIORITY_HIGH                  (tskIDLE_PRIORITY + 3)      //high
#define OS_PRIORITY_REALTIME              (configMAX_PRIORITIES - 1)  //realtime (highest)typedef struct  {uni_u32 stack_size;uni_u32 priority;char task_name[16];
}thread_param;
typedef void (*start_routine)(void *);
#define uni_pthread_t                     TaskHandle_t
#define uni_pthread_id()                  xTaskGetCurrentTaskHandle()
int uni_pthread_create(uni_pthread_t *thread, thread_param *para,start_routine task_func, void* arg);
#define uni_pthread_detach(th)            
#define uni_pthread_destroy(th)           vTaskDelete(th)#define uni_mutex_t                       SemaphoreHandle_t
int uni_pthread_mutex_init(uni_mutex_t *mutex);
#define uni_pthread_mutex_destroy(mtx_ptr) \vSemaphoreDelete(mtx_ptr)
#define uni_pthread_mutex_lock(mtx_ptr)    \xSemaphoreTake(mtx_ptr, portMAX_DELAY)
#define uni_pthread_mutex_unlock(mtx_ptr)  \xSemaphoreGive(mtx_ptr)static inline uni_u64 uni_get_clock_time_ms(void) {TickType_t xTicks = xTaskGetTickCount();return xTicks * portTICK_RATE_MS;
}static inline uni_u32 uni_get_clock_time_sec(void) {TickType_t xTicks = xTaskGetTickCount();return xTicks / configTICK_RATE_HZ;
}
FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.
使用版本如上

具体配置文件如下:

#define configUSE_PREEMPTION			1
#define configUSE_IDLE_HOOK			1
#define configUSE_TICK_HOOK			0
#define configCPU_CLOCK_HZ			( ( unsigned long ) 120000000)
#define configTICK_RATE_HZ			( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES			(  10 )
#define configMINIMAL_STACK_SIZE		( ( uint16_t ) 512 )
#define configTOTAL_HEAP_SIZE			( ( size_t ) ( 37 * 1024 ) )
#define configMAX_TASK_NAME_LEN			( 16 )
#define configUSE_TRACE_FACILITY		1
#define configUSE_16_BIT_TICKS			0
#define configIDLE_SHOULD_YIELD			1
#define configUSE_MUTEXES			1
#define configQUEUE_REGISTRY_SIZE		8
#define configCHECK_FOR_STACK_OVERFLOW	        0
#define configUSE_RECURSIVE_MUTEXES		1
#define configUSE_MALLOC_FAILED_HOOK	        0
#define configUSE_APPLICATION_TASK_TAG	        0
#define configUSE_COUNTING_SEMAPHORES	        1
#define configGENERATE_RUN_TIME_STATS	        1
#define configSUPPORT_ZOL                       1/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 		        0
#define configMAX_CO_ROUTINE_PRIORITIES        ( 2 )/* Software timer definitions. */
#define configUSE_TIMERS			0
#define configTIMER_TASK_PRIORITY		( 2 )
#define configTIMER_QUEUE_LENGTH		10
#define configTIMER_TASK_STACK_DEPTH	        ( configMINIMAL_STACK_SIZE * 2 )/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet		1
#define INCLUDE_uxTaskPriorityGet		1
#define INCLUDE_vTaskDelete			1
#define INCLUDE_vTaskCleanUpResources	        0
#define INCLUDE_vTaskSuspend			0
#define INCLUDE_vTaskDelayUntil			1
#define INCLUDE_vTaskDelay			1
#define INCLUDE_xTaskGetSchedulerState          1
#define INCLUDE_pcTaskGetTaskName 1#define configPRIO_BITS       		2        /* 4 priority levels *//* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY			0xf/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY	5/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
//#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )//0�������л�ʱ�ر������ж�   1�������л�ʱ�ر��ж����ȼ�Ϊ1��2��3���ж�  2�������л�ʱ�ر��ж����ȼ�Ϊ2��3���ж�  3�������л�ʱ�ر��ж����ȼ�Ϊ3���ж�
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	0/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
//#define vPortSVCHandler SVC_Handler
//#define xPortPendSVHandler PendSV_Handler/* IMPORTANT: This define MUST be commented when used with STM32Cube firmware,to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
/* #define xPortSysTickHandler SysTick_Handler */#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE()	xTickCount#define INCLUDE_xSemaphoreGetMutexHolder 1#define traceTASK_DELETE DeleteTaskMallocMem//#define use_MCPS_ANALYSIS
#ifdef use_MCPS_ANALYSIS
#define traceTASK_SWITCHED_IN()  trace_TASK_SWITCHED_IN()
#define traceTASK_SWITCHED_OUT() trace_TASK_SWITCHED_OUT()
#endif#endif /* FREERTOS_CONFIG_H */

http://www.ppmy.cn/news/87448.html

相关文章

B站动态自检方法1 bilibili应用自检

文章目录 相关地址注意事项主要流程假设你的 IP:192.188.0.100端口必须设置&#xff1a;8899一、电脑设置代理1、查看IP2、电脑设置代理 二、手机配置代理三、安装证书四、启动动态自检方式11、点击开启动态检测2、按测试流程进行测试&#xff1a;3、完成自测后&#xff0c;点击…

vue3选项式API

私人博客 许小墨のBlog —— 菜鸡博客直通车 系列文章完整版&#xff0c;配图更多&#xff0c;CSDN博文图片需要手动上传&#xff0c;因此文章配图较少&#xff0c;看不懂的可以去菜鸡博客参考一下配图&#xff01; 系列文章目录 前端系列文章——传送门 后端系列文章——传送…

ChatGPT 4.0大升级,能替代留学中介吗?

ChatGPT4.0发布了&#xff01; 在之前轰动世界版本的基础上又有了大幅度升级&#xff0c;根据官方介绍&#xff0c;它的输入可以是文字&#xff08;上限2.5万字&#xff09;还可以是图像&#xff0c;是一个超大的多模态模型。 越来越多的人开始好奇这个东西到底能用来做什么&…

MyBatis-Plus 可视化代码生成器来啦,生产力直接拉满

在基于Mybatis的开发模式中&#xff0c;很多开发者还会选择Mybatis-Plus来辅助功能开发&#xff0c;以此提高开发的效率。虽然Mybatis也有代码生成的工具&#xff0c;但Mybatis-Plus由于在Mybatis基础上做了一些调整&#xff0c;因此&#xff0c;常规的生成工具生成的代码还有一…

C++设计模式学习(二)

模板方法 GOF-23模式分类 从目的来看: 创建型(Creational)模式:将对象的部分创建工作延迟到子类或者其他对象,从而应对需求变化为对象创建时具体类型实现引来的冲击。结构型(Structural)模式:通过类继承或者对象组合获得更灵活的结构,从而应对需求变化为对象的结构带来的冲击…

2023电工杯数学建模B题思路模型代码

占个位置吧&#xff0c;开始在本帖实时更新电工杯数学建模赛题思路代码&#xff0c;文章末尾获取&#xff01; B题思路分析 B题就是一个评价类的题目&#xff0c;整体难度就远低于A题了&#xff0c;这个题目主要是评估人工智能对大学生学习的影响。我们需要先对提供的数据进行…

PyTorch-Forecasting一个新的时间序列预测库

时间序列预测在金融、天气预报、销售预测和需求预测等各个领域发挥着至关重要的作用。PyTorch- forecasting是一个建立在PyTorch之上的开源Python包&#xff0c;专门用于简化和增强时间序列的工作。在本文中我们介绍PyTorch-Forecasting的特性和功能&#xff0c;并进行示例代码…

2023电工杯数学建模A题B题

占个位置吧&#xff0c;开始在本帖实时更新电工杯数学建模赛题思路代码&#xff0c;文章末尾获取&#xff01; A题思路分析 问题一&#xff1a;1典型住户电采暖负荷用电行为分析 &#xff08;1&#xff09;在满足温控区间约束条件下&#xff0c;分析典型房间温变过程微分方程…