⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 powermodes.c

📁 ti-Chipcon CC1010 1G以下Soc应用开发源码实例。包括rf,powermodes,clockmodes,flashRW,interrupts,timer,pwm,uart...所有底
💻 C
字号:
/*****************************************************************************
 *                                                                           *
 *        **********                                                         *
 *       ************                                                        *
 *      ***        ***                                                       *
 *      ***   +++   ***                                                      *
 *      ***   + +   ***                                                      *
 *      ***   +                    CHIPCON CC1010 EXAMPLE PROGRAM            *
 *      ***   + +   ***                      POWER MODES                     *
 *      ***   +++   ***                                                      *
 *      ***       ***                                                        *
 *       ***********                                                         *
 *        *********                                                          *
 *                                                                           *
 *****************************************************************************
 * Demonstrates the CC1010 power modes: Idle and Stop mode                   *
 * - ENTER_IDLE_MODE and ENTER_SLEEP_MODE macros demonstrated                *
 *                                                                           *
 * The program can not be single-stepped in the debugger.                    *
 * The program can however be run stand-alone on the CC1010 EB.              *
 *                                                                           *
 * Pressing switch button 1 will start the program. Idle mode will be        *
 * entered and the green LED will light up when the timer 0 interrupt is     *
 * serviced. This brings the chip out of idle mode. Now, pressing switch     *
 * button 2 will light the yellow LED and enter sleep mode. When the reset   *
 * button is pressed the chip exits sleep mode and the LEDs go out.          *
 *****************************************************************************
 * Author:              ARR                                                  *
 *****************************************************************************
 * Revision history:                                                         *
 * 1.0  2002/08/29      First public release                                 *
 *                                                                           *
 * $Log: powermodes.c,v $
 * Revision 1.2  2002/11/18 11:49:19  kht
 * Added startup macros
 *
 * Revision 1.1  2002/10/14 09:31:09  tos
 * Initial version in CVS.
 *
 *                                                                           *
 ****************************************************************************/

#include <chipcon/hal.h>
#include <chipcon/cc1010eb.h>

// Timer value in XRAM
word xdata timer_val;

int main() {

    // Disable watchdog timer
    WDT_ENABLE(FALSE);

    // Startup macros for speed and low power consumption
    MEM_NO_WAIT_STATES();
    FLASH_SET_POWER_MODE(FLASH_STANDBY_BETWEEN_READS);

    // All I/Os are inputs after reset. Make I/Os connected to LEDs outputs
    RLED=YLED=GLED=BLED=LED_OFF;
    RLED_OE(TRUE); YLED_OE(TRUE); GLED_OE(TRUE); BLED_OE(TRUE);

    // Set up timer 0 as an interrupt timer w/ max period
    halConfigTimer01(TIMER0 | TIMER01_INT_TIMER, 0, CC1010EB_CLKFREQ, &timer_val);

    // Setup timer 0 as an interrupt source
    INT_ENABLE(INUM_TIMER0, INT_ON);
    INT_PRIORITY(INUM_TIMER0, INT_HIGH);

    // Turn on interrupts
    INT_GLOBAL_ENABLE(INT_ON);

    // Infinite loop
    while(1) {

        // Switch LEDS off
        YLED=GLED=LED_OFF;

        // push any switch button to start
        while (1) {
            if (SW1_PRESSED) break;
        }

        // Run timer, the overflow will trigger an interrupt
        TIMER0_RUN(TRUE);

        // Set IDLE mode
        ENTER_IDLE_MODE();

        // Disable timer
        TIMER0_RUN(FALSE);

        // push any switch button to start
        while (1) {
            if (SW2_PRESSED) break;
        }

        // Turn on yellow LED
        YLED = LED_ON;

        // Set STOP (sleep) mode
        // Power on/off or reset switch button will set active mode and restart the program
        ENTER_SLEEP_MODE();

    }
}

// ISR (interrupt service routine) for timer 0
// The interrupt is cleared by hardware
void isr_timer0() interrupt INUM_TIMER0 {
    ISR_TIMER0_ADJUST(timer_val);
    GLED = LED_ON; // set green LED when interrupt is serviced
} //end isr_timer0()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -