]> git.sur5r.net Git - freertos/commitdiff
Minor formatting changes to the Keil and RVDS PSoC5 demos.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 5 Jan 2011 14:16:28 +0000 (14:16 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 5 Jan 2011 14:16:28 +0000 (14:16 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1226 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/IntQueueTimer.c
Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/ParTest.c
Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/Serial.c
Demo/CORTEX_CY8C5588_PSoC_Creator_Keil/FreeRTOS_Demo.cydsn/main.c
Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/IntQueueTimer.c
Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/ParTest.c
Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/Serial.c
Demo/CORTEX_CY8C5588_PSoC_Creator_RVDS/FreeRTOS_Demo.cydsn/main.c

index 94787b3d4c07ac650dd2e6de155ea0b160830573..0005bf2a40a9129d38d382417a911256b4770485 100644 (file)
@@ -60,8 +60,8 @@ extern portBASE_TYPE xFirstTimerHandler( void );
 extern portBASE_TYPE xSecondTimerHandler( void );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 extern portBASE_TYPE xSecondTimerHandler( void );\r
 /*---------------------------------------------------------------------------*/\r
 \r
-CY_ISR_PROTO(vHighFrequencyFirstISR);\r
-CY_ISR_PROTO(vHighFrequencySecondISR);\r
+CY_ISR_PROTO( vHighFrequencyFirstISR );\r
+CY_ISR_PROTO( vHighFrequencySecondISR );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 /**\r
 /*---------------------------------------------------------------------------*/\r
 \r
 /**\r
@@ -73,11 +73,11 @@ void vInitialiseTimerForIntQueueTest( void )
        {\r
                /* Initialise and start the First Timer ISR. */\r
                isr_High_Frequency_2000Hz_ClearPending();\r
        {\r
                /* Initialise and start the First Timer ISR. */\r
                isr_High_Frequency_2000Hz_ClearPending();\r
-               isr_High_Frequency_2000Hz_StartEx((cyisraddress)vHighFrequencyFirstISR);\r
+               isr_High_Frequency_2000Hz_StartEx( ( cyisraddress ) vHighFrequencyFirstISR );\r
 \r
                /* Initialise and start the Second Timer ISR. */\r
                isr_High_Frequency_2001Hz_ClearPending();\r
 \r
                /* Initialise and start the Second Timer ISR. */\r
                isr_High_Frequency_2001Hz_ClearPending();\r
-               isr_High_Frequency_2001Hz_StartEx((cyisraddress)vHighFrequencySecondISR);\r
+               isr_High_Frequency_2001Hz_StartEx( ( cyisraddress ) vHighFrequencySecondISR );\r
        }\r
        taskEXIT_CRITICAL();\r
 }\r
        }\r
        taskEXIT_CRITICAL();\r
 }\r
