FastLED 3.9.15
Loading...
Searching...
No Matches

◆ div1024_32_16()

LIB8STATIC u16 fl::div1024_32_16 ( u32 in32)

Helper routine to divide a 32-bit value by 1024, returning only the low 16 bits.

On AVR, uses optimized assembly (6 shifts vs 40). Used to convert millis to "binary seconds" (1 bsecond == 1024 millis).

Definition at line 45 of file time_functions.h.

45 {
46 u16 out16;
47#if defined(FL_IS_AVR)
48 asm volatile(" lsr %D[in] \n\t"
49 " ror %C[in] \n\t"
50 " ror %B[in] \n\t"
51 " lsr %D[in] \n\t"
52 " ror %C[in] \n\t"
53 " ror %B[in] \n\t"
54 " mov %B[out],%C[in] \n\t"
55 " mov %A[out],%B[in] \n\t"
56 : [in] "+r"(in32), [out] "=r"(out16));
57#else
58 out16 = (in32 >> 10) & 0xFFFF;
59#endif
60 return out16;
61}

References FL_NOEXCEPT, and LIB8STATIC.

Referenced by bseconds16().

+ Here is the caller graph for this function: