|
楼主 |
发表于 2017-8-15 13:01:49
|
显示全部楼层
我尝试了增加堆栈也不行,如下是我的配置和代码请帮忙检查一下,可能有点多,谢谢了!- /*****************************************************************************
- *
- * 模块名称 : 主函数
- * 文件名称 : main.c
- * 版 本 : V1.0
- * 说 明 : 主函数文件
- *
- * 修改记录 :
- * 版本号 日期 作者 说明
- * V1.0 2017-07-18 wendell 正式发布
- *
- *
- ******************************************************************************/
- #include "stm32f103_main.h"
- static void vTaskLED1(void *pvParameters);
- static void vTaskLED2(void *pvParameters);
- static void vTaskLED3(void *pvParameters);
- static void AppTaskCreate (void);
- void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName);
- static TaskHandle_t xHandleTaskLED1 = NULL;
- static TaskHandle_t xHandleTaskLED2 = NULL;
- static TaskHandle_t xHandleTaskLED3 = NULL;
- /*******************************************************************************
- * 函 数 名: vTaskLED1
- * 功能说明: 任务1
- * 形 参: 无
- * 返 回 值: 无
- *******************************************************************************/
- static void vTaskLED1(void *pvParameters)
- {
- while(1)
- {
- printf("我在执行,我是任务 vTaskLED1 \\r\\n");
- Bsp_LEDToggle(LED1);
- vTaskDelay(800);
- }
- }
- /*******************************************************************************
- * 函 数 名: vTaskLED2
- * 功能说明: 任务2
- * 形 参: 无
- * 返 回 值: 无
- *******************************************************************************/
- static void vTaskLED2(void *pvParameters)
- {
- while(1)
- {
- printf("我在执行,我是任务 vTaskLED2 \\r\\n");
- Bsp_LEDToggle(LED2);
- vTaskDelay(200);
- }
- }
- /*******************************************************************************
- * 函 数 名: vTaskLED3
- * 功能说明: 任务3
- * 形 参: 无
- * 返 回 值: 无
- *******************************************************************************/
- static void vTaskLED3(void *pvParameters)
- {
- GUI_DispString("www.armfly.com \\navailable");
- while(1)
- {
- printf("我在执行,我是任务 vTaskLED3 \\r\\n");
- GUI_Delay(10);
- //Bsp_LEDToggle(LED3);
- //vTaskDelay(400);
- }
- }
- /*******************************************************************************
- * 函 数 名: AppTaskCreate
- * 功能说明: 创建任务
- * 形 参: 无
- * 返 回 值: 无
- *******************************************************************************/
- static void AppTaskCreate (void)
- {
- //任务函数 任务名称 栈大小 任务参数 优先级 任务句柄
- xTaskCreate( vTaskLED1,"vTaskLED1",512, NULL, 5,&xHandleTaskLED1);
- xTaskCreate( vTaskLED2,"vTaskLED2",512, NULL, 3,&xHandleTaskLED2);
- xTaskCreate( vTaskLED3,"vTaskLED3",2048, NULL, 2,&xHandleTaskLED3);
- }
- /*
- *********************************************************************************************************
- * 函 数 名: vApplicationStackOverflowHook
- * 功能说明: 栈溢出的钩子函数
- * 形 参: xTask 任务句柄
- * pcTaskName 任务名
- * 返 回 值: 无
- *********************************************************************************************************
- */
- void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
- {
- printf("task: %s stack error \\r\\n", pcTaskName);
- }
- int main(void)
- {
- //为了防止初始化 STM32 外设时有中断服务程序执行,这里禁止全局中断(除了 NMI 和 HardFault)
- __set_PRIMASK(1);
- Bsp_Init();
- printf("***********************************\\r\\n");
- GUI_Init();
- GUI_SetBkColor(GUI_BLUE);
- GUI_SetColor(GUI_RED);
- GUI_Clear();
- GUI_SetFont(&GUI_Font8x18);
- GUI_DispString("test test test test");
-
- printf("aaaaaaaaaaaaaaa\\r\\n");
- AppTaskCreate();
- vTaskStartScheduler();
- while(1);
- }
复制代码- /******************************************************************************
- 已经设置项
- ******************************************************************************/
- //确保是被编译器使用,不是被汇编文件所使用
- #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
- #include <stdint.h>
- extern volatile uint32_t ulHighFrequencyTimerTicks;
- #endif
- //内核调度方式 1 抢占式 0 合作式调度
- #define configUSE_PREEMPTION 1
- //配置用于使能 tickless 低功耗模式 1 使能 0 禁止
- #define configUSE_TICKLESS_IDLE 0
- //禁止空闲任务钩子函数
- #define configUSE_IDLE_HOOK 0
- //禁能滴答定时器中断里面执行的钩子函数
- #define configUSE_TICK_HOOK 0
- //CPU 主频
- #define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )
- //系统节拍数
- #define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
- //用户最大任务数,实际使用时为 0 - (configMAX_PRIORITIES- 1 )
- #define configMAX_PRIORITIES ( 6 )
- //参数用于定义空闲任务的栈空间大小,单位字,即 4 字节
- #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 1024 )
- //定义堆大小,FreeRTOS 内核,用户动态内存申请,任务栈,任务创建,信号量创建,
- //消息队列创建等都需要用这个空间
- #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 17 * 1024 ) )
- //任务名的长度 末尾的结束符 '\\0'也要计算在内
- #define configMAX_TASK_NAME_LEN ( 16 )
- //使能此配置将添加额外的结构体成员和函数,以此来协助可视化和跟踪,在使用
- //IAR 中的 FreeRTOS插件时要使能这个配置,否则无法显示任务栈的使用情况
- #define configUSE_TRACE_FACILITY 1
- //事件标志的个数 0 为 32bit 的 低 24bit
- #define configUSE_16_BIT_TICKS 0
- //使能与空闲任务同优先级的任务 使能抢占式调度器 且创建与空闲任务同优先级的任务
- #define configIDLE_SHOULD_YIELD 1
- /* Co-routine definitions. */
- //使能合作式调度相关函数
- #define configUSE_CO_ROUTINES 0
- //此参数用于定义可供用户使用的最大的合作式任务优先级数,如果这个定义的是 5,
- //那么用户可以使用的优先级号是 0,1,2,3,4,不包含 5,
- #define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
- //使能计数信号量
- #define configUSE_COUNTING_SEMAPHORES 1
- //使能互斥信号量
- #define configUSE_MUTEXES 1
- //使能任务间直接的消息传递,包含信号量,事件标志组和消息邮箱
- #define configUSE_TASK_NOTIFICATIONS 1
- /******************************************************************************
- 查看任务状态配置
- ******************************************************************************/
- #define configGENERATE_RUN_TIME_STATS 1
- #define configUSE_TRACE_FACILITY 1
- #define configUSE_STATS_FORMATTING_FUNCTIONS 1
- #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() (ulHighFrequencyTimerTicks = 0ul)
- #define portGET_RUN_TIME_COUNTER_VALUE() ulHighFrequencyTimerTicks
复制代码 GUI_X_FreeRTOS.c
- /*********************************************************************
- * Portions COPYRIGHT 2016 STMicroelectronics *
- * Portions SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- **********************************************************************
- * *
- * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- ** emWin V5.32 - Graphical user interface for embedded applications **
- All Intellectual Property rights in the Software belongs to SEGGER.
- emWin is protected by international copyright laws. Knowledge of the
- source code may not be used to write a similar product. This file may
- only be used in accordance with the following terms:
- The software has been licensed to STMicroelectronics International
- N.V. a Dutch company with a Swiss branch and its headquarters in Plan-
- les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the
- purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_
- troller products commercialized by Licensee only, sublicensed and dis_
- tributed under the terms and conditions of the End User License Agree_
- ment supplied by STMicroelectronics International N.V.
- Full source code is available at: www.segger.com
- We appreciate your understanding and fairness.
- ----------------------------------------------------------------------
- File : GUI_X.C
- Purpose : This file provides emWin Interface with FreeRTOS
- ---------------------------END-OF-HEADER------------------------------
- */
- /**
- ******************************************************************************
- * @attention
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2
- *
- * 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.
- *
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "GUI.h"
-
- /* FreeRTOS include files */
- #include "FreeRTOS.h"
- #include "task.h"
- #include "timers.h"
- #include "semphr.h"
-
- /*********************************************************************
- *
- * Global data
- */
- static xSemaphoreHandle xQueueMutex;
- static xSemaphoreHandle xSemaTxDone;
- /*********************************************************************
- *
- * Timing:
- * GUI_X_GetTime()
- * GUI_X_Delay(int)
- Some timing dependent routines require a GetTime
- and delay function. Default time unit (tick), normally is
- 1 ms.
- */
- int GUI_X_GetTime(void)
- {
- return ((int) xTaskGetTickCount());
- }
- void GUI_X_Delay(int ms)
- {
- vTaskDelay( ms );
- }
- /*********************************************************************
- *
- * GUI_X_Init()
- *
- * Note:
- * GUI_X_Init() is called from GUI_Init is a possibility to init
- * some hardware which needs to be up and running before the GUI.
- * If not required, leave this routine blank.
- */
- void GUI_X_Init(void) {
- }
- /*********************************************************************
- *
- * GUI_X_ExecIdle
- *
- * Note:
- * Called if WM is in idle state
- */
- void GUI_X_ExecIdle(void)
- {
- vTaskDelay(30/portTICK_RATE_MS);
- }
- /*********************************************************************
- *
- * Multitasking:
- *
- * GUI_X_InitOS()
- * GUI_X_GetTaskId()
- * GUI_X_Lock()
- * GUI_X_Unlock()
- *
- * Note:
- * The following routines are required only if emWin is used in a
- * true multi task environment, which means you have more than one
- * thread using the emWin API.
- * In this case the
- * #define GUI_OS 1
- * needs to be in GUIConf.h
- */
- /* Init OS */
- void GUI_X_InitOS(void)
- {
- /* Create Mutex lock */
- xQueueMutex = xSemaphoreCreateMutex();
- configASSERT (xQueueMutex != NULL);
-
- /* Queue Semaphore */
- vSemaphoreCreateBinary( xSemaTxDone );
- configASSERT ( xSemaTxDone != NULL );
- }
- void GUI_X_Unlock(void)
- {
- xSemaphoreGive( xQueueMutex );
- }
- void GUI_X_Lock(void)
- {
- if(xQueueMutex == NULL)
- {
- GUI_X_InitOS();
- }
-
- xSemaphoreTake( xQueueMutex, portMAX_DELAY );
- }
- /* Get Task handle */
- U32 GUI_X_GetTaskId(void)
- {
- return ((U32) xTaskGetCurrentTaskHandle());
- }
- void GUI_X_WaitEvent (void)
- {
- while( xSemaphoreTake(xSemaTxDone, portMAX_DELAY ) != pdTRUE );
- }
- void GUI_X_SignalEvent (void)
- {
- xSemaphoreGive( xSemaTxDone );
- }
- /*********************************************************************
- *
- * Logging: OS dependent
- Note:
- Logging is used in higher debug levels only. The typical target
- build does not use logging and does therefor not require any of
- the logging routines below. For a release build without logging
- the routines below may be eliminated to save some space.
- (If the linker is not function aware and eliminates unreferenced
- functions automatically)
- */
- void GUI_X_Log (const char *s) { }
- void GUI_X_Warn (const char *s) { }
- void GUI_X_ErrorOut(const char *s) { }
- /*************************** End of file ****************************/
复制代码 |
|