index e98e673def9c6f56e22b4e815e185771f015a7b6..56f3053039b3839f019998662eb74642f47e40ec 100644 (file)
@@ -67,7 +67,8 @@ static volatile char cLedOutput[ partstMAX_LED ];
 void vParTestInitialise( void )\r
 {\r
 long lIndex;\r
 void vParTestInitialise( void )\r
 {\r
 long lIndex;\r
-       for ( lIndex = 0; lIndex < partstMAX_LED; lIndex++ )\r
+\r
+       for( lIndex = 0; lIndex < partstMAX_LED; lIndex++ )\r
        {\r
                cLedOutput[ lIndex ] = 0;\r
        }\r
        {\r
                cLedOutput[ lIndex ] = 0;\r
        }\r
@@ -78,7 +79,7 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
 {\r
        taskENTER_CRITICAL();\r
        {\r
 {\r
        taskENTER_CRITICAL();\r
        {\r
-               switch ( uxLED )\r
+               switch( uxLED )\r
                {\r
                        case 0:\r
                                Pin_LED_0_Write( xValue & 0x1 );\r
                {\r
                        case 0:\r
                                Pin_LED_0_Write( xValue & 0x1 );\r
@@ -100,7 +101,7 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
        taskEXIT_CRITICAL();\r
        \r
        /* Record the output for the sake of toggling. */\r
        taskEXIT_CRITICAL();\r
        \r
        /* Record the output for the sake of toggling. */\r
-       if ( uxLED < partstMAX_LED )\r
+       if( uxLED < partstMAX_LED )\r
        {\r
                cLedOutput[ uxLED ] = ( xValue & 0x1 );\r
        }\r
        {\r
                cLedOutput[ uxLED ] = ( xValue & 0x1 );\r
        }\r
@@ -109,7 +110,7 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
 \r
 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
 {\r
 \r
 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
 {\r
-       if ( uxLED < partstMAX_LED )\r
+       if( uxLED < partstMAX_LED )\r
        {\r
                vParTestSetLED( uxLED, !cLedOutput[ uxLED ] );\r
        }\r
        {\r
                vParTestSetLED( uxLED, !cLedOutput[ uxLED ] );\r
        }\r
index a82d0c00a345da24590b9b00be805393fb93fd18..e81352fed55ef8343da4583e0eab1a57d4159f38 100644 (file)
@@ -61,8 +61,8 @@
 #define serialSTRING_DELAY_TICKS               ( portMAX_DELAY )\r
 /*---------------------------------------------------------------------------*/\r
 \r
 #define serialSTRING_DELAY_TICKS               ( portMAX_DELAY )\r
 /*---------------------------------------------------------------------------*/\r
 \r
-CY_ISR_PROTO(vUartRxISR);\r
-CY_ISR_PROTO(vUartTxISR);\r
+CY_ISR_PROTO( vUartRxISR );\r
+CY_ISR_PROTO( vUartTxISR );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 static xQueueHandle xSerialTxQueue = NULL;\r
 /*---------------------------------------------------------------------------*/\r
 \r
 static xQueueHandle xSerialTxQueue = NULL;\r
@@ -85,23 +85,24 @@ xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned port
        UART_1_SetTxInterruptMode( 0 );\r
 \r
        /* Both configured successfully. */\r
        UART_1_SetTxInterruptMode( 0 );\r
 \r
        /* Both configured successfully. */\r
-       return (xComPortHandle)( xSerialTxQueue && xSerialRxQueue );\r
+       return ( xComPortHandle )( xSerialTxQueue && xSerialRxQueue );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
 {\r
 unsigned short usIndex = 0;\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
 {\r
 unsigned short usIndex = 0;\r
-       for ( usIndex = 0; usIndex < usStringLength; usIndex++ )\r
+\r
+       for( usIndex = 0; usIndex < usStringLength; usIndex++ )\r
        {\r
                /* Check for pre-mature end of line. */\r
        {\r
                /* Check for pre-mature end of line. */\r
-               if ( '\0' == pcString[ usIndex ] )\r
+               if( '\0' == pcString[ usIndex ] )\r
                {\r
                        break;\r
                }\r
                \r
                /* Send out, one character at a time. */\r
                {\r
                        break;\r
                }\r
                \r
                /* Send out, one character at a time. */\r
-               if ( pdTRUE != xSerialPutChar( NULL, pcString[ usIndex ], serialSTRING_DELAY_TICKS ) )\r
+               if( pdTRUE != xSerialPutChar( NULL, pcString[ usIndex ], serialSTRING_DELAY_TICKS ) )\r
                {\r
                        /* Failed to send, this will be picked up in the receive comtest task. */\r
                }\r
                {\r
                        /* Failed to send, this will be picked up in the receive comtest task. */\r
                }\r
@@ -112,7 +113,8 @@ unsigned short usIndex = 0;
 signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
 {\r
 portBASE_TYPE xReturn = pdFALSE;\r
 signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
 {\r
 portBASE_TYPE xReturn = pdFALSE;\r
-       if ( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) )\r
+\r
+       if( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) )\r
        {\r
                /* Picked up a character. */\r
                xReturn = pdTRUE;\r
        {\r
                /* Picked up a character. */\r
                xReturn = pdTRUE;\r
@@ -126,7 +128,7 @@ signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar
 portBASE_TYPE xReturn = pdFALSE;\r
 \r
        /* The ISR is processing characters is so just add to the end of the queue. */\r
 portBASE_TYPE xReturn = pdFALSE;\r
 \r
        /* The ISR is processing characters is so just add to the end of the queue. */\r
-       if ( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) )\r
+       if( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) )\r
        {       \r
                xReturn = pdTRUE;\r
        }\r
        {       \r
                xReturn = pdTRUE;\r
        }\r
@@ -137,9 +139,8 @@ portBASE_TYPE xReturn = pdFALSE;
        }\r
 \r
        /* Make sure that the interrupt will fire in the case where:\r
        }\r
 \r
        /* Make sure that the interrupt will fire in the case where:\r
-       *     Currently sending so the Tx Complete will fire.\r
-       *     Not sending so the Empty will fire.\r
-       */\r
+           Currently sending so the Tx Complete will fire.\r
+           Not sending so the Empty will fire. */\r
        taskENTER_CRITICAL();\r
                UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY );\r
        taskEXIT_CRITICAL();\r
        taskENTER_CRITICAL();\r
                UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY );\r
        taskEXIT_CRITICAL();\r
@@ -150,7 +151,7 @@ portBASE_TYPE xReturn = pdFALSE;
 \r
 CY_ISR(vUartRxISR)\r
 {\r
 \r
 CY_ISR(vUartRxISR)\r
 {\r
-portBASE_TYPE xTaskWoken = pdFALSE;\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 volatile unsigned char ucStatus = 0;\r
 signed char cInChar = 0;\r
 unsigned long ulMask = 0;\r
 volatile unsigned char ucStatus = 0;\r
 signed char cInChar = 0;\r
 unsigned long ulMask = 0;\r
@@ -159,7 +160,7 @@ unsigned long ulMask = 0;
        ucStatus = UART_1_ReadRxStatus();\r
 \r
        /* Only interested in a character being received. */\r
        ucStatus = UART_1_ReadRxStatus();\r
 \r
        /* Only interested in a character being received. */\r
-       if ( 0 != ( ucStatus & UART_1_RX_STS_FIFO_NOTEMPTY ) )\r
+       if( 0 != ( ucStatus & UART_1_RX_STS_FIFO_NOTEMPTY ) )\r
        {\r
                /* Get the character. */\r
                cInChar = UART_1_GetChar();\r
        {\r
                /* Get the character. */\r
                cInChar = UART_1_GetChar();\r
@@ -168,7 +169,7 @@ unsigned long ulMask = 0;
                ulMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
                        /* Try to deliver the character. */\r
                ulMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
                        /* Try to deliver the character. */\r
-                       if ( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xTaskWoken ) )\r
+                       if( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xHigherPriorityTaskWoken ) )\r
                        {\r
                                /* Run out of space. */\r
                        }\r
                        {\r
                                /* Run out of space. */\r
                        }\r
@@ -176,14 +177,20 @@ unsigned long ulMask = 0;
                portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );\r
        }\r
 \r
                portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );\r
        }\r
 \r
-       /* If we delivered the character then a context switch might be required. */\r
-       portEND_SWITCHING_ISR( xTaskWoken );\r
+       /* If we delivered the character then a context switch might be required.\r
+       xHigherPriorityTaskWoken was set to pdFALSE on interrupt entry.  If calling \r
+       xQueueSendFromISR() caused a task to unblock, and the unblocked task has\r
+       a priority equal to or higher than the currently running task (the task this\r
+       ISR interrupted), then xHigherPriorityTaskWoken will have been set to pdTRUE and\r
+       portEND_SWITCHING_ISR() will request a context switch to the newly unblocked\r
+       task. */\r
+       portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 CY_ISR(vUartTxISR)\r
 {\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 CY_ISR(vUartTxISR)\r
 {\r
-portBASE_TYPE xTaskWoken = pdFALSE;\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 volatile unsigned char ucStatus = 0;\r
 signed char cOutChar = 0;\r
 unsigned long ulMask = 0;\r
 volatile unsigned char ucStatus = 0;\r
 signed char cOutChar = 0;\r
 unsigned long ulMask = 0;\r
@@ -192,35 +199,38 @@ unsigned long ulMask = 0;
        ucStatus = UART_1_ReadTxStatus();\r
        \r
        /* Check to see whether this is a genuine interrupt. */\r
        ucStatus = UART_1_ReadTxStatus();\r
        \r
        /* Check to see whether this is a genuine interrupt. */\r
-       if ( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) )\r
-               || ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) )\r
+       if( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) ) || ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) )\r
        {       \r
                /* Mask off the other RTOS interrupts to interact with the queue. */\r
                ulMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
        {       \r
                /* Mask off the other RTOS interrupts to interact with the queue. */\r
                ulMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
-                       if ( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xTaskWoken ) )\r
+                       if( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xHigherPriorityTaskWoken ) )\r
                        {\r
                                /* Send the next character. */\r
                                UART_1_PutChar( cOutChar );                     \r
 \r
                                /* If we are firing, then the only interrupt we are interested in\r
                        {\r
                                /* Send the next character. */\r
                                UART_1_PutChar( cOutChar );                     \r
 \r
                                /* If we are firing, then the only interrupt we are interested in\r
-                               * is the Complete. The application code will add the Empty interrupt\r
-                               * when there is something else to be done.\r
-                               */\r
+                               is the Complete. The application code will add the Empty interrupt\r
+                               when there is something else to be done. */\r
                                UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE );\r
                        }\r
                        else\r
                        {\r
                                UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE );\r
                        }\r
                        else\r
                        {\r
-                               /* There is no work left so disable the interrupt\r
-                                * until the application puts more into the queue.\r
-                                */\r
+                               /* There is no work left so disable the interrupt until the application \r
+                               puts more into the queue. */\r
                                UART_1_SetTxInterruptMode( 0 );\r
                        }\r
                }\r
                portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );\r
        }\r
 \r
                                UART_1_SetTxInterruptMode( 0 );\r
                        }\r
                }\r
                portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );\r
        }\r
 \r
