Вы находитесь на странице: 1из 5

Copyright(c) 2012 Analog Devices, Inc. All Rights Reserved.

This software is proprietary and confidential. By using this software you agree

to the terms of the associated Analog Devices License Agreement.

*********************************************************************************/

/*

* NAME: EZkit Push Button.c (Block-based Talk through)

* PURPOSE: Blink LEDs with the buttons on the ADSP-21262 EZKIT

*/

#include <stdio.h> /* Get declaration of puts and definition of NULL. */

#include <stdint.h> /* Get definition of uint32_t. */

#include <assert.h> /* Get the definition of support for standard C asserts. */

#include <builtins.h> /* Get definitions of compiler built-in functions */

#include <platform_include.h> /* System and IOP register bit and address definitions. */

#include <processor_include.h> /* Get definitions of the part being built*/

#include <services/int/adi_int.h> /* Interrupt Handler API header. */

#include "adi_initialize.h"

#include <sru.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.*/

#define LED1 1
#define LED2 2

#define LED3 4

#define LED4 8

void DAIroutine(void);

void IRQ1_routine(void);

void IRQ2_routine(void);

void handle_LED(int);

void main()

/* Initialize managed drivers and/or services at the start of main(). */

adi_initComponents();

/*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;

sysreg_bit_set( sysreg_MODE2,IRQ1E|IRQ2E);

adi_int_InstallHandler(ADI_CID_DAIHI,(ADI_INT_HANDLER_PTR )DAIroutine,0,true);

adi_int_InstallHandler(ADI_CID_SPIHI,(ADI_INT_HANDLER_PTR )DAIroutine,0,true);

adi_int_InstallHandler(ADI_CID_IRQ1I,(ADI_INT_HANDLER_PTR ) IRQ1_routine,0,true);

adi_int_InstallHandler(ADI_CID_IRQ2I,(ADI_INT_HANDLER_PTR ) IRQ2_routine,0,true);
/*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);

puts("Press push buttons to light the LED ");

for(;;)

NOP();

}
}

void IRQ1_routine(void)

handle_LED(LED1);

void IRQ2_routine(void)

handle_LED(LED2);

/*Set up interrupt service routines to toggle LEDs 3 and 4.*/

void DAIroutine(void)

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;

Вам также может понравиться