Moved format into msc
This commit is contained in:
parent
47342ea053
commit
4bb7270d81
19
USBNova.ino
19
USBNova.ino
|
@ -9,7 +9,6 @@
|
|||
#include "src/attack/attack.h"
|
||||
#include "src/preferences/preferences.h"
|
||||
#include "src/duckparser/duckparser.h"
|
||||
#include "src/format/format.h"
|
||||
#include "src/tasks/tasks.h"
|
||||
|
||||
void setup() {
|
||||
|
@ -18,16 +17,12 @@ void setup() {
|
|||
selector::init();
|
||||
// Initialize memory and ceck for problems
|
||||
if (!msc::init()) {
|
||||
format::start(); // Format the drive
|
||||
|
||||
// If it still fails, blink red LED
|
||||
if (!msc::init()) {
|
||||
while (true) {
|
||||
led::setColor(255, 0, 0);
|
||||
delay(500);
|
||||
led::setColor(0, 0, 0);
|
||||
delay(500);
|
||||
}
|
||||
// Blink red and do nothing
|
||||
while (true) {
|
||||
led::setColor(255, 0, 0);
|
||||
delay(500);
|
||||
led::setColor(0, 0, 0);
|
||||
delay(500);
|
||||
}
|
||||
}
|
||||
preferences::load();
|
||||
|
@ -52,7 +47,7 @@ void setup() {
|
|||
// Format Flash
|
||||
if ((selector::mode() == SETUP) && preferences::getFormat()) {
|
||||
led::setColor(255, 255, 255);
|
||||
format::start(preferences::getDriveName().c_str());
|
||||
msc::format(preferences::getDriveName().c_str());
|
||||
}
|
||||
|
||||
// Create preferences file if it doesn't exist yet
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace format {
|
||||
bool start(const char* drive_name = "USB Nova");
|
||||
}
|
|
@ -8,9 +8,11 @@
|
|||
#include <string>
|
||||
#include <stack>
|
||||
|
||||
#include "SPI.h"
|
||||
#include "Adafruit_SPIFlash.h"
|
||||
#include "Adafruit_TinyUSB.h"
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_SPIFlash.h>
|
||||
#include <Adafruit_TinyUSB.h>
|
||||
|
||||
#include "format.h"
|
||||
|
||||
namespace msc {
|
||||
// ===== PRIVATE ===== //
|
||||
|
@ -72,13 +74,22 @@ namespace msc {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Try formatting the drive if initialization failed
|
||||
if(!fatfs.begin(&flash)) {
|
||||
debugln("Couldn't mount flash!");
|
||||
return false;
|
||||
format();
|
||||
|
||||
if(!fatfs.begin(&flash)) {
|
||||
debugln("Couldn't mount flash!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool format(const char* drive_name) {
|
||||
return format::start(drive_name);
|
||||
}
|
||||
|
||||
void setID(const char* vid, const char* pid, const char* rev) {
|
||||
usb_msc.setID(vid, pid, rev); // Max. 8, 16, 4 characters
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace msc {
|
||||
bool init();
|
||||
bool format(const char* drive_name = "USB Nova");
|
||||
|
||||
void setID(const char* vid, const char* pid, const char* rev);
|
||||
void enableDrive();
|
||||
|
|
Loading…
Reference in New Issue