-       /* If we delivered the character then a context switch might be required. */\r
-       portEND_SWITCHING_ISR( xTaskWoken );\r
+       /* If we delivered the character then a context switch might be required.\r
+       xHigherPriorityTaskWoken was set to pdFALSE on interrupt entry.  If calling \r
+       xQueueSendFromISR() caused a task to unblock, and the unblocked task has\r
+       a priority equal to or higher than the currently running task (the task this\r
+       ISR interrupted), then xHigherPriorityTaskWoken will have been set to pdTRUE and\r
+       portEND_SWITCHING_ISR() will request a context switch to the newly unblocked\r
+       task. */\r
+       portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 }\r
 /*---------------------------------------------------------------------------*/\r
index 3aa26e31cff374a8cc3cb926c9d7dbb9584e3655..fe8b6ff3fb9d527868132bc5fd60921d46173a9b 100644 (file)
@@ -107,7 +107,7 @@ tick hook. */
 extern void vSetupTimerTest( void );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 extern void vSetupTimerTest( void );\r
 /*---------------------------------------------------------------------------*/\r
 \r
-/**\r
+/*\r
  * The Check task periodical interrogates each of the running tests to\r
  * ensure that they are still executing correctly.\r
  * If all the tests pass, then the LCD is updated with Pass, the number of \r
  * The Check task periodical interrogates each of the running tests to\r
  * ensure that they are still executing correctly.\r
  * If all the tests pass, then the LCD is updated with Pass, the number of \r
@@ -117,7 +117,7 @@ extern void vSetupTimerTest( void );
  */\r
 void vCheckTask( void *pvParameters );\r
 \r
  */\r
 void vCheckTask( void *pvParameters );\r
 \r
-/**\r
+/*\r
  * Installs the RTOS interrupt handlers and starts the peripherals.\r
  */\r
 static void prvHardwareSetup( void );\r
  * Installs the RTOS interrupt handlers and starts the peripherals.\r
  */\r
 static void prvHardwareSetup( void );\r
@@ -131,25 +131,6 @@ unsigned long ulIteration = 0;
     /* Place your initialization/startup code here (e.g. MyInst_Start()) */\r
        prvHardwareSetup();\r
 \r
     /* Place your initialization/startup code here (e.g. MyInst_Start()) */\r
        prvHardwareSetup();\r
 \r
-       /* Poll the switch connected to P1[7]\r
-        * to prevent the Soak test from (re)starting.\r
-        */\r
-       while ( 0 != Startup_Release_Switch_Read() )\r
-       {\r
-               if ( 100000 <= ulIteration++ )\r
-               {\r
-                       vParTestToggleLED( ulLed++ );\r
-                       ulLed = ulLed % 4;\r
-                       ulIteration = 0;\r
-               }\r
-       }\r
-       \r
-       /* Reset the LEDS. */\r
-       for ( ulLed = 0; ulLed < 4; ulLed++ )\r
-       {\r
-               vParTestSetLED( ulLed, pdFALSE );\r
-       }\r
-\r
        /* Start the standard demo tasks.  These are just here to exercise the\r
        kernel port and provide examples of how the FreeRTOS API can be used. */\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
        /* Start the standard demo tasks.  These are just here to exercise the\r
        kernel port and provide examples of how the FreeRTOS API can be used. */\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
@@ -167,7 +148,7 @@ unsigned long ulIteration = 0;
        vStartInterruptQueueTasks();\r
 \r
        /* Start the error checking task. */\r
        vStartInterruptQueueTasks();\r
 \r
        /* Start the error checking task. */\r
-       (void)xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
+       ( void ) xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
 \r
        /* Configure the timers used by the fast interrupt timer test. */\r
        vSetupTimerTest();\r
 \r
        /* Configure the timers used by the fast interrupt timer test. */\r
        vSetupTimerTest();\r
@@ -181,8 +162,11 @@ unsigned long ulIteration = 0;
     task.  The idle task is created within vTaskStartScheduler(). */\r
        vTaskStartScheduler();\r
 \r
     task.  The idle task is created within vTaskStartScheduler(). */\r
        vTaskStartScheduler();\r
 \r
-       /* Should never reach here. */\r
-       for (;;);\r
+       /* Should never reach here as the kernel will now be running.  If\r
+       vTaskStartScheduler() does return then it is very likely that there was\r
+       insufficient (FreeRTOS) heap space available to create all the tasks,\r
+       including the idle task that is created within vTaskStartScheduler() itself. */\r
+       for( ;; );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
@@ -195,18 +179,18 @@ extern void vPortSVCHandler( void );
 extern cyisraddress CyRamVectors[];\r
 \r
        /* Install the OS Interrupt Handlers. */\r
 extern cyisraddress CyRamVectors[];\r
 \r
        /* Install the OS Interrupt Handlers. */\r
-       CyRamVectors[11] = (cyisraddress)vPortSVCHandler;\r
-       CyRamVectors[14] = (cyisraddress)xPortPendSVHandler;\r
-       CyRamVectors[15] = (cyisraddress)xPortSysTickHandler;\r
+       CyRamVectors[ 11 ] = ( cyisraddress ) vPortSVCHandler;\r
+       CyRamVectors[ 14 ] = ( cyisraddress ) xPortPendSVHandler;\r
+       CyRamVectors[ 15 ] = ( cyisraddress ) xPortSysTickHandler;\r
 \r
        /* Start-up the peripherals. */\r
 \r
        /* Enable and clear the LCD Display. */\r
        LCD_Character_Display_Start();\r
        LCD_Character_Display_ClearDisplay();\r
 \r
        /* Start-up the peripherals. */\r
 \r
        /* Enable and clear the LCD Display. */\r
        LCD_Character_Display_Start();\r
        LCD_Character_Display_ClearDisplay();\r
-       LCD_Character_Display_Position(0,0);\r
-       LCD_Character_Display_PrintString("www.FreeRTOS.org ");\r
-       LCD_Character_Display_Position(1,0);\r
+       LCD_Character_Display_Position( 0, 0 );\r
+       LCD_Character_Display_PrintString( "www.FreeRTOS.org " );\r
+       LCD_Character_Display_Position( 1, 0 );\r
        LCD_Character_Display_PrintString("CY8C5588AX-060  ");\r
 \r
        /* Start the UART. */\r
        LCD_Character_Display_PrintString("CY8C5588AX-060  ");\r
 \r
        /* Start the UART. */\r
