matlab_23550/Inu/main.c

145 lines
3.1 KiB
C
Raw Normal View History

2024-12-27 10:50:32 +03:00
/**************************************************************************
Description: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> INU.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>/<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD>/<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>.<EFBFBD>.
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 2021.10.05
**************************************************************************/
#include "def.h"
#include "main.h"
void control_processor_led(void);
void talk_with_desk(void);
void talk_with_mst(void);
void write_eeprom(void);
extern void detcoeff(void);
extern void init28335(void);
#ifndef ML
void main(void) {
// disable the watchdog
EALLOW;
SysCtrlRegs.WDCR = 0x0068;
EDIS;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
init28335();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
detcoeff();
// re-enable the watchdog
EALLOW;
SysCtrlRegs.WDCR = 0x00A8;
// ... clear the WD counter
SysCtrlRegs.WDKEY = 0x55;
SysCtrlRegs.WDKEY = 0xAA;
EDIS;
// clear Interrupt Flag ADC Sequencer 1
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
// clear PIEIFR1 register
PieCtrlRegs.PIEIFR1.all = 0;
// before we can start we have to enable interrupt mask in the PIE unit
PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
// core line 1 (INT1)
IER |= M_INT1;
// enable global interrupts and higher priority real-time debug events
EINT;
ERTM;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (up-down-count mode)
EPwm1Regs.TBCTL.bit.CTRMODE = 2;
EPwm2Regs.TBCTL.bit.CTRMODE = 2;
EPwm3Regs.TBCTL.bit.CTRMODE = 2;
EPwm4Regs.TBCTL.bit.CTRMODE = 2;
EPwm5Regs.TBCTL.bit.CTRMODE = 2;
EPwm6Regs.TBCTL.bit.CTRMODE = 2;
#ifdef ML
EPwm7Regs.TBCTL.bit.CTRMODE = 2;
EPwm8Regs.TBCTL.bit.CTRMODE = 2;
EPwm9Regs.TBCTL.bit.CTRMODE = 2;
EPwm10Regs.TBCTL.bit.CTRMODE = 2;
EPwm11Regs.TBCTL.bit.CTRMODE = 2;
EPwm12Regs.TBCTL.bit.CTRMODE = 2;
#endif
// loop forever
while(1) {
// <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><>
// ( -> mst)
talk_with_mst();
// <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><>
// ( -> param[], eprom.writeRequestNumber)
talk_with_desk();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> EEPROM
// (param[], eprom.writeRequestNumber -> eprom.writeRequestNumber)
if ( eprom.writeRequestNumber > 0 ) {
write_eeprom();
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
control_processor_led();
} //while(1)
} //void main(void)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
void control_processor_led(void) {
static unsigned short Tled = (unsigned short)(0.5/TY);
static unsigned short tLed = 0;
if ( tLed < Tled ) {
tLed++;
}
else {
tLed = 1;
// <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if ( state == STATE_SHUTDOWN ) {
LED_GREEN1_OFF;
LED_GREEN2_OFF;
LED_RED_TOGGLE;
}
// <20> <20><><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
else if ( state == STATE_STOP ) {
LED_GREEN1_TOGGLE;
LED_GREEN2_OFF;
LED_RED_OFF;
}
// <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
else {
LED_GREEN1_OFF;
LED_GREEN2_TOGGLE;
LED_RED_OFF;
}
}
} //void control_processor_led(void)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><>
// ( -> param[], eprom.writeRequestNumber)
void talk_with_desk(void) {
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><>
// ( -> mst)
void talk_with_mst(void) {
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> EEPROM
// (param[], eprom.writeRequestNumber -> eprom.writeRequestNumber)
void write_eeprom(void) {
}
#endif //ML