Implement OTP dumping

This commit is contained in:
BlackMark 2022-06-02 21:38:32 +02:00
parent fbc40cbab9
commit 061b789319
4 changed files with 37 additions and 2 deletions

@ -1 +1 @@
Subproject commit 7a0f00ceab04f291596d0c1064e64833b4f7a280 Subproject commit 91b49cd536ea8542908bdfb68a6cb7164128df52

View File

@ -224,6 +224,9 @@
<Compile Include="eink\eink.hpp"> <Compile Include="eink\eink.hpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="eink\otp.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="flash\flash.hpp"> <Compile Include="flash\flash.hpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>

@ -1 +1 @@
Subproject commit 6edb2e5a21e0ce58ff2df936caee8b84e240a46b Subproject commit f9014aea6cbbb1ea76f30148a64e6c3fc3152dcd

View File

@ -1,5 +1,7 @@
#include "clock.hpp" #include "clock.hpp"
#include <type_traits>
#include "eink/eink.hpp" #include "eink/eink.hpp"
#include "flash/flash.hpp" #include "flash/flash.hpp"
#include "io/io.hpp" #include "io/io.hpp"
@ -13,6 +15,33 @@ REGISTER_UART0_INT_VECTORS(uart_t);
using spi_t = eink::Spi<io::P::C4, io::P::C5, io::P::C3, io::P::C2>; using spi_t = eink::Spi<io::P::C4, io::P::C5, io::P::C3, io::P::C2>;
using eink_t = eink::Eink<200, 200, spi_t, io::P::C1, io::P::C0>; using eink_t = eink::Eink<200, 200, spi_t, io::P::C1, io::P::C0>;
void dumpOTP(eink_t &einkDisplay, uart_t &serial)
{
constexpr auto printWidth = 16;
auto printedCnt = std::size_t{0};
einkDisplay.dumpOTP([&serial, &printedCnt](const auto &data) {
constexpr auto printAddress = true;
if (printedCnt > 0 && printedCnt % printWidth == 0) {
serial << F("\r\n");
}
if (printAddress && printedCnt % printWidth == 0) {
serial << F("0x");
serial.txNumber<std::size_t, 16, 4>(printedCnt);
serial << F(": ");
}
serial << F("0x");
serial.txNumber<std::remove_cvref_t<decltype(data)>, 16, 2>(data);
serial << F(", ");
++printedCnt;
});
serial << F("\r\n");
}
int main() int main()
{ {
uart_t serial; uart_t serial;
@ -33,6 +62,9 @@ int main()
serial << F("e-Paper draw") << F("\r\n"); serial << F("e-Paper draw") << F("\r\n");
einkDisplay.draw(RLE_IMAGE); einkDisplay.draw(RLE_IMAGE);
serial << F("e-Paper dump OTP") << F("\r\n");
dumpOTP(einkDisplay, serial);
serial << F("e-Paper sleep") << F("\r\n"); serial << F("e-Paper sleep") << F("\r\n");
einkDisplay.sleep(); einkDisplay.sleep();