MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / processFlasherCommand

Function processFlasherCommand

ESP32_AP-Flasher/src/usbflasher.cpp:341–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339CC_interface *ccflasherp = nullptr;
340
341void processFlasherCommand(struct flasherCommand* cmd, uint8_t transportType) {
342 uint8_t* tempbuffer;
343 uint8_t temp_buff[16];
344 uint32_t spi_speed = 0;
345 uint8_t powerPinCount = 1;
346 static uint32_t curspeed = 0;
347 uint8_t numPowerPins;
348
349#ifdef HAS_RGB_LED
350 shortBlink(CRGB::White);
351#else
352 quickBlink(2);
353#endif
354
355 switch (cmd->command) {
356 case CMD_GET_VERSION:
357 wsSerial("> get version");
358 temp_buff[0] = FLASHER_VERSION >> 24;
359 temp_buff[1] = FLASHER_VERSION >> 16;
360 temp_buff[2] = FLASHER_VERSION >> 8;
361 temp_buff[3] = FLASHER_VERSION;
362 sendFlasherAnswer(cmd->command, temp_buff, 4, transportType);
363 break;
364 case CMD_RESET_ESP:
365 wsSerial("reset");
366 sendFlasherAnswer(cmd->command, NULL, 0, transportType);
367 delay(100);
368 ESP.restart();
369 break;
370 case CMD_SET_POWER:
371 wsSerial("> power");
372 switch (selectedFlasherPort) {
373 case 0:
374 numPowerPins = sizeof(powerPins);
375 powerControl(cmd->data[0], (uint8_t*)powerPins, numPowerPins);
376 break;
377 case 1:
378 numPowerPins = sizeof(powerPins2);
379 powerControl(cmd->data[0], (uint8_t*)powerPins2, numPowerPins);
380 break;
381 case 2:
382 numPowerPins = sizeof(powerPins3);
383 powerControl(cmd->data[0], (uint8_t*)powerPins3, numPowerPins);
384 break;
385 }
386 sendFlasherAnswer(CMD_SET_POWER, NULL, 0, transportType);
387 break;
388 case CMD_RESET:
389 wsSerial("> reset tag");
390 if (zbsflasherp != nullptr) {
391 zbsflasherp->zbs->reset();
392 delete zbsflasherp;
393 zbsflasherp = nullptr;
394 }
395 if (nrfflasherp != nullptr) {
396 nrfflasherp->nrf_soft_reset();
397 delete nrfflasherp;
398 nrfflasherp = nullptr;

Callers 2

flasherDataHandlerFunction · 0.70
usbFlasherTaskFunction · 0.70

Calls 15

wsSerialFunction · 0.85
printfMethod · 0.80
printlnMethod · 0.80
shortBlinkFunction · 0.70
quickBlinkFunction · 0.70
sendFlasherAnswerFunction · 0.70
powerControlFunction · 0.70
autoFlashFunction · 0.70
delayFunction · 0.50
resetMethod · 0.45
nrf_soft_resetMethod · 0.45
erase_flashMethod · 0.45

Tested by

no test coverage detected