From 92afdc40b1a3576d6bfc38cbebad8b90ae91e563 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Thu, 6 Mar 2008 16:51:57 +0000 Subject: [PATCH] Update commenting ready for release. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@236 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../RTOSDemo/FreeRTOSConfig.h | 2 - .../PPC405_Xilinx_Virtex4_GCC/RTOSDemo/main.c | 57 +++++++-------- .../RTOSDemo/partest/partest.c | 2 - .../RTOSDemo/serial/serial.c | 69 +++++++++++-------- 4 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/FreeRTOSConfig.h b/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/FreeRTOSConfig.h index 6225b540f..dec25fc64 100644 --- a/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/FreeRTOSConfig.h +++ b/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/FreeRTOSConfig.h @@ -87,6 +87,4 @@ to exclude the API function. */ #define INCLUDE_uxTaskGetStackHighWaterMark 1 -#define configKERNEL_INTERRUPT_PRIORITY 6 - #endif /* FREERTOS_CONFIG_H */ diff --git a/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/main.c b/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/main.c index 7ebdfa711..3cb568645 100644 --- a/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/main.c +++ b/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/main.c @@ -135,7 +135,7 @@ static void prvSetupHardware( void ); /*-----------------------------------------------------------*/ -/* xRegTestStatus will geet set to pdFAIL by the regtest tasks if they +/* xRegTestStatus will get set to pdFAIL by the regtest tasks if they discover an unexpected value. */ static unsigned portBASE_TYPE xRegTestStatus = pdPASS; @@ -151,7 +151,7 @@ int main( void ) prvSetupHardware(); /* Start the standard demo application tasks. Note that the baud rate used - by the comtest tasks is set by the hardware, so the baud rate paramter + by the comtest tasks is set by the hardware, so the baud rate parameter passed has no effect. */ vStartLEDFlashTasks( mainLED_TASK_PRIORITY ); vStartIntegerMathTasks( tskIDLE_PRIORITY ); @@ -261,6 +261,10 @@ static void prvErrorChecks( void *pvParameters ) portTickType xDelayPeriod = mainNO_ERROR_CHECK_DELAY, xLastExecutionTime; volatile unsigned portBASE_TYPE uxFreeStack; + /* This call is just to demonstrate the use of the function - nothing is + done with the value. You would expect the stack high water mark to be + lower (the function to return a larger value) here at function entry than + later following calls to other functions. */ uxFreeStack = uxTaskGetStackHighWaterMark( NULL ); /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil() @@ -271,12 +275,14 @@ volatile unsigned portBASE_TYPE uxFreeStack; operating without error. */ for( ;; ) { + /* Again just for demo purposes - uxFreeStack should have a lower value + here than following the call to uxTaskGetStackHighWaterMark() on the + task entry. */ uxFreeStack = uxTaskGetStackHighWaterMark( NULL ); /* Wait until it is time to check again. The time we wait here depends on whether an error has been detected or not. When an error is detected the time is shortened resulting in a faster LED flash rate. */ - /* Perform this check every mainCHECK_DELAY milliseconds. */ vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod ); /* See if the other tasks are all ok. */ @@ -299,11 +305,18 @@ static void prvSetupHardware( void ) XCache_EnableICache( 0x80000000 ); XCache_EnableDCache( 0x80000000 ); + /* Setup the IO port for use with the LED outputs. */ vParTestInitialise(); } +/*-----------------------------------------------------------*/ static void prvRegTestTask1( void *pvParameters ) { + /* The first register test task as described at the top of this file. The + values used in the registers are different to those use in the second + register test task. Also, unlike the second register test task, this task + yields between setting the register values and subsequently checking the + register values. */ asm volatile ( "RegTest1Start: \n\t" \ @@ -416,9 +429,13 @@ static void prvRegTestTask1( void *pvParameters ) " b RegTest1Start \n\t" \ ); } +/*-----------------------------------------------------------*/ static void prvRegTestTask2( void *pvParameters ) { + /* The second register test task as described at the top of this file. + Note that this task fills the registers with different values to the + first register test task. */ asm volatile ( "RegTest2Start: \n\t" \ @@ -455,9 +472,6 @@ static void prvRegTestTask2( void *pvParameters ) " li 30, 130 \n\t" \ " li 31, 131 \n\t" \ " \n\t" \ - " sc \n\t" \ - " nop \n\t" \ - " \n\t" \ " cmpwi 0, 11 \n\t" \ " bne RegTest2Fail \n\t" \ " cmpwi 2, 12 \n\t" \ @@ -531,34 +545,11 @@ static void prvRegTestTask2( void *pvParameters ) " b RegTest2Start \n\t" \ ); } +/*-----------------------------------------------------------*/ - -#if 0 - -static void prvRegTestTask2( void *pvParameters ) -{ -volatile unsigned int i= 0; - - for( ;; ) - { - i++; - taskYIELD(); - } -} - -static void prvRegTestTask1( void *pvParameters ) -{ -volatile unsigned int i= 0; - - for( ;; ) - { - i++; - taskYIELD(); - } -} - -#endif - +/* This hook function will get called if there is a suspected stack overflow. +An overflow can cause the task name to be corrupted, in which case the task +handle needs to be used to determine the offending task. */ void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName ); void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName ) { diff --git a/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/partest/partest.c b/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/partest/partest.c index d552c385a..40091acfa 100644 --- a/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/partest/partest.c +++ b/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/partest/partest.c @@ -44,8 +44,6 @@ /* Scheduler includes. */ #include "FreeRTOS.h" -#define partstNUM_LEDs 8 - /* Demo application includes. */ #include "partest.h" diff --git a/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/serial/serial.c b/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/serial/serial.c index d4c1750e5..911276549 100644 --- a/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/serial/serial.c +++ b/Demo/PPC405_Xilinx_Virtex4_GCC/RTOSDemo/serial/serial.c @@ -53,12 +53,10 @@ /* Demo application includes. */ #include "serial.h" -/* Microblaze driver includes. */ +/* Library includes. */ #include "xparameters.h" #include "xuartlite.h" #include "xuartlite_l.h" -#include "xintc_l.h" -#include "xintc.h" /*-----------------------------------------------------------*/ @@ -67,26 +65,31 @@ transmitted. */ static xQueueHandle xRxedChars; static xQueueHandle xCharsForTx; +/* Structure that maintains information on the UART being used. */ static XUartLite xUART; +/* + * Sample UART interrupt handler. Note this is used to demonstrate the kernel + * features and test the port - it is not intended to represent an efficient + * implementation. + */ static void vSerialISR( XUartLite *pxUART ); /*-----------------------------------------------------------*/ xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) { -unsigned portLONG ulControlReg, ulMask; -extern XIntc xInterruptController; - /* NOTE: The baud rate used by this driver is determined by the hardware parameterization of the UART Lite peripheral, and the baud value passed to this function has no effect. */ + ( void ) ulWantedBaud; /* Create the queues used to hold Rx and Tx characters. */ xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) ); xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) ); - if( ( xRxedChars ) && ( xCharsForTx ) ) + /* Only initialise the UART if the queues were created correctly. */ + if( ( xRxedChars != NULL ) && ( xCharsForTx != NULL ) ) { XUartLite_Initialize( &xUART, XPAR_RS232_UART_DEVICE_ID ); @@ -94,11 +97,15 @@ extern XIntc xInterruptController; XUartLite_DisableInterrupt( &xUART ); if( xPortInstallInterruptHandler( XPAR_OPB_INTC_0_RS232_UART_INTERRUPT_INTR, ( XInterruptHandler )vSerialISR, (void *)&xUART ) == pdPASS ) - { + { + /* xPortInstallInterruptHandler() could fail if + vPortSetupInterruptController() has not been called prior to this + function. */ XUartLite_EnableInterrupt( &xUART ); } } + /* There is only one port so the handle is not used. */ return ( xComPortHandle ) 0; } /*-----------------------------------------------------------*/ @@ -170,31 +177,37 @@ void vSerialClose( xComPortHandle xPort ) static void vSerialISR( XUartLite *pxUART ) { unsigned portLONG ulISRStatus; -portBASE_TYPE xTaskWokenByTx = pdFALSE, xTaskWokenByRx = pdFALSE; +portBASE_TYPE xTaskWokenByTx = pdFALSE, xTaskWokenByRx = pdFALSE, lDidSomething; portCHAR cChar; - ulISRStatus = XIo_In32( pxUART->RegBaseAddress + XUL_STATUS_REG_OFFSET ); - - if( ( ulISRStatus & (XUL_SR_RX_FIFO_FULL | XUL_SR_RX_FIFO_VALID_DATA ) ) != 0 ) - { - /* A character is available - place it in the queue of received - characters. This might wake a task that was blocked waiting for - data. */ - cChar = ( portCHAR ) XIo_In32( pxUART->RegBaseAddress + XUL_RX_FIFO_OFFSET ); - xTaskWokenByRx = xQueueSendFromISR( xRxedChars, &cChar, xTaskWokenByRx ); - } - - if( ( ulISRStatus & XUL_SR_TX_FIFO_EMPTY ) != 0 ) - { - /* There is space in the FIFO - if there are any characters queue for - transmission they can be send to the UART now. This might unblock a - task that was waiting for space to become available on the Tx queue. */ - if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xTaskWokenByTx ) == pdTRUE ) + do + { + lDidSomething = pdFALSE; + + ulISRStatus = XIo_In32( pxUART->RegBaseAddress + XUL_STATUS_REG_OFFSET ); + + if( ( ulISRStatus & (XUL_SR_RX_FIFO_FULL | XUL_SR_RX_FIFO_VALID_DATA ) ) != 0 ) { - XIo_Out32( pxUART->RegBaseAddress + XUL_TX_FIFO_OFFSET, cChar ); + /* A character is available - place it in the queue of received + characters. This might wake a task that was blocked waiting for + data. */ + cChar = ( portCHAR ) XIo_In32( pxUART->RegBaseAddress + XUL_RX_FIFO_OFFSET ); + xTaskWokenByRx = xQueueSendFromISR( xRxedChars, &cChar, xTaskWokenByRx ); + lDidSomething = pdTRUE; } - } + if( ( ulISRStatus & XUL_SR_TX_FIFO_EMPTY ) != 0 ) + { + /* There is space in the FIFO - if there are any characters queue for + transmission they can be sent to the UART now. This might unblock a + task that was waiting for space to become available on the Tx queue. */ + if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xTaskWokenByTx ) == pdTRUE ) + { + XIo_Out32( pxUART->RegBaseAddress + XUL_TX_FIFO_OFFSET, cChar ); + lDidSomething = pdTRUE; + } + } + } while( lDidSomething == pdTRUE ); /* If we woke any tasks we may require a context switch. */ if( xTaskWokenByTx || xTaskWokenByRx ) -- 2.39.5