#define MOTOR_DRIVE_VERSION 6 ↓ #define MOTOR_DRIVE_VERSION 5 TIMEOUT_VALUE 1.0f ↓ TIMEOUT_VALUE 10.0f ↓

Dependencies:   mbed can_network_definition_2022 bitCommunication_Ver2 motorDrive_LAP PID QEI_hw LPC1549QEI LPC1549_EEPROM motorDrive_SMB MedianFilter2020 buzzer USBDevice

Committer:
YutaTogashi
Date:
Tue Jun 30 23:16:09 2020 +0000
Revision:
3:097710997f6b
Parent:
2:40528aee5ebe
Child:
4:6e88615c830b
20200701 add safetyControl

Who changed what in which revision?

UserRevisionLine numberNew contents of line
YutaTogashi 2:40528aee5ebe 1 /***************************************
YutaTogashi 2:40528aee5ebe 2 MotorDriver Ver4 or Ver5 or Ver6 select
YutaTogashi 2:40528aee5ebe 3 ***************************************/
YutaTogashi 2:40528aee5ebe 4 //<注意>プログラム上でのバージョンです
YutaTogashi 2:40528aee5ebe 5 //Ver4 2019Bチーム手動機で使っていたMD
YutaTogashi 2:40528aee5ebe 6 //Ver5 2019Bチーム自動機で使っていたMD
YutaTogashi 2:40528aee5ebe 7 //Ver6 センサ入力に対応したMD
YutaTogashi 3:097710997f6b 8 #define MOTOR_DRIVER_VERSION 5
YutaTogashi 2:40528aee5ebe 9 /***************************************
YutaTogashi 2:40528aee5ebe 10 SMB or LAP select
YutaTogashi 2:40528aee5ebe 11 ***************************************/
YutaTogashi 2:40528aee5ebe 12 //駆動方式の選択 選択する方のコメントアウトを外してください.
YutaTogashi 2:40528aee5ebe 13 //<default> SMBモード
YutaTogashi 2:40528aee5ebe 14 //<option> LAPモード
YutaTogashi 2:40528aee5ebe 15 #define MOTOR_DRIVER_MODE_SMB
YutaTogashi 2:40528aee5ebe 16 //#define MOTOR_DRIVER_MODE_LAP
YutaTogashi 2:40528aee5ebe 17 /*************************************************************************************************************************/
YutaTogashi 2:40528aee5ebe 18 // souce code
YutaTogashi 2:40528aee5ebe 19 /***************************
YutaTogashi 2:40528aee5ebe 20 include file
YutaTogashi 2:40528aee5ebe 21 ***************************/
YutaTogashi 0:4fe08f484460 22 #include "mbed.h"
YutaTogashi 0:4fe08f484460 23 #include "can_network_definition.h"
YutaTogashi 0:4fe08f484460 24 #include "bitCommunication.h"
YutaTogashi 0:4fe08f484460 25 #include "buzzer.h"
YutaTogashi 0:4fe08f484460 26 #include "eeprom.h"
YutaTogashi 0:4fe08f484460 27 #include "eeprom_initalize.h"
YutaTogashi 0:4fe08f484460 28 #include "QEI.h"
YutaTogashi 0:4fe08f484460 29 #include "Pid.h"
YutaTogashi 0:4fe08f484460 30 #include "motorDrive_SMB.h"
YutaTogashi 0:4fe08f484460 31 #include "motorDrive_LAP.h"
YutaTogashi 0:4fe08f484460 32 #include "MedianFilter.h"
YutaTogashi 0:4fe08f484460 33 #include "definition.h"
YutaTogashi 0:4fe08f484460 34 /******************************
YutaTogashi 0:4fe08f484460 35 definition instance
YutaTogashi 0:4fe08f484460 36 ******************************/
YutaTogashi 0:4fe08f484460 37 CAN can(CAN_PIN[CAN_RD],CAN_PIN[CAN_TD]);
YutaTogashi 0:4fe08f484460 38 Serial pc(SERIAL_PIN[SERIAL_TX],SERIAL_PIN[SERIAL_RX],communication_baud::PC);
YutaTogashi 0:4fe08f484460 39 BusIn idSwitch(ID_PIN[SWITCH1],ID_PIN[SWITCH2],ID_PIN[SWITCH3],ID_PIN[SWITCH4]);
YutaTogashi 0:4fe08f484460 40 QEI encoder(ENCODER_PIN[ENCODER_A],ENCODER_PIN[ENCODER_B],NC,ENCODER_PPR);
YutaTogashi 2:40528aee5ebe 41 //motorDriveSMB motor(A3921_PIN[PWMH],A3921_PIN[PHASE]);
YutaTogashi 0:4fe08f484460 42 buzzer led(LED_PIN[FREE]);
YutaTogashi 0:4fe08f484460 43 PwmOut pwmLed[2] = {
YutaTogashi 0:4fe08f484460 44 PwmOut(LED_PIN[CW]),
YutaTogashi 0:4fe08f484460 45 PwmOut(LED_PIN[CCW]),
YutaTogashi 0:4fe08f484460 46 };
YutaTogashi 0:4fe08f484460 47 Pid pid;
YutaTogashi 0:4fe08f484460 48 Ticker controlCycle;
YutaTogashi 0:4fe08f484460 49 Timer errorTimer;
YutaTogashi 2:40528aee5ebe 50 #ifndef MOTOR_DRIVER_MODE_LAP
YutaTogashi 2:40528aee5ebe 51 motorDriveLAP motor(A3921_PIN[PWMH],A3921_PIN[PHASE]);
YutaTogashi 2:40528aee5ebe 52 #else
YutaTogashi 2:40528aee5ebe 53 motorDriveSMB motor(A3921_PIN[PWMH],A3921_PIN[PHASE]);
YutaTogashi 2:40528aee5ebe 54 #endif
YutaTogashi 2:40528aee5ebe 55 #if MOTOR_DRIVER_VERSION == 4
YutaTogashi 2:40528aee5ebe 56 DigitalOut pwml(PWML_PIN,true);
YutaTogashi 2:40528aee5ebe 57 #endif
YutaTogashi 0:4fe08f484460 58 /******************************
YutaTogashi 0:4fe08f484460 59 global variable
YutaTogashi 0:4fe08f484460 60 ******************************/
YutaTogashi 0:4fe08f484460 61 float parameter[PARAMETER_NUMBER] = {0.0f,0.0f,0.0f,0.0f};
YutaTogashi 0:4fe08f484460 62 float outputDuty = 0.0f;
YutaTogashi 0:4fe08f484460 63 float targetRpm = 0.0f;
YutaTogashi 0:4fe08f484460 64 int powerFilterCount;
YutaTogashi 0:4fe08f484460 65 int powerFilterArray[10];
YutaTogashi 3:097710997f6b 66 bool enable_motor_output = false; //モーターへの出力許可を管理(true : 出力可能 , false : 出力を強制停止)
YutaTogashi 0:4fe08f484460 67 bool outputMode = false;
YutaTogashi 0:4fe08f484460 68 bool printfMode = false;
YutaTogashi 0:4fe08f484460 69 bool receiveParameterStatus[4] = {false,false,false,false};
YutaTogashi 0:4fe08f484460 70 /******************************
YutaTogashi 0:4fe08f484460 71 definition function
YutaTogashi 0:4fe08f484460 72 ******************************/
YutaTogashi 0:4fe08f484460 73 void initalize();
YutaTogashi 0:4fe08f484460 74 void mainLoop();
YutaTogashi 3:097710997f6b 75 void outputIndicator(float control_duty);
YutaTogashi 3:097710997f6b 76 void safetyControl(float duty);
YutaTogashi 0:4fe08f484460 77 void canReceiveHandler();
YutaTogashi 0:4fe08f484460 78 void debag();
YutaTogashi 0:4fe08f484460 79 /******************************
YutaTogashi 0:4fe08f484460 80 function content
YutaTogashi 0:4fe08f484460 81 ******************************/
YutaTogashi 0:4fe08f484460 82 int main() {
YutaTogashi 0:4fe08f484460 83 initalize();
YutaTogashi 0:4fe08f484460 84 while(1){
YutaTogashi 0:4fe08f484460 85 }
YutaTogashi 0:4fe08f484460 86 }
YutaTogashi 0:4fe08f484460 87
YutaTogashi 0:4fe08f484460 88 void initalize() {
YutaTogashi 0:4fe08f484460 89 can_flame eepromData;
YutaTogashi 0:4fe08f484460 90
YutaTogashi 0:4fe08f484460 91 Chip_EEPROM_init();
YutaTogashi 0:4fe08f484460 92 __disable_irq();
YutaTogashi 0:4fe08f484460 93 read_eeprom((char*)0, eepromData.c, 4);
YutaTogashi 0:4fe08f484460 94 parameter[KP] = eepromData.f;
YutaTogashi 0:4fe08f484460 95 read_eeprom((char*)4, eepromData.c, 4);
YutaTogashi 0:4fe08f484460 96 parameter[KI] = eepromData.f;
YutaTogashi 0:4fe08f484460 97 read_eeprom((char*)8, eepromData.c, 4);
YutaTogashi 0:4fe08f484460 98 parameter[KD] = eepromData.f;
YutaTogashi 0:4fe08f484460 99 __enable_irq();
YutaTogashi 2:40528aee5ebe 100
YutaTogashi 2:40528aee5ebe 101 NVIC_SetPriority(C_CAN0_IRQn,0);
YutaTogashi 2:40528aee5ebe 102 NVIC_SetPriority(QEI_IRQn,1);
YutaTogashi 0:4fe08f484460 103
YutaTogashi 0:4fe08f484460 104 can.frequency(communication_baud::CAN);
YutaTogashi 2:40528aee5ebe 105 can.attach(&canReceiveHandler,CAN::RxIrq);
YutaTogashi 2:40528aee5ebe 106
YutaTogashi 2:40528aee5ebe 107 wait_ms(1000);
YutaTogashi 0:4fe08f484460 108
YutaTogashi 0:4fe08f484460 109 motor.setupFrequency(motor_option::FREQUENCY);
YutaTogashi 0:4fe08f484460 110 motor.setupLimitDuty(motor_option::LOWER_LIMIT,motor_option::UPPER_LIMIT);
YutaTogashi 2:40528aee5ebe 111
YutaTogashi 0:4fe08f484460 112 pid.setup(parameter[KP],parameter[KI],parameter[KD],SPEED_PID,period::CONTROL_CYCLE);
YutaTogashi 0:4fe08f484460 113
YutaTogashi 0:4fe08f484460 114 errorTimer.start();
YutaTogashi 0:4fe08f484460 115 pc.printf("Initalize MotorDriver!\r\n\r\n");
YutaTogashi 0:4fe08f484460 116 controlCycle.attach(&mainLoop,period::CONTROL_CYCLE);
YutaTogashi 0:4fe08f484460 117 }
YutaTogashi 0:4fe08f484460 118
YutaTogashi 2:40528aee5ebe 119 void mainLoop() {
YutaTogashi 0:4fe08f484460 120 if(outputMode) {
YutaTogashi 0:4fe08f484460 121 pid.setup(parameter[KP],parameter[KI],parameter[KD],SPEED_PID,period::CONTROL_CYCLE);
YutaTogashi 0:4fe08f484460 122 pid.calculate(targetRpm,encoder.getRPM());
YutaTogashi 0:4fe08f484460 123 outputDuty = pid.getDuty();
YutaTogashi 0:4fe08f484460 124 }
YutaTogashi 3:097710997f6b 125 /*
YutaTogashi 0:4fe08f484460 126 if(errorTimer.read() > TIMEOUT_VALUE) {
YutaTogashi 0:4fe08f484460 127 led.output(0.5f);
YutaTogashi 0:4fe08f484460 128 outputDuty = 0.0f;
YutaTogashi 0:4fe08f484460 129 } else {
YutaTogashi 0:4fe08f484460 130 led.output(outputMode);
YutaTogashi 0:4fe08f484460 131 }
YutaTogashi 0:4fe08f484460 132
YutaTogashi 2:40528aee5ebe 133 outputIndicator(outputDuty);
YutaTogashi 0:4fe08f484460 134 motor.output(outputDuty);
YutaTogashi 3:097710997f6b 135 */
YutaTogashi 3:097710997f6b 136 if(errorTimer.read() > TIMEOUT_VALUE) enable_motor_output = false;
YutaTogashi 3:097710997f6b 137 else enable_motor_output = true;
YutaTogashi 3:097710997f6b 138
YutaTogashi 3:097710997f6b 139 if(enable_motor_output) {
YutaTogashi 3:097710997f6b 140 led.output(outputMode);
YutaTogashi 3:097710997f6b 141 outputIndicator(outputDuty);
YutaTogashi 3:097710997f6b 142 motor.output(outputDuty);
YutaTogashi 3:097710997f6b 143 } else {
YutaTogashi 3:097710997f6b 144 led.output(0.5f);
YutaTogashi 3:097710997f6b 145 safetyControl(0.05f);
YutaTogashi 3:097710997f6b 146 pid.reset();
YutaTogashi 3:097710997f6b 147 outputIndicator(outputDuty);
YutaTogashi 3:097710997f6b 148 motor.output(outputDuty);
YutaTogashi 3:097710997f6b 149 }
YutaTogashi 0:4fe08f484460 150 debag();
YutaTogashi 2:40528aee5ebe 151
YutaTogashi 0:4fe08f484460 152 }
YutaTogashi 0:4fe08f484460 153
YutaTogashi 0:4fe08f484460 154 void debag() {
YutaTogashi 0:4fe08f484460 155 if(!(printfMode)) {
YutaTogashi 0:4fe08f484460 156 pc.printf("SWITCH:%d\t",idSwitch.read());
YutaTogashi 0:4fe08f484460 157 pc.printf("DUTY:%.2f\t",outputDuty);
YutaTogashi 0:4fe08f484460 158 pc.printf("RPM:%.2f\t",encoder.getRPM());
YutaTogashi 0:4fe08f484460 159
YutaTogashi 0:4fe08f484460 160 if(outputMode) {
YutaTogashi 0:4fe08f484460 161 pc.printf("TARGET:%.1f\t",targetRpm);
YutaTogashi 0:4fe08f484460 162 pc.printf("Kp:%f\t",parameter[KP]);
YutaTogashi 0:4fe08f484460 163 pc.printf("Ki:%f\t",parameter[KI]);
YutaTogashi 0:4fe08f484460 164 pc.printf("Kd:%f\t",parameter[KD]);
YutaTogashi 0:4fe08f484460 165 }
YutaTogashi 0:4fe08f484460 166 pc.printf("TIME:%f",errorTimer.read());
YutaTogashi 0:4fe08f484460 167 pc.printf("\r\n");
YutaTogashi 0:4fe08f484460 168 } else {
YutaTogashi 2:40528aee5ebe 169 pc.printf("%f",targetRpm);
YutaTogashi 2:40528aee5ebe 170 pc.printf("%f,",encoder.getRPM());
YutaTogashi 0:4fe08f484460 171 pc.printf(",%f",outputDuty);
YutaTogashi 0:4fe08f484460 172 pc.printf("\r\n");
YutaTogashi 0:4fe08f484460 173 }
YutaTogashi 0:4fe08f484460 174 }
YutaTogashi 0:4fe08f484460 175
YutaTogashi 2:40528aee5ebe 176 void outputIndicator(float duty) {
YutaTogashi 2:40528aee5ebe 177 if(fabs(duty) > 0.0f) {
YutaTogashi 2:40528aee5ebe 178 if(duty > 0.0f) {
YutaTogashi 2:40528aee5ebe 179 pwmLed[CW].write(fabs(duty));
YutaTogashi 0:4fe08f484460 180 pwmLed[CCW].write(0.0f);
YutaTogashi 0:4fe08f484460 181 } else {
YutaTogashi 0:4fe08f484460 182 pwmLed[CW].write(0.0f);
YutaTogashi 2:40528aee5ebe 183 pwmLed[CCW].write(fabs(duty));
YutaTogashi 0:4fe08f484460 184 }
YutaTogashi 0:4fe08f484460 185 } else {
YutaTogashi 0:4fe08f484460 186 pwmLed[CW].write(0.0f);
YutaTogashi 0:4fe08f484460 187 pwmLed[CCW].write(0.0f);
YutaTogashi 0:4fe08f484460 188 }
YutaTogashi 0:4fe08f484460 189 }
YutaTogashi 0:4fe08f484460 190
YutaTogashi 3:097710997f6b 191 void safetyControl(float control_duty) {
YutaTogashi 3:097710997f6b 192 if(fabs(outputDuty - 0.0f) > 0.20f) {
YutaTogashi 3:097710997f6b 193 if(outputDuty > 0.0f) outputDuty -= control_duty;
YutaTogashi 3:097710997f6b 194 else outputDuty += control_duty;
YutaTogashi 3:097710997f6b 195 } else {
YutaTogashi 3:097710997f6b 196 outputDuty = 0.0f;
YutaTogashi 3:097710997f6b 197 }
YutaTogashi 3:097710997f6b 198 }
YutaTogashi 3:097710997f6b 199
YutaTogashi 0:4fe08f484460 200 void canReceiveHandler() {
YutaTogashi 0:4fe08f484460 201 can_flame message,returnMessage;
YutaTogashi 0:4fe08f484460 202 CANMessage sendMsg,receiveMessage;
YutaTogashi 0:4fe08f484460 203
YutaTogashi 0:4fe08f484460 204 can.read(receiveMessage);
YutaTogashi 0:4fe08f484460 205
YutaTogashi 0:4fe08f484460 206 sendMsg.id = MAIN_MCU;
YutaTogashi 0:4fe08f484460 207
YutaTogashi 0:4fe08f484460 208 if((MD_0_MCU + idSwitch.read()) == receiveMessage.id) {
YutaTogashi 0:4fe08f484460 209 errorTimer.reset();
YutaTogashi 0:4fe08f484460 210 switch ((int)receiveMessage.data[0]) {
YutaTogashi 0:4fe08f484460 211 case md_can_flame::SEND_KP:
YutaTogashi 0:4fe08f484460 212 for(int i=2;i<6;i++) message.c[i-2] = receiveMessage.data[i];
YutaTogashi 0:4fe08f484460 213 __disable_irq();
YutaTogashi 0:4fe08f484460 214 write_eeprom(message.c,(char*)0,4);
YutaTogashi 0:4fe08f484460 215 __enable_irq();
YutaTogashi 0:4fe08f484460 216 parameter[KP] = message.f;
YutaTogashi 0:4fe08f484460 217 receiveParameterStatus[0] = true;
YutaTogashi 0:4fe08f484460 218 break;
YutaTogashi 0:4fe08f484460 219 case md_can_flame::SEND_KI:
YutaTogashi 0:4fe08f484460 220 for(int i=2;i<6;i++) message.c[i-2] = receiveMessage.data[i];
YutaTogashi 0:4fe08f484460 221 __disable_irq();
YutaTogashi 0:4fe08f484460 222 write_eeprom(message.c,(char*)4,4);
YutaTogashi 0:4fe08f484460 223 __enable_irq();
YutaTogashi 0:4fe08f484460 224 parameter[KI] = message.f;
YutaTogashi 0:4fe08f484460 225 receiveParameterStatus[1] = true;
YutaTogashi 0:4fe08f484460 226 break;
YutaTogashi 0:4fe08f484460 227 case md_can_flame::SEND_KD:
YutaTogashi 0:4fe08f484460 228 for(int i=2;i<6;i++) message.c[i-2] = receiveMessage.data[i];
YutaTogashi 0:4fe08f484460 229 __disable_irq();
YutaTogashi 0:4fe08f484460 230 write_eeprom(message.c,(char*)8,4);
YutaTogashi 0:4fe08f484460 231 __enable_irq();
YutaTogashi 0:4fe08f484460 232 parameter[KD] = message.f;
YutaTogashi 0:4fe08f484460 233 receiveParameterStatus[2] = true;
YutaTogashi 0:4fe08f484460 234 break;
YutaTogashi 0:4fe08f484460 235 case md_can_flame::SEND_ACCELERATION:
YutaTogashi 0:4fe08f484460 236 for(int i=2;i<6;i++) message.c[i-2] = receiveMessage.data[i];
YutaTogashi 0:4fe08f484460 237 parameter[ACCELERATION] = message.f;
YutaTogashi 0:4fe08f484460 238 receiveParameterStatus[3] = true;
YutaTogashi 0:4fe08f484460 239 break;
YutaTogashi 0:4fe08f484460 240 case md_can_flame::SEND_CONTROL_DUTY:
YutaTogashi 0:4fe08f484460 241 for(int i=2;i<6;i++) message.c[i-2] = receiveMessage.data[i];
YutaTogashi 0:4fe08f484460 242 outputDuty = message.f;
YutaTogashi 0:4fe08f484460 243 outputMode = false;
YutaTogashi 0:4fe08f484460 244 break;
YutaTogashi 0:4fe08f484460 245 case md_can_flame::SEND_CONTROL_RPM:
YutaTogashi 0:4fe08f484460 246 if(bitRead((int)receiveMessage.data[1],0)) {
YutaTogashi 0:4fe08f484460 247 for(int i=2;i<6;i++) message.c[i-2] = receiveMessage.data[i];
YutaTogashi 0:4fe08f484460 248 targetRpm = message.f;
YutaTogashi 0:4fe08f484460 249 outputMode = true;
YutaTogashi 0:4fe08f484460 250 } else {
YutaTogashi 0:4fe08f484460 251 targetRpm = 0.0f;
YutaTogashi 0:4fe08f484460 252 outputDuty = 0.0f;
YutaTogashi 0:4fe08f484460 253 pid.reset();
YutaTogashi 0:4fe08f484460 254 outputMode = false;
YutaTogashi 0:4fe08f484460 255 }
YutaTogashi 0:4fe08f484460 256 break;
YutaTogashi 0:4fe08f484460 257 case md_can_flame::REQUEST_RECEIVE_CURRENT:
YutaTogashi 0:4fe08f484460 258 //no code
YutaTogashi 0:4fe08f484460 259 break;
YutaTogashi 0:4fe08f484460 260 case md_can_flame::REQUEST_RECEIVE_ERROR:
YutaTogashi 0:4fe08f484460 261 int parameterStatus = 0;
YutaTogashi 0:4fe08f484460 262 for(int i=0;i<4;i++) bitWrite(&parameterStatus,i,receiveParameterStatus[i]);
YutaTogashi 0:4fe08f484460 263 sendMsg.data[0] = md_can_flame::REQUEST_RECEIVE_ERROR;
YutaTogashi 0:4fe08f484460 264 sendMsg.data[2] = parameterStatus;
YutaTogashi 0:4fe08f484460 265 can.write(sendMsg);
YutaTogashi 0:4fe08f484460 266 break;
YutaTogashi 0:4fe08f484460 267 case md_can_flame::REQUEST_RECEIVE_POSITION:
YutaTogashi 0:4fe08f484460 268 returnMessage.i = encoder.getPosition();
YutaTogashi 0:4fe08f484460 269 sendMsg.data[0] = md_can_flame::REQUEST_RECEIVE_POSITION;
YutaTogashi 0:4fe08f484460 270 for(int i=0;i<4;i++) sendMsg.data[i+2] = returnMessage.c[i];
YutaTogashi 0:4fe08f484460 271 can.write(sendMsg);
YutaTogashi 0:4fe08f484460 272 break;
YutaTogashi 0:4fe08f484460 273 case md_can_flame::REQUEST_RECEIVE_ROTATION:
YutaTogashi 0:4fe08f484460 274 returnMessage.f = static_cast<float>(encoder.getRotation());
YutaTogashi 0:4fe08f484460 275 sendMsg.data[0] = md_can_flame::REQUEST_RECEIVE_ROTATION;
YutaTogashi 0:4fe08f484460 276 for(int i=0;i<4;i++) sendMsg.data[i+2] = returnMessage.c[i];
YutaTogashi 0:4fe08f484460 277 can.write(sendMsg);
YutaTogashi 0:4fe08f484460 278 break;
YutaTogashi 0:4fe08f484460 279 case md_can_flame::REQUEST_RECEIVE_RPS:
YutaTogashi 0:4fe08f484460 280 returnMessage.f = encoder.getRPS();
YutaTogashi 0:4fe08f484460 281 sendMsg.data[0] = md_can_flame::REQUEST_RECEIVE_RPS;
YutaTogashi 0:4fe08f484460 282 for(int i=0;i<4;i++) sendMsg.data[i+2] = returnMessage.c[i];
YutaTogashi 0:4fe08f484460 283 can.write(sendMsg);
YutaTogashi 0:4fe08f484460 284 break;
YutaTogashi 0:4fe08f484460 285 case md_can_flame::REQUEST_RECEIVE_RPM:
YutaTogashi 0:4fe08f484460 286 returnMessage.f = encoder.getRPM();
YutaTogashi 0:4fe08f484460 287 sendMsg.data[0] = md_can_flame::REQUEST_RECEIVE_RPM;
YutaTogashi 0:4fe08f484460 288 for(int i=0;i<4;i++) sendMsg.data[i+2] = returnMessage.c[i];
YutaTogashi 0:4fe08f484460 289 can.write(sendMsg);
YutaTogashi 0:4fe08f484460 290 break;
YutaTogashi 0:4fe08f484460 291 case md_can_flame::REQUEST_PRINTF_DEBAG:
YutaTogashi 0:4fe08f484460 292 printfMode = false;
YutaTogashi 0:4fe08f484460 293 break;
YutaTogashi 0:4fe08f484460 294 case md_can_flame::REQUEST_PRINTF_FORMAT_CSV:
YutaTogashi 0:4fe08f484460 295 printfMode = true;
YutaTogashi 0:4fe08f484460 296 break;
YutaTogashi 0:4fe08f484460 297 case md_can_flame::REQUEST_RESET_QEI:
YutaTogashi 0:4fe08f484460 298 encoder.reset();
YutaTogashi 0:4fe08f484460 299 break;
YutaTogashi 0:4fe08f484460 300 case md_can_flame::REQUEST_RESET_MCU:
YutaTogashi 0:4fe08f484460 301 NVIC_SystemReset();
YutaTogashi 0:4fe08f484460 302 break;
YutaTogashi 0:4fe08f484460 303 default:
YutaTogashi 0:4fe08f484460 304 break;
YutaTogashi 0:4fe08f484460 305 }
YutaTogashi 0:4fe08f484460 306 } else if(ALL_MCU == receiveMessage.id) {
YutaTogashi 3:097710997f6b 307 //NVIC_SystemReset();
YutaTogashi 0:4fe08f484460 308 } else {
YutaTogashi 0:4fe08f484460 309
YutaTogashi 0:4fe08f484460 310 }
YutaTogashi 0:4fe08f484460 311 }