From a39234c0fd11d788aaab4b19de6bf01bf94f69fb Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Wed, 14 Nov 2018 11:44:03 +0800 Subject: [PATCH] Update Key interrupt priority and can work now, comment configUSE_TICK_HOOK in FreeRTOSConfig.h --- src/STM32L_FreeRTOS/FreeRTOS/FreeRTOSConfig.h | 43 ++++++++++++++++++++- src/STM32L_FreeRTOS/board/stm32_vport.c | 69 ++++++++++++++++++---------------- src/STM32L_FreeRTOS/board/stm32_key.c | 2 3 files changed, 78 insertions(+), 36 deletions(-) diff --git a/src/STM32L_FreeRTOS/FreeRTOS/FreeRTOSConfig.h b/src/STM32L_FreeRTOS/FreeRTOS/FreeRTOSConfig.h index 706012c..f6d2351 100644 --- a/src/STM32L_FreeRTOS/FreeRTOS/FreeRTOSConfig.h +++ b/src/STM32L_FreeRTOS/FreeRTOS/FreeRTOSConfig.h @@ -40,23 +40,60 @@ * See http://www.freertos.org/a00110.html *----------------------------------------------------------*/ +/* Ϊ1ʱRTOSʹ����ռʽ��������Ϊ0ʱRTOSʹ��ʱ��Ƭ������*/ #define configUSE_PREEMPTION 1 + +/* ��RTOS��������ʼ������Ϊ�˱�֤������һ�����������У����������Զ�������ռ��������ȼ��� + ����Ϊ1ʹ�ÿ��й��Ӻ�����0���Կ��й��Ӻ����� */ #define configUSE_IDLE_HOOK 1 -#define configUSE_TICK_HOOK 0 // Modify 1->0 by gwx + +/* ʱ��Ƭ���Ӻ������Ժܷ����ʵ��һ����ʱ�����ܡ�����Ϊ1ʹ��ʱ��Ƭ���Ӻ�����0����ʱ��Ƭ���Ӻ����� */ +#define configUSE_TICK_HOOK 0 + +/* д��ʵ�ʵ�CPU�ں�ʱ��Ƶ�ʣ�Ҳ����CPUָ��ִ��Ƶ�ʣ�ͨ����ΪFcclk�����ô�ֵ��Ϊ����ȷ������ϵͳ�����ж����ڡ� */ #define configCPU_CLOCK_HZ ( 32000000UL ) + +/* RTOS ϵͳ�����жϵ�Ƶ�ʡ���һ���жϵĴ�����ÿ���ж�RTOS�������������ȡ� */ #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) + +/* ����Ӧ�ó�����Ч�����ȼ���Ŀ���κ������������Թ���һ�����ȼ���ʹ��Э�̿��Ե����ĸ�����������Ȩ�� + ��RTOS�ں��У�ÿ����Ч���ȼ���������һ������RAM��������ֵ��Ҫ�������Ӧ��ʵ����Ҫ�����ȼ���Ŀ��*/ #define configMAX_PRIORITIES ( 5 ) + +/* �����������ʹ�õĶ�ջ��С�����ֶ������ֽ�Ϊ��λ��ͨ����ֵ��ӦС�ڶ�Ӧ��������ʾ�����ļ�FreeRTOSConfig.h�ж������ֵ��*/ #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 10 * 1024 ) ) // Modify 10->5 by gwx + +/* ָ��malloc()����ĶѵĴ�С�� ÿ�����������С��������������ʱ�����ź���ʱ��RTOS�ں˻�Ϊ�˷���RAM�������RAM�����ڶ� */ +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 10 * 1024 ) ) + +/* ����������ʱ����Ҫ��������������Ϣ���ַ��������������������ַ�������ȡ����ﶨ��ij��Ȱ����ַ�����������\0���� */ #define configMAX_TASK_NAME_LEN ( 16 ) + +/* ���ó�1��ʾ�������ӻ����ٵ��ԣ��ἤ��һЩ���ӵĽṹ���Ա�ͺ����� */ #define configUSE_TRACE_FACILITY 1 + +/* ����ϵͳ���ļ������ı������ͣ�������portTickType�DZ�ʾ16λ��������32λ������0��ʾ32λ�������Σ�1��ʾ16λ�������� */ #define configUSE_16_BIT_TICKS 0 + +/* ����������������ڿ������ȼ��е���Ϊ�� */ #define configIDLE_SHOULD_YIELD 1 + +/* ����Ϊ1��ʾʹ�û����������ó�0��ʾ���Ի������� */ #define configUSE_MUTEXES 1 + +/* ������Լ�¼�Ķ��к��ź����������Ŀ��*/ #define configQUEUE_REGISTRY_SIZE 5 + +/* Ϊ��ͬ�ij�����ʹ�ò�ͬ��ջ��������ơ� */ #define configCHECK_FOR_STACK_OVERFLOW 2 + +/* ���ó�1��ʾʹ�õݹ黥���������ó�0��ʾ��ʹ�á� */ #define configUSE_RECURSIVE_MUTEXES 0 + +/* �ú�����Ϊ1����ô���붨��һ��malloc()ʧ�ܹ��Ӻ��������������Ϊ0��malloc()ʧ�ܹ��Ӻ������ᱻ���ã������Ѿ����������������*/ #define configUSE_MALLOC_FAILED_HOOK 1 + +/* ʹ�������ǩ���� */ #define configUSE_APPLICATION_TASK_TAG 0 /* Co-routine definitions. */ @@ -94,6 +131,7 @@ /* Prevent the following definitions being included when FreeRTOSConfig.h is included from an asm file. */ +#if (configUSE_TICK_HOOK == 1 ) #include "stm32l1xx_tim.h" extern void vConfigureTimerForRunTimeStats( void ); extern unsigned long ulTIM6_OverflowCount; @@ -109,6 +147,7 @@ ulCountValue = ( ( ulTIM6_OverflowCount << 16UL ) | ( unsigned long ) TIM6->CNT ); \ TIM_Cmd( TIM6, ENABLE ); \ } +#endif // (configUSE_TICK_HOOK == 1 ) #endif /* FREERTOS_CONFIG_H */ diff --git a/src/STM32L_FreeRTOS/board/stm32_key.c b/src/STM32L_FreeRTOS/board/stm32_key.c index 7ba7b9d..a7cb3b8 100644 --- a/src/STM32L_FreeRTOS/board/stm32_key.c +++ b/src/STM32L_FreeRTOS/board/stm32_key.c @@ -30,7 +30,7 @@ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); /* ��ʼ���ж����ȼ� */ - NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); + NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; diff --git a/src/STM32L_FreeRTOS/board/stm32_vport.c b/src/STM32L_FreeRTOS/board/stm32_vport.c index 3771570..8671ccc 100644 --- a/src/STM32L_FreeRTOS/board/stm32_vport.c +++ b/src/STM32L_FreeRTOS/board/stm32_vport.c @@ -17,10 +17,45 @@ void prvSetupHardware( void ) { init_led_gpio(); - //init_keys_interrupt(); + init_keys_interrupt(); stm32_init_printf(USART_PORT1, 115200); } + +/* FreeRTOSConfig.h�ж����˺� configUSE_MALLOC_FAILED_HOOK ����Ҫ�ú���ʵ�� */ +void vApplicationMallocFailedHook( void ) +{ + /* Called if a call to pvPortMalloc() fails because there is insufficient + free memory available in the FreeRTOS heap. pvPortMalloc() is called + internally by FreeRTOS API functions that create tasks, queues or + semaphores. */ + for( ;; ); +} + + +/* FreeRTOSConfig.h�ж����˺� configUSE_IDLE_HOOK ����Ҫ�ú���ʵ�� */ +void vApplicationIdleHook( void ) +{ + /* Called on each iteration of the idle task. In this case the idle task + just enters a low(ish) power mode. */ + PWR_EnterSleepMode( PWR_Regulator_ON, PWR_SLEEPEntry_WFI ); +} + +/* FreeRTOSConfig.h�ж����˺� configCHECK_FOR_STACK_OVERFLOW ����Ҫ�ú���ʵ�� */ +void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) +{ + ( void ) pcTaskName; + ( void ) pxTask; + + /* Run time stack overflow checking is performed if + configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook + function is called if a stack overflow is detected. */ + for( ;; ); +} + + +/* FreeRTOSConfig.h�ж����˺� configUSE_TICK_HOOK ����Ҫ�ú���ʵ�� */ +#if (configUSE_TICK_HOOK == 1 ) void vConfigureTimerForRunTimeStats( void ) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; @@ -85,38 +120,7 @@ TIM_ClearITPendingBit( TIM6, TIM_IT_Update ); } } -/*-----------------------------------------------------------*/ -void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) -{ - ( void ) pcTaskName; - ( void ) pxTask; - - /* Run time stack overflow checking is performed if - configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook - function is called if a stack overflow is detected. */ - for( ;; ); -} -/*-----------------------------------------------------------*/ - -void vApplicationMallocFailedHook( void ) -{ - /* Called if a call to pvPortMalloc() fails because there is insufficient - free memory available in the FreeRTOS heap. pvPortMalloc() is called - internally by FreeRTOS API functions that create tasks, queues or - semaphores. */ - for( ;; ); -} -/*-----------------------------------------------------------*/ - -void vApplicationIdleHook( void ) -{ - /* Called on each iteration of the idle task. In this case the idle task - just enters a low(ish) power mode. */ - PWR_EnterSleepMode( PWR_Regulator_ON, PWR_SLEEPEntry_WFI ); -} - -#if 0 void vApplicationTickHook( void ) { static unsigned long ulCounter = 0; @@ -134,4 +138,3 @@ } } #endif -/*-----------------------------------------------------------*/ -- Gitblit v1.9.1