@@ -236,97 +220,97 @@ extern unsigned portSHORT usMaxJitter;
        /* Intialise the sleeper. */\r
        xDelay = xTaskGetTickCount();\r
        \r
        /* Intialise the sleeper. */\r
        xDelay = xTaskGetTickCount();\r
        \r
-       for ( ;; )\r
+       for( ;; )\r
        {\r
                /* Perform this check every mainCHECK_DELAY milliseconds. */\r
                vTaskDelayUntil( &xDelay, mainCHECK_DELAY );\r
                \r
                /* Check that all of the Demo tasks are still running. */\r
        {\r
                /* Perform this check every mainCHECK_DELAY milliseconds. */\r
                vTaskDelayUntil( &xDelay, mainCHECK_DELAY );\r
                \r
                /* Check that all of the Demo tasks are still running. */\r
-               if ( pdTRUE != xAreBlockingQueuesStillRunning() )\r
+               if( pdTRUE != xAreBlockingQueuesStillRunning() )\r
                {\r
                        usErrorCode |= 0x1;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x1;\r
                }\r
                \r
-               if ( pdTRUE != xAreBlockTimeTestTasksStillRunning() )\r
+               if( pdTRUE != xAreBlockTimeTestTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x2;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x2;\r
                }\r
                \r
-               if ( pdTRUE != xAreCountingSemaphoreTasksStillRunning() )\r
+               if( pdTRUE != xAreCountingSemaphoreTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x4;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x4;\r
                }\r
                \r
-               if ( pdTRUE != xIsCreateTaskStillRunning() )\r
+               if( pdTRUE != xIsCreateTaskStillRunning() )\r
                {\r
                        usErrorCode |= 0x8;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x8;\r
                }\r
                \r
-               if ( pdTRUE != xAreDynamicPriorityTasksStillRunning() )\r
+               if( pdTRUE != xAreDynamicPriorityTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x10;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x10;\r
                }\r
                \r
-               if ( pdTRUE != xAreMathsTaskStillRunning() )\r
+               if( pdTRUE != xAreMathsTaskStillRunning() )\r
                {\r
                        usErrorCode |= 0x20;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x20;\r
                }\r
                \r
-               if ( pdTRUE != xAreGenericQueueTasksStillRunning() )\r
+               if( pdTRUE != xAreGenericQueueTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x40;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x40;\r
                }\r
                \r
-               if ( pdTRUE != xAreIntegerMathsTaskStillRunning() )\r
+               if( pdTRUE != xAreIntegerMathsTaskStillRunning() )\r
                {\r
                        usErrorCode |= 0x80;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x80;\r
                }\r
                \r
-               if ( pdTRUE != xArePollingQueuesStillRunning() )\r
+               if( pdTRUE != xArePollingQueuesStillRunning() )\r
                {\r
                        usErrorCode |= 0x100;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x100;\r
                }\r
                \r
-               if ( pdTRUE != xAreQueuePeekTasksStillRunning() )\r
+               if( pdTRUE != xAreQueuePeekTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x200;\r
                }\r
                                \r
                {\r
                        usErrorCode |= 0x200;\r
                }\r
                                \r
-               if ( pdTRUE != xAreSemaphoreTasksStillRunning() )\r
+               if( pdTRUE != xAreSemaphoreTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x400;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x400;\r
                }\r
                \r
-               if ( pdTRUE != xAreComTestTasksStillRunning() )\r
+               if( pdTRUE != xAreComTestTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x800;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x800;\r
                }\r
                \r
-               if ( pdTRUE != xAreIntQueueTasksStillRunning() )\r
+               if( pdTRUE != xAreIntQueueTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x1000;\r
                }\r
 \r
                /* Clear the display. */\r
                LCD_Character_Display_ClearDisplay();\r
                {\r
                        usErrorCode |= 0x1000;\r
                }\r
 \r
                /* Clear the display. */\r
                LCD_Character_Display_ClearDisplay();\r
-               if ( 0 == usErrorCode )\r
+               if( 0 == usErrorCode )\r
                {\r
                {\r
-                       LCD_Character_Display_Position( (ulRow) & 0x1, 0);\r
-                       LCD_Character_Display_PrintString("Pass: ");\r
-                       LCD_Character_Display_PrintNumber(ulIteration++);\r
-                       LCD_Character_Display_Position( (++ulRow) & 0x1, 0);\r
-                       LCD_Character_Display_PrintString("Jitter(ns):");\r
-                       LCD_Character_Display_PrintNumber((usMaxJitter * mainNS_PER_CLOCK));\r
+                       LCD_Character_Display_Position( ( ulRow ) & 0x1, 0);\r
+                       LCD_Character_Display_PrintString( "Pass: " );\r
+                       LCD_Character_Display_PrintNumber( ulIteration++ );\r
+                       LCD_Character_Display_Position( ( ++ulRow ) & 0x1, 0 );\r
+                       LCD_Character_Display_PrintString( "Jitter(ns):" );\r
+                       LCD_Character_Display_PrintNumber( ( usMaxJitter * mainNS_PER_CLOCK ) );\r
                }\r
                else\r
                {\r
                        /* Do something to indicate the failure. */\r
                }\r
                else\r
                {\r
                        /* Do something to indicate the failure. */\r
-                       LCD_Character_Display_Position( (ulRow) & 0x1, 0);\r
-                       LCD_Character_Display_PrintString("Fail at: ");\r
-                       LCD_Character_Display_PrintNumber(ulIteration);\r
-                       LCD_Character_Display_Position( (++ulRow) & 0x1, 0);\r
-                       LCD_Character_Display_PrintString("Error: 0x");\r
-                       LCD_Character_Display_PrintHexUint16(usErrorCode);\r
+                       LCD_Character_Display_Position( ( ulRow ) & 0x1, 0 );\r
+                       LCD_Character_Display_PrintString( "Fail at: " );\r
+                       LCD_Character_Display_PrintNumber( ulIteration );\r
+                       LCD_Character_Display_Position( ( ++ulRow ) & 0x1, 0 );\r
+                       LCD_Character_Display_PrintString( "Error: 0x" );\r
+                       LCD_Character_Display_PrintHexUint16( usErrorCode );\r
                }\r
        }\r
 }\r
                }\r
        }\r
 }\r
