diff --git a/ion/src/device/bench/Makefile b/ion/src/device/bench/Makefile index dd9ff604a..9d3a22d2f 100644 --- a/ion/src/device/bench/Makefile +++ b/ion/src/device/bench/Makefile @@ -21,7 +21,6 @@ ion_device_bench_src += $(addprefix ion/src/device/bench/command/, \ lcd_timing.o \ led.cpp \ mcu_serial.cpp \ - pcb_version.cpp \ ping.cpp \ print.cpp \ screen_id.cpp \ @@ -30,4 +29,5 @@ ion_device_bench_src += $(addprefix ion/src/device/bench/command/, \ standby.cpp \ usb_plugged.cpp \ vblank.cpp \ + write_pcb_version.cpp \ ) diff --git a/ion/src/device/bench/bench.cpp b/ion/src/device/bench/bench.cpp index e7dd9c326..f732a3116 100644 --- a/ion/src/device/bench/bench.cpp +++ b/ion/src/device/bench/bench.cpp @@ -23,7 +23,6 @@ constexpr CommandHandler handles[] = { CommandHandler("LCD_TIMING", Command::LCDTiming), CommandHandler("LED", Command::LED), CommandHandler("MCU_SERIAL", Command::MCUSerial), - CommandHandler("PCB_VERSION", Command::PCBVersion), CommandHandler("PING", Command::Ping), CommandHandler("PRINT", Command::Print), CommandHandler("SCREEN_ID", Command::ScreenID), @@ -32,6 +31,7 @@ constexpr CommandHandler handles[] = { CommandHandler("STANDBY", Command::Standby), CommandHandler("USB_PLUGGED", Command::USBPlugged), CommandHandler("VBLANK", Command::VBlank), + CommandHandler("WRITE_PCB_VERSION", Command::WritePCBVersion), CommandHandler(nullptr, nullptr) }; diff --git a/ion/src/device/bench/command/command.h b/ion/src/device/bench/command/command.h index 70d895f8b..3067fe824 100644 --- a/ion/src/device/bench/command/command.h +++ b/ion/src/device/bench/command/command.h @@ -24,7 +24,7 @@ void LCDPins(const char * input); void LCDTiming(const char * input); void LED(const char * input); void MCUSerial(const char * input); -void PCBVersion(const char * input); +void WritePCBVersion(const char * input); void Ping(const char * input); void Print(const char * input); void ScreenID(const char * input); diff --git a/ion/src/device/bench/command/pcb_version.cpp b/ion/src/device/bench/command/write_pcb_version.cpp similarity index 84% rename from ion/src/device/bench/command/pcb_version.cpp rename to ion/src/device/bench/command/write_pcb_version.cpp index 99f1e29f0..e8399e001 100644 --- a/ion/src/device/bench/command/pcb_version.cpp +++ b/ion/src/device/bench/command/write_pcb_version.cpp @@ -6,7 +6,7 @@ namespace Device { namespace Bench { namespace Command { -void PCBVersion(const char * input) { +void WritePCBVersion(const char * input) { if (input != nullptr) { reply(sSyntaxError); return; @@ -18,12 +18,12 @@ void PCBVersion(const char * input) { #if IN_FACTORY Board::writePCBVersion(PCB_LATEST); /* Read directly from memory, as when IN_FACTORY is true, the method - * readPCBVersion always returns PCB_LATEST. */ + * pcbVersion always returns PCB_LATEST. */ if (Board::readPCBVersionInMemory() != PCB_LATEST) { reply(sKO); return; } - Board::lockVersionOTP(); + Board::lockPCBVersion(); #endif reply(sOK); } diff --git a/ion/src/device/n0100/drivers/board.cpp b/ion/src/device/n0100/drivers/board.cpp index bd1345a4d..5dfe99e0d 100644 --- a/ion/src/device/n0100/drivers/board.cpp +++ b/ion/src/device/n0100/drivers/board.cpp @@ -230,7 +230,7 @@ void shutdownClocks(bool keepLEDAwake) { RCC.AHB1ENR()->set(ahb1enr); } -PCBVersion readPCBVersion() { +PCBVersion pcbVersion() { return PCB_LATEST; } @@ -240,7 +240,7 @@ PCBVersion readPCBVersionInMemory() { void writePCBVersion(PCBVersion) {} -void lockVersionOTP() {} +void lockPCBVersion() {} } } diff --git a/ion/src/device/n0110/drivers/board.cpp b/ion/src/device/n0110/drivers/board.cpp index f4ab39c23..f2a1db2a2 100644 --- a/ion/src/device/n0110/drivers/board.cpp +++ b/ion/src/device/n0110/drivers/board.cpp @@ -378,7 +378,7 @@ constexpr int pcbVersionOTPIndex = 0; * because the OTP are initialized with 1s, we store the bitwise-not of the * version number. This way, devices with blank OTP are considered version 0. */ -PCBVersion readPCBVersion() { +PCBVersion pcbVersion() { #if IN_FACTORY /* When flashing for the first time, we want all systems that depend on the * PCB version to function correctly before flashing the PCB version. This @@ -399,9 +399,9 @@ void writePCBVersion(PCBVersion version) { InternalFlash::WriteMemory(destination, reinterpret_cast(&formattedVersion), sizeof(formattedVersion)); } -void lockVersionOTP() { +void lockPCBVersion() { uint8_t * destination = reinterpret_cast(InternalFlash::Config::OTPLocksAddress + pcbVersionOTPIndex); - uint8_t zero = 0x00; + uint8_t zero = 0; InternalFlash::WriteMemory(destination, &zero, sizeof(zero)); } diff --git a/ion/src/device/n0110/drivers/usb.cpp b/ion/src/device/n0110/drivers/usb.cpp index 86ac0a6a2..d56cee475 100644 --- a/ion/src/device/n0110/drivers/usb.cpp +++ b/ion/src/device/n0110/drivers/usb.cpp @@ -10,7 +10,7 @@ using namespace Regs; namespace USB { bool useAlternateFunctionVbus() { - return Board::readPCBVersion() == 0; + return Board::pcbVersion() == 0; } void initVbus() { diff --git a/ion/src/device/shared/drivers/board.h b/ion/src/device/shared/drivers/board.h index 68dcaa2be..a94d8cd4f 100644 --- a/ion/src/device/shared/drivers/board.h +++ b/ion/src/device/shared/drivers/board.h @@ -27,10 +27,10 @@ void setClockFrequency(Frequency f); typedef uint32_t PCBVersion; -PCBVersion readPCBVersion(); +PCBVersion pcbVersion(); PCBVersion readPCBVersionInMemory(); void writePCBVersion(PCBVersion version); -void lockVersionOTP(); +void lockPCBVersion(); } }