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

📄 ezkit push button.c

📁 ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代码
💻 C
字号:


//ADSP-21262 Blink LEDs with the buttons on the EZKIT

//Buttons to push on ezkit: FLAG1 (IRQ1) lights LED1, FLAG2 (IRQ2) lights LED4
//Buttons to push on ezkit: DAI_P19 lights LED3, DAI_P20 lights LED4
//DAI_P19 is associated with interrupt 23 (MISCB1) and Interrupt 23's ISR sets LED3
//DAI_P20 is associated with interrupt 24 (MISCB2) and Interrupt 24's ISR sets LED4


#include <def21262.h>
#include <cdef21262.h>

// The following definition allows the SRU macro to check for errors. Once the routings have
// been verified, this definition can be removed to save some program memory space.
// The preprocessor will issue a warning stating this when using the SRU macro without this
// definition
#define SRUDEBUG  // Check SRU Routings for errors.
#include <SRU.h>

#include <signal.h>


#define LED1 1
#define LED2 2
#define LED3 4
#define LED4 8

void DAIroutine(int);
void IRQ1_routine(int);
void IRQ2_routine(int);
void handle_LED(int);

main(){
//Set up interrupt priorities
    *pDAI_IRPTL_PRI = SRU_EXTMISCB1_INT  | SRU_EXTMISCB2_INT;    //unmask individual interrupts
    *pDAI_IRPTL_RE = SRU_EXTMISCB1_INT  | SRU_EXTMISCB2_INT;    //make sure interrupts latch on the rising edge
    *pSYSCTL |= IRQ1EN|IRQ2EN;

    asm("#include <def21262.h>");
    asm("bit set mode2 IRQ1E|IRQ2E;");

    interrupt(SIG_DAIH,DAIroutine);
    interrupt(SIG_SPIH,DAIroutine);

    interrupt(SIG_IRQ1,IRQ1_routine);
    interrupt(SIG_IRQ2,IRQ2_routine);
//Pin Assignments in SRU_PIN3 (Group D)

    //assign pin buffer 19 low so it is an input
    SRU(LOW,DAI_PB19_I);

    //assign pin buffer 20 low so it is an input
    SRU(LOW,DAI_PB20_I);

//Route MISCB singnals in SRU_EXT_MISCB (Group E)

    //route so that DAI pin buffer 19 connects to MISCB1
    SRU(DAI_PB19_O,MISCB1_I);

    //route so that DAI pin buffer 20 connects to MISCB2
    SRU(DAI_PB20_O,MISCB2_I);

//Pin Buffer Disable in SRU_PINEN0 (Group F)

    //assign pin 19 low so it is an input
    SRU(LOW,PBEN19_I);

    //assign pin 20 low so it is an input
    SRU(LOW,PBEN20_I);

    for(;;)
    {}
}

void IRQ1_routine(int sig_int){
     handle_LED(LED1);
}


void IRQ2_routine(int sig_int){
     handle_LED(LED2);
}

//Set up interrupt service routines to toggle LEDs 3 and 4.
void DAIroutine(int sig_int){
    static int interrupt_reg;

    interrupt_reg = *pDAI_IRPTL_H;

    //test for SRU_EXTMISCB1_INT
    if ((interrupt_reg & SRU_EXTMISCB1_INT) != 0)
        handle_LED(LED3);

    //test for SRU_EXTMISCB2_INT
    if ((interrupt_reg & SRU_EXTMISCB2_INT) != 0)
        handle_LED(LED4);
}

void handle_LED(int led_value){
//lights as described at the top of the file
    *pPPCTL=0;

    *pIIPP=(int) &led_value;
    *pIMPP=1;
    *pICPP=1;
    *pEMPP=1;
    *pECPP=1;
    *pEIPP=0x400000;

    *pPPCTL=PPTRAN|PPBHC|PPDUR20|PPDEN|PPEN;
}

⌨️ 快捷键说明

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