From: richardbarry Date: Sun, 19 Dec 2010 20:31:41 +0000 (+0000) Subject: Developing STM32L152 demo - still a work in progress. X-Git-Tag: V6.1.1~83 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3573a84d4a14cdc6f5b14cd9d866f10a222f84ba;p=freertos Developing STM32L152 demo - still a work in progress. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1174 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/Cortex_STM32L152_IAR/FreeRTOSConfig.h b/Demo/Cortex_STM32L152_IAR/FreeRTOSConfig.h index 7d6cf4cc8..75f29bd88 100644 --- a/Demo/Cortex_STM32L152_IAR/FreeRTOSConfig.h +++ b/Demo/Cortex_STM32L152_IAR/FreeRTOSConfig.h @@ -68,7 +68,7 @@ #define configUSE_PREEMPTION 1 #define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 +#define configUSE_TICK_HOOK 1 #define configCPU_CLOCK_HZ ( 32000000UL ) #define configTICK_RATE_HZ ( ( portTickType ) 1000 ) #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 ) diff --git a/Demo/Cortex_STM32L152_IAR/RTOSDemo.ewp b/Demo/Cortex_STM32L152_IAR/RTOSDemo.ewp index 3da15ae98..1148e8bb4 100644 --- a/Demo/Cortex_STM32L152_IAR/RTOSDemo.ewp +++ b/Demo/Cortex_STM32L152_IAR/RTOSDemo.ewp @@ -1753,6 +1753,9 @@ Standard_Demo_Code + + $PROJ_DIR$\..\Common\Minimal\dynamic.c + $PROJ_DIR$\..\Common\Minimal\flash.c diff --git a/Demo/Cortex_STM32L152_IAR/main.c b/Demo/Cortex_STM32L152_IAR/main.c index 06476f648..2433edd98 100644 --- a/Demo/Cortex_STM32L152_IAR/main.c +++ b/Demo/Cortex_STM32L152_IAR/main.c @@ -62,6 +62,7 @@ /* Demo application includes. */ #include "partest.h" #include "flash.h" +#include "dynamic.h" /* ST driver includes. */ #include "stm32l1xx_usart.h" @@ -82,6 +83,7 @@ #define mainMESSAGE_BUTTON_LEFT ( 3 ) #define mainMESSAGE_BUTTON_RIGHT ( 4 ) #define mainMESSAGE_BUTTON_SEL ( 5 ) +#define mainMESSAGE_STATUS ( 6 ) /* * System configuration is performed prior to main() being called, this function @@ -111,12 +113,12 @@ void main( void ) { xTaskCreate( prvLCDTask, ( signed char * ) "LCD", mainLCD_TASK_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL ); xTaskCreate( vTempTask, ( signed char * ) "Temp", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); + vStartDynamicPriorityTasks(); + vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY ); + + vTaskStartScheduler(); } - vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY ); - - vTaskStartScheduler(); - for( ;; ); } /*-----------------------------------------------------------*/ @@ -132,7 +134,7 @@ static char cBuffer[ 32 ]; { xQueueReceive( xLCDQueue, &xReceivedMessage, portMAX_DELAY ); - if( lLine >= Line9 ) + if( lLine > Line9 ) { LCD_Clear( Blue ); lLine = 0; @@ -142,13 +144,15 @@ static char cBuffer[ 32 ]; { case mainMESSAGE_BUTTON_UP : sprintf( cBuffer, "Button up = %d", xReceivedMessage.lMessageValue ); break; - case mainMESSAGE_BUTTON_DOWN : + case mainMESSAGE_BUTTON_DOWN : sprintf( cBuffer, "Button down = %d", xReceivedMessage.lMessageValue ); break; - case mainMESSAGE_BUTTON_LEFT : + case mainMESSAGE_BUTTON_LEFT : sprintf( cBuffer, "Button left = %d", xReceivedMessage.lMessageValue ); break; - case mainMESSAGE_BUTTON_RIGHT : + case mainMESSAGE_BUTTON_RIGHT : sprintf( cBuffer, "Button right = %d", xReceivedMessage.lMessageValue ); break; - case mainMESSAGE_BUTTON_SEL : + case mainMESSAGE_BUTTON_SEL : sprintf( cBuffer, "Select interrupt!" ); + break; + case mainMESSAGE_STATUS : sprintf( cBuffer, "Task status = %s", ( ( xReceivedMessage.lMessageValue ) ? "PASS" : "FAIL" ) ); break; default : sprintf( cBuffer, "Unknown message" ); break; @@ -160,9 +164,41 @@ static char cBuffer[ 32 ]; } /*-----------------------------------------------------------*/ +void EXTI9_5_IRQHandler( void ) +{ +const xQueueMessage xMessage = { mainMESSAGE_BUTTON_SEL, 0 }; +long lHigherPriorityTaskWoken = pdFALSE; + + xQueueSendFromISR( xLCDQueue, &xMessage, &lHigherPriorityTaskWoken ); + EXTI_ClearITPendingBit( SEL_BUTTON_EXTI_LINE ); + portEND_SWITCHING_ISR( lHigherPriorityTaskWoken ); +} +/*-----------------------------------------------------------*/ + +void vApplicationTickHook( void ) +{ +static unsigned long ulCounter = 0; +static const unsigned long ulCheckFrequency = 5000UL / portTICK_RATE_MS; +static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS }; +long lHigherPriorityTaskWoken = pdFALSE; /* Not used in this case as this is the tick hook. */ + + ulCounter++; + if( ulCounter >= ulCheckFrequency ) + { + if( xAreDynamicPriorityTasksStillRunning() != pdPASS ) + { + xStatusMessage.lMessageValue = pdFAIL; + } + + xQueueSendFromISR( xLCDQueue, &xStatusMessage, &lHigherPriorityTaskWoken ); + ulCounter = 0; + } +} +/*-----------------------------------------------------------*/ + static void vTempTask( void *pv ) { -long lLastState = pdFALSE; +long lLastState = pdTRUE; long lState; xQueueMessage xMessage; @@ -187,13 +223,20 @@ static void prvSetupHardware( void ) /* Initialise the LEDs. */ vParTestInitialise(); - //BUTTON_MODE_EXTI + // /* Initialise the joystick inputs. */ STM_EVAL_PBInit( BUTTON_UP, BUTTON_MODE_GPIO ); STM_EVAL_PBInit( BUTTON_DOWN, BUTTON_MODE_GPIO ); STM_EVAL_PBInit( BUTTON_LEFT, BUTTON_MODE_GPIO ); STM_EVAL_PBInit( BUTTON_RIGHT, BUTTON_MODE_GPIO ); - STM_EVAL_PBInit( BUTTON_SEL, BUTTON_MODE_GPIO ); + + /* The select button in the middle of the joystick is configured to generate + an interrupt. The Eval board library will configure the interrupt + priority to be the lowest priority available - this is important as the + interrupt service routine makes use of a FreeRTOS API function so must + therefore use a priority equal to or below that set by the + configMAX_SYSCALL_INTERRUPT_PRIORITY() value set in FreeRTOSConfig.h. */ + STM_EVAL_PBInit( BUTTON_SEL, BUTTON_MODE_EXTI ); #if 0 USART_InitTypeDef USART_InitStructure; diff --git a/Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.dni b/Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.dni index 241c15162..943e2414e 100644 --- a/Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.dni +++ b/Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.dni @@ -1,5 +1,5 @@ [DebugChecksum] -Checksum=1807629591 +Checksum=685534858 [DisAssemblyWindow] NumStates=_ 1 State 1=_ 1 @@ -41,6 +41,10 @@ ActionState=1 [TraceHelper] Enabled=0 ShowSource=1 +[Disassemble mode] +mode=0 +[Breakpoints] +Count=0 [Log file] LoggingEnabled=_ 0 LogFile=_ "" @@ -48,6 +52,9 @@ Category=_ 0 [TermIOLog] LoggingEnabled=_ 0 LogFile=_ "" +[Aliases] +Count=0 +SuppressDialog=0 [CallStackLog] Enabled=0 [DriverProfiling] @@ -55,10 +62,3 @@ Enabled=0 Mode=995247177 Graph=0 Symbiont=0 -[Disassemble mode] -mode=0 -[Breakpoints] -Count=0 -[Aliases] -Count=0 -SuppressDialog=0 diff --git a/Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.wsdt b/Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.wsdt index af878919c..d2fbefbc7 100644 --- a/Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.wsdt +++ b/Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.wsdt @@ -17,7 +17,7 @@ 20121632481201622 - + TabID-27630-4718 @@ -25,24 +25,24 @@ Workspace - RTOSDemoRTOSDemo/System_and_ST_CodeRTOSDemo/System_and_ST_Code/Eval_Board_LibraryRTOSDemo/System_and_ST_Code/Peripheral_Library + RTOSDemoRTOSDemo/FreeRTOS_SourceRTOSDemo/Standard_Demo_CodeRTOSDemo/System_and_ST_CodeRTOSDemo/System_and_ST_Code/Eval_Board_LibraryRTOSDemo/System_and_ST_Code/Peripheral_Library - 0TabID-10002-7709BuildBuildTabID-18437-21512Debug LogDebug-Log0 + 0TabID-10002-7709BuildBuildTabID-18437-21512Debug LogDebug-Log0 - TextEditor$WS_DIR$\main.c0113083308300100000010000001 + TextEditor$WS_DIR$\main.c058356035600TextEditor$WS_DIR$\system_and_ST_code\STM32L152_EVAL\stm32l152_eval.c02691095410954TextEditor$WS_DIR$\system_and_ST_code\STM32L1xx_StdPeriph_Driver\src\stm32l1xx_syscfg.c012548154815TextEditor$WS_DIR$\system_and_ST_code\startup_stm32l1xx_md.s03091006510083TextEditor$WS_DIR$\..\..\Source\portable\IAR\ARM_CM3\portmacro.h09143414381TextEditor$WS_DIR$\..\..\Source\portable\IAR\ARM_CM3\portasm.s09246444644TextEditor$WS_DIR$\..\..\Source\queue.c07942917729177TextEditor$WS_DIR$\..\Common\Minimal\dynamic.c03881547915515TextEditor$WS_DIR$\..\..\Source\tasks.c011073820938209TextEditor$WS_DIR$\FreeRTOSConfig.h05036953695TextEditor$WS_DIR$\system_and_ST_code\STM32L152_EVAL\stm32l152_eval_lcd.c0612241224TextEditor$WS_DIR$\system_and_ST_code\STM32L1xx_StdPeriph_Driver\src\stm32l1xx_gpio.c030295249524TextEditor$WS_DIR$\system_and_ST_code\STM32L1xx_StdPeriph_Driver\src\stm32l1xx_spi.c02014721472TextEditor$WS_DIR$\..\..\Source\portable\IAR\ARM_CM3\port.c0162712871280100000010000001 - iaridepm.enu1-2-2740285-2-2200200119048203666170833755601-2-21981682-2-216842001002381203666119048203666 + iaridepm.enu1-2-2740285-2-2200200119048203666170833755601-2-21981682-2-216842001002381203666119048203666