@@ -335,13 +319,15 @@ extern unsigned portSHORT usMaxJitter;
 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )\r
 {\r
        /* The stack space has been execeeded for a task, considering allocating more. */\r
 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )\r
 {\r
        /* The stack space has been execeeded for a task, considering allocating more. */\r
-       for (;;);\r
+       taskDISABLE_INTERRUPTS();\r
+       for( ;; );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vApplicationMallocFailedHook( void )\r
 {\r
        /* The heap space has been execeeded. */\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vApplicationMallocFailedHook( void )\r
 {\r
        /* The heap space has been execeeded. */\r
-       for (;;);\r
+       taskDISABLE_INTERRUPTS();\r
+       for( ;; );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 }\r
 /*---------------------------------------------------------------------------*/\r
index 94787b3d4c07ac650dd2e6de155ea0b160830573..0005bf2a40a9129d38d382417a911256b4770485 100644 (file)
@@ -60,8 +60,8 @@ extern portBASE_TYPE xFirstTimerHandler( void );
 extern portBASE_TYPE xSecondTimerHandler( void );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 extern portBASE_TYPE xSecondTimerHandler( void );\r
 /*---------------------------------------------------------------------------*/\r
 \r
-CY_ISR_PROTO(vHighFrequencyFirstISR);\r
-CY_ISR_PROTO(vHighFrequencySecondISR);\r
+CY_ISR_PROTO( vHighFrequencyFirstISR );\r
+CY_ISR_PROTO( vHighFrequencySecondISR );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 /**\r
 /*---------------------------------------------------------------------------*/\r
 \r
 /**\r
@@ -73,11 +73,11 @@ void vInitialiseTimerForIntQueueTest( void )
        {\r
                /* Initialise and start the First Timer ISR. */\r
                isr_High_Frequency_2000Hz_ClearPending();\r
        {\r
                /* Initialise and start the First Timer ISR. */\r
                isr_High_Frequency_2000Hz_ClearPending();\r
-               isr_High_Frequency_2000Hz_StartEx((cyisraddress)vHighFrequencyFirstISR);\r
+               isr_High_Frequency_2000Hz_StartEx( ( cyisraddress ) vHighFrequencyFirstISR );\r
 \r
                /* Initialise and start the Second Timer ISR. */\r
                isr_High_Frequency_2001Hz_ClearPending();\r
 \r
                /* Initialise and start the Second Timer ISR. */\r
                isr_High_Frequency_2001Hz_ClearPending();\r
-               isr_High_Frequency_2001Hz_StartEx((cyisraddress)vHighFrequencySecondISR);\r
+               isr_High_Frequency_2001Hz_StartEx( ( cyisraddress ) vHighFrequencySecondISR );\r
        }\r
        taskEXIT_CRITICAL();\r
 }\r
        }\r
        taskEXIT_CRITICAL();\r
 }\r
