#include "DSP28x_Project.h"
extern void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr);
extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadEnd;
extern Uint16 RamfuncsRunStart;
uint32_t distance=0;
/*
* main.c
*/
int main(void) {
InitSysCtrl();
InitGpio();
DINT;
InitPieCtrl();
IER=0x00;
IFR=0x00;
InitPieVectTable();
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
InitFlash();
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0,60,6000);
CpuTimer0Regs.TCR.all=0x0010;
//CpuTimer0Regs.TCR.bit.TSS=1;
IER |= M_INT1;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // timer0 (1.7)
EINT;
ERTM;
while(1)
{
GpioDataRegs.GPADAT.bit.GPIO0=1;
DELAY_US(20L);
GpioDataRegs.GPADAT.bit.GPIO0=0;
while(GpioDataRegs.GPADAT.bit.GPIO1==0);
CpuTimer0Regs.TCR.all=0x4001;
while(GpioDataRegs.GPADAT.bit.GPIO1==1);
distance = CpuTimer0.InterruptCount*17;
CpuTimer0Regs.TCR.all=0x0011;
if(distance<500)
{
GpioDataRegs.GPACLEAR.bit.GPIO2=1;
}
else
GpioDataRegs.GPASET.bit.GPIO2=1;
}
} |