本帖最后由 xiaolinen 于 2022-10-18 22:44 编辑
一:叙述
本来这篇是想做一个总结的,但是因为测评使用过程中出现的问题已经记录,并且在实际开发过程中要用到freertos实时系统,所以不再总结,而是在官方提供的freertos_demo中进行了更改,算是做一个小小的测试!
二:程序
在FreeRTOSConfig.h文件中,将configTICK_RATE_HZ宏定义由500修改为了1000;
- /********************************************************************************************************
- * @File main.c
- *
- * @brief This is the source file for B91m
- *
- * @author Driver Group
- * @date 2019
- *
- * @par Copyright (c) 2019, Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
- * All rights reserved.
- *
- * 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
- *
- * http://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.
- *
- *******************************************************************************************************/
- #include "app_config.h"
- #include "calibration.h"
- #include <FreeRTOS.h>
- #include <task.h>
- #include <queue.h>
- #include <timers.h>
- #include <stdio.h>
-
- #define timerTick 4
-
- static TaskHandle_t test_handle=NULL;
- static TimerHandle_t softWaveTimer=NULL;
- static uint32_t MboxValue;
-
- static void test_task(void *pvParameters){
- uint32_t notifyValue;
-
- while(1){
- if(pdTRUE == xTaskNotifyWait((uint32_t )0x00,(uint32_t)0xffffffff,(uint32_t*)¬ifyValue,0)){
- printf("Hello!\r\n");
- }
-
- if(notifyValue >= timerTick){
- xTimerStop(softWaveTimer,0);
- }
- vTaskDelay(10);
- }
- (void)(pvParameters);
- }
-
- extern void vPortRestoreTask();
-
- void pxSoftWaveTimer(TimerHandle_t xTimer)
- {
- uint32_t TimerID;
- TimerID = (uint32_t)pvTimerGetTimerID(xTimer);
- if(TimerID == 1){
- xTaskNotify((TaskHandle_t )test_handle,(uint32_t )MboxValue,(eNotifyAction)eSetValueWithOverwrite);
- MboxValue++;
- }
- }
-
- /**
- * @brief This is main function
- * @return none
- */
- int main (void)
- {
- sys_init(LDO_1P4_LDO_1P8, VBAT_MAX_VALUE_GREATER_THAN_3V6);
-
- user_read_flash_value_calib();
-
- CCLK_24M_HCLK_24M_PCLK_24M;
-
- if(0 ){
- vPortRestoreTask();
- }else{
- xTaskCreate( test_task,"test",configMINIMAL_STACK_SIZE,NULL,0,&test_handle );
-
- softWaveTimer = xTimerCreate("softwaveTimer",1000,pdTRUE,(void*)1,pxSoftWaveTimer);
- xTimerStart(softWaveTimer,0);
-
- vTaskStartScheduler();
- }
-
- return 0;
- }
-
三:现象