From 8320dfb885d569dc73362a01d5439c9fcd698372 Mon Sep 17 00:00:00 2001 From: Richard Barry Date: Mon, 11 Nov 2013 14:49:36 +0000 Subject: [PATCH] Update the SAM4L low power demo to use the ASF enable/disable interrupts functions rather than manipulating the PIRMASK directly - and in so doing allow other ASF functions to be called with the interrupt enable bit nesting. --- .../FreeRTOS_Demo.cproj | 26 ++++++++----------- .../src/SAM4L_low_power_tick_management.c | 9 +++---- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj index a4d899029..afaf06514 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj @@ -18,7 +18,7 @@ Native true false - + exception_table 1 3.5.1 @@ -135,12 +135,8 @@ com.atmel.avrdbg.tool.samice com.atmel.avrdbg.tool.samice - J-Link-OB-SAM3U128 - 000480008435 - true - false - - + J-Link + 000480008423 127.0.0.1 1882 @@ -158,13 +154,13 @@ 0 0 0 - 4000000 + 32000 true true - + 0x20000000 2 @@ -212,7 +208,7 @@ -fdata-sections True True - -std=gnu99 -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ + -std=gnu99 -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ arm_cortexM4l_math @@ -227,7 +223,7 @@ True -T../src/asf/sam/utils/linker_scripts/sam4l/sam4l4/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb - -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ + -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ ../src/asf/sam/utils/preprocessor @@ -256,7 +252,7 @@ %24(ToolchainDir)\..\..\CMSIS_Atmel\Device\ATMEL\sam4l\include - -DARM_MATH_CM4=true -DBOARD=SAM4L_EK -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ + -DARM_MATH_CM4=true -DBOARD=SAM4L_EK -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ ../src/asf/sam/utils/preprocessor @@ -336,7 +332,7 @@ True Maximum (-g3) True - -std=gnu99 -Wmissing-field-initializers -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ + -std=gnu99 -Wmissing-field-initializers -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ libm @@ -350,7 +346,7 @@ True -T../src/asf/sam/utils/linker_scripts/sam4l/sam4l4/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb - -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ + -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ ../src/asf/sam/utils/preprocessor @@ -380,7 +376,7 @@ Default (-g) - -DARM_MATH_CM4=true -DBOARD=SAM4L_EK -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ + -DARM_MATH_CM4=true -DBOARD=SAM4L_EK -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ -D__ATSAM4LC4C__ ../src/asf/sam/utils/preprocessor diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/SAM4L_low_power_tick_management.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/SAM4L_low_power_tick_management.c index a00f30b35..694b73d2b 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/SAM4L_low_power_tick_management.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/SAM4L_low_power_tick_management.c @@ -253,7 +253,7 @@ asynchronous timer (AST), as the tick is generated from the low power AST and not the SysTick as would normally be the case on a Cortex-M. */ void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime ) { -uint32_t ulAlarmValue, ulCompleteTickPeriods; +uint32_t ulAlarmValue, ulCompleteTickPeriods, ulInterruptStatus; eSleepModeStatus eSleepAction; portTickType xModifiableIdleTime; enum sleepmgr_mode xSleepMode; @@ -284,8 +284,7 @@ enum sleepmgr_mode xSleepMode; /* Enter a critical section but don't use the taskENTER_CRITICAL() method as that will mask interrupts that should exit sleep mode. */ - __asm volatile( "cpsid i \n\t" - "dsb \n\t" ); + ulInterruptStatus = cpu_irq_save(); /* The tick flag is set to false before sleeping. If it is true when sleep mode is exited then sleep mode was probably exited because the tick was @@ -303,7 +302,7 @@ enum sleepmgr_mode xSleepMode; /* Re-enable interrupts - see comments above the cpsid instruction() above. */ - __asm volatile( "cpsie i" ); + cpu_irq_restore( ulInterruptStatus ); } else { @@ -345,7 +344,7 @@ enum sleepmgr_mode xSleepMode; /* Re-enable interrupts - see comments above the cpsid instruction() above. */ - __asm volatile( "cpsie i" ); + cpu_irq_restore( ulInterruptStatus ); if( ulTickFlag != pdFALSE ) {