Update repo

This commit is contained in:
hangpersonal committed 2026-08-30 23:04:35 -07:00
1 parent 749dab5721
commit ce65a0f59a
14950 files changed
+4408250 -1

No files matched your search

@@ -0,0 +1,28 @@
<projectSpec>
<project
name="lpm_ex1_haltwake"
device="TMS320F28377S"
cgtVersion="22.6.0.LTS"
products="C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xS"
>
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=CPU1 --define=DEBUG --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 --define RAM" />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=CPU1 --define=DEBUG --define=_FLASH --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 " />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/targetConfigs/TMS320F28377S.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_FLASH_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/F2837xS_CodeStartBranch.asm" targetDirectory="device" />
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../lpm_ex1_haltwake.c" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,28 @@
<projectSpec>
<project
name="lpm_ex2_idlewake"
device="TMS320F28377S"
cgtVersion="22.6.0.LTS"
products="C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xS"
>
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 --define RAM" />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --define=_FLASH --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 " />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/targetConfigs/TMS320F28377S.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_FLASH_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/F2837xS_CodeStartBranch.asm" targetDirectory="device" />
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../lpm_ex2_idlewake.c" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,28 @@
<projectSpec>
<project
name="lpm_ex3_standbywake"
device="TMS320F28377S"
cgtVersion="22.6.0.LTS"
products="C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2837xS"
>
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 --define RAM" />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --float_support=fpu32 --define=DEBUG --define=_FLASH --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --define=CPU1 --diag_warning=225 --diag_suppress=10063 --display_error_number" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 " />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/targetConfigs/TMS320F28377S.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/cmd/2837xS_Generic_FLASH_lnk.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
<file action="copy" path="../../../../driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../../../../../../device_support/f2837xs/common/source/F2837xS_CodeStartBranch.asm" targetDirectory="device" />
<file action="link" path="../../../../driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../lpm_ex3_standbywake.c" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,251 @@
//#############################################################################
//
// FILE: lpm_ex1_haltwake.c
//
// TITLE: Halt entry and Exit example.
//
//! \addtogroup driver_example_list
//! <h1>Low Power Modes: Halt Mode and Wakeup</h1>
//!
//! This example puts the device into HALT mode. If the lowest
//! possible current consumption in HALT mode is desired, the
//! JTAG connector must be removed from the device board while
//! the device is in HALT mode.
//!
//! The example then wakes up the device from HALT using GPIO0.
//! GPIO0 wakes the device from HALT mode when a high-to-low
//! signal is detected on the pin. This pin must be pulsed by
//! an external agent for wakeup.
//!
//! The wakeup process begins as soon as GPIO0 is held low for the
//! time indicated in the device datasheet. After the
//! device wakes up, GPIO1 can be observed to go low.
//!
//! GPIO0 is configured as the LPM wakeup pin to trigger a
//! WAKEINT interrupt upon detection of a low pulse.
//! Initially, pull GPIO0 high externally.
//!
//! To observe when device wakes from HALT mode, monitor
//! GPIO1 with an oscilloscope (Cleared to 0 in WAKEINT ISR)
//!
//! \b External \b Connections \n
//! - GPIO0, GPIO1
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2014-2024 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#ifdef _FLASH
// These are defined by the linker (see device linker command file)
extern uint16_t RamfuncsLoadStart;
extern uint16_t RamfuncsLoadSize;
extern uint16_t RamfuncsRunStart;
#endif
//
// Defines
//
// Define if the INTOSC0/1 will be enabled during HALT
#define HALT_OSCON 1 // OSC ON
//#define HALT_OSCON 0 // OSC OFF
//
// Function Prototypes
//
__interrupt void wakeISR(void);
//
// Main
//
void main(void)
{
//
// When the example is used with the watchdog Timer, the watchdog
// timer will reset the device when it is LPM. If the example is run
// from flash and the device is in a boot to flash configuration,
// then it will restart the application and will enter the condition
// below and ESTOP0 if the debugger is connected.
//
// Check whether this was a normal startup or a watchdog reset.
//
if( SysCtl_getResetCause() == SYSCTL_CAUSE_WDRS)
{
SysCtl_clearResetCause(SYSCTL_CAUSE_WDRS);
ESTOP0;
}
//
// Configure PLL, disable WD, enable peripheral clocks.
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
//
// GPIO0 is the external wake-up source
//
GPIO_setMasterCore(0, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_0_GPIO0);
GPIO_setDirectionMode(0, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP);
GPIO_setQualificationMode(0, GPIO_QUAL_ASYNC);
//
// GPIO1 is an output
//
GPIO_setMasterCore(1, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_1_GPIO1);
GPIO_setDirectionMode(1,GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(1, GPIO_PIN_TYPE_STD);
//
// Use GPIO0 to wake the CPU from halt.
//
SysCtl_enableLPMWakeupPin(0);
//
// Disable global interrupts.
//
DINT;
//
// Initialize interrupt controller and vector table.
//
Interrupt_initModule();
Interrupt_initVectorTable();
IER = 0x0000;
IFR = 0x0000;
//
// Map the ISR to the wake interrupt.
//
Interrupt_register(INT_WAKE, wakeISR);
//
// Enable the wake interrupt in the PIE: Group 1 interrupt 8.
//
Interrupt_enable(INT_WAKE);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
//
// Enable global interrupts.
//
EINT;
//
// Check if HALT_OSCON is defined.
//
if(HALT_OSCON)
{
//
// Enable watchdog in halt.
//
SysCtl_enableWatchdogStandbyWakeup();
SysCtl_setWatchdogMode(SYSCTL_WD_MODE_RESET);
SysCtl_enableWatchdogInHalt();
//
// Enable the watchdog to wake the device from halt.
// Uncomment this section if a watchdog wakeup is desired.
//
// SysCtl_serviceWatchdog();
// SysCtl_enableWatchdog();
}
else
{
//
// Disable watchdog in halt.
//
SysCtl_disableWatchdogStandbyWakeup();
SysCtl_disableWatchdogInHalt();
}
//
// Power down the flash bank and pump. Ensure there are no subsequent
// flash accesses.
//
Flash_powerDown(FLASH0CTRL_BASE);
//
// Set GPIO1 high.
//
GPIO_writePin(1, 1);
//
// Enter halt mode.
//
SysCtl_enterHaltMode();
//
// Reconfigure PLL after waking from halt.
//
SysCtl_setClock(DEVICE_SETCLOCK_CFG);
ESTOP0;
//
// Loop forever.
//
while(1)
{
}
}
//
// wakeISR() - this will be triggered from a watchdog timeout and set
// GPIO1 low.
//
__interrupt void
wakeISR(void)
{
//
// Write GPIO1 low.
//
GPIO_writePin(1, 0);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
//
// End of File
//
@@ -0,0 +1,272 @@
//#############################################################################
//
// FILE: lpm_ex2_idlewake.c
//
// TITLE: Idle entry and Exit example.
//
//! \addtogroup driver_example_list
//! <h1>Low Power Modes: Device Idle Mode and Wakeup</h1>
//!
//! This example puts the device into IDLE mode then
//! wakes up the device from IDLE using watchdog timer or using XINT1
//! which triggers on a falling edge of GPIO0.
//!
//! In the case of watchdog, the device wakes up from the IDLE mode when
//! the watch dog timer overflows, triggering an interrupt. In the ISR, the LED
//! is toggled to indicate the device is out of IDLE mode.
//! A pre scalar is set for the watch dog timer to change the counter overflow
//! time.
//!
//! In the case of XINT1, this GPIO0 pin must be pulled from high to low
//! by an external agent for wakeup. GPIO0 is configured as an XINT1 pin
//! to trigger an XINT1 interrupt upon detection of a falling edge.
//!
//! Initially, pull GPIO0 high externally. To wake device
//! from IDLE mode by triggering an XINT1 interrupt,
//! pull GPIO0 low (falling edge). The wakeup process begins as soon
//! as GPIO0 is held low for the time indicated in the device datasheet.
//! After the device wakes up, GPIO1 can be observed to go low.
//!
//! \b External \b Connections \n
//! - In the case of XINT1, To observe the device wakeup from IDLE mode,
//! monitor GPIO1 with an oscilloscope, which goes high in the XINT_1_ISR.
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2014-2024 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
//
// Comment for waking through GPIO.
//
#define WD_WAKE
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#ifdef _FLASH
// These are defined by the linker (see device linker command file)
extern uint16_t RamfuncsLoadStart;
extern uint16_t RamfuncsLoadSize;
extern uint16_t RamfuncsRunStart;
#endif
uint16_t toggle = 1, count = 0, i = 0, pass = 0;
//
// Function Prototypes
//
#ifndef WD_WAKE
__interrupt void xint1ISR(void);
#else
__interrupt void wakeupISR(void);
#endif
//
// Main
//
void main(void)
{
//
// Configure PLL, disable WD, enable peripheral clocks.
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
#ifndef WD_WAKE
//
// GPIO0 is the external wake-up source
//
GPIO_setMasterCore(0, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_0_GPIO0);
GPIO_setDirectionMode(0, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP);
GPIO_setQualificationMode(0, GPIO_QUAL_ASYNC);
//
// GPIO1 is an output
//
GPIO_setMasterCore(1, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_1_GPIO1);
GPIO_setDirectionMode(1,GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(1, GPIO_PIN_TYPE_STD);
#else
//
//Led toggling is a measure of wakeup
//
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
#endif
#ifndef WD_WAKE
//
// Configure GPIO0 as external wake source. The input XBAR is configured
// to map the GPIO0 to the XINT1 using XBAR input 4
//
XBAR_setInputPin(XBAR_INPUT4, 0);
GPIO_setInterruptType(GPIO_INT_XINT1, GPIO_INT_TYPE_FALLING_EDGE);
GPIO_enableInterrupt(GPIO_INT_XINT1);
#endif
//
// Disable global interrupts.
//
DINT;
//
// Initialize interrupt controller and vector table.
//
Interrupt_initModule();
Interrupt_initVectorTable();
IER = 0x0000;
IFR = 0x0000;
#ifndef WD_WAKE
//
// Map the ISR to the XINT1 interrupt.
//
Interrupt_register(INT_XINT1, xint1ISR);
#else
//
// Re-map watchdog wake interrupt signal to call the ISR function in this
// example
//
Interrupt_register(INT_WAKE, &wakeupISR);
#endif
#ifndef WD_WAKE
//
// Enable the wake interrupt in the PIE: Group 1 interrupt 4.
//
Interrupt_enable(INT_XINT1);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
#else
//
// Set the watchdog to generate an interrupt signal instead of a
// reset signal
//
SysCtl_setWatchdogMode(SYSCTL_WD_MODE_INTERRUPT);
SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
//
// Enable the watchdog wake interrupt signal in the
// PIE: Group 1 interrupt 8.
//
Interrupt_enable(INT_WAKE);
#endif
// Enable global interrupts.
//
EINT;
#ifdef WD_WAKE
//
// Reset the watchdog counter
//
SysCtl_serviceWatchdog();
//
// Enable the watchdog
//
SysCtl_enableWatchdog();
#endif
//
// Power down the flash bank and pump. Ensure there are no subsequent
// flash accesses.
//
Flash_powerDown(FLASH0CTRL_BASE);
#ifndef WD_WAKE
//
// Set GPIO1 high.
//
GPIO_writePin(1, 1);
#endif
//
// Enter idle mode.
//
SysCtl_enterIdleMode();
//
// Loop forever.
//
while(1)
{
}
}
#ifndef WD_WAKE
//
// xint1ISR - External interrupt when GPIO0 is pulled from high to low.
//
__interrupt void
xint1ISR(void)
{
Example_PassCount++;
//
// Write GPIO1 low.
//
GPIO_writePin(1, 0);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
#else
//
// Wakeup ISR - The interrupt service routine called when the watchdog
// triggers the wake interrupt signal
//
__interrupt void
wakeupISR(void)
{
Example_PassCount++;
for(i=0;i<6;i++)
{
GPIO_writePin(DEVICE_GPIO_PIN_LED1, toggle);
DEVICE_DELAY_US(50000);
toggle= !toggle;
}
toggle=!toggle;
//
// Acknowledge this interrupt located in group 1
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
#endif
//
// End of File
//
@@ -0,0 +1,286 @@
//#############################################################################
//
// FILE: lpm_ex3_standbywake.c
//
// TITLE: Standby entry and Exit example.
//
//! \addtogroup driver_example_list
//! <h1>Low Power Modes: Device Standby Mode and Wakeup</h1>
//!
//! This example puts the device into STANDBY mode. If the lowest
//! possible current consumption in STANDBY mode is desired, the
//! JTAG connector must be removed from the device board while
//! the device is in STANDBY mode.
//!
//! This example puts the device into STANDBY mode then wakes up
//! the device from STANDBY using watchdog timer or an LPM wakeup pin.
//!
//! In case of watchdog , the device wakes up from the STANDBY mode
//! when the watch dog timer overflows triggering an interrupt. In the ISR,
//! the LED is toggled to indicate the device is out of STANDBY mode.
//! A pre scalar is set for the watch dog timer to change the counter overflow
//! time.
//!
//! In case of wakeup pin , GPIO0 is configured as the LPM wakeup pin
//! to trigger a WAKEINT interrupt upon detection of a low pulse.
//! Initially, pull GPIO0 high externally. To wake device
//! from STANDBY mode, pull GPIO0 low for at least (2+QUALSTDBY)
//! OSCLKS, then pull it high again.
//!
//! The example then wakes up the device from STANDBY using GPIO0.
//! GPIO0 wakes the device from STANDBY mode when a low pulse
//! (signal goes high->low->high)is detected on the pin.
//! This pin must be pulsed by an external agent for wakeup.
//!
//! As soon as GPIO0 goes high again after the pulse, the device
//! should wake up, and GPIO1 can be observed to toggle low.
//!
//! \b External \b Connections \n
//! - To observe when device wakes from STANDBY mode, monitor
//! GPIO1 with an oscilloscope (set to 0 in WAKEINT ISR)
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2014-2024 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
//
// Comment for waking through GPIO.
//
#define WD_WAKE
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#ifdef _FLASH
// These are defined by the linker (see device linker command file)
extern uint16_t RamfuncsLoadStart;
extern uint16_t RamfuncsLoadSize;
extern uint16_t RamfuncsRunStart;
#endif
uint16_t toggle = 1, count = 0, i = 0, pass = 0;
//
// Function Prototypes
//
#ifndef WD_WAKE
__interrupt void wakeISR(void);
#else
__interrupt void wakeupISR(void);
#endif
//
// Main
//
void main(void)
{
//
// Configure PLL, disable WD, enable peripheral clocks.
//
Device_init();
//
// Disable pin locks and enable internal pullups.
//
Device_initGPIO();
#ifndef WD_WAKE
//
// GPIO0 is the external wake-up source
//
GPIO_setMasterCore(0, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_0_GPIO0);
GPIO_setDirectionMode(0, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(0, GPIO_PIN_TYPE_STD | GPIO_PIN_TYPE_PULLUP);
GPIO_setQualificationMode(0, GPIO_QUAL_ASYNC);
//
// GPIO1 is an output
//
GPIO_setMasterCore(1, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_1_GPIO1);
GPIO_setDirectionMode(1,GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(1, GPIO_PIN_TYPE_STD);
#else
//
//Led toggling is a measure of wakeup
//
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
#endif
#ifndef WD_WAKE
//
// Use GPIO0 to wake the CPU from standby.
//
SysCtl_enableLPMWakeupPin(0);
//
// The wakeup signal should be (2+QUALSTBY) OSCCLKs wide
//
SysCtl_setStandbyQualificationPeriod(2);
#else
//
//Watch dog is used to wake up from watch dog
//
SysCtl_enableWatchdogStandbyWakeup();
#endif
//
// Disable global interrupts.
//
DINT;
//
// Initialize interrupt controller and vector table.
//
Interrupt_initModule();
Interrupt_initVectorTable();
IER = 0x0000;
IFR = 0x0000;
#ifndef WD_WAKE
//
// Map the ISR to the wake interrupt. This would be triggered
// when the LPM wake pin, mapped to the GPIO0 is pulled low.
//
Interrupt_register(INT_WAKE, wakeISR);
#else
//
// Re-map watchdog wake interrupt signal to call the ISR function in this
// example
//
Interrupt_register(INT_WAKE, &wakeupISR);
#endif
//
// Enable the wake interrupt in the PIE: Group 1 interrupt 8.
//
Interrupt_enable(INT_WAKE);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
#ifdef WD_WAKE
//
// Set the watchdog to generate an interrupt signal instead of a
// reset signal
//
SysCtl_setWatchdogMode(SYSCTL_WD_MODE_INTERRUPT);
SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
//
// Enable the watchdog wake interrupt signal
#endif
//
// Enable global interrupts.
//
EINT;
#ifdef WD_WAKE
//
// Reset the watchdog counter
//
SysCtl_serviceWatchdog();
//
// Enable the watchdog
//
SysCtl_enableWatchdog();
#endif
//
// Power down the flash bank and pump. Ensure there are no subsequent
// flash accesses.
//
Flash_powerDown(FLASH0CTRL_BASE);
#ifndef WD_WAKE
//
// Set GPIO1 high.
//
GPIO_writePin(1, 1);
#endif
//
// Enter standby mode.
//
SysCtl_enterStandbyMode();
//
// Loop forever.
//
while(1)
{
}
}
#ifndef WD_WAKE
//
// wakeISR - The interrupt service routine called when the watchdog
// triggers the wake interrupt signal
//
__interrupt void
wakeISR(void)
{
Example_PassCount++;
//
// Write GPIO1 low.
//
GPIO_writePin(1, 0);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
#else
//
// Wakeup ISR - The interrupt service routine called when the watchdog
// triggers the wake interrupt signal
//
__interrupt void
wakeupISR(void)
{
Example_PassCount++;
for(i = 0; i < 6; i++)
{
GPIO_writePin(DEVICE_GPIO_PIN_LED1, toggle);
DEVICE_DELAY_US(50000);
toggle = !toggle;
}
toggle = !toggle;
//
// Acknowledge this interrupt located in group 1
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
#endif
//
// End of File
//