|
|
|
// Some comments about author
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
|
|
|
|
#include "DSP2833x_Examples.h"
|
|
|
|
#include "Protocol/CAN.h"
|
|
|
|
|
|
|
|
|
|
|
|
//Functions declarations
|
|
|
|
void idle_loop(void);
|
|
|
|
interrupt void cpu_timer0_isr(void);
|
|
|
|
//interrupt void adc_isr(void);
|
|
|
|
|
|
|
|
canSpace::CAN canTest;
|
|
|
|
Uint16 msgsSent = 0;
|
|
|
|
Uint16 infCounter = 0;
|
|
|
|
volatile Uint16 testCounter = 0;
|
|
|
|
Uint32 testVar = 0;
|
|
|
|
volatile bool startTX = false;
|
|
|
|
canSpace::CANMessage message;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
ServiceDog();
|
|
|
|
DisableDog();
|
|
|
|
|
|
|
|
InitSysCtrl();
|
|
|
|
|
|
|
|
DINT;
|
|
|
|
|
|
|
|
InitPieCtrl();
|
|
|
|
|
|
|
|
IER = 0x0000;
|
|
|
|
IFR = 0x0000;
|
|
|
|
|
|
|
|
InitPieVectTable();
|
|
|
|
|
|
|
|
EALLOW;
|
|
|
|
PieVectTable.TINT0 = &cpu_timer0_isr;
|
|
|
|
EDIS;
|
|
|
|
|
|
|
|
// memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (Uint32)&RamfuncsLoadSize);
|
|
|
|
|
|
|
|
// Call Flash Initialization to setup flash waitstates
|
|
|
|
// This function must reside in RAM
|
|
|
|
// InitFlash();
|
|
|
|
|
|
|
|
|
|
|
|
// flash.setup(SECTORD, (Uint16*)0x320000, (Uint16*)0x327FFF);
|
|
|
|
|
|
|
|
// configuration_parameters.setup(TIME_SAMPLE_CONTROL, TIME_SAMPLE_CONTROL_SLOW, TIME_SAMPLE_SERVICE, TPWM, FCPU, FPWM);
|
|
|
|
// configuration_parameters.load_flash();
|
|
|
|
//configuration_parameters.extract_configuration(system_config);
|
|
|
|
// configuration_parameters.extract_configuration(test_config);
|
|
|
|
|
|
|
|
InitCpuTimers();
|
|
|
|
ConfigCpuTimer(&CpuTimer0, 150, 800);
|
|
|
|
|
|
|
|
IER |= M_INT1; // Enable CPU Interrupt 1
|
|
|
|
// Enable ADCINT in PIE
|
|
|
|
// PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
|
|
|
|
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Enable global Interrupts and higher priority real-time debug events:
|
|
|
|
//
|
|
|
|
EINT; // Enable Global interrupt INTM
|
|
|
|
ERTM; // Enable Global realtime interrupt DBGM
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Start CPU Timer
|
|
|
|
//
|
|
|
|
// core.cpu_timers.start();
|
|
|
|
//
|
|
|
|
|
|
|
|
canTest.initGpio(canSpace::CANB);
|
|
|
|
canTest.config(canSpace::CANB, 100);
|
|
|
|
// canTest.configTxMBoxes();
|
|
|
|
canTest.configTxMBox(1, canSpace::ConfigMBox(false, 0xAAA, 0x0, false, false, 0xF));
|
|
|
|
canTest.configRxMBoxes(25, canSpace::ConfigMBox(false, 0xAAA, 0x0, false, false, 0xF));
|
|
|
|
|
|
|
|
// InitECanGpio();
|
|
|
|
// InitECan();
|
|
|
|
|
|
|
|
CpuTimer0.RegsAddr->TCR.bit.TSS = 0;
|
|
|
|
|
|
|
|
message.msgctrl.bit.DLC = 8;
|
|
|
|
message.mdl.byte.BYTE0 = 0x11;
|
|
|
|
message.mdl.byte.BYTE1 = 0x22;
|
|
|
|
message.mdl.byte.BYTE2 = 0x33;
|
|
|
|
message.mdl.byte.BYTE3 = 0x44;
|
|
|
|
message.mdh.byte.BYTE4 = 0xAA;
|
|
|
|
message.mdh.byte.BYTE5 = 0xBB;
|
|
|
|
message.mdh.byte.BYTE6 = 0xCC;
|
|
|
|
message.mdh.byte.BYTE7 = 0xDD;
|
|
|
|
|
|
|
|
idle_loop();
|
|
|
|
//
|
|
|
|
}//end main()
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
void idle_loop()
|
|
|
|
{
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
infCounter++;
|
|
|
|
if (startTX){
|
|
|
|
startTX = false;
|
|
|
|
canTest.transmitMsg(1, message);
|
|
|
|
msgsSent++;
|
|
|
|
}
|
|
|
|
if(canTest.isNewMessage()){
|
|
|
|
testCounter++;
|
|
|
|
testVar = canTest.receiveMsg(25, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
}//end while
|
|
|
|
//
|
|
|
|
}//end idle_loop()
|
|
|
|
//
|
|
|
|
|
|
|
|
interrupt void cpu_timer0_isr(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
//
|
|
|
|
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP1;
|
|
|
|
}//end
|