sensors::led::WS2812B
WS2812B Finiteframes using a dedicated timer's CC-triggered circular DMA. RGB N is the strip length; BufferLen is the TOTAL waveform capacity in LED units, not the strip length and not the capacity of one half. Only theframe is stored per LED. Each DMA half is refilled in its consumed-half interrupt. The application must service interrupts and finish each refill before DMA returns to that half (24 * BufferLen / 2 bit periods). Exclusively owned timer, up-counting edge-aligned PWM1, active-high output, CCR preload enabled, initial Pulse=0, no repetition/slave/one-pulse mode or CC control preload; update events must remain enabled. The bit rate MUST be 800 kbit/s. ARR therefore counts one 1.25 us bit; zero/one high times are derived from ARR as 24%/52% of the period, i.e. about 300 ns / 650 ns per bit. No timing argument is accepted. Linked CC DMA: circular, memory-to-peripheral, incrementing halfword memory, fixed halfword peripheral; CC DMA requests, not update DMA requests. The application configures the timer clock, PSC/ARR, GPIO AF, DMA request, DMA IRQ/HAL_DMA_IRQHandler, and any advanced-timer break/output settings. PWM mode, polarity, preload, GPIO pulls and idle/off-state levels must all be configured in CubeMX. The driver never reconfigures them. The stopped output must remain LOW; GPIO/advanced-timer idle settings are board-owned. It must ensure the actual pin is driven and the actual timing meets the LED datasheet. Ticks alone do not identify the timer's counter frequency. Validation uses HAL getters and Init metadata, not direct register reads. Settings without HAL getters are application preconditions; bypassing HAL or changing configuration externally is not detected by this driver. Hardware contract, checked by show where possible: Buffer is memory::DMABuffer<48 * BufferLen>, a 32-byte aligned byte array. It must reside in DMA-accessible SRAM (NOT the H7 default DTCM .bss). Place it using the project's linker/section scheme. The buffer must be noncacheable or hardware-coherent: this driver does not clean D-Cache. A barrier alone does not provide cache coherency. No cache policy is changed. One task owns all normal API calls. Only the three explicitly forwarded HAL callbacks run in ISR context. No callbacks are installed globally. Forward: HAL_TIM_PWM_PulseFinishedHalfCpltCallback -> onHalfTransfer; HAL_TIM_PWM_PulseFinishedCallback -> onTransferComplete; HAL_TIM_ErrorCallback -> onError. Buffer stop() Buffer Construction never touches HAL/peripherals and never sends an initial frame. Driver andmust outlive, asynchronous DMA abort completion (!isBusy()), and any forwarded callback. Detach forwarding before destroying the driver. The destructor deliberately does not invoke uninitialized HAL. Never access the borrowedwhile owned by this driver. Do not change timer/DMA configuration during its lifetime. Between frames PWM and DMA are stopped. The project's fixed GPIO/timer configuration must hold DIN LOW.
构造与析构
3WS2812B
sensors::led::WS2812B< N, BufferLen >::WS2812B (TIM_HandleTypeDef *htim, std::uint32_t channel, Buffer &buffer) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:103WS2812B
sensors::led::WS2812B< N, BufferLen >::WS2812B (WS2812B &&)=delete
上游未提供说明。
led/ws2812/WS2812B.hpp:110WS2812B
sensors::led::WS2812B< N, BufferLen >::WS2812B (const WS2812B &)=delete
上游未提供说明。
led/ws2812/WS2812B.hpp:108成员函数
24alignFrameStart
bool sensors::led::WS2812B< N, BufferLen >::alignFrameStart () noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:321channelIndex
unsigned sensors::led::WS2812B< N, BufferLen >::channelIndex () const noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:252clear
bool sensors::led::WS2812B< N, BufferLen >::clear () noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:129consumed
void sensors::led::WS2812B< N, BufferLen >::consumed (TIM_HandleTypeDef *htim, unsigned half) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:419dmaReady
bool sensors::led::WS2812B< N, BufferLen >::dmaReady () const noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:274dmaRequest
std::uint32_t sensors::led::WS2812B< N, BufferLen >::dmaRequest () const noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:279fill
bool sensors::led::WS2812B< N, BufferLen >::fill (Color color) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:121fillHalf
void sensors::led::WS2812B< N, BufferLen >::fillHalf (unsigned half) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:361getState
State sensors::led::WS2812B< N, BufferLen >::getState () const noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:131highTicks
static constexpr std::uint32_t sensors::led::WS2812B< N, BufferLen >::highTicks (std::uint32_t period, std::uint32_t percent) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:285isBusy
bool sensors::led::WS2812B< N, BufferLen >::isBusy () const noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:139loadPixel
void sensors::led::WS2812B< N, BufferLen >::loadPixel () noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:353onError
void sensors::led::WS2812B< N, BufferLen >::onError (TIM_HandleTypeDef *htim) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:234onHalfTransfer
void sensors::led::WS2812B< N, BufferLen >::onHalfTransfer (TIM_HandleTypeDef *htim) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:231onTransferComplete
void sensors::led::WS2812B< N, BufferLen >::onTransferComplete (TIM_HandleTypeDef *htim) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:232operator=
WS2812B & sensors::led::WS2812B< N, BufferLen >::operator= (WS2812B &&)=delete
上游未提供说明。
led/ws2812/WS2812B.hpp:111operator=
WS2812B & sensors::led::WS2812B< N, BufferLen >::operator= (const WS2812B &)=delete
上游未提供说明。
led/ws2812/WS2812B.hpp:109selectedDma
DMA_HandleTypeDef * sensors::led::WS2812B< N, BufferLen >::selectedDma () const noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:257setPixel
bool sensors::led::WS2812B< N, BufferLen >::setPixel (std::size_t index, Color color) noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:113show
HAL_StatusTypeDef sensors::led::WS2812B< N, BufferLen >::show () noexcept
HAL_BUSY also covers an asynchronous abort still awaiting its DMA IRQ. stop() Errors remain visible until an explicitclears them after abort.
led/ws2812/WS2812B.hpp:149stop
HAL_StatusTypeDef sensors::led::WS2812B< N, BufferLen >::stop () noexcept
Request a safe stop, or explicitly clear a latched error. HAL_BUSY means abort is pending: retain this object/Buffer and service the DMA IRQ before reuse/destruction. Does nothing to an unused timer. A mid-frame stop leaves the last CCR value; the next frame may begin with one invalid bit. Normal frame completion ends on all-zero padding.
led/ws2812/WS2812B.hpp:211stopPwmDma
bool sensors::led::WS2812B< N, BufferLen >::stopPwmDma () noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:344txBarrier
static void sensors::led::WS2812B< N, BufferLen >::txBarrier () noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:333validConfiguration
bool sensors::led::WS2812B< N, BufferLen >::validConfiguration () noexcept
上游未提供说明。
led/ws2812/WS2812B.hpp:291成员变量
19HalfSampleBytes
std::size_t sensors::led::WS2812B< N, BufferLen >::HalfSampleBytes
上游未提供说明。
led/ws2812/WS2812B.hpp:84HalfSampleCount
std::size_t sensors::led::WS2812B< N, BufferLen >::HalfSampleCount
上游未提供说明。
led/ws2812/WS2812B.hpp:82ResetPeriods
std::uint32_t sensors::led::WS2812B< N, BufferLen >::ResetPeriods
上游未提供说明。
led/ws2812/WS2812B.hpp:90SampleBytes
std::size_t sensors::led::WS2812B< N, BufferLen >::SampleBytes
上游未提供说明。
led/ws2812/WS2812B.hpp:83SampleCount
std::size_t sensors::led::WS2812B< N, BufferLen >::SampleCount
上游未提供说明。
led/ws2812/WS2812B.hpp:81bitMask_
std::uint32_t sensors::led::WS2812B< N, BufferLen >::bitMask_
上游未提供说明。
led/ws2812/WS2812B.hpp:448buffer_
Buffer& sensors::led::WS2812B< N, BufferLen >::buffer_
上游未提供说明。
led/ws2812/WS2812B.hpp:438channel_
const std::uint32_t sensors::led::WS2812B< N, BufferLen >::channel_
上游未提供说明。
led/ws2812/WS2812B.hpp:437dma_
DMA_HandleTypeDef* sensors::led::WS2812B< N, BufferLen >::dma_
上游未提供说明。
led/ws2812/WS2812B.hpp:443htim_
TIM_HandleTypeDef* const sensors::led::WS2812B< N, BufferLen >::htim_
上游未提供说明。
led/ws2812/WS2812B.hpp:436oneHighTicks_
std::uint16_t sensors::led::WS2812B< N, BufferLen >::oneHighTicks_
上游未提供说明。
led/ws2812/WS2812B.hpp:440paddingHalf_
bool sensors::led::WS2812B< N, BufferLen >::paddingHalf_[2] [2]
上游未提供说明。
led/ws2812/WS2812B.hpp:449phase_
Phase sensors::led::WS2812B< N, BufferLen >::phase_
上游未提供说明。
led/ws2812/WS2812B.hpp:444pixelIndex_
std::size_t sensors::led::WS2812B< N, BufferLen >::pixelIndex_
上游未提供说明。
led/ws2812/WS2812B.hpp:446pixelWord_
std::uint32_t sensors::led::WS2812B< N, BufferLen >::pixelWord_
上游未提供说明。
led/ws2812/WS2812B.hpp:447pixels_
std::array<Color, N> sensors::led::WS2812B< N, BufferLen >::pixels_
上游未提供说明。
led/ws2812/WS2812B.hpp:441resetRemaining_
std::size_t sensors::led::WS2812B< N, BufferLen >::resetRemaining_
上游未提供说明。
led/ws2812/WS2812B.hpp:445state_
std::atomic<State> sensors::led::WS2812B< N, BufferLen >::state_
上游未提供说明。
led/ws2812/WS2812B.hpp:442zeroHighTicks_
std::uint16_t sensors::led::WS2812B< N, BufferLen >::zeroHighTicks_
上游未提供说明。
led/ws2812/WS2812B.hpp:439嵌套类型
6Buffer
using sensors::led::WS2812B< N, BufferLen >::Buffer = memory::DMABuffer<SampleBytes>
上游未提供说明。
led/ws2812/WS2812B.hpp:86CacheClean
using sensors::led::WS2812B< N, BufferLen >::CacheClean = void (*)(const void*, std::size_t)
上游未提供说明。
led/ws2812/WS2812B.hpp:92上游未提供说明。
led/ws2812/WS2812B.hpp:75Phase
上游未提供说明。
LeadingReset- 上游未提供说明。
Padding- 上游未提供说明。
Pixels- 上游未提供说明。
TrailingReset- 上游未提供说明。
RGB
using sensors::led::WS2812B< N, BufferLen >::RGB = Color
上游未提供说明。
led/ws2812/WS2812B.hpp:79State
上游未提供说明。
Error- 上游未提供说明。
Idle- 上游未提供说明。
Sending- 上游未提供说明。
Stopping- 上游未提供说明。