#include "spisim.h" #include "system.h" SpiSim::SpiSim() noexcept : nss(GPIOA,4), sck(GPIOA,5), mosi(GPIOA,7) { delay_init(); nss << true; sck << false; mosi << false; } void SpiSim::outbyte(const uint8_t b) const { nss << false; for (unsigned n=0u; n<8; n++) { const bool bit = (b & (1u << n)) ? true : false; mosi << bit; delay_us (2); sck << true; delay_us (4); sck << false; delay_us (2); } nss << true; }