mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Update commenting ready for release.
This commit is contained in:
parent
f73e663411
commit
f39424feee
|
@ -87,6 +87,4 @@ to exclude the API function. */
|
||||||
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
|
|
||||||
|
|
||||||
#define configKERNEL_INTERRUPT_PRIORITY 6
|
|
||||||
|
|
||||||
#endif /* FREERTOS_CONFIG_H */
|
#endif /* FREERTOS_CONFIG_H */
|
||||||
|
|
|
@ -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. */
|
discover an unexpected value. */
|
||||||
static unsigned portBASE_TYPE xRegTestStatus = pdPASS;
|
static unsigned portBASE_TYPE xRegTestStatus = pdPASS;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ int main( void )
|
||||||
prvSetupHardware();
|
prvSetupHardware();
|
||||||
|
|
||||||
/* Start the standard demo application tasks. Note that the baud rate used
|
/* 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. */
|
passed has no effect. */
|
||||||
vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
|
vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
|
||||||
vStartIntegerMathTasks( tskIDLE_PRIORITY );
|
vStartIntegerMathTasks( tskIDLE_PRIORITY );
|
||||||
|
@ -261,6 +261,10 @@ static void prvErrorChecks( void *pvParameters )
|
||||||
portTickType xDelayPeriod = mainNO_ERROR_CHECK_DELAY, xLastExecutionTime;
|
portTickType xDelayPeriod = mainNO_ERROR_CHECK_DELAY, xLastExecutionTime;
|
||||||
volatile unsigned portBASE_TYPE uxFreeStack;
|
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 );
|
uxFreeStack = uxTaskGetStackHighWaterMark( NULL );
|
||||||
|
|
||||||
/* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
|
/* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
|
||||||
|
@ -271,12 +275,14 @@ volatile unsigned portBASE_TYPE uxFreeStack;
|
||||||
operating without error. */
|
operating without error. */
|
||||||
for( ;; )
|
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 );
|
uxFreeStack = uxTaskGetStackHighWaterMark( NULL );
|
||||||
|
|
||||||
/* Wait until it is time to check again. The time we wait here depends
|
/* 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
|
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. */
|
detected the time is shortened resulting in a faster LED flash rate. */
|
||||||
/* Perform this check every mainCHECK_DELAY milliseconds. */
|
|
||||||
vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
|
vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );
|
||||||
|
|
||||||
/* See if the other tasks are all ok. */
|
/* See if the other tasks are all ok. */
|
||||||
|
@ -299,11 +305,18 @@ static void prvSetupHardware( void )
|
||||||
XCache_EnableICache( 0x80000000 );
|
XCache_EnableICache( 0x80000000 );
|
||||||
XCache_EnableDCache( 0x80000000 );
|
XCache_EnableDCache( 0x80000000 );
|
||||||
|
|
||||||
|
/* Setup the IO port for use with the LED outputs. */
|
||||||
vParTestInitialise();
|
vParTestInitialise();
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvRegTestTask1( void *pvParameters )
|
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
|
asm volatile
|
||||||
(
|
(
|
||||||
"RegTest1Start: \n\t" \
|
"RegTest1Start: \n\t" \
|
||||||
|
@ -416,9 +429,13 @@ static void prvRegTestTask1( void *pvParameters )
|
||||||
" b RegTest1Start \n\t" \
|
" b RegTest1Start \n\t" \
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvRegTestTask2( void *pvParameters )
|
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
|
asm volatile
|
||||||
(
|
(
|
||||||
"RegTest2Start: \n\t" \
|
"RegTest2Start: \n\t" \
|
||||||
|
@ -455,9 +472,6 @@ static void prvRegTestTask2( void *pvParameters )
|
||||||
" li 30, 130 \n\t" \
|
" li 30, 130 \n\t" \
|
||||||
" li 31, 131 \n\t" \
|
" li 31, 131 \n\t" \
|
||||||
" \n\t" \
|
" \n\t" \
|
||||||
" sc \n\t" \
|
|
||||||
" nop \n\t" \
|
|
||||||
" \n\t" \
|
|
||||||
" cmpwi 0, 11 \n\t" \
|
" cmpwi 0, 11 \n\t" \
|
||||||
" bne RegTest2Fail \n\t" \
|
" bne RegTest2Fail \n\t" \
|
||||||
" cmpwi 2, 12 \n\t" \
|
" cmpwi 2, 12 \n\t" \
|
||||||
|
@ -531,34 +545,11 @@ static void prvRegTestTask2( void *pvParameters )
|
||||||
" b RegTest2Start \n\t" \
|
" b RegTest2Start \n\t" \
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* This hook function will get called if there is a suspected stack overflow.
|
||||||
#if 0
|
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. */
|
||||||
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
|
|
||||||
|
|
||||||
void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName );
|
void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName );
|
||||||
void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName )
|
void vApplicationStackOverflowHook( xTaskHandle xTask, signed portCHAR *pcTaskName )
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,8 +44,6 @@
|
||||||
/* Scheduler includes. */
|
/* Scheduler includes. */
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
|
|
||||||
#define partstNUM_LEDs 8
|
|
||||||
|
|
||||||
/* Demo application includes. */
|
/* Demo application includes. */
|
||||||
#include "partest.h"
|
#include "partest.h"
|
||||||
|
|
||||||
|
|
|
@ -53,12 +53,10 @@
|
||||||
/* Demo application includes. */
|
/* Demo application includes. */
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
|
||||||
/* Microblaze driver includes. */
|
/* Library includes. */
|
||||||
#include "xparameters.h"
|
#include "xparameters.h"
|
||||||
#include "xuartlite.h"
|
#include "xuartlite.h"
|
||||||
#include "xuartlite_l.h"
|
#include "xuartlite_l.h"
|
||||||
#include "xintc_l.h"
|
|
||||||
#include "xintc.h"
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -67,26 +65,31 @@ transmitted. */
|
||||||
static xQueueHandle xRxedChars;
|
static xQueueHandle xRxedChars;
|
||||||
static xQueueHandle xCharsForTx;
|
static xQueueHandle xCharsForTx;
|
||||||
|
|
||||||
|
/* Structure that maintains information on the UART being used. */
|
||||||
static XUartLite xUART;
|
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 );
|
static void vSerialISR( XUartLite *pxUART );
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
xComPortHandle xSerialPortInitMinimal( unsigned portLONG ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
|
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
|
/* 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
|
parameterization of the UART Lite peripheral, and the baud value passed to
|
||||||
this function has no effect. */
|
this function has no effect. */
|
||||||
|
( void ) ulWantedBaud;
|
||||||
|
|
||||||
/* Create the queues used to hold Rx and Tx characters. */
|
/* Create the queues used to hold Rx and Tx characters. */
|
||||||
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
|
xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed portCHAR ) );
|
||||||
xCharsForTx = xQueueCreate( uxQueueLength + 1, ( 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 );
|
XUartLite_Initialize( &xUART, XPAR_RS232_UART_DEVICE_ID );
|
||||||
|
@ -95,10 +98,14 @@ extern XIntc xInterruptController;
|
||||||
|
|
||||||
if( xPortInstallInterruptHandler( XPAR_OPB_INTC_0_RS232_UART_INTERRUPT_INTR, ( XInterruptHandler )vSerialISR, (void *)&xUART ) == pdPASS )
|
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 );
|
XUartLite_EnableInterrupt( &xUART );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* There is only one port so the handle is not used. */
|
||||||
return ( xComPortHandle ) 0;
|
return ( xComPortHandle ) 0;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -170,31 +177,37 @@ void vSerialClose( xComPortHandle xPort )
|
||||||
static void vSerialISR( XUartLite *pxUART )
|
static void vSerialISR( XUartLite *pxUART )
|
||||||
{
|
{
|
||||||
unsigned portLONG ulISRStatus;
|
unsigned portLONG ulISRStatus;
|
||||||
portBASE_TYPE xTaskWokenByTx = pdFALSE, xTaskWokenByRx = pdFALSE;
|
portBASE_TYPE xTaskWokenByTx = pdFALSE, xTaskWokenByRx = pdFALSE, lDidSomething;
|
||||||
portCHAR cChar;
|
portCHAR cChar;
|
||||||
|
|
||||||
ulISRStatus = XIo_In32( pxUART->RegBaseAddress + XUL_STATUS_REG_OFFSET );
|
do
|
||||||
|
{
|
||||||
|
lDidSomething = pdFALSE;
|
||||||
|
|
||||||
if( ( ulISRStatus & (XUL_SR_RX_FIFO_FULL | XUL_SR_RX_FIFO_VALID_DATA ) ) != 0 )
|
ulISRStatus = XIo_In32( pxUART->RegBaseAddress + XUL_STATUS_REG_OFFSET );
|
||||||
{
|
|
||||||
/* 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 )
|
if( ( ulISRStatus & (XUL_SR_RX_FIFO_FULL | XUL_SR_RX_FIFO_VALID_DATA ) ) != 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 )
|
|
||||||
{
|
{
|
||||||
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 we woke any tasks we may require a context switch. */
|
||||||
if( xTaskWokenByTx || xTaskWokenByRx )
|
if( xTaskWokenByTx || xTaskWokenByRx )
|
||||||
|
|
Loading…
Reference in a new issue