static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex ) { TickType_t xDelayPeriod; static unsigned long *pulRandomBytes = mainFIRST_PROGRAM_BYTES; /* Co-routine MUST start with a call to crSTART. */ crSTART( xHandle ); for(;;) { /* Was the previously transmitted string received correctly? */ if( uxErrorStatus != pdPASS ) { /* An error was encountered so set the error LED. */ vSetErrorLED(); } /* The next character to Tx is the first in the string. */ cNextChar = mainFIRST_TX_CHAR; UARTIntDisable( UART0_BASE, UART_INT_TX ); { /* Send the first character. */ if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) ) { HWREG( UART0_BASE + UART_O_DR ) = cNextChar; } /* Move the variable to the char to Tx on so the ISR transmits the next character in the string once this one has completed. */ cNextChar++; } UARTIntEnable(UART0_BASE, UART_INT_TX); /* Toggle the LED to show a new string is being transmitted. */ vParTestToggleLED( mainCOMMS_TX_LED ); /* Delay before we start the string off again. A pseudo-random delay is used as this will provide a better test. */ xDelayPeriod = xTaskGetTickCount() + ( *pulRandomBytes ); pulRandomBytes++; if( pulRandomBytes > mainTOTAL_PROGRAM_MEMORY ) { pulRandomBytes = mainFIRST_PROGRAM_BYTES; } /* Make sure we don't wait too long... */ xDelayPeriod &= mainMAX_TX_DELAY; /* ...but we do want to wait. */ if( xDelayPeriod < mainMIN_TX_DELAY ) { xDelayPeriod = mainMIN_TX_DELAY; } /* Block for the random(ish) time. */ crDELAY( xHandle, xDelayPeriod ); } /* Co-routine MUST end with a call to crEND. */ crEND(); }
void vApplicationTickHook( void ) { static unsigned long ulCallCount = 0, ulErrorFound = pdFALSE; /* The rate at which LED D4 will toggle if an error has been found in one or more of the standard demo tasks. */ const unsigned long ulErrorFlashRate = 500 / portTICK_PERIOD_MS; /* The rate at which LED D4 will toggle if no errors have been found in any of the standard demo tasks. */ const unsigned long ulNoErrorCheckRate = 5000 / portTICK_PERIOD_MS; ulCallCount++; if( ulErrorFound != pdFALSE ) { /* We have already found an error, so flash the LED with the appropriate frequency. */ if( ulCallCount > ulErrorFlashRate ) { ulCallCount = 0; vParTestToggleLED( mainERROR_LED ); } } else { if( ulCallCount > ulNoErrorCheckRate ) { ulCallCount = 0; /* We have not yet found an error. Check all the demo tasks to ensure this is still the case. */ if( xAreBlockingQueuesStillRunning() != pdTRUE ) { ulErrorFound |= 0x01; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { ulErrorFound |= 0x02; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { ulErrorFound |= 0x04; } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { ulErrorFound |= 0x08; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { ulErrorFound |= 0x10; } vParTestToggleLED( mainERROR_LED ); } } }