From: richardbarry Date: Fri, 3 Aug 2012 15:21:21 +0000 (+0000) Subject: Add vQueueDelete() to the MPU port. X-Git-Tag: V7.2.0~12 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f92473dc33599dcff9f4941942721de7552ae5b9;p=freertos Add vQueueDelete() to the MPU port. Added volatile key word to the queue xRxLock and xTxLock members. Ensure the portPRIVILEGED_BIT bit is set when the timer task is being created by the kernel - as it was for the idle task. Necessary for MPU port. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1760 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/ParTest.c b/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/ParTest.c index 54fe4976e..dd35507fe 100644 --- a/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/ParTest.c +++ b/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/ParTest.c @@ -82,7 +82,7 @@ /* The number of LEDs available to the user on the evaluation kit. */ #define partestNUM_LEDS ( 3UL ) -/* Definitions not included in sam3s_ek.h. */ +/* Definitions not included in sam4s_ek.h. */ #define LED2_GPIO ( PIO_PC20_IDX ) /* One of the LEDs is wired in the inverse to the others as it is also used as @@ -121,20 +121,20 @@ void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) if( xValue != pdFALSE ) { /* Turn the LED on. */ - portENTER_CRITICAL(); + taskENTER_CRITICAL(); { gpio_set_pin_low( ulLED[ uxLED ]); } - portEXIT_CRITICAL(); + taskEXIT_CRITICAL(); } else { /* Turn the LED off. */ - portENTER_CRITICAL(); + taskENTER_CRITICAL(); { gpio_set_pin_high( ulLED[ uxLED ]); } - portEXIT_CRITICAL(); + taskEXIT_CRITICAL(); } } } @@ -144,7 +144,11 @@ void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) { if( uxLED < partestNUM_LEDS ) { - gpio_toggle_pin( ulLED[ uxLED ] ); + taskENTER_CRITICAL(); + { + gpio_toggle_pin( ulLED[ uxLED ] ); + } + taskEXIT_CRITICAL(); } } diff --git a/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/serial.c b/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/serial.c index ed407a217..e71158ebe 100644 --- a/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/serial.c +++ b/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/serial.c @@ -110,6 +110,7 @@ static xQueueHandle xCharsForTx; /*-----------------------------------------------------------*/ + /* * See the serial.h header file. */ @@ -239,6 +240,14 @@ void vSerialClose( xComPortHandle xPort ) } /*-----------------------------------------------------------*/ +/* + * It should be noted that the com test tasks (which use make use of this file) + * are included to demonstrate queues being used to communicate between tasks + * and interrupts, and to demonstrate a context switch being performed from + * inside an interrupt service routine. The serial driver used here is *not* + * intended to represent an efficient implementation. Real applications should + * make use of the USARTS peripheral DMA channel (PDC). + */ void USART1_Handler( void ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; diff --git a/Demo/WIN32-MSVC-lwIP/WIN32.suo b/Demo/WIN32-MSVC-lwIP/WIN32.suo index 05a748979..4f0b2bb74 100644 Binary files a/Demo/WIN32-MSVC-lwIP/WIN32.suo and b/Demo/WIN32-MSVC-lwIP/WIN32.suo differ diff --git a/Source/portable/GCC/ARM_CM3_MPU/port.c b/Source/portable/GCC/ARM_CM3_MPU/port.c index 5d8993d36..9c424bcc6 100644 --- a/Source/portable/GCC/ARM_CM3_MPU/port.c +++ b/Source/portable/GCC/ARM_CM3_MPU/port.c @@ -210,6 +210,7 @@ portBASE_TYPE MPU_xQueueGiveMutexRecursive( xQueueHandle xMutex ); signed portBASE_TYPE MPU_xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); signed portBASE_TYPE MPU_xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ); void MPU_vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName ); +void MPU_vQueueDelete( xQueueHandle xQueue ); void *MPU_pvPortMalloc( size_t xSize ); void MPU_vPortFree( void *pv ); void MPU_vPortInitialiseBlocks( void ); @@ -1071,6 +1072,16 @@ signed portBASE_TYPE xReturn; #endif /*-----------------------------------------------------------*/ +void MPU_vQueueDelete( xQueueHandle xQueue ) +{ +portBASE_TYPE xRunningPrivileged = prvRaisePrivilege(); + + vQueueDelete( xQueue ); + + portRESET_PRIVILEGE( xRunningPrivileged ); +} +/*-----------------------------------------------------------*/ + void *MPU_pvPortMalloc( size_t xSize ) { void *pvReturn; diff --git a/Source/queue.c b/Source/queue.c index a546dcc08..dff11b1b4 100644 --- a/Source/queue.c +++ b/Source/queue.c @@ -85,7 +85,7 @@ task.h is included from an application file. */ * PUBLIC LIST API documented in list.h *----------------------------------------------------------*/ -/* Constants used with the cRxLock and cTxLock structure members. */ +/* Constants used with the cRxLock and xTxLock structure members. */ #define queueUNLOCKED ( ( signed portBASE_TYPE ) -1 ) #define queueLOCKED_UNMODIFIED ( ( signed portBASE_TYPE ) 0 ) @@ -133,8 +133,8 @@ typedef struct QueueDefinition unsigned portBASE_TYPE uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */ unsigned portBASE_TYPE uxItemSize; /*< The size of each items that the queue will hold. */ - signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ - signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + volatile signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ + volatile signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ #if ( configUSE_TRACE_FACILITY == 1 ) unsigned char ucQueueNumber; diff --git a/Source/timers.c b/Source/timers.c index 2dd68db7e..947e044ad 100644 --- a/Source/timers.c +++ b/Source/timers.c @@ -200,12 +200,12 @@ portBASE_TYPE xReturn = pdFAIL; { /* Create the timer task, storing its handle in xTimerTaskHandle so it can be returned by the xTimerGetTimerDaemonTaskHandle() function. */ - xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, &xTimerTaskHandle ); + xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle ); } #else { /* Create the timer task without storing its handle. */ - xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, NULL); + xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL); } #endif } @@ -442,7 +442,7 @@ portTickType xNextExpireTime; static portTickType prvSampleTimeNow( portBASE_TYPE *pxTimerListsWereSwitched ) { portTickType xTimeNow; -static portTickType xLastTime = ( portTickType ) 0U; +PRIVILEGED_DATA static portTickType xLastTime = ( portTickType ) 0U; xTimeNow = xTaskGetTickCount();