From 36655f1c19bfeb9a3786fd5561d9c1e1d27203aa Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Wed, 24 Mar 2021 10:42:26 +0100 Subject: [PATCH] [ion/device/n0110] Change getter for OTPAddress --- ion/src/device/n0110/drivers/board.cpp | 4 ++-- ion/src/device/n0110/drivers/config/internal_flash.h | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ion/src/device/n0110/drivers/board.cpp b/ion/src/device/n0110/drivers/board.cpp index bcb354d02..f4ab39c23 100644 --- a/ion/src/device/n0110/drivers/board.cpp +++ b/ion/src/device/n0110/drivers/board.cpp @@ -390,11 +390,11 @@ PCBVersion readPCBVersion() { } PCBVersion readPCBVersionInMemory() { - return ~*reinterpret_cast(InternalFlash::Config::OTPAddresses[pcbVersionOTPIndex]); + return ~*reinterpret_cast(InternalFlash::Config::OTPAddress(pcbVersionOTPIndex)); } void writePCBVersion(PCBVersion version) { - uint8_t * destination = reinterpret_cast(InternalFlash::Config::OTPAddresses[pcbVersionOTPIndex]); + uint8_t * destination = reinterpret_cast(InternalFlash::Config::OTPAddress(pcbVersionOTPIndex)); PCBVersion formattedVersion = ~version; InternalFlash::WriteMemory(destination, reinterpret_cast(&formattedVersion), sizeof(formattedVersion)); } diff --git a/ion/src/device/n0110/drivers/config/internal_flash.h b/ion/src/device/n0110/drivers/config/internal_flash.h index d8efa2b65..9a1c7a84a 100644 --- a/ion/src/device/n0110/drivers/config/internal_flash.h +++ b/ion/src/device/n0110/drivers/config/internal_flash.h @@ -19,12 +19,8 @@ constexpr static uint32_t SectorAddresses[NumberOfSectors+1] = { constexpr static uint32_t OTPStartAddress = 0x1FF07800; constexpr static uint32_t OTPLocksAddress = 0x1FF07A00; constexpr static int NumberOfOTPBlocks = 16; -constexpr static uint32_t OTPAddresses[NumberOfOTPBlocks] = { - 0x1FF07800, 0x1FF07820, 0x1FF07840, 0x1FF07860, - 0x1FF07880, 0x1FF078A0, 0x1FF078C0, 0x1FF078E0, - 0x1FF07900, 0x1FF07920, 0x1FF07940, 0x1FF07960, - 0x1FF07980, 0x1FF079A0, 0x1FF079C0, 0x1FF079E0, -}; +constexpr static uint32_t OTPBlockSize = 0x20; +constexpr uint32_t OTPAddress(int block) { return OTPStartAddress + block * OTPBlockSize; }; } }