| author | libdlo <libdlo@displaylink.com> | 2009-06-14 01:37:56 (GMT) |
|---|---|---|
| committer | libdlo <libdlo@displaylink.com> | 2009-06-14 01:37:56 (GMT) |
| commit | d6322da0b2277bb5fa1615832529ead179aa51cf (patch) (side-by-side diff) | |
| tree | 0a78d2e2118e6d6a9df7dcdaaaf8dd4c2e2ad5cb | |
| parent | fa04eed0f8d6f86ba4569396ebd7d0eec6def4d2 (diff) | |
| download | libdlo-d6322da0b2277bb5fa1615832529ead179aa51cf.zip libdlo-d6322da0b2277bb5fa1615832529ead179aa51cf.tar.gz | |
Clean up lsfr16 to not use static local var, etc.
| -rw-r--r-- | src/dlo_mode.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/dlo_mode.c b/src/dlo_mode.c index c0eb1be..b341557 100644 --- a/src/dlo_mode.c +++ b/src/dlo_mode.c @@ -566,19 +566,14 @@ static dlo_modenum_t get_mode_number(dlo_device_t * const dev, const uint16_t wi * (which is why it doesn't apply to all registers). It's actually * for convenience on the hardware side, as the registers are used as counters */ -static uint32_t lfsr16(uint32_t v) +static uint16_t lfsr16(uint16_t v) { - static uint32_t prev = 0; - static uint32_t _v = 0xFFFF; + uint32_t _v = 0xFFFF; - if (v != prev) - { - _v = 0xFFFF; - while (v--) - _v = ((_v << 1) | (((_v >> 15) ^ (_v >> 4) ^ (_v >> 2) ^ (_v >> 1)) & 1)) & 0xFFFF; - prev = v; + while (v--) { + _v = ((_v << 1) | (((_v >> 15) ^ (_v >> 4) ^ (_v >> 2) ^ (_v >> 1)) & 1)) & 0xFFFF; } - return _v; + return (uint16_t) _v; } inline dlo_retcode_t vreg_big_endian(dlo_device_t * const dev, uint8_t reg, uint16_t val){ |
