#include "Key.h"
#define RELAYON GpioDataRegs.GPASET.bit.GPIO1
#define RELAYOFF GpioDataRegs.GPACLEAR.bit.GPIO1
interrupt void ISRExint1 (void);
void relay_init ()
{
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;//set GPIO1 as output
EDIS;
}
void key_interrupt_init ()
{
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO13 = 0;
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 13;
XIntruptRegs.XINT1CR.bit.POLARITY = 0;
XIntruptRegs.XINT1CR.bit.ENABLE = 1;
EDIS;
IER = 0x0001;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
PieCtrlRegs.PIEIER1.bit.INTx4 = 1;
EALLOW;
PieVectTable.XINT1 = &ISRExint1;
EDIS;
}
interrupt void ISRExint1 (void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
RELAYON = 1;
DELAY_US(1000000);
RELAYOFF = 1;
}
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
#include "Key.h"
void main ()
{
InitSysCtrl();
// IER = 0x0000;
// IFR = 0x0000;
// InitPieCtrl();
InitPieVectTable();
relay_init();
key_interrupt_init();
GpioDataRegs.GPASET.bit.GPIO1 = 1;
EINT;
while(1);
}