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

📄 int_ext.c

📁 基于cc1010的设计实例
💻 C
字号:
/*****************************************************************************
 *                                                                           *
 *        **********                                                         *
 *       ************                                                        *
 *      ***        ***                                                       *
 *      ***   +++   ***                                                      *
 *      ***   + +   ***                                                      *
 *      ***   +                    CHIPCON CC1010 EXAMPLE PROGRAM            *
 *      ***   + +   ***                 EXTERNAL INTERRUPTS                  *
 *      ***   +++   ***                                                      *
 *      ***       ***                                                        *
 *       ***********                                                         *
 *        *********                                                          *
 *                                                                           *
 *****************************************************************************
 * Demonstrates the CC1010 external interrupt sources. Uses:                 *
 * - INT_EXTERNAL0_TRIGGER_ON_LEVEL, INT_PRIORITY, INT_ENABLE,               *
 *   INT_EXTERNAL1_TRIGGER_ON_LEVEL, INT_GLOBAL_ENABLE macros.               *
 *                                                                           *
 * The program cannot be run with single-step operation in the debugger,     *
 * because the debugger's use of interrupts interfere with the operation.    *
 *                                                                           *
 * The program enables the two external interrupts, external 0 on the P3.2   *
 * pin and external 1 on the P3.3 pin. Button 2 will trigger external 0,     *
 * and button 3 will trigger external 1. External interrupt 0 turns on the   *
 * green LED, external interrupt 1 turns on the yellow LED.                  *
 *****************************************************************************
 * Author:              ARR                                                  *
 *****************************************************************************
 * Revision history:                                                         *
 * 1.0  2002/08/29      First public release                                 *
 *                                                                           *
 * $Log: int_ext.c,v $
 * Revision 1.2  2002/11/18 10:50:11  kht
 * Added startup macros
 *
 * Revision 1.1  2002/10/11 15:06:02  tos
 * Initial version in CVS.
 *
 *                                                                           *
 ****************************************************************************/

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

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 ports 2.5 and 2.7 high and low, respectively
    PORTDIRBIT(2, 5, POUT);
    PORTDIRBIT(2, 7, POUT);
    PORTBIT(2, 5) = 1;
    PORTBIT(2, 7) = 0;

    // Setup external interrupt 0 as an interrupt source
    INT_EXTERNAL0_TRIGGER_ON_LEVEL();
    INT_PRIORITY(INUM_EXTERNAL0, INT_HIGH);
    INT_ENABLE(INUM_EXTERNAL0, INT_ON);

    // Setup external interrupt 1 as an interrupt source
    INT_EXTERNAL1_TRIGGER_ON_LEVEL();
    INT_PRIORITY(INUM_EXTERNAL1, INT_LOW);
    INT_ENABLE(INUM_EXTERNAL1, INT_ON);

    // Turn on interrupts
    INT_GLOBAL_ENABLE(INT_ON);

    // Infinite loop, program is interrupt driven
    while(1);
}

// ISR (interrupt service routine) for ext int 0, priority 1
// The interrupt is cleared by hardware
void isr_extint0() interrupt INUM_EXTERNAL0 {
    GLED = LED_ON;
} //end isr_extint0()

// ISR (interrupt service routine) for ext int 1, priority 3
// The interrupt is cleared by hardware
void isr_extint1() interrupt INUM_EXTERNAL1 {
    YLED = LED_ON;
} //end isr_extint1()

⌨️ 快捷键说明

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