Add software timer use to the new MPU demo.

Update CEC1302 demos to demonstrate both aggregated and disaggregated interrupts.
pull/4/head
Richard Barry 9 years ago
parent 345819d550
commit 12a0be1e69

@ -91,7 +91,7 @@ extern "C" {
/* Set configCREATE_LOW_POWER_DEMO to one to run the simple blinky demo low power
example, or 1 to run the more comprehensive test and demo application. See
the comments at the top of main.c for more information. */
#define configCREATE_LOW_POWER_DEMO 0
#define configCREATE_LOW_POWER_DEMO 1
/* Some configuration is dependent on the demo being built. */
#if( configCREATE_LOW_POWER_DEMO == 1 )
@ -130,7 +130,7 @@ the comments at the top of main.c for more information. */
#define configCPU_CLOCK_HZ 48000000
#define configMAX_PRIORITIES ( 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 120 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 28 * 1024 ) )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 26 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 10 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
@ -161,7 +161,7 @@ FreeRTOS/Source/tasks.c for limitations. */
/* Software timer definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( 2 )
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
#define configTIMER_QUEUE_LENGTH 5
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )

File diff suppressed because one or more lines are too long

@ -6,8 +6,8 @@
<Header>### uVision Project, (C) Keil Software</Header>
<Extensions>
<cExt>*.c;*.S</cExt>
<aExt></aExt>
<cExt>*.c</cExt>
<aExt>*.S</aExt>
<oExt>*.obj</oExt>
<lExt>*.lib</lExt>
<tExt>*.txt; *.h; *.inc</tExt>
@ -73,7 +73,7 @@
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
@ -89,7 +89,7 @@
<sRfunc>1</sRfunc>
<sRbox>1</sRbox>
<tLdApp>1</tLdApp>
<tGomain>0</tGomain>
<tGomain>1</tGomain>
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
@ -122,7 +122,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=120,149,354,683,0)(1012=-1,-1,-1,-1,0)</Name>
<Name>(1010=75,100,485,643,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=120,149,354,683,0)(1012=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -140,30 +140,18 @@
<Name>-UV1115SAE -O2983 -S0 -C0 -P00 -N00("ARM CoreSight JTAG-DP") -D00(4BA00477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO11 -FD118000 -FC8000 -FN1 -FF0NEW_DEVICE.FLM -FS0100000 -FL018000 -FP0($$Device:ARMCM4_FP$Device\ARM\Flash\NEW_DEVICE.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>0</LineNumber>
<EnabledFlag>0</EnabledFlag>
<Address>38</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename></Filename>
<ExecCommand></ExecCommand>
<Expression>0x00000026</Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>ulLED</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>pxNewTCB-&gt;pxStack</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
<Mm>
@ -179,7 +167,7 @@
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>1</aLwin>
<aLwin>0</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
@ -245,7 +233,7 @@
<Group>
<GroupName>main_and_config</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -277,7 +265,7 @@
<Group>
<GroupName>FreeRTOS_Source</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -369,7 +357,7 @@
<Group>
<GroupName>main_low_power</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -529,7 +517,7 @@
<GroupNumber>5</GroupNumber>
<FileNumber>24</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\main_full\IntQueueTimer.c</PathWithFileName>
@ -573,6 +561,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>28</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\Common\Minimal\StaticAllocation.c</PathWithFileName>
<FilenameWithoutPath>StaticAllocation.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -583,7 +583,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>28</FileNumber>
<FileNumber>29</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -595,7 +595,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>29</FileNumber>
<FileNumber>30</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>

@ -234,11 +234,11 @@
<interw>1</interw>
<bigend>0</bigend>
<Strict>0</Strict>
<Optim>0</Optim>
<wLevel>2</wLevel>
<Optim>1</Optim>
<wLevel>3</wLevel>
<uThumb>1</uThumb>
<VariousControls>
<MiscControls>-mfloat-abi=softfp -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections -O0 -g</MiscControls>
<MiscControls>-mfloat-abi=softfp -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections -g</MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath>..;..\..\..\Source\include;..\..\..\Source\portable\GCC\ARM_CM4F;..\..\Common\include;..\peripheral_library;..\CMSIS;..\main_full</IncludePath>
@ -429,6 +429,11 @@
<FileType>1</FileType>
<FilePath>..\..\Common\Minimal\death.c</FilePath>
</File>
<File>
<FileName>StaticAllocation.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\Common\Minimal\StaticAllocation.c</FilePath>
</File>
</Files>
</Group>
<Group>

@ -35,7 +35,7 @@ PROVIDE ( _Main_Stack_Limit = __Main_Stack_Limit ) ;
* There will be a link error if there is not this amount of
* RAM free at the end.
*/
_Minimum_Stack_Size = 256 ;
_Minimum_Stack_Size = 1024 ;
/*
* Default heap definitions.

@ -121,9 +121,7 @@ __isr_vector:
.long NVIC_Handler_GIRQ09
.long NVIC_Handler_GIRQ10
.long NVIC_Handler_GIRQ11
;.long NVIC_Handler_GIRQ12
.long interrupt_irq12
;.long NVIC_Handler_GIRQ13
.long NVIC_Handler_GIRQ12
.long NVIC_Handler_GIRQ13
.long NVIC_Handler_GIRQ14
.long NVIC_Handler_GIRQ15
@ -180,6 +178,9 @@ Reset_Handler:
*
* All addresses must be aligned to 4 bytes boundary.
*/
ldr sp, =__SRAM_segment_end__
sub sp, sp, #4
ldr r1, =__etext
ldr r2, =__data_start__
ldr r3, =__data_end__
@ -250,10 +251,10 @@ Default_Handler:
def_irq_handler MemManage_Handler
def_irq_handler BusFault_Handler
def_irq_handler UsageFault_Handler
def_irq_handler SVC_Handler
/* def_irq_handler SVC_Handler */
def_irq_handler DebugMon_Handler
def_irq_handler PendSV_Handler
def_irq_handler SysTick_Handler
/* def_irq_handler PendSV_Handler */
/* def_irq_handler SysTick_Handler */
def_irq_handler DEF_IRQHandler
def_irq_handler NVIC_Handler_I2C0

@ -89,7 +89,7 @@
<sRfunc>1</sRfunc>
<sRbox>1</sRbox>
<tLdApp>1</tLdApp>
<tGomain>1</tGomain>
<tGomain>0</tGomain>
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
@ -152,6 +152,16 @@
<WinNumber>1</WinNumber>
<ItemText>ulLED,0x0A</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>ulTimerCounts</ItemText>
</Ww>
<Ww>
<count>2</count>
<WinNumber>1</WinNumber>
<ItemText>ulx</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
<Mm>
@ -201,7 +211,7 @@
<Group>
<GroupName>System</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -265,7 +275,7 @@
<Group>
<GroupName>FreeRTOS_Source</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -345,7 +355,7 @@
<GroupNumber>3</GroupNumber>
<FileNumber>11</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\Source\portable\RVDS\ARM_CM4F\port.c</PathWithFileName>
@ -421,7 +431,7 @@
<GroupNumber>5</GroupNumber>
<FileNumber>16</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\Common\Minimal\flop.c</PathWithFileName>
@ -561,6 +571,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>28</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\Common\Minimal\StaticAllocation.c</PathWithFileName>
<FilenameWithoutPath>StaticAllocation.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -571,7 +593,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>28</FileNumber>
<FileNumber>29</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -583,7 +605,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>29</FileNumber>
<FileNumber>30</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -595,7 +617,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>30</FileNumber>
<FileNumber>31</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -607,7 +629,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>31</FileNumber>
<FileNumber>32</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>

@ -310,7 +310,7 @@
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>1</Optim>
<Optim>0</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
@ -594,6 +594,11 @@
<FileType>1</FileType>
<FilePath>..\..\Common\Minimal\death.c</FilePath>
</File>
<File>
<FileName>StaticAllocation.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\Common\Minimal\StaticAllocation.c</FilePath>
</File>
</Files>
</Group>
<Group>

@ -0,0 +1,5 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://www.freertos.org/Microchip_CEC1302_ARM_Cortex-M4F_Low_Power_Demo.html
IDList=

@ -76,6 +76,9 @@
* more comprehensive test and demo application is implemented and described in
* main_full.c.
*
* The simple blinky demo uses aggregated interrupts. The full demo uses
* disaggregated interrupts.
*
* This file implements the code that is not demo specific, including the
* hardware setup and standard FreeRTOS hook functions.
*
@ -147,10 +150,18 @@ int main( void )
of this file. */
#if( configCREATE_LOW_POWER_DEMO == 1 )
{
/* The low power demo also demonstrated aggregated interrupts, so clear
the interrupt control register to disable the alternative NVIC vectors. */
mainEC_INTERRUPT_CONTROL = pdFALSE;
main_low_power();
}
#else
{
/* The full demo also demonstrated disaggregated interrupts, so set the
interrupt control register to enable the alternative NVIC vectors. */
mainEC_INTERRUPT_CONTROL = pdTRUE;
main_full();
}
#endif
@ -168,9 +179,6 @@ extern unsigned long __Vectors[];
/* Disable M4 write buffer: fix CEC1302 hardware bug. */
mainNVIC_AUX_ACTLR |= 0x07;
/* Enable alternative NVIC vectors. */
mainEC_INTERRUPT_CONTROL = pdTRUE;
system_set_ec_clock();
/* Assuming downloading code via the debugger - so ensure the hardware

@ -75,6 +75,9 @@
* on using conifgCREATE_LOW_POWER_DEMO in main.c. This file implements the
* comprehensive test and demo version.
*
* The simple blinky demo uses aggregated interrupts. The full demo uses
* disaggregated interrupts.
*
* NOTE 2: This file only contains the source code that is specific to the
* full demo. Generic functions, such FreeRTOS hook functions, and functions
* required to configure the hardware, are defined in main.c.
@ -129,6 +132,7 @@
#include "IntQueue.h"
#include "EventGroupsDemo.h"
#include "TaskNotify.h"
#include "StaticAllocation.h"
/* Priorities for the demo application tasks. */
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1UL )
@ -223,6 +227,7 @@ void main_full( void )
vStartEventGroupTasks();
vStartTaskNotifyTask();
vStartInterruptQueueTasks();
vStartStaticallyAllocatedTasks();
/* Create the register check tasks, as described at the top of this file */
xTaskCreate( prvRegTestTaskEntry1, "Reg1", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_1_PARAMETER, tskIDLE_PRIORITY, NULL );
@ -265,10 +270,10 @@ unsigned long ulErrorFound = pdFALSE;
xLastExecutionTime = xTaskGetTickCount();
/* Cycle for ever, delaying then checking all the other tasks are still
operating without error. The onboard LED is toggled on each iteration.
operating without error. The on board LED is toggled on each iteration.
If an error is detected then the delay period is decreased from
mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD. This has the
effect of increasing the rate at which the onboard LED toggles, and in so
effect of increasing the rate at which the on board LED toggles, and in so
doing gives visual feedback of the system status. */
for( ;; )
{
@ -322,6 +327,11 @@ unsigned long ulErrorFound = pdFALSE;
ulErrorFound = 1UL << 10UL;
}
if( xAreStaticAllocationTasksStillRunning() != pdPASS )
{
ulErrorFound = 1UL << 11UL;
}
if( xAreEventGroupTasksStillRunning() != pdPASS )
{
ulErrorFound = 1UL << 12UL;

@ -102,13 +102,23 @@ sleep mode by an interrupt other than the tick interrupt, and therefore
allowing an additional paths through the code to be tested. */
#define lpINCLUDE_TEST_TIMER 0
/* Some registers are accessed directly as the library is not compatible with
all the compilers used. */
/* Registers and bits required to use the htimer in aggregated mode. */
#define lpHTIMER_PRELOAD_REGISTER ( * ( volatile uint16_t * ) 0x40009800 )
#define lpHTIMER_CONTROL_REGISTER ( * ( volatile uint16_t * ) 0x40009804 )
#define lpHTIMER_COUNT_REGISTER ( * ( volatile uint16_t * ) 0x40009808 )
#define lpEC_GIRQ17_ENABLE_SET ( * ( volatile uint32_t * ) 0x4000C0B8 )
#define lpHTIMER_INTERRUPT_CONTROL_BIT ( 1UL << 20UL )
#define lpEC_GIRQ17_SOURCE ( * ( volatile uint32_t * ) 0x4000C0B4 )
#define lpEC_GIRQ17_ENABLE_CLEAR ( * ( volatile uint32_t * ) 0x4000C0C0 )
#define lpBLOCK_ENABLE_SET ( * ( volatile uint32_t * ) 0x4000c200 )
#define lpGIRQ17_BIT_HTIMER ( 1UL << 20UL )
#define lpHTIMER_GIRQ_BLOCK ( 1Ul << 17UL )
/* Registers and bits required to use btimer 0 in aggregated mode. */
#define lpGIRQ23_ENABLE_SET ( * ( volatile uint32_t * ) 0x4000C130 )
#define lpEC_GIRQ23_SOURCE ( * ( volatile uint32_t * ) 0x4000C12C )
#define lpEC_GIRQ23_ENABLE_CLEAR ( * ( volatile uint32_t * ) 0x4000C138 )
#define lpGIRQ23_BIT_TIMER0 ( 1UL << 0UL )
#define lpBTIMER_GIRQ_BLOCK ( 1UL << 23UL )
/*
* The low power demo does not use the SysTick, so override the
@ -152,34 +162,50 @@ static volatile uint32_t ulTickFlag = pdFALSE;
/*-----------------------------------------------------------*/
void NVIC_Handler_HIB_TMR( void )
void NVIC_Handler_GIRQ17( void )
{
lpHTIMER_PRELOAD_REGISTER = ulHighResolutionReloadValue;
/* The low power demo is using aggregated interrupts, so although in the
demo the htimer is the only peripheral that will generate interrupts on
this vector, in a real application it would be necessary to first check the
interrupt source. */
if( ( lpEC_GIRQ17_SOURCE & lpGIRQ17_BIT_HTIMER ) != 0 )
{
/* The htimer interrupted. Clear the interrupt. */
lpEC_GIRQ17_SOURCE = lpGIRQ17_BIT_HTIMER;
lpHTIMER_PRELOAD_REGISTER = ( uint16_t ) ulHighResolutionReloadValue;
/* Increment the RTOS tick. */
if( xTaskIncrementTick() != pdFALSE )
{
/* A context switch is required. Context switching is performed in
the PendSV interrupt. Pend the PendSV interrupt. */
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
}
/* Increment the RTOS tick. */
if( xTaskIncrementTick() != pdFALSE )
/* The CPU woke because of a tick. */
ulTickFlag = pdTRUE;
}
else
{
/* A context switch is required. Context switching is performed in
the PendSV interrupt. Pend the PendSV interrupt. */
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
/* Don't expect any other interrupts to use this vector in this
demo. Force an assert. */
configASSERT( lpEC_GIRQ17_SOURCE == 0 );
}
/* The CPU woke because of a tick. */
ulTickFlag = pdTRUE;
}
/*-----------------------------------------------------------*/
#if( lpINCLUDE_TEST_TIMER == 1 )
#define lpGIRQ23_ENABLE_SET ( * ( uint32_t * ) 0x4000C130 )
#define tmrGIRQ23_BIT_TIMER0 ( 1UL << 0UL )
static void prvSetupBasicTimer( void )
{
const uint8_t ucTimerChannel = 0;
const uint32_t ulTimer0Count = configCPU_CLOCK_HZ / 10;
lpGIRQ23_ENABLE_SET = tmrGIRQ23_BIT_TIMER0;
/* Enable btimer 0 interrupt in the aggregated GIRQ23 block. */
lpEC_GIRQ23_SOURCE = lpGIRQ23_BIT_TIMER0;
lpEC_GIRQ23_ENABLE_CLEAR = lpGIRQ23_BIT_TIMER0;
lpBLOCK_ENABLE_SET = lpBTIMER_GIRQ_BLOCK;
lpGIRQ23_ENABLE_SET = lpGIRQ23_BIT_TIMER0;
/* To fully test the low power tick processing it is necessary to sometimes
bring the MCU out of its sleep state by a method other than the tick
@ -187,9 +213,9 @@ void NVIC_Handler_HIB_TMR( void )
purpose. */
btimer_init( ucTimerChannel, BTIMER_AUTO_RESTART | BTIMER_COUNT_DOWN | BTIMER_INT_EN, 0, ulTimer0Count, ulTimer0Count );
btimer_interrupt_status_get_clr( ucTimerChannel );
NVIC_SetPriority( TIMER0_IRQn, ucTimerChannel );
NVIC_ClearPendingIRQ( TIMER0_IRQn );
NVIC_EnableIRQ( TIMER0_IRQn );
NVIC_SetPriority( GIRQ23_IRQn, ucTimerChannel );
NVIC_ClearPendingIRQ( GIRQ23_IRQn );
NVIC_EnableIRQ( GIRQ23_IRQn );
btimer_start( ucTimerChannel );
}
@ -198,22 +224,25 @@ void NVIC_Handler_HIB_TMR( void )
void vPortSetupTimerInterrupt( void )
{
ulMaximumPossibleSuppressedHighResolutionTicks = ( ( uint32_t ) USHRT_MAX ) / ulReloadValueForOneHighResolutionTick;
ulMaximumPossibleSuppressedHighResolutionTicks = ( ( uint32_t ) USHRT_MAX ) / ulReloadValueForOneHighResolutionTick;
/* Set up the hibernation timer to start at the value required by the
tick interrupt. */
lpHTIMER_PRELOAD_REGISTER = ulHighResolutionReloadValue;
lpHTIMER_CONTROL_REGISTER = mainHTIMER_HIGH_RESOLUTION;
/* Enable the HTIMER interrupt. Equivalent to enable_htimer0_irq(); */
lpEC_GIRQ17_ENABLE_SET |= lpHTIMER_INTERRUPT_CONTROL_BIT;
/* Enable the HTIMER interrupt in the aggregated GIR17 block. */
lpEC_GIRQ17_SOURCE = lpGIRQ17_BIT_HTIMER;
lpEC_GIRQ17_ENABLE_CLEAR = lpGIRQ17_BIT_HTIMER;
lpBLOCK_ENABLE_SET = lpHTIMER_GIRQ_BLOCK;
lpEC_GIRQ17_ENABLE_SET = lpGIRQ17_BIT_HTIMER;
/* The hibernation timer is not an auto-reload timer, so gets reset
from within the ISR itself. For that reason it's interrupt is set
to the highest possible priority to ensure clock slippage is minimised. */
NVIC_SetPriority( HTIMER_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
NVIC_ClearPendingIRQ( HTIMER_IRQn );
NVIC_EnableIRQ( HTIMER_IRQn );
NVIC_SetPriority( GIRQ17_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
NVIC_ClearPendingIRQ( GIRQ17_IRQn );
NVIC_EnableIRQ( GIRQ17_IRQn );
/* A basic timer is also started, purely for test purposes. Its only
purpose is to bring the CPU out of its sleep mode by an interrupt other
@ -327,7 +356,7 @@ TickType_t xModifiableIdleTime;
/* Allow the application to define some post sleep processing. */
configPOST_SLEEP_PROCESSING( xModifiableIdleTime );
/* Stop the hibernation timer. Again, the time the tiemr is stopped
/* Stop the hibernation timer. Again, the time the timer is stopped
for is accounted for as best it can be, but using the tickless mode
will inevitably result in some tiny drift of the time maintained by the
kernel with respect to calendar time. Take the count value first as
@ -402,14 +431,31 @@ TickType_t xModifiableIdleTime;
}
/*-----------------------------------------------------------*/
void NVIC_Handler_TMR0( void )
void NVIC_Handler_GIRQ23( void )
{
/* This timer is used for test purposes. Its only function is to
generate interrupts while the MCU is sleeping, so the MCU is sometimes
brought out of sleep by a means other than the tick interrupt. */
}
/*-----------------------------------------------------------*/
static volatile uint32_t ulTimerCounts = 0;
/* The low power demo is using aggregated interrupts, so although in the
demo btimer 0 is the only peripheral that will generate interrupts on
this vector, in a real application it would be necessary to first check the
interrupt source. */
if( ( lpEC_GIRQ23_SOURCE & lpGIRQ23_BIT_TIMER0 ) != 0 )
{
/* Btimer0 interrupted. Clear the interrupt. */
lpEC_GIRQ23_SOURCE = lpGIRQ23_BIT_TIMER0;
#endif /* configCREATE_LOW_POWER_DEMO */
/* This timer is used for test purposes. Its only function is to
generate interrupts while the MCU is sleeping, so the MCU is sometimes
brought out of sleep by a means other than the tick interrupt. */
ulTimerCounts++;
}
else
{
/* Don't expect any other interrupts to use this vector in this
demo. Force an assert. */
configASSERT( lpEC_GIRQ23_SOURCE == 0 );
}
}
/*-----------------------------------------------------------*/
#endif /* configCREATE_LOW_POWER_DEMO == 1 */

@ -75,6 +75,10 @@
* configCREATE_LOW_POWER_DEMO in main.c. This file implements the low power
* version.
*
* The simple blinky demo uses aggregated interrupts. The full demo uses
* disaggregated interrupts.
*
*
* NOTE 2: This file only contains the source code that is specific to the
* low power demo. Generic functions, such FreeRTOS hook functions, and
* functions required to configure the hardware are defined in main.c.

File diff suppressed because one or more lines are too long

@ -117,7 +117,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGDARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=1234,201,1699,501,0)</Name>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=1215,201,1680,501,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -155,12 +155,7 @@
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>ulStillAliveCounts</ItemText>
</Ww>
<Ww>
<count>2</count>
<WinNumber>1</WinNumber>
<ItemText>ulStatus</ItemText>
<ItemText>ulExpireCount</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
@ -269,7 +264,7 @@
<Group>
<GroupName>FreeRTOS_Source</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

@ -74,9 +74,11 @@
* the new xTaskCreateRestricted() API functions. The purpose of each created
* task is documented in the comments above the task function prototype (in
* this file), with the task behaviour demonstrated and documented within the
* task function itself. In addition a queue is used to demonstrate passing
* data between protected/restricted tasks as well as passing data between an
* interrupt and a protected/restricted task.
* task function itself.
*
* In addition a queue is used to demonstrate passing data between
* protected/restricted tasks as well as passing data between an interrupt and
* a protected/restricted task, and a software timer is used.
*/
/* Standard includes. */
@ -87,6 +89,7 @@
#include "task.h"
#include "queue.h"
#include "semphr.h"
#include "timers.h"
/*-----------------------------------------------------------*/
@ -106,6 +109,10 @@
#define mainNVIC_AUX_ACTLR ( * ( volatile uint32_t * ) 0xE000E008 )
#define mainEC_INTERRUPT_CONTROL ( * ( volatile uint32_t * ) 0x4000FC18 )
/* The period of the timer must be less than the rate at which
mainPRINT_SYSTEM_STATUS messages are sent to the check task - otherwise the
check task will think the timer has stopped. */
#define mainTIMER_PERIOD pdMS_TO_TICKS( 200 )
/*-----------------------------------------------------------*/
/* Prototypes for functions that implement tasks. -----------*/
/*-----------------------------------------------------------*/
@ -193,6 +200,12 @@ static void prvSendImAlive( QueueHandle_t xHandle, uint32_t ulTaskNumber );
*/
static void prvTestMemoryRegions( void );
/*
* Callback function used with the timer that uses the queue to send messages
* to the check task.
*/
static void prvTimerCallback( TimerHandle_t xExpiredTimer );
/*-----------------------------------------------------------*/
/* The handle of the queue used to communicate between tasks and between tasks
@ -206,6 +219,8 @@ static QueueHandle_t xFileScopeCheckQueue = NULL;
done for code coverage test purposes only. */
static TaskHandle_t xTaskToDelete = NULL;
/* The timer that periodically sends data to the check task on the queue. */
static TimerHandle_t xTimer = NULL;
/*-----------------------------------------------------------*/
/* Data used by the 'check' task. ---------------------------*/
@ -396,6 +411,15 @@ int main( void )
NULL /* Handle. */
);
/* Create and start the software timer. */
xTimer = xTimerCreate( "Timer", /* Test name for the timer. */
mainTIMER_PERIOD, /* Period of the timer. */
pdTRUE, /* The timer will auto-reload itself. */
( void * ) 0, /* The timer's ID is used to count the number of times it expires - initialise this to 0. */
prvTimerCallback ); /* The function called when the timer expires. */
configASSERT( xTimer );
xTimerStart( xTimer, mainDONT_BLOCK );
/* Start the scheduler. */
vTaskStartScheduler();
@ -463,7 +487,7 @@ volatile uint32_t ulStatus = pdPASS;
( void ) ulStatus;
}
/* print pcStatusMessage here. */
/**** print pcStatusMessage here. ****/
( void ) pcStatusMessage;
/* Reset the count of 'still alive' messages. */
@ -1023,7 +1047,20 @@ void MemManage_Handler( void )
" handler2_address_const: .word hard_fault_handler \n"
);
}
/*-----------------------------------------------------------*/
static void prvTimerCallback( TaskHandle_t xExpiredTimer )
{
uint32_t ulCount;
/* The count of the number of times this timer has expired is saved in the
timer's ID. Obtain the current count. */
ulCount = ( uint32_t ) pvTimerGetTimerID( xTimer );
/* Increment the count, and save it back into the timer's ID. */
ulCount++;
vTimerSetTimerID( xTimer, ( void * ) ulCount );
}
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an

