From: richardbarry Date: Thu, 30 Jun 2011 15:12:42 +0000 (+0000) Subject: Comment the new standard demo files that were introduced for the new MicroBlaze demo... X-Git-Tag: V7.0.2~132 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=94a9e23b2bdc7c083e54b03b6c7103367f111f50;p=freertos Comment the new standard demo files that were introduced for the new MicroBlaze demo project. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1478 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/Demo_Source/comtest_strings.c b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/Demo_Source/comtest_strings.c index e5746e298..fa8e87e92 100644 --- a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/Demo_Source/comtest_strings.c +++ b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/Demo_Source/comtest_strings.c @@ -60,19 +60,19 @@ * See http://www.serialporttool.com/CommEcho.htm for a suitable echo server * for Windows hosts. * - * The timer sends a string to the UART, toggles an LED, then waits resets - * itself by changing its own period. The period is calculated as a pseudo - * random number between comTX_MAX_BLOCK_TIME and comTX_MIN_BLOCK_TIME. + * The timer sends a string to the UART, toggles an LED, then resets itself by + * changing its own period. The period is calculated as a pseudo random number + * between comTX_MAX_BLOCK_TIME and comTX_MIN_BLOCK_TIME. * - * The task blocks on an Rx queue waiting for a character to become - * available. Received characters are checked to ensure they match those - * transmitted by the Tx timer. An error is latched if characters are missing, - * incorrect, or arrive too slowly. + * The task blocks on an Rx queue waiting for a character to become available. + * Received characters are checked to ensure they match those transmitted by the + * Tx timer. An error is latched if characters are missing, incorrect, or + * arrive too slowly. * * How characters are actually transmitted and received is port specific. Demos * that include this test/demo file will provide example drivers. The Tx timer - * executes in the context of the timer service (daemon) task, and must therefore - * never attempt to block. + * executes in the context of the timer service (daemon) task, and must + * therefore never attempt to block. * */ @@ -100,7 +100,7 @@ /* The size of the stack given to the Rx task. */ #define comSTACK_SIZE configMINIMAL_STACK_SIZE -/* See the comment above the declaraction of uxBaseLED. */ +/* See the comment above the declaraction of the uxBaseLED variable. */ #define comTX_LED_OFFSET ( 0 ) #define comRX_LED_OFFSET ( 1 ) @@ -125,13 +125,17 @@ baud rate being used. */ /* The string that is transmitted and received. */ #define comTRANSACTED_STRING "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" +/* A block time of 0 simply means "don't block". */ +#define comtstDONT_BLOCK ( portTickType ) 0 + /* Handle to the com port used by both tasks. */ static xComPortHandle xPort = NULL; -/* The transmit timer as described at the top of the file. */ -static void vComTxTimerCallback( xTimerHandle xTimer ); +/* The callback function allocated to the transmit timer, as described in the +comments at the top of this file. */ +static void prvComTxTimerCallback( xTimerHandle xTimer ); -/* The receive task as described at the top of the file. */ +/* The receive task as described in the comments at the top of this file. */ static void vComRxTask( void *pvParameters ); /* The Rx task will toggle LED ( uxBaseLED + comRX_LED_OFFSET). The Tx task @@ -143,7 +147,8 @@ function - provided no errors have ever been latched. If this variable stops incrementing, then an error has occurred. */ static volatile unsigned portBASE_TYPE uxRxLoops = 0UL; -/* The timer used to periodically transmit the string. */ +/* The timer used to periodically transmit the string. This is the timer that +has prvComTxTimerCallback allocated to it as its callback function. */ static xTimerHandle xTxTimer = NULL; /* The string length is held at file scope so the Tx timer does not need to @@ -157,7 +162,7 @@ void vStartComTestStringsTasks( unsigned portBASE_TYPE uxPriority, unsigned long /* Store values that are used at run time. */ uxBaseLED = uxLED; - /* Calculate the string length here, rather than each time the timer + /* Calculate the string length here, rather than each time the Tx timer executes. */ xStringLength = strlen( comTRANSACTED_STRING ); @@ -165,23 +170,23 @@ void vStartComTestStringsTasks( unsigned portBASE_TYPE uxPriority, unsigned long detect the end of the string in the Rx task. */ xStringLength++; - /* Initialise the com port then spawn the Rx task and create the Tx + /* Initialise the com port, then spawn the Rx task and create the Tx timer. */ xSerialPortInitMinimal( ulBaudRate, ( xStringLength * 2U ) ); /* Create the Rx task and the Tx timer. The timer is started from the Rx task. */ xTaskCreate( vComRxTask, ( signed char * ) "COMRx", comSTACK_SIZE, NULL, uxPriority, ( xTaskHandle * ) NULL ); - xTxTimer = xTimerCreate( ( const signed char * ) "TxTimer", comTX_MIN_BLOCK_TIME, pdFALSE, NULL, vComTxTimerCallback ); + xTxTimer = xTimerCreate( ( const signed char * ) "TxTimer", comTX_MIN_BLOCK_TIME, pdFALSE, NULL, prvComTxTimerCallback ); configASSERT( xTxTimer ); } /*-----------------------------------------------------------*/ -static void vComTxTimerCallback( xTimerHandle xTimer ) +static void prvComTxTimerCallback( xTimerHandle xTimer ) { portTickType xTimeToWait; - /* Just to stop compiler warnings. */ + /* The parameter is not used in this case. */ ( void ) xTimer; /* Send the string. How this is actually performed depends on the @@ -197,7 +202,7 @@ portTickType xTimeToWait; /* Wait a pseudo random time before sending the string again. */ xTimeToWait = xTaskGetTickCount() + comOFFSET_TIME; - /* Ensure the time to wait does not greater than comTX_MAX_BLOCK_TIME. */ + /* Ensure the time to wait is not greater than comTX_MAX_BLOCK_TIME. */ xTimeToWait %= comTX_MAX_BLOCK_TIME; /* Ensure the time to wait is not less than comTX_MIN_BLOCK_TIME. */ @@ -209,7 +214,7 @@ portTickType xTimeToWait; /* Reset the timer to run again xTimeToWait ticks from now. This function is called from the context of the timer task, so the block time must not be anything other than zero. */ - xTimerChangePeriod( xTxTimer, xTimeToWait, 0 ); + xTimerChangePeriod( xTxTimer, xTimeToWait, comtstDONT_BLOCK ); } /*-----------------------------------------------------------*/ @@ -219,7 +224,7 @@ portBASE_TYPE xState = comtstWAITING_START_OF_STRING, xErrorOccurred = pdFALSE; signed char *pcExpectedByte, cRxedChar; const xComPortHandle xPort = NULL; - /* Just to stop compiler warnings. */ + /* The parameter is not used in this example. */ ( void ) pvParameters; /* Start the Tx timer. This only needs to be started once, as it will @@ -237,7 +242,7 @@ const xComPortHandle xPort = NULL; { /* A character definitely should have been received by now. As a character was not received an error must have occurred (which might - just be that the loopback connector is not fitted. */ + just be that the loopback connector is not fitted). */ xErrorOccurred = pdTRUE; } @@ -252,16 +257,15 @@ const xComPortHandle xPort = NULL; xState = comtstWAITING_END_OF_STRING; pcExpectedByte++; - /* Block for a short period. This just allows the Rx queue to - contain more than one character, and therefore prevent - thrashing reads to the queue and repetitive context switches as - each character is received. */ + /* Block for a short period. This just allows the Rx queue + to contain more than one character, and therefore prevent + thrashing reads to the queue, and repetitive context + switches as each character is received. */ vTaskDelay( comSHORT_DELAY ); } break; case comtstWAITING_END_OF_STRING: - if( cRxedChar == *pcExpectedByte ) { /* The received character was the expected character. Was @@ -271,7 +275,7 @@ const xComPortHandle xPort = NULL; { /* The entire string has been received. If no errors have been latched, then increment the loop counter to - show that this task is still healthy. */ + show this task is still healthy. */ if( xErrorOccurred == pdFALSE ) { uxRxLoops++; @@ -314,7 +318,7 @@ portBASE_TYPE xReturn; /* If the count of successful reception loops has not changed than at some time an error occurred (i.e. a character was received out of sequence) - and we will return false. */ + and false is returned. */ if( uxRxLoops == 0UL ) { xReturn = pdFALSE; @@ -325,7 +329,7 @@ portBASE_TYPE xReturn; } /* Reset the count of successful Rx loops. When this function is called - again it should have been incremented. */ + again it should have been incremented again. */ uxRxLoops = 0UL; return xReturn; diff --git a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/Demo_Source/sp_flop.c b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/Demo_Source/sp_flop.c index 33b45362d..6d08042bb 100644 --- a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/Demo_Source/sp_flop.c +++ b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/Demo_Source/sp_flop.c @@ -56,14 +56,16 @@ * point calculation - using single precision variables. * * All the tasks run at the idle priority and never block or yield. This causes - * all eight tasks to time slice with the idle task. Running at the idle priority - * means that these tasks will get pre-empted any time another task is ready to run - * or a time slice occurs. More often than not the pre-emption will occur mid - * calculation, creating a good test of the schedulers context switch mechanism - a - * calculation producing an unexpected result could be a symptom of a corruption in - * the context of a task. + * all eight tasks to time slice with the idle task, and other idle priority + * tasks. Running at the idle priority means that these tasks will get + * pre-empted any time another task is ready to run or a time slice occurs. + * More often than not the pre-emption will occur mid calculation, creating a + * good test of the schedulers context switch mechanism - a calculation + * producing an unexpected result could be a symptom of a corruption in the + * context of a task. */ +/* Standard includes. */ #include #include @@ -74,37 +76,39 @@ /* Demo program include files. */ #include "flop.h" +/* The size of the stack allocated to each floating point test task. */ #define mathSTACK_SIZE configMINIMAL_STACK_SIZE + +/* The number of tasks that are created. */ #define mathNUMBER_OF_TASKS ( 8 ) /* Four tasks, each of which performs a different floating point calculation. Each of the four is created twice. */ -static portTASK_FUNCTION_PROTO( vCompetingMathTask1, pvParameters ); -static portTASK_FUNCTION_PROTO( vCompetingMathTask2, pvParameters ); -static portTASK_FUNCTION_PROTO( vCompetingMathTask3, pvParameters ); -static portTASK_FUNCTION_PROTO( vCompetingMathTask4, pvParameters ); +static void prvCompetingMathTask1( void *pvParameters ); +static void prvCompetingMathTask2( void *pvParameters ); +static void prvCompetingMathTask3( void *pvParameters ); +static void prvCompetingMathTask4( void *pvParameters ); /* These variables are used to check that all the tasks are still running. If a -task gets a calculation wrong it will -stop incrementing its check variable. */ +task gets a calculation wrong it will stop incrementing its check variable. */ static volatile unsigned short usTaskCheck[ mathNUMBER_OF_TASKS ] = { ( unsigned short ) 0 }; /*-----------------------------------------------------------*/ void vStartMathTasks( unsigned portBASE_TYPE uxPriority ) { - xTaskCreate( vCompetingMathTask1, ( signed char * ) "Math1", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 0 ] ), uxPriority, NULL ); - xTaskCreate( vCompetingMathTask2, ( signed char * ) "Math2", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 1 ] ), uxPriority, NULL ); - xTaskCreate( vCompetingMathTask3, ( signed char * ) "Math3", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 2 ] ), uxPriority, NULL ); - xTaskCreate( vCompetingMathTask4, ( signed char * ) "Math4", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 3 ] ), uxPriority, NULL ); - xTaskCreate( vCompetingMathTask1, ( signed char * ) "Math5", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 4 ] ), uxPriority, NULL ); - xTaskCreate( vCompetingMathTask2, ( signed char * ) "Math6", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 5 ] ), uxPriority, NULL ); - xTaskCreate( vCompetingMathTask3, ( signed char * ) "Math7", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 6 ] ), uxPriority, NULL ); - xTaskCreate( vCompetingMathTask4, ( signed char * ) "Math8", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 7 ] ), uxPriority, NULL ); + xTaskCreate( prvCompetingMathTask1, ( signed char * ) "Math1", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 0 ] ), uxPriority, NULL ); + xTaskCreate( prvCompetingMathTask2, ( signed char * ) "Math2", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 1 ] ), uxPriority, NULL ); + xTaskCreate( prvCompetingMathTask3, ( signed char * ) "Math3", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 2 ] ), uxPriority, NULL ); + xTaskCreate( prvCompetingMathTask4, ( signed char * ) "Math4", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 3 ] ), uxPriority, NULL ); + xTaskCreate( prvCompetingMathTask1, ( signed char * ) "Math5", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 4 ] ), uxPriority, NULL ); + xTaskCreate( prvCompetingMathTask2, ( signed char * ) "Math6", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 5 ] ), uxPriority, NULL ); + xTaskCreate( prvCompetingMathTask3, ( signed char * ) "Math7", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 6 ] ), uxPriority, NULL ); + xTaskCreate( prvCompetingMathTask4, ( signed char * ) "Math8", mathSTACK_SIZE, ( void * ) &( usTaskCheck[ 7 ] ), uxPriority, NULL ); } /*-----------------------------------------------------------*/ -static portTASK_FUNCTION( vCompetingMathTask1, pvParameters ) +static void prvCompetingMathTask1( void *pvParameters ) { volatile float f1, f2, f3, f4; volatile unsigned short *pusTaskCheckVariable; @@ -156,7 +160,7 @@ short sError = pdFALSE; } /*-----------------------------------------------------------*/ -static portTASK_FUNCTION( vCompetingMathTask2, pvParameters ) +static void prvCompetingMathTask2( void *pvParameters ) { volatile float f1, f2, f3, f4; volatile unsigned short *pusTaskCheckVariable; @@ -209,7 +213,7 @@ short sError = pdFALSE; } /*-----------------------------------------------------------*/ -static portTASK_FUNCTION( vCompetingMathTask3, pvParameters ) +static void prvCompetingMathTask3( void *pvParameters ) { volatile float *pfArray, fTotal1, fTotal2, fDifference, fPosition; volatile unsigned short *pusTaskCheckVariable; @@ -267,7 +271,7 @@ short sError = pdFALSE; } /*-----------------------------------------------------------*/ -static portTASK_FUNCTION( vCompetingMathTask4, pvParameters ) +static void prvCompetingMathTask4( void *pvParameters ) { volatile float *pfArray, fTotal1, fTotal2, fDifference, fPosition; volatile unsigned short *pusTaskCheckVariable; @@ -328,8 +332,8 @@ short sError = pdFALSE; /* This is called to check that all the created tasks are still running. */ portBASE_TYPE xAreMathsTaskStillRunning( void ) { -/* Keep a history of the check variables so we know if they have been incremented -since the last call. */ +/* Keep a history of the check variables so it can be determined if they have +been incremented since the last call of this function. */ static unsigned short usLastTaskCheck[ mathNUMBER_OF_TASKS ] = { ( unsigned short ) 0 }; portBASE_TYPE xReturn = pdTRUE, xTask;