]> git.sur5r.net Git - freertos/blobdiff - Demo/ARM7_LPC2138_Rowley/main.c
UpdUpdate IAR projects to use Embedded Workbench V5.11.
[freertos] / Demo / ARM7_LPC2138_Rowley / main.c
index c6208d4f9bb8baedda4ffe42c9fab712f3b98705..4dae2144c000fabcc214c6ac2f3a25da7f1edf07 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-       FreeRTOS.org V4.1.2 - Copyright (C) 2003-2006 Richard Barry.\r
+       FreeRTOS.org V4.7.0 - Copyright (C) 2003-2007 Richard Barry.\r
 \r
        This file is part of the FreeRTOS.org distribution.\r
 \r
        See http://www.FreeRTOS.org for documentation, latest information, license \r
        and contact details.  Please ensure to read the configuration and relevant \r
        port sections of the online documentation.\r
+\r
+       Also see http://www.SafeRTOS.com a version that has been certified for use\r
+       in safety critical systems, plus commercial licensing, development and\r
+       support options.\r
        ***************************************************************************\r
 */\r
 \r
@@ -77,6 +81,7 @@
 #include "integer.h"\r
 #include "PollQ.h"\r
 #include "blocktim.h"\r
+#include "recmutex.h"\r
 \r
 /* Hardware configuration definitions. */\r
 #define mainBUS_CLK_FULL                                       ( ( unsigned portCHAR ) 0x01 )\r
@@ -93,6 +98,8 @@
 #define mainLED_DELAY                                          ( ( portTickType ) 500 / portTICK_RATE_MS )\r
 #define mainCHECK_DELAY                                                ( ( portTickType ) 5000 / portTICK_RATE_MS )\r
 #define mainLIST_BUFFER_SIZE                           2048\r
+#define mainNO_DELAY                                           ( 0 )\r
+#define mainSHORT_DELAY                                                ( 150 / portTICK_RATE_MS )\r
 \r
 /* Task priorities. */\r
 #define mainLED_TASK_PRIORITY                          ( tskIDLE_PRIORITY + 2 )\r
@@ -165,6 +172,7 @@ int main( void )
        vStartDynamicPriorityTasks();\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
     vCreateBlockTimeTasks();\r
+    vStartRecursiveMutexTasks();\r
 \r
        /* Start the tasks defined within this file. */\r
        xTaskCreate( vLEDTask, "LED", configMINIMAL_STACK_SIZE, NULL, mainLED_TASK_PRIORITY, NULL );\r
@@ -175,7 +183,7 @@ int main( void )
        /* Start the scheduler. */\r
        vTaskStartScheduler();\r
 \r
-       /* The scheduler should now running, so we will only ever reach here if we\r
+       /* The scheduler should now be running, so we will only ever reach here if we\r
        ran out of heap space. */\r
 \r
        return 0;\r
@@ -253,6 +261,11 @@ const portCHAR * const pcFailMessage = "FAIL\n";
                        xErrorOccurred = pdTRUE;\r
                }\r
 \r
+               if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+               {\r
+                       xErrorOccurred = pdTRUE;\r
+               }\r
+\r
                /* Send either a pass or fail message.  If an error is found it is\r
                never cleared again. */\r
                if( xErrorOccurred == pdTRUE )\r
@@ -287,7 +300,7 @@ static void vButtonHandlerTask( void *pvParameters )
 static portCHAR cListBuffer[ mainLIST_BUFFER_SIZE ];\r
 const portCHAR *pcList = &( cListBuffer[ 0 ] );\r
 const portCHAR * const pcHeader = "\nTask          State  Priority  Stack      #\n************************************************";\r
-extern void (vButtonISR) ( void );\r
+extern void (vButtonISRWrapper) ( void );\r
 \r
        /* Configure the interrupt. */\r
        portENTER_CRITICAL();   \r
@@ -300,15 +313,19 @@ extern void (vButtonISR) ( void );
                /* Setup the VIC for EINT 1. */\r
                VICIntSelect &= ~mainEINT_1_VIC_CHANNEL_BIT;\r
                VICIntEnable |= mainEINT_1_VIC_CHANNEL_BIT;\r
-               VICVectAddr1 = ( portLONG ) vButtonISR;\r
+               VICVectAddr1 = ( portLONG ) vButtonISRWrapper;\r
                VICVectCntl1 = mainEINT_1_ENABLE_BIT | mainEINT_1_CHANNEL;\r
        }\r
        portEXIT_CRITICAL();\r
 \r
        for( ;; )\r
        {\r
+               /* For debouncing, wait a while then clear the semaphore. */\r
+               vTaskDelay( mainSHORT_DELAY );\r
+               xSemaphoreTake( xButtonSemaphore, mainNO_DELAY );\r
+\r
                /* Wait for an interrupt. */\r
-               while( xSemaphoreTake( xButtonSemaphore, portMAX_DELAY ) != pdPASS );\r
+               xSemaphoreTake( xButtonSemaphore, portMAX_DELAY );\r
 \r
                /* Send the column headers to the print task for display. */\r
                xQueueSend( xPrintQueue, &pcHeader, portMAX_DELAY );\r