MCPcopy Create free account
hub / github.com/FastLED/FastLED / dmaChannelEdgeCount

Function dmaChannelEdgeCount

src/platforms/arm/lpc/rx_sct_capture.cpp.hpp:288–299  ·  view source on GitHub ↗

Compute how many DMA transfers (= captured edges) have landed in the channel's ring. The CHANNEL.XFERCFG register exposes the live residual count and the CFGVALID flag (UM11029 §16.6 Table 321): While the channel is armed, residual = (N-1) - K where K = writes done On natural completion (K == N), CFGVALID drops to 0 and residual = 0

Source from the content-addressed store, hash-verified

286// * While the channel is armed, residual = (N-1) - K where K = writes done
287// * On natural completion (K == N), CFGVALID drops to 0 and residual = 0
288inline fl::u32 dmaChannelEdgeCount(fl::u32 ch) FL_NOEXCEPT {
289 const fl::u32 cfgnow = dma(kDmaChXferCfg(ch));
290 const fl::u32 residual = (cfgnow >> 16) & 0x3FFu;
291 const bool completed = (cfgnow & kXferCfgValid) == 0;
292 if (completed) {
293 return static_cast<fl::u32>(kDmaRingSize);
294 }
295 if (residual >= kDmaRingSize) {
296 return 0;
297 }
298 return static_cast<fl::u32>(kDmaRingSize) - 1u - residual;
299}
300#endif // FASTLED_LPC_RX_SCT_DMA
301
302} // namespace

Callers 1

waitMethod · 0.85

Calls 1

kDmaChXferCfgFunction · 0.85

Tested by

no test coverage detected