/* Demo application includes. */\r
#include "partest.h"\r
#include "flash.h"\r
+#include "dynamic.h"\r
\r
/* ST driver includes. */\r
#include "stm32l1xx_usart.h"\r
#define mainMESSAGE_BUTTON_LEFT ( 3 )\r
#define mainMESSAGE_BUTTON_RIGHT ( 4 )\r
#define mainMESSAGE_BUTTON_SEL ( 5 )\r
+#define mainMESSAGE_STATUS ( 6 )\r
\r
/*\r
* System configuration is performed prior to main() being called, this function\r
{\r
xTaskCreate( prvLCDTask, ( signed char * ) "LCD", mainLCD_TASK_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );\r
xTaskCreate( vTempTask, ( signed char * ) "Temp", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+ vStartDynamicPriorityTasks();\r
+ vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
+ \r
+ vTaskStartScheduler();\r
}\r
\r
- vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
- \r
- vTaskStartScheduler();\r
- \r
for( ;; );\r
}\r
/*-----------------------------------------------------------*/\r
{\r
xQueueReceive( xLCDQueue, &xReceivedMessage, portMAX_DELAY );\r
\r
- if( lLine >= Line9 )\r
+ if( lLine > Line9 )\r
{\r
LCD_Clear( Blue );\r
lLine = 0;\r
{\r
case mainMESSAGE_BUTTON_UP : sprintf( cBuffer, "Button up = %d", xReceivedMessage.lMessageValue );\r
break;\r
- case mainMESSAGE_BUTTON_DOWN :\r
+ case mainMESSAGE_BUTTON_DOWN : sprintf( cBuffer, "Button down = %d", xReceivedMessage.lMessageValue );\r
break;\r
- case mainMESSAGE_BUTTON_LEFT :\r
+ case mainMESSAGE_BUTTON_LEFT : sprintf( cBuffer, "Button left = %d", xReceivedMessage.lMessageValue );\r
break;\r
- case mainMESSAGE_BUTTON_RIGHT :\r
+ case mainMESSAGE_BUTTON_RIGHT : sprintf( cBuffer, "Button right = %d", xReceivedMessage.lMessageValue );\r
break;\r
- case mainMESSAGE_BUTTON_SEL :\r
+ case mainMESSAGE_BUTTON_SEL : sprintf( cBuffer, "Select interrupt!" );\r
+ break;\r
+ case mainMESSAGE_STATUS : sprintf( cBuffer, "Task status = %s", ( ( xReceivedMessage.lMessageValue ) ? "PASS" : "FAIL" ) );\r
break;\r
default : sprintf( cBuffer, "Unknown message" );\r
break;\r
}\r
/*-----------------------------------------------------------*/\r
\r
+void EXTI9_5_IRQHandler( void )\r
+{\r
+const xQueueMessage xMessage = { mainMESSAGE_BUTTON_SEL, 0 };\r
+long lHigherPriorityTaskWoken = pdFALSE;\r
+\r
+ xQueueSendFromISR( xLCDQueue, &xMessage, &lHigherPriorityTaskWoken );\r
+ EXTI_ClearITPendingBit( SEL_BUTTON_EXTI_LINE );\r
+ portEND_SWITCHING_ISR( lHigherPriorityTaskWoken );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationTickHook( void )\r
+{\r
+static unsigned long ulCounter = 0;\r
+static const unsigned long ulCheckFrequency = 5000UL / portTICK_RATE_MS;\r
+static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS };\r
+long lHigherPriorityTaskWoken = pdFALSE; /* Not used in this case as this is the tick hook. */\r
+\r
+ ulCounter++;\r
+ if( ulCounter >= ulCheckFrequency )\r
+ {\r
+ if( xAreDynamicPriorityTasksStillRunning() != pdPASS )\r
+ {\r
+ xStatusMessage.lMessageValue = pdFAIL;\r
+ }\r
+ \r
+ xQueueSendFromISR( xLCDQueue, &xStatusMessage, &lHigherPriorityTaskWoken );\r
+ ulCounter = 0;\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
static void vTempTask( void *pv )\r
{\r
-long lLastState = pdFALSE;\r
+long lLastState = pdTRUE;\r
long lState;\r
xQueueMessage xMessage;\r
\r
/* Initialise the LEDs. */\r
vParTestInitialise();\r
\r
- //BUTTON_MODE_EXTI\r
+ //\r
/* Initialise the joystick inputs. */\r
STM_EVAL_PBInit( BUTTON_UP, BUTTON_MODE_GPIO );\r
STM_EVAL_PBInit( BUTTON_DOWN, BUTTON_MODE_GPIO );\r
STM_EVAL_PBInit( BUTTON_LEFT, BUTTON_MODE_GPIO );\r
STM_EVAL_PBInit( BUTTON_RIGHT, BUTTON_MODE_GPIO );\r
- STM_EVAL_PBInit( BUTTON_SEL, BUTTON_MODE_GPIO );\r
+ \r
+ /* The select button in the middle of the joystick is configured to generate\r
+ an interrupt. The Eval board library will configure the interrupt\r
+ priority to be the lowest priority available - this is important as the\r
+ interrupt service routine makes use of a FreeRTOS API function so must\r
+ therefore use a priority equal to or below that set by the\r
+ configMAX_SYSCALL_INTERRUPT_PRIORITY() value set in FreeRTOSConfig.h. */\r
+ STM_EVAL_PBInit( BUTTON_SEL, BUTTON_MODE_EXTI );\r
\r
#if 0 \r
USART_InitTypeDef USART_InitStructure;\r