|
FDO2 Driver 0.1.0
API reference
|
The UART port of the FDO2 driver: the CRTP base, its pin enums, the UartPort concept and the line requirements.
More...
#include <concepts>#include <cstddef>#include <cstdint>#include "fdo2_detail.hpp"#include "fdo2_protocol.hpp"#include "fdo2_types.hpp"Go to the source code of this file.
Classes | |
| class | fdo2::UartInterface< Derived > |
| CRTP base of the platform UART port. More... | |
Namespaces | |
| namespace | fdo2 |
The FDO2 driver: everything it declares lives here; internals in detail. | |
Concepts | |
| concept | fdo2::UartPort |
Satisfied by a class that derives from UartInterface<Port> and implements the required hooks with exactly the types above and noexcept. | |
Enumerations | |
| enum class | fdo2::CtrlPin : uint8_t { fdo2::Power = 0 } |
Control pins the port may drive through the optional GpioSet() hook. More... | |
| enum class | fdo2::GpioSignal : uint8_t { fdo2::INACTIVE = 0 , fdo2::ACTIVE = 1 } |
| Logical level of a control pin; the port maps it to the physical polarity. More... | |
Variables | |
Bus requirements | |
What the FDO2 needs from the UART and its supply (datasheet sections 2 and 4). A port and a board configuration check their settings against these with | |
| constexpr uint32_t | fdo2::kPortDefaultBaud = 19'200 |
| Rate after every power-up (datasheet 4). | |
| constexpr uint32_t | fdo2::kLogicLevelMv = 3000 |
| Logic level of the module's UART, millivolts (datasheet 2, Interface). | |
| constexpr uint32_t | fdo2::kMaxLogicLevelMv = 3300 |
| Absolute maximum on the module's UART pins, millivolts: a 5 V host needs a level shifter. | |
| constexpr uint32_t | fdo2::kSupplyMinMv = 3300 |
| Lowest supply the datasheet allows, millivolts (below it the readings can be wrong). | |
| constexpr uint32_t | fdo2::kSupplyMaxMv = 5000 |
| Highest supply, millivolts (absolute maximum 5.5 V). | |
| constexpr uint32_t | fdo2::kPowerUpMs = 1000 |
| Time from power to the first answer, milliseconds ("ca. 1 sec", datasheet 4). | |
| constexpr uint32_t | fdo2::kRxBufferBytes = 800 |
Receive buffer a port needs to never lose a #RDUM reply, bytes (or it polls every 300 ms). | |
| constexpr uint32_t | fdo2::kMaxBaudRate = 115'200 |
Highest baud rate the module accepts (datasheet 4.3, #BAUD). | |
| constexpr uint32_t | fdo2::kTurnaroundUs = 2000 |
The UART port of the FDO2 driver: the CRTP base, its pin enums, the UartPort concept and the line requirements.
The driver never calls an SDK. It calls hooks on a class you derive from fdo2::UartInterface<Self>:
bool EnsureInitialized() noexcept (required): UART up at Config::baud (19200 after every power-up), 8N1, no flow control; true at once afterwards.bool Write(const uint8_t* data, std::size_t len) noexcept (required): send all len bytes (may block until queued); false on an error. One command line per call.std::size_t Read(uint8_t* data, std::size_t max, uint32_t timeout_ms) noexcept (required): return the bytes already received, 0 to max, waiting at most timeout_ms for the first byte; 0 must not block; never more than max.bool FlushInput() noexcept (required): drop every received byte not yet returned by Read().void DelayUs(uint32_t us) noexcept (for the blocking calls): wait at least us; a compile error at the first blocking call otherwise.uint32_t NowUs() noexcept (optional): free-running monotonic microsecond counter, wrap-safe; with it Poll() measures its own time, without it Poll(elapsed_us) exists.bool SetBaudRate(uint32_t baud) noexcept (optional): reconfigure the UART; without it SetBaudRate() returns Unsupported.bool GpioSet(CtrlPin, GpioSignal) noexcept (optional): CtrlPin::Power: ACTIVE powers the module (an external load switch).void Log(LogLevel, const char*) noexcept (optional): plain text, never a format.19200 baud, 8 data bits, no parity, 1 stop bit, no handshake after every power-up (datasheet section 4). The port moves raw bytes; the driver builds, frames, checks and times everything. Read() is not an all-or-nothing read: the reply length is unknown, so it returns the count received. A port whose SDK returns only a status polls its FIFO level first.