index e98e673def9c6f56e22b4e815e185771f015a7b6..56f3053039b3839f019998662eb74642f47e40ec 100644 (file)
@@ -67,7 +67,8 @@ static volatile char cLedOutput[ partstMAX_LED ];
 void vParTestInitialise( void )\r
 {\r
 long lIndex;\r
 void vParTestInitialise( void )\r
 {\r
 long lIndex;\r
-       for ( lIndex = 0; lIndex < partstMAX_LED; lIndex++ )\r
+\r
+       for( lIndex = 0; lIndex < partstMAX_LED; lIndex++ )\r
        {\r
                cLedOutput[ lIndex ] = 0;\r
        }\r
        {\r
                cLedOutput[ lIndex ] = 0;\r
        }\r
@@ -78,7 +79,7 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
 {\r
        taskENTER_CRITICAL();\r
        {\r
 {\r
        taskENTER_CRITICAL();\r
        {\r
-               switch ( uxLED )\r
+               switch( uxLED )\r
                {\r
                        case 0:\r
                                Pin_LED_0_Write( xValue & 0x1 );\r
                {\r
                        case 0:\r
                                Pin_LED_0_Write( xValue & 0x1 );\r
@@ -100,7 +101,7 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
        taskEXIT_CRITICAL();\r
        \r
        /* Record the output for the sake of toggling. */\r
        taskEXIT_CRITICAL();\r
        \r
        /* Record the output for the sake of toggling. */\r
-       if ( uxLED < partstMAX_LED )\r
+       if( uxLED < partstMAX_LED )\r
        {\r
                cLedOutput[ uxLED ] = ( xValue & 0x1 );\r
        }\r
        {\r
                cLedOutput[ uxLED ] = ( xValue & 0x1 );\r
        }\r
@@ -109,7 +110,7 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
 \r
 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
 {\r
 \r
 void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
 {\r
-       if ( uxLED < partstMAX_LED )\r
+       if( uxLED < partstMAX_LED )\r
        {\r
                vParTestSetLED( uxLED, !cLedOutput[ uxLED ] );\r
        }\r
        {\r
                vParTestSetLED( uxLED, !cLedOutput[ uxLED ] );\r
        }\r
index a82d0c00a345da24590b9b00be805393fb93fd18..e81352fed55ef8343da4583e0eab1a57d4159f38 100644 (file)
@@ -61,8 +61,8 @@
 #define serialSTRING_DELAY_TICKS               ( portMAX_DELAY )\r
 /*---------------------------------------------------------------------------*/\r
 \r
 #define serialSTRING_DELAY_TICKS               ( portMAX_DELAY )\r
 /*---------------------------------------------------------------------------*/\r
 \r
-CY_ISR_PROTO(vUartRxISR);\r
-CY_ISR_PROTO(vUartTxISR);\r
+CY_ISR_PROTO( vUartRxISR );\r
+CY_ISR_PROTO( vUartTxISR );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 static xQueueHandle xSerialTxQueue = NULL;\r
 /*---------------------------------------------------------------------------*/\r
 \r
 static xQueueHandle xSerialTxQueue = NULL;\r
@@ -85,23 +85,24 @@ xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned port
        UART_1_SetTxInterruptMode( 0 );\r
 \r
        /* Both configured successfully. */\r
        UART_1_SetTxInterruptMode( 0 );\r
 \r
        /* Both configured successfully. */\r
-       return (xComPortHandle)( xSerialTxQueue && xSerialRxQueue );\r
+       return ( xComPortHandle )( xSerialTxQueue && xSerialRxQueue );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
 {\r
 unsigned short usIndex = 0;\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
 {\r
 unsigned short usIndex = 0;\r
-       for ( usIndex = 0; usIndex < usStringLength; usIndex++ )\r
+\r
+       for( usIndex = 0; usIndex < usStringLength; usIndex++ )\r
        {\r
                /* Check for pre-mature end of line. */\r
        {\r
                /* Check for pre-mature end of line. */\r
-               if ( '\0' == pcString[ usIndex ] )\r
+               if( '\0' == pcString[ usIndex ] )\r
                {\r
                        break;\r
                }\r
                \r
                /* Send out, one character at a time. */\r
                {\r
                        break;\r
                }\r
                \r
                /* Send out, one character at a time. */\r
-               if ( pdTRUE != xSerialPutChar( NULL, pcString[ usIndex ], serialSTRING_DELAY_TICKS ) )\r
+               if( pdTRUE != xSerialPutChar( NULL, pcString[ usIndex ], serialSTRING_DELAY_TICKS ) )\r
                {\r
                        /* Failed to send, this will be picked up in the receive comtest task. */\r
                }\r
                {\r
                        /* Failed to send, this will be picked up in the receive comtest task. */\r
                }\r
@@ -112,7 +113,8 @@ unsigned short usIndex = 0;
 signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
 {\r
 portBASE_TYPE xReturn = pdFALSE;\r
 signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
 {\r
 portBASE_TYPE xReturn = pdFALSE;\r
-       if ( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) )\r
+\r
+       if( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) )\r
        {\r
                /* Picked up a character. */\r
                xReturn = pdTRUE;\r
        {\r
                /* Picked up a character. */\r
                xReturn = pdTRUE;\r
@@ -126,7 +128,7 @@ signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar
 portBASE_TYPE xReturn = pdFALSE;\r
 \r
        /* The ISR is processing characters is so just add to the end of the queue. */\r
 portBASE_TYPE xReturn = pdFALSE;\r
 \r
        /* The ISR is processing characters is so just add to the end of the queue. */\r
-       if ( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) )\r
+       if( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) )\r
        {       \r
                xReturn = pdTRUE;\r
        }\r
        {       \r
                xReturn = pdTRUE;\r
        }\r
@@ -137,9 +139,8 @@ portBASE_TYPE xReturn = pdFALSE;
        }\r
 \r
        /* Make sure that the interrupt will fire in the case where:\r
        }\r
 \r
        /* Make sure that the interrupt will fire in the case where:\r
-       *     Currently sending so the Tx Complete will fire.\r
-       *     Not sending so the Empty will fire.\r
-       */\r
+           Currently sending so the Tx Complete will fire.\r
+           Not sending so the Empty will fire. */\r
        taskENTER_CRITICAL();\r
                UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY );\r
        taskEXIT_CRITICAL();\r
        taskENTER_CRITICAL();\r
                UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY );\r
        taskEXIT_CRITICAL();\r
@@ -150,7 +151,7 @@ portBASE_TYPE xReturn = pdFALSE;
 \r
 CY_ISR(vUartRxISR)\r
 {\r
 \r
 CY_ISR(vUartRxISR)\r
 {\r
-portBASE_TYPE xTaskWoken = pdFALSE;\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 volatile unsigned char ucStatus = 0;\r
 signed char cInChar = 0;\r
 unsigned long ulMask = 0;\r
 volatile unsigned char ucStatus = 0;\r
 signed char cInChar = 0;\r
 unsigned long ulMask = 0;\r
@@ -159,7 +160,7 @@ unsigned long ulMask = 0;
        ucStatus = UART_1_ReadRxStatus();\r
 \r
        /* Only interested in a character being received. */\r
        ucStatus = UART_1_ReadRxStatus();\r
 \r
        /* Only interested in a character being received. */\r
-       if ( 0 != ( ucStatus & UART_1_RX_STS_FIFO_NOTEMPTY ) )\r
+       if( 0 != ( ucStatus & UART_1_RX_STS_FIFO_NOTEMPTY ) )\r
        {\r
                /* Get the character. */\r
                cInChar = UART_1_GetChar();\r
        {\r
                /* Get the character. */\r
                cInChar = UART_1_GetChar();\r
@@ -168,7 +169,7 @@ unsigned long ulMask = 0;
                ulMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
                        /* Try to deliver the character. */\r
                ulMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
                        /* Try to deliver the character. */\r
-                       if ( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xTaskWoken ) )\r
+                       if( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xHigherPriorityTaskWoken ) )\r
                        {\r
                                /* Run out of space. */\r
                        }\r
                        {\r
                                /* Run out of space. */\r
                        }\r
@@ -176,14 +177,20 @@ unsigned long ulMask = 0;
                portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );\r
        }\r
 \r
                portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );\r
        }\r
 \r
-       /* If we delivered the character then a context switch might be required. */\r
-       portEND_SWITCHING_ISR( xTaskWoken );\r
+       /* If we delivered the character then a context switch might be required.\r
+       xHigherPriorityTaskWoken was set to pdFALSE on interrupt entry.  If calling \r
+       xQueueSendFromISR() caused a task to unblock, and the unblocked task has\r
+       a priority equal to or higher than the currently running task (the task this\r
+       ISR interrupted), then xHigherPriorityTaskWoken will have been set to pdTRUE and\r
+       portEND_SWITCHING_ISR() will request a context switch to the newly unblocked\r
+       task. */\r
+       portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 CY_ISR(vUartTxISR)\r
 {\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 CY_ISR(vUartTxISR)\r
 {\r
-portBASE_TYPE xTaskWoken = pdFALSE;\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 volatile unsigned char ucStatus = 0;\r
 signed char cOutChar = 0;\r
 unsigned long ulMask = 0;\r
 volatile unsigned char ucStatus = 0;\r
 signed char cOutChar = 0;\r
 unsigned long ulMask = 0;\r
@@ -192,35 +199,38 @@ unsigned long ulMask = 0;
        ucStatus = UART_1_ReadTxStatus();\r
        \r
        /* Check to see whether this is a genuine interrupt. */\r
        ucStatus = UART_1_ReadTxStatus();\r
        \r
        /* Check to see whether this is a genuine interrupt. */\r
-       if ( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) )\r
-               || ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) )\r
+       if( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) ) || ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) )\r
        {       \r
                /* Mask off the other RTOS interrupts to interact with the queue. */\r
                ulMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
        {       \r
                /* Mask off the other RTOS interrupts to interact with the queue. */\r
                ulMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
-                       if ( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xTaskWoken ) )\r
+                       if( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xHigherPriorityTaskWoken ) )\r
                        {\r
                                /* Send the next character. */\r
                                UART_1_PutChar( cOutChar );                     \r
 \r
                                /* If we are firing, then the only interrupt we are interested in\r
                        {\r
                                /* Send the next character. */\r
                                UART_1_PutChar( cOutChar );                     \r
 \r
                                /* If we are firing, then the only interrupt we are interested in\r
-                               * is the Complete. The application code will add the Empty interrupt\r
-                               * when there is something else to be done.\r
-                               */\r
+                               is the Complete. The application code will add the Empty interrupt\r
+                               when there is something else to be done. */\r
                                UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE );\r
                        }\r
                        else\r
                        {\r
                                UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE );\r
                        }\r
                        else\r
                        {\r
-                               /* There is no work left so disable the interrupt\r
-                                * until the application puts more into the queue.\r
-                                */\r
+                               /* There is no work left so disable the interrupt until the application \r
+                               puts more into the queue. */\r
                                UART_1_SetTxInterruptMode( 0 );\r
                        }\r
                }\r
                portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );\r
        }\r
 \r
                                UART_1_SetTxInterruptMode( 0 );\r
                        }\r
                }\r
                portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );\r
        }\r
 \r
