<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.archiver.base.1920617400" name="GNU ARM Archiver" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.archiver.base"/>\r
</toolChain>\r
</folderInfo>\r
- <fileInfo id="com.silabs.ide.si32.gcc.debug#com.silabs.ide.si32.gcc:4.8.3.20131129.566130702" name="low_power_tick_management_BURTC.c" rcbsApplicability="disable" resourcePath="Source/Low_Power_Demo/low_power_tick_management_BURTC.c" toolsToInvoke="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1299820402.669016646">\r
- <tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1299820402.669016646" name="GNU ARM C Compiler" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1299820402"/>\r
- </fileInfo>\r
<sourceEntries>\r
<entry excluding="Source/FreeRTOS_Source/portable/GCC/ARM_CM4F|Source/SilLabs_Code/kits/EFM32WG_STK3800|Source/SilLabs_Code/Device/SiliconLabs/EFM32GG/Source|Source/SilLabs_Code/Device/SiliconLabs/EFM32WG|Source/SilLabs_Code/CMSIS/efm32wg|CMSIS/efm32wg|Source/SilLabs_Code/kits/bsp/bsp_dk_3201.c|Source/SilLabs_Code/kits/bsp/bsp_dk_3200.c|Source/SilLabs_Code/kits/bsp/bsp_dk_leds.c|Source/RTT|Source/SilLabs_Code/kits/bsp/bsp_dk_mcuboard.c|Source/SilLabs_Code/kits/bsp/bsp_bcc.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>\r
</sourceEntries>\r
* See the comments at the top of main.c, main_full.c and main_low_power.c for\r
* more information.\r
*/\r
-#define configCREATE_LOW_POWER_DEMO 2\r
+#define configCREATE_LOW_POWER_DEMO 1\r
\r
/* Some configuration is dependent on the demo being built. */\r
#if( configCREATE_LOW_POWER_DEMO == 0 )\r
#define configUSE_MALLOC_FAILED_HOOK ( 0 )\r
#define configUSE_IDLE_HOOK ( 0 )\r
\r
- #define configENERGY_MODE ( sleepEM4 )\r
+ #define configENERGY_MODE ( sleepEM3 )\r
\r
#elif( configCREATE_LOW_POWER_DEMO == 2 )\r
\r
#define configTIMER_QUEUE_LENGTH ( 10 )\r
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )\r
\r
-/* Interrupt nesting behaviour configuration. */\r
-#define configKERNEL_INTERRUPT_PRIORITY ( 255 )\r
-#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 191 ) /* equivalent to 0xa0, or priority 5. */\r
+/* Cortex-M specific definitions. */\r
+#ifdef __NVIC_PRIO_BITS\r
+ /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */\r
+ #define configPRIO_BITS __NVIC_PRIO_BITS\r
+#else\r
+ #define configPRIO_BITS 3 /* 7 priority levels */\r
+#endif\r
+\r
+/* The lowest interrupt priority that can be used in a call to a "set priority"\r
+function. */\r
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x07\r
+\r
+/* The highest interrupt priority that can be used by any interrupt service\r
+routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL\r
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER\r
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */\r
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 0x05\r
+\r
+/* Interrupt priorities used by the kernel port layer itself. These are generic\r
+to all Cortex-M ports, and do not rely on any particular library functions. */\r
+#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )\r
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!\r
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */\r
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )\r
+\r
\r
/* Optional functions - most linkers will remove unused functions anyway. */\r
#define INCLUDE_vTaskPrioritySet ( 1 )\r
BURTC_Init( &xBURTCInitStruct );\r
\r
/* The tick interrupt must be set to the lowest priority possible. */\r
- NVIC_SetPriority( BURTC_IRQn, configKERNEL_INTERRUPT_PRIORITY );\r
+ NVIC_SetPriority( BURTC_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY );\r
NVIC_ClearPendingIRQ( BURTC_IRQn );\r
NVIC_EnableIRQ( BURTC_IRQn );\r
BURTC_CompareSet( 0, ulReloadValueForOneTick );\r
\r
void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )\r
{\r
-uint32_t ulReloadValue, ulCompleteTickPeriods, ulCurrentCount;\r
+uint32_t ulReloadValue, ulCompleteTickPeriods, ulCountBeforeSleep, ulCountAfterSleep;\r
eSleepModeStatus eSleepAction;\r
TickType_t xModifiableIdleTime;\r
\r
result in some tiny drift of the time maintained by the kernel with respect\r
to calendar time. The count is latched before stopping the timer as\r
stopping the timer appears to clear the count. */\r
- ulCurrentCount = BURTC_CounterGet();\r
+ ulCountBeforeSleep = BURTC_CounterGet();\r
BURTC_Enable( false );\r
\r
+ /* If this function is re-entered before one complete tick period then the\r
+ reload value might be to take into account a partial tick, but just reading\r
+ the count assumes it is counting up to a full ticks worth - so add in the\r
+ different if any. */\r
+ ulCountBeforeSleep += ( ulReloadValueForOneTick - BURTC_CompareGet( 0 ) );\r
+\r
/* Enter a critical section but don't use the taskENTER_CRITICAL() method as\r
that will mask interrupts that should exit sleep mode. */\r
INT_Disable();\r
+ __asm volatile( "dsb" );\r
+ __asm volatile( "isb" );\r
\r
/* The tick flag is set to false before sleeping. If it is true when sleep\r
mode is exited then sleep mode was probably exited because the tick was\r
{\r
/* Restart tick and count up to whatever was left of the current time\r
slice. */\r
- BURTC_CompareSet( 0, ulReloadValueForOneTick - ulCurrentCount );\r
+ BURTC_CompareSet( 0, ( ulReloadValueForOneTick - ulCountBeforeSleep ) + ulStoppedTimerCompensation );\r
BURTC_Enable( true );\r
\r
/* Re-enable interrupts - see comments above the cpsid instruction()\r
{\r
/* Adjust the reload value to take into account that the current time\r
slice is already partially complete. */\r
- ulReloadValue -= ulCurrentCount;\r
+ ulReloadValue -= ulCountBeforeSleep;\r
BURTC_CompareSet( 0, ulReloadValue );\r
\r
/* Restart the BURTC. */\r
result in some tiny drift of the time maintained by the kernel with\r
respect to calendar time. The count value is latched before stopping\r
the timer as stopping the timer appears to clear the count. */\r
- ulCurrentCount = BURTC_CounterGet();\r
+ ulCountAfterSleep = BURTC_CounterGet();\r
BURTC_Enable( false );\r
\r
/* Re-enable interrupts - see comments above the cpsid instruction()\r
above. */\r
INT_Enable();\r
+ __asm volatile( "dsb" );\r
+ __asm volatile( "isb" );\r
\r
if( ulTickFlag != pdFALSE )\r
{\r
function is called with the scheduler suspended the actual tick\r
processing will not occur until after this function has exited.\r
Reset the reload value with whatever remains of this tick period. */\r
- ulReloadValue = ulReloadValueForOneTick - ulCurrentCount;\r
+ ulReloadValue = ulReloadValueForOneTick - ulCountAfterSleep;\r
BURTC_CompareSet( 0, ulReloadValue );\r
\r
/* The tick interrupt handler will already have pended the tick\r
{\r
/* Something other than the tick interrupt ended the sleep. How\r
many complete tick periods passed while the processor was\r
- sleeping? */\r
- ulCompleteTickPeriods = ulCurrentCount / ulReloadValueForOneTick;\r
+ sleeping? Add back in the adjustment that was made to the reload\r
+ value to account for the fact that a time slice was part way through\r
+ when this function was called. */\r
+ ulCountAfterSleep += ulCountBeforeSleep;\r
+ ulCompleteTickPeriods = ulCountAfterSleep / ulReloadValueForOneTick;\r
\r
/* The reload value is set to whatever fraction of a single tick\r
period remains. */\r
- ulReloadValue = ulCurrentCount - ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+ ulCountAfterSleep -= ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+ ulReloadValue = ulReloadValueForOneTick - ulCountAfterSleep;\r
+\r
if( ulReloadValue == 0 )\r
{\r
/* There is no fraction remaining. */\r
\r
void BURTC_IRQHandler( void )\r
{\r
- if( ulTickFlag == pdFALSE )\r
+ ulTickFlag = pdTRUE;\r
+\r
+ if( RTC_CompareGet( 0 ) != ulReloadValueForOneTick )\r
{\r
- /* Set BURTC interrupt to one RTOS tick period. */\r
+ /* Set RTC interrupt to one RTOS tick period. */\r
BURTC_Enable( false );\r
BURTC_CompareSet( 0, ulReloadValueForOneTick );\r
- ulTickFlag = pdTRUE;\r
BURTC_Enable( true );\r
}\r
\r
/* SiLabs library includes. */\r
#include "em_cmu.h"\r
#include "em_rtc.h"\r
+#include "em_burtc.h"\r
#include "em_rmu.h"\r
#include "em_int.h"\r
#include "sleep.h"\r
\r
+#define lpINCLUDE_TEST_TIMER 1\r
+\r
/* SEE THE COMMENTS ABOVE THE DEFINITION OF configCREATE_LOW_POWER_DEMO IN\r
FreeRTOSConfig.h\r
This file contains functions that will override the default implementations\r
*/\r
void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );\r
\r
+/* If lpINCLUDE_TEST_TIMER is defined then the BURTC is used to generate\r
+interrupts that will wake the processor prior to the expected idle time\r
+completing. The timer interval can be altered to test different\r
+scenarios. */\r
+#if( lpINCLUDE_TEST_TIMER == 1 )\r
+ static void prvSetupTestTimer( void );\r
+#endif\r
+\r
/*-----------------------------------------------------------*/\r
\r
/* Calculate how many clock increments make up a single tick period. */\r
RTC_IntDisable( RTC_IFC_COMP0 );\r
\r
/* The tick interrupt must be set to the lowest priority possible. */\r
- NVIC_SetPriority( RTC_IRQn, configKERNEL_INTERRUPT_PRIORITY );\r
+ NVIC_SetPriority( RTC_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY );\r
NVIC_ClearPendingIRQ( RTC_IRQn );\r
NVIC_EnableIRQ( RTC_IRQn );\r
RTC_CompareSet( 0, ulReloadValueForOneTick );\r
RTC_IntClear( RTC_IFC_COMP0 );\r
RTC_IntEnable( RTC_IF_COMP0 );\r
RTC_Enable( true );\r
+\r
+ /* If lpINCLUDE_TEST_TIMER is defined then the BURTC is used to generate\r
+ interrupts that will wake the processor prior to the expected idle time\r
+ completing. The timer interval can be altered to test different\r
+ scenarios. */\r
+ #if( lpINCLUDE_TEST_TIMER == 1 )\r
+ prvSetupTestTimer();\r
+ #endif\r
}\r
/*-----------------------------------------------------------*/\r
\r
void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )\r
{\r
-uint32_t ulReloadValue, ulCompleteTickPeriods, ulCurrentCount;\r
+uint32_t ulReloadValue, ulCompleteTickPeriods, ulCountBeforeSleep, ulCountAfterSleep;\r
eSleepModeStatus eSleepAction;\r
TickType_t xModifiableIdleTime;\r
\r
in some tiny drift of the time maintained by the kernel with respect to\r
calendar time. The count is latched before stopping the timer as stopping\r
the timer appears to clear the count. */\r
- ulCurrentCount = RTC_CounterGet();\r
+ ulCountBeforeSleep = RTC_CounterGet();\r
RTC_Enable( false );\r
\r
+ /* If this function is re-entered before one complete tick period then the\r
+ reload value might be to take into account a partial tick, but just reading\r
+ the count assumes it is counting up to a full ticks worth - so add in the\r
+ different if any. */\r
+ ulCountBeforeSleep += ( ulReloadValueForOneTick - RTC_CompareGet( 0 ) );\r
+\r
/* Enter a critical section but don't use the taskENTER_CRITICAL() method as\r
that will mask interrupts that should exit sleep mode. */\r
INT_Disable();\r
{\r
/* Restart tick and count up to whatever was left of the current time\r
slice. */\r
- RTC_CompareSet( 0, ulReloadValueForOneTick - ulCurrentCount );\r
+ RTC_CompareSet( 0, ( ulReloadValueForOneTick - ulCountBeforeSleep ) + ulStoppedTimerCompensation );\r
RTC_Enable( true );\r
\r
/* Re-enable interrupts - see comments above the cpsid instruction()\r
{\r
/* Adjust the reload value to take into account that the current time\r
slice is already partially complete. */\r
- ulReloadValue -= ulCurrentCount;\r
+ ulReloadValue -= ulCountBeforeSleep;\r
RTC_CompareSet( 0, ulReloadValue );\r
\r
/* Restart the RTC. */\r
result in some tiny drift of the time maintained by the kernel with\r
respect to calendar time. The count value is latched before stopping\r
the timer as stopping the timer appears to clear the count. */\r
- ulCurrentCount = RTC_CounterGet();\r
+ ulCountAfterSleep = RTC_CounterGet();\r
RTC_Enable( false );\r
\r
/* Re-enable interrupts - see comments above the cpsid instruction()\r
function is called with the scheduler suspended the actual tick\r
processing will not occur until after this function has exited.\r
Reset the reload value with whatever remains of this tick period. */\r
- ulReloadValue = ulReloadValueForOneTick - ulCurrentCount;\r
+ ulReloadValue = ulReloadValueForOneTick - ulCountAfterSleep;\r
RTC_CompareSet( 0, ulReloadValue );\r
\r
/* The tick interrupt handler will already have pended the tick\r
{\r
/* Something other than the tick interrupt ended the sleep. How\r
many complete tick periods passed while the processor was\r
- sleeping? */\r
- ulCompleteTickPeriods = ulCurrentCount / ulReloadValueForOneTick;\r
+ sleeping? Add back in the adjustment that was made to the reload\r
+ value to account for the fact that a time slice was part way through\r
+ when this function was called. */\r
+ ulCountAfterSleep += ulCountBeforeSleep;\r
+ ulCompleteTickPeriods = ulCountAfterSleep / ulReloadValueForOneTick;\r
\r
/* The reload value is set to whatever fraction of a single tick\r
period remains. */\r
- ulReloadValue = ulCurrentCount - ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+ ulCountAfterSleep -= ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+ ulReloadValue = ulReloadValueForOneTick - ulCountAfterSleep;\r
+\r
if( ulReloadValue == 0 )\r
{\r
/* There is no fraction remaining. */\r
\r
void RTC_IRQHandler( void )\r
{\r
- if( ulTickFlag == pdFALSE )\r
+ ulTickFlag = pdTRUE;\r
+\r
+ if( RTC_CompareGet( 0 ) != ulReloadValueForOneTick )\r
{\r
/* Set RTC interrupt to one RTOS tick period. */\r
RTC_Enable( false );\r
RTC_CompareSet( 0, ulReloadValueForOneTick );\r
- ulTickFlag = pdTRUE;\r
RTC_Enable( true );\r
}\r
\r
}\r
portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( lpINCLUDE_TEST_TIMER == 1 )\r
+\r
+ /* If lpINCLUDE_TEST_TIMER is defined then the BURTC is used to generate\r
+ interrupts that will wake the processor prior to the expected idle time\r
+ completing. The timer interval can be altered to test different\r
+ scenarios. */\r
+ static void prvSetupTestTimer( void )\r
+ {\r
+ BURTC_Init_TypeDef xBURTCInitStruct = BURTC_INIT_DEFAULT;\r
+ const uint32_t ulBURTClockHz = 2000UL, ulInterruptFrequency = 1000UL;\r
+ const uint32_t ulReload = ( ulBURTClockHz / ulInterruptFrequency );\r
+\r
+ /* Ensure LE modules are accessible. */\r
+ CMU_ClockEnable( cmuClock_CORELE, true );\r
+\r
+ /* Enable access to BURTC registers. */\r
+ RMU_ResetControl( rmuResetBU, false );\r
+\r
+ /* Generate periodic interrupts from BURTC. */\r
+ xBURTCInitStruct.mode = burtcModeEM3; /* Operational in EM3. */\r
+ xBURTCInitStruct.clkSel = burtcClkSelULFRCO;/* ULFRCO clock. */\r
+ xBURTCInitStruct.clkDiv = burtcClkDiv_1; /* 2kHz ULFRCO clock. */\r
+ xBURTCInitStruct.compare0Top = true; /* Wrap on COMP0. */\r
+ BURTC_IntDisable( BURTC_IF_COMP0 );\r
+ BURTC_Init( &xBURTCInitStruct );\r
+\r
+ NVIC_SetPriority( BURTC_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY );\r
+ NVIC_ClearPendingIRQ( BURTC_IRQn );\r
+ NVIC_EnableIRQ( BURTC_IRQn );\r
+ BURTC_CompareSet( 0, ulReload );\r
+ BURTC_IntClear( BURTC_IF_COMP0 );\r
+ BURTC_IntEnable( BURTC_IF_COMP0 );\r
+ BURTC_CounterReset();\r
+ }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( lpINCLUDE_TEST_TIMER == 1 )\r
\r
-#endif /* ( configCREATE_LOW_POWER_DEMO == 1 ) */\r
+ /* If lpINCLUDE_TEST_TIMER is defined then the BURTC is used to generate\r
+ interrupts that will wake the processor prior to the expected idle time\r
+ completing. The timer interval can be altered to test different\r
+ scenarios. */\r
+ volatile uint32_t ulTestTimerCounts = 0;\r
+\r
+ void BURTC_IRQHandler( void )\r
+ {\r
+ /* Nothing to do here - just testing the code in the scenario where a\r
+ tickless idle period is ended prior to the expected maximum idle time\r
+ expiring. */\r
+ BURTC_IntClear( _RTC_IFC_MASK );\r
+ ulTestTimerCounts++;\r
+ }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
\r
+#endif /* ( configCREATE_LOW_POWER_DEMO == 2 ) */\r
* main_low_power() creates one queue, and two tasks. It then starts the\r
* scheduler.\r
*\r
- * TBD\r
+ * The Queue Send Task:\r
+ * The queue send task is implemented by the prvQueueSendTask() function in\r
+ * this file. It sends the value 100 to the queue every second.\r
+ *\r
+ * The Queue Receive Task:\r
+ * The queue receive task is implemented by the prvQueueReceiveTask() function\r
+ * in this file. prvQueueReceiveTask() blocks on the queue, blipping (quickly\r
+ * turn on then off again) the LED each time it received the value 100 from the\r
+ * queue send task. The queue send task writes to the queue every second, so\r
+ * the LED will blip once a second.\r
+ *\r
+ * The RTOS tick is turned off when the queue send task and queue receive task\r
+ * are both in the Blocked state.\r
+ *\r
*/\r
\r
-#warning Description of demo in comments above is not correct.\r
\r
/* Kernel includes. */\r
#include "FreeRTOS.h"\r
*\r
*/\r
\r
-#warning Check the tick suppression routine in the case where the system unblocks before an entire tick period has expired.\r
-\r
/* FreeRTOS includes. */\r
#include "FreeRTOS.h"\r
#include "task.h"\r
* main_low_power() is used when configCREATE_LOW_POWER_DEMO is set to 1.\r
* main_full() is used when configCREATE_LOW_POWER_DEMO is set to 0.\r
*/\r
-#if( configCREATE_LOW_POWER_DEMO == 1 )\r
+#if( configCREATE_LOW_POWER_DEMO != 0 )\r
extern void main_low_power( void );\r
#else\r
extern void main_full( void );\r
xBlockingQueueParameters *pxQueueParameters3, *pxQueueParameters4;\r
xBlockingQueueParameters *pxQueueParameters5, *pxQueueParameters6;\r
const UBaseType_t uxQueueSize1 = 1, uxQueueSize5 = 5;\r
-const TickType_t xBlockTime = ( TickType_t ) 1000 / portTICK_PERIOD_MS;\r
+const TickType_t xBlockTime = pdMS_TO_TICKS( ( TickType_t ) 1000 );\r
const TickType_t xDontBlock = ( TickType_t ) 0;\r
\r
/* Create the first two tasks as described at the top of the file. */\r
#define ebDONT_BLOCK ( 0 )\r
\r
/* A 5ms delay. */\r
-#define ebSHORT_DELAY ( 5 / portTICK_PERIOD_MS )\r
+#define ebSHORT_DELAY pdMS_TO_TICKS( ( TickType_t ) 5 )\r
\r
/* Used in the selective bits test which checks no, one or both tasks blocked on\r
event bits in a group are unblocked as appropriate as different bits get set. */\r
\r
#define pollqSTACK_SIZE configMINIMAL_STACK_SIZE\r
#define pollqQUEUE_SIZE ( 10 )\r
-#define pollqPRODUCER_DELAY ( ( TickType_t ) 200 / portTICK_PERIOD_MS )\r
+#define pollqPRODUCER_DELAY ( pdMS_TO_TICKS( ( TickType_t ) 200 ) )\r
#define pollqCONSUMER_DELAY ( pollqPRODUCER_DELAY - ( TickType_t ) ( 20 / portTICK_PERIOD_MS ) )\r
#define pollqNO_DELAY ( ( TickType_t ) 0 )\r
#define pollqVALUES_TO_PRODUCE ( ( BaseType_t ) 3 )\r
xPolledQueue = xQueueCreate( pollqQUEUE_SIZE, ( UBaseType_t ) sizeof( uint16_t ) );\r
\r
/* vQueueAddToRegistry() adds the queue to the queue registry, if one is\r
- in use. The queue registry is provided as a means for kernel aware \r
+ in use. The queue registry is provided as a means for kernel aware\r
debuggers to locate queues and has no purpose if a kernel aware debugger\r
is not being used. The call to vQueueAddToRegistry() will be removed\r
- by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is \r
+ by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is\r
defined to be less than 1. */\r
vQueueAddToRegistry( xPolledQueue, "Poll_Test_Queue" );\r
\r
BaseType_t xError = pdFALSE, xLoop;\r
\r
for( ;; )\r
- { \r
+ {\r
for( xLoop = 0; xLoop < pollqVALUES_TO_PRODUCE; xLoop++ )\r
{\r
/* Send an incrementing number on the queue without blocking. */\r
BaseType_t xError = pdFALSE;\r
\r
for( ;; )\r
- { \r
+ {\r
/* Loop until the queue is empty. */\r
while( uxQueueMessagesWaiting( *( ( QueueHandle_t * ) pvParameters ) ) )\r
{\r
/* A delay inserted when the Tx task changes its priority to be above the idle\r
task priority to ensure the idle priority tasks get some CPU time before the\r
next iteration of the queue set Tx task. */\r
-#define queuesetTX_LOOP_DELAY ( 200 / portTICK_PERIOD_MS )\r
+#define queuesetTX_LOOP_DELAY pdMS_TO_TICKS( ( TickType_t ) 200 )\r
\r
/* The allowable maximum deviation between a received value and the expected\r
received value. A deviation will occur when data is received from a queue\r
}\r
\r
/* Wait for a message to arrive on one of the queues in the set. */\r
- xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY ); \r
+ xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );\r
\r
if( xActivatedQueue == NULL )\r
{\r
static volatile UBaseType_t uxTasksRunningAtStart = 0;\r
\r
/* When a task deletes itself, it stack and TCB are cleaned up by the Idle task.\r
-Under heavy load the idle task might not get much processing time, so it would \r
+Under heavy load the idle task might not get much processing time, so it would\r
be legitimate for several tasks to remain undeleted for a short period. There\r
may also be a few other unexpected tasks if, for example, the tasks that test\r
static allocation are also being used. */\r
/* Record the number of tasks that are running now so we know if any of the\r
suicidal tasks have failed to be killed. */\r
uxTasksRunningAtStart = ( UBaseType_t ) uxTaskGetNumberOfTasks();\r
- \r
+\r
/* FreeRTOS.org versions before V3.0 started the idle-task as the very\r
first task. The idle task was then already included in uxTasksRunningAtStart.\r
From FreeRTOS V3.0 on, the idle task is started when the scheduler is\r
started. Therefore the idle task is not yet accounted for. We correct\r
this by increasing uxTasksRunningAtStart by 1. */\r
uxTasksRunningAtStart++;\r
- \r
- /* From FreeRTOS version 7.0.0 can optionally create a timer service task. \r
+\r
+ /* From FreeRTOS version 7.0.0 can optionally create a timer service task.\r
If this is done, then uxTasksRunningAtStart needs incrementing again as that\r
too is created when the scheduler is started. */\r
#if configUSE_TIMERS == 1\r
#endif\r
}\r
/*-----------------------------------------------------------*/\r
- \r
+\r
static portTASK_FUNCTION( vSuicidalTask, pvParameters )\r
{\r
volatile long l1, l2;\r
TaskHandle_t xTaskToKill;\r
-const TickType_t xDelay = ( TickType_t ) 200 / portTICK_PERIOD_MS;\r
+const TickType_t xDelay = pdMS_TO_TICKS( ( TickType_t ) 200 );\r
\r
if( pvParameters != NULL )\r
{\r
\r
static portTASK_FUNCTION( vCreateTasks, pvParameters )\r
{\r
-const TickType_t xDelay = ( TickType_t ) 1000 / portTICK_PERIOD_MS;\r
+const TickType_t xDelay = pdMS_TO_TICKS( ( TickType_t ) 1000 );\r
UBaseType_t uxPriority;\r
\r
uxPriority = *( UBaseType_t * ) pvParameters;\r
{\r
usLastCreationCount = usCreationCount;\r
}\r
- \r
+\r
uxTasksRunningNow = ( UBaseType_t ) uxTaskGetNumberOfTasks();\r
\r
if( uxTasksRunningNow < uxTasksRunningAtStart )\r