ISF15ACP4 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts | Enumerations
isf15acp4_spi_interface.hpp File Reference

The write-only SPI port of the ISF15ACP4 driver: the CRTP base, its pin enums, the SpiPort concept and the bus requirements. More...

#include <array>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <span>
#include "isf15acp4_detail.hpp"
#include "isf15acp4_registers.hpp"
#include "isf15acp4_types.hpp"

Go to the source code of this file.

Classes

class  isf15acp4::SpiInterface< Derived >
 CRTP base of the platform SPI port. More...
 

Namespaces

namespace  isf15acp4
 The ISF15ACP4 driver: everything it declares lives here; internals in detail.
 

Concepts

concept  isf15acp4::SpiPort
 Satisfied by a class that derives from SpiInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool: EnsureInitialized(), Write() and GpioSet() (RES# and the VCC enable).
 

Enumerations

enum class  isf15acp4::CtrlPin : uint8_t { isf15acp4::Reset = 0 , isf15acp4::VccEnable }
 The pins the port drives through GpioSet(). More...
 
enum class  isf15acp4::GpioSignal : uint8_t { isf15acp4::INACTIVE = 0 , isf15acp4::ACTIVE = 1 }
 Logical level of a control pin; the port maps it to the physical polarity. More...
 
enum class  isf15acp4::DataKind : uint8_t { isf15acp4::Command = 0 , isf15acp4::Data = 1 }
 What a transfer carries: it sets the D/C# pin (section 7.2). More...
 

Variables

Bus requirements

What the controller needs from the SPI bus (SSD1331 section 7.1.3, Table 21; NKK sheet E7). A port and a board configuration check their settings against these with static_assert (handbook KB-CPP-123).

constexpr uint8_t isf15acp4::kSpiMode = 0
 
constexpr bool isf15acp4::kMsbFirst = true
 Each byte is clocked most significant bit first, D7 first (section 7.1.3).
 
constexpr uint32_t isf15acp4::kMaxClockHz = 6'600'000
 Highest SCK frequency: tcycle 150 ns minimum (Table 21), 6.66 MHz.
 
constexpr uint32_t isf15acp4::kMinCsHighNs = 150
 
constexpr uint32_t isf15acp4::kCsSetupNs = 75
 CS# low to the first SCK edge, tCSS (Table 21).
 
constexpr uint32_t isf15acp4::kCsHoldNs = 60
 Last SCK edge to CS# high, tCSH (Table 21).
 
constexpr bool isf15acp4::kContinuousWord = false
 
constexpr uint32_t isf15acp4::kDcSetupNs = 40
 D/C# valid before the clock edge that starts a byte, tAS (Table 21).
 
constexpr uint32_t isf15acp4::kDcHoldNs = 40
 D/C# held after the byte, tAH (Table 21).
 
constexpr bool isf15acp4::kWriteOnly = true
 There is no MISO: nothing can be read back.
 

Detailed Description

The write-only SPI port of the ISF15ACP4 driver: the CRTP base, its pin enums, the SpiPort concept and the bus requirements.

The driver never calls an SDK. It calls hooks on a class you derive from isf15acp4::SpiInterface<Self>:

Hook Contract
bool EnsureInitialized() noexcept Bring the SPI bus and every pin up at its idle level on the first call (VCC enable off, RES# high, CS# high); true at once afterwards
bool Write(DataKind kind, const uint8_t* data, std::size_t len) noexcept One write-only transfer of len >= 1 bytes: set D/C# for kind (Command low, Data high), CS# low, clock every byte out, CS# high
bool GpioSet(CtrlPin pin, GpioSignal signal) noexcept Drive RES# or the VCC enable; false when the pin could not be driven
void DelayUs(uint32_t us) noexcept Wait at least us microseconds

Optional hooks, described in isf15acp4.hpp: bool ReadSwitch(bool& high) noexcept (the switch pin's physical level), uint32_t NowMs() noexcept (a free-running millisecond counter) and void Log(LogLevel, const char*) noexcept.

The bus is write only: serial mode has no read (SSD1331 section 8.1) and the module has no MISO pin (NKK sheet E6). Write() returning true means the bytes were clocked out, never that the controller received them. What the controller needs from the bus is below as constexpr values (kSpiMode to kContinuousWord, SSD1331 section 7.1.3 and Table 21, NKK sheet E7); a port checks its settings against them with static_assert.

Pins and their idle levels (handbook KB-HW-018): before it enables an output the port drives it to its idle level, and before the first transfer. The VCC enable idles OFF (GpioSignal::INACTIVE: the 15 V OLED supply is off): this is the safety pin, and the driver also drives it off before it resets the controller. RES# idles high (INACTIVE: not in reset). CS# idles high. D/C# is set by Write() for every transfer. SCK idles low in mode 0.