-       /* If we delivered the character then a context switch might be required. */\r
-       portEND_SWITCHING_ISR( xTaskWoken );\r
+       /* If we delivered the character then a context switch might be required.\r
+       xHigherPriorityTaskWoken was set to pdFALSE on interrupt entry.  If calling \r
+       xQueueSendFromISR() caused a task to unblock, and the unblocked task has\r
+       a priority equal to or higher than the currently running task (the task this\r
+       ISR interrupted), then xHigherPriorityTaskWoken will have been set to pdTRUE and\r
+       portEND_SWITCHING_ISR() will request a context switch to the newly unblocked\r
+       task. */\r
+       portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 }\r
 /*---------------------------------------------------------------------------*/\r
index 3aa26e31cff374a8cc3cb926c9d7dbb9584e3655..fe8b6ff3fb9d527868132bc5fd60921d46173a9b 100644 (file)
@@ -107,7 +107,7 @@ tick hook. */
 extern void vSetupTimerTest( void );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 extern void vSetupTimerTest( void );\r
 /*---------------------------------------------------------------------------*/\r
 \r
-/**\r
+/*\r
  * The Check task periodical interrogates each of the running tests to\r
  * ensure that they are still executing correctly.\r
  * If all the tests pass, then the LCD is updated with Pass, the number of \r
  * The Check task periodical interrogates each of the running tests to\r
  * ensure that they are still executing correctly.\r
  * If all the tests pass, then the LCD is updated with Pass, the number of \r
@@ -117,7 +117,7 @@ extern void vSetupTimerTest( void );
  */\r
 void vCheckTask( void *pvParameters );\r
 \r
  */\r
 void vCheckTask( void *pvParameters );\r
 \r
-/**\r
+/*\r
  * Installs the RTOS interrupt handlers and starts the peripherals.\r
  */\r
 static void prvHardwareSetup( void );\r
  * Installs the RTOS interrupt handlers and starts the peripherals.\r
  */\r
 static void prvHardwareSetup( void );\r
@@ -131,25 +131,6 @@ unsigned long ulIteration = 0;
     /* Place your initialization/startup code here (e.g. MyInst_Start()) */\r
        prvHardwareSetup();\r
 \r
     /* Place your initialization/startup code here (e.g. MyInst_Start()) */\r
        prvHardwareSetup();\r
 \r
-       /* Poll the switch connected to P1[7]\r
-        * to prevent the Soak test from (re)starting.\r
-        */\r
-       while ( 0 != Startup_Release_Switch_Read() )\r
-       {\r
-               if ( 100000 <= ulIteration++ )\r
-               {\r
-                       vParTestToggleLED( ulLed++ );\r
-                       ulLed = ulLed % 4;\r
-                       ulIteration = 0;\r
-               }\r
-       }\r
-       \r
-       /* Reset the LEDS. */\r
-       for ( ulLed = 0; ulLed < 4; ulLed++ )\r
-       {\r
-               vParTestSetLED( ulLed, pdFALSE );\r
-       }\r
-\r
        /* Start the standard demo tasks.  These are just here to exercise the\r
        kernel port and provide examples of how the FreeRTOS API can be used. */\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
        /* Start the standard demo tasks.  These are just here to exercise the\r
        kernel port and provide examples of how the FreeRTOS API can be used. */\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
@@ -167,7 +148,7 @@ unsigned long ulIteration = 0;
        vStartInterruptQueueTasks();\r
 \r
        /* Start the error checking task. */\r
        vStartInterruptQueueTasks();\r
 \r
        /* Start the error checking task. */\r
-       (void)xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
+       ( void ) xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
 \r
        /* Configure the timers used by the fast interrupt timer test. */\r
        vSetupTimerTest();\r
 \r
        /* Configure the timers used by the fast interrupt timer test. */\r
        vSetupTimerTest();\r
@@ -181,8 +162,11 @@ unsigned long ulIteration = 0;
     task.  The idle task is created within vTaskStartScheduler(). */\r
        vTaskStartScheduler();\r
 \r
     task.  The idle task is created within vTaskStartScheduler(). */\r
        vTaskStartScheduler();\r
 \r
-       /* Should never reach here. */\r
-       for (;;);\r
+       /* Should never reach here as the kernel will now be running.  If\r
+       vTaskStartScheduler() does return then it is very likely that there was\r
+       insufficient (FreeRTOS) heap space available to create all the tasks,\r
+       including the idle task that is created within vTaskStartScheduler() itself. */\r
+       for( ;; );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
@@ -195,18 +179,18 @@ extern void vPortSVCHandler( void );
 extern cyisraddress CyRamVectors[];\r
 \r
        /* Install the OS Interrupt Handlers. */\r
 extern cyisraddress CyRamVectors[];\r
 \r
        /* Install the OS Interrupt Handlers. */\r
-       CyRamVectors[11] = (cyisraddress)vPortSVCHandler;\r
-       CyRamVectors[14] = (cyisraddress)xPortPendSVHandler;\r
-       CyRamVectors[15] = (cyisraddress)xPortSysTickHandler;\r
+       CyRamVectors[ 11 ] = ( cyisraddress ) vPortSVCHandler;\r
+       CyRamVectors[ 14 ] = ( cyisraddress ) xPortPendSVHandler;\r
+       CyRamVectors[ 15 ] = ( cyisraddress ) xPortSysTickHandler;\r
 \r
        /* Start-up the peripherals. */\r
 \r
        /* Enable and clear the LCD Display. */\r
        LCD_Character_Display_Start();\r
        LCD_Character_Display_ClearDisplay();\r
 \r
        /* Start-up the peripherals. */\r
 \r
        /* Enable and clear the LCD Display. */\r
        LCD_Character_Display_Start();\r
        LCD_Character_Display_ClearDisplay();\r
-       LCD_Character_Display_Position(0,0);\r
-       LCD_Character_Display_PrintString("www.FreeRTOS.org ");\r
-       LCD_Character_Display_Position(1,0);\r
+       LCD_Character_Display_Position( 0, 0 );\r
+       LCD_Character_Display_PrintString( "www.FreeRTOS.org " );\r
+       LCD_Character_Display_Position( 1, 0 );\r
        LCD_Character_Display_PrintString("CY8C5588AX-060  ");\r
 \r
        /* Start the UART. */\r
        LCD_Character_Display_PrintString("CY8C5588AX-060  ");\r
 \r
        /* Start the UART. */\r
@@ -236,97 +220,97 @@ extern unsigned portSHORT usMaxJitter;
        /* Intialise the sleeper. */\r
        xDelay = xTaskGetTickCount();\r
        \r
        /* Intialise the sleeper. */\r
        xDelay = xTaskGetTickCount();\r
        \r