@ -1052,7 +1052,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
/* Increment the lock count so the task that unlocks the queue
knows that data was posted while it was locked. */
pxQueue->cTxLock = cTxLock + 1;
pxQueue->cTxLock = ( int8_t ) ( cTxLock + 1 );
}
xReturn = pdPASS;
@ -1217,7 +1217,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
/* Increment the lock count so the task that unlocks the queue
knows that data was posted while it was locked. */
pxQueue->cTxLock = cTxLock + 1;
pxQueue->cTxLock = ( int8_t ) ( cTxLock + 1 );
}
xReturn = pdPASS;
@ -1505,7 +1505,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
/* Increment the lock count so the task that unlocks the queue
knows that data was removed while it was locked. */
pxQueue->cRxLock = cRxLock + 1;
pxQueue->cRxLock = ( int8_t ) ( cRxLock + 1 );
}
xReturn = pdPASS;
@ -1654,6 +1654,12 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
mtCOVERAGE_TEST_MARKER();
}
}
#else
{
/* The queue must have been statically allocated, so is not going to be
deleted. Avoid compiler warnings about the unused parameter. */
( void ) pxQueue;
}
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
}
/*-----------------------------------------------------------*/
@ -2534,7 +2540,7 @@ BaseType_t xReturn;
}
else
{
pxQueueSetContainer->cTxLock = cTxLock + 1;
pxQueueSetContainer->cTxLock = ( int8_t ) ( cTxLock + 1 );
}
}
else

Loading…
Cancel
Save