-       for ( ;; )\r
+       for( ;; )\r
        {\r
                /* Perform this check every mainCHECK_DELAY milliseconds. */\r
                vTaskDelayUntil( &xDelay, mainCHECK_DELAY );\r
                \r
                /* Check that all of the Demo tasks are still running. */\r
        {\r
                /* Perform this check every mainCHECK_DELAY milliseconds. */\r
                vTaskDelayUntil( &xDelay, mainCHECK_DELAY );\r
                \r
                /* Check that all of the Demo tasks are still running. */\r
-               if ( pdTRUE != xAreBlockingQueuesStillRunning() )\r
+               if( pdTRUE != xAreBlockingQueuesStillRunning() )\r
                {\r
                        usErrorCode |= 0x1;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x1;\r
                }\r
                \r
-               if ( pdTRUE != xAreBlockTimeTestTasksStillRunning() )\r
+               if( pdTRUE != xAreBlockTimeTestTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x2;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x2;\r
                }\r
                \r
-               if ( pdTRUE != xAreCountingSemaphoreTasksStillRunning() )\r
+               if( pdTRUE != xAreCountingSemaphoreTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x4;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x4;\r
                }\r
                \r
-               if ( pdTRUE != xIsCreateTaskStillRunning() )\r
+               if( pdTRUE != xIsCreateTaskStillRunning() )\r
                {\r
                        usErrorCode |= 0x8;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x8;\r
                }\r
                \r
-               if ( pdTRUE != xAreDynamicPriorityTasksStillRunning() )\r
+               if( pdTRUE != xAreDynamicPriorityTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x10;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x10;\r
                }\r
                \r
-               if ( pdTRUE != xAreMathsTaskStillRunning() )\r
+               if( pdTRUE != xAreMathsTaskStillRunning() )\r
                {\r
                        usErrorCode |= 0x20;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x20;\r
                }\r
                \r
-               if ( pdTRUE != xAreGenericQueueTasksStillRunning() )\r
+               if( pdTRUE != xAreGenericQueueTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x40;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x40;\r
                }\r
                \r
-               if ( pdTRUE != xAreIntegerMathsTaskStillRunning() )\r
+               if( pdTRUE != xAreIntegerMathsTaskStillRunning() )\r
                {\r
                        usErrorCode |= 0x80;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x80;\r
                }\r
                \r
-               if ( pdTRUE != xArePollingQueuesStillRunning() )\r
+               if( pdTRUE != xArePollingQueuesStillRunning() )\r
                {\r
                        usErrorCode |= 0x100;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x100;\r
                }\r
                \r
-               if ( pdTRUE != xAreQueuePeekTasksStillRunning() )\r
+               if( pdTRUE != xAreQueuePeekTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x200;\r
                }\r
                                \r
                {\r
                        usErrorCode |= 0x200;\r
                }\r
                                \r
-               if ( pdTRUE != xAreSemaphoreTasksStillRunning() )\r
+               if( pdTRUE != xAreSemaphoreTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x400;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x400;\r
                }\r
                \r
-               if ( pdTRUE != xAreComTestTasksStillRunning() )\r
+               if( pdTRUE != xAreComTestTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x800;\r
                }\r
                \r
                {\r
                        usErrorCode |= 0x800;\r
                }\r
                \r
-               if ( pdTRUE != xAreIntQueueTasksStillRunning() )\r
+               if( pdTRUE != xAreIntQueueTasksStillRunning() )\r
                {\r
                        usErrorCode |= 0x1000;\r
                }\r
 \r
                /* Clear the display. */\r
                LCD_Character_Display_ClearDisplay();\r
                {\r
                        usErrorCode |= 0x1000;\r
                }\r
 \r
                /* Clear the display. */\r
                LCD_Character_Display_ClearDisplay();\r
-               if ( 0 == usErrorCode )\r
+               if( 0 == usErrorCode )\r
                {\r
                {\r
-                       LCD_Character_Display_Position( (ulRow) & 0x1, 0);\r
-                       LCD_Character_Display_PrintString("Pass: ");\r
-                       LCD_Character_Display_PrintNumber(ulIteration++);\r
-                       LCD_Character_Display_Position( (++ulRow) & 0x1, 0);\r
-                       LCD_Character_Display_PrintString("Jitter(ns):");\r
-                       LCD_Character_Display_PrintNumber((usMaxJitter * mainNS_PER_CLOCK));\r
+                       LCD_Character_Display_Position( ( ulRow ) & 0x1, 0);\r
+                       LCD_Character_Display_PrintString( "Pass: " );\r
+                       LCD_Character_Display_PrintNumber( ulIteration++ );\r
+                       LCD_Character_Display_Position( ( ++ulRow ) & 0x1, 0 );\r
+                       LCD_Character_Display_PrintString( "Jitter(ns):" );\r
+                       LCD_Character_Display_PrintNumber( ( usMaxJitter * mainNS_PER_CLOCK ) );\r
                }\r
                else\r
                {\r
                        /* Do something to indicate the failure. */\r
                }\r
                else\r
                {\r
                        /* Do something to indicate the failure. */\r
-                       LCD_Character_Display_Position( (ulRow) & 0x1, 0);\r
-                       LCD_Character_Display_PrintString("Fail at: ");\r
-                       LCD_Character_Display_PrintNumber(ulIteration);\r
-                       LCD_Character_Display_Position( (++ulRow) & 0x1, 0);\r
-                       LCD_Character_Display_PrintString("Error: 0x");\r
-                       LCD_Character_Display_PrintHexUint16(usErrorCode);\r
+                       LCD_Character_Display_Position( ( ulRow ) & 0x1, 0 );\r
+                       LCD_Character_Display_PrintString( "Fail at: " );\r
+                       LCD_Character_Display_PrintNumber( ulIteration );\r
+                       LCD_Character_Display_Position( ( ++ulRow ) & 0x1, 0 );\r
+                       LCD_Character_Display_PrintString( "Error: 0x" );\r
+                       LCD_Character_Display_PrintHexUint16( usErrorCode );\r
                }\r
        }\r
 }\r
                }\r
        }\r
 }\r
@@ -335,13 +319,15 @@ extern unsigned portSHORT usMaxJitter;
 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )\r
 {\r
        /* The stack space has been execeeded for a task, considering allocating more. */\r
 void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )\r
 {\r
        /* The stack space has been execeeded for a task, considering allocating more. */\r
-       for (;;);\r
+       taskDISABLE_INTERRUPTS();\r
+       for( ;; );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vApplicationMallocFailedHook( void )\r
 {\r
        /* The heap space has been execeeded. */\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vApplicationMallocFailedHook( void )\r
 {\r
        /* The heap space has been execeeded. */\r
-       for (;;);\r
+       taskDISABLE_INTERRUPTS();\r
+       for( ;; );\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 }\r
 /*---------------------------------------------------------------------------*/\r