From e758988579c3bf058214bf6e4ae56cf27b52bcfb Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 4 Jun 2017 19:25:41 +0200 Subject: o Decoding manufacturer and command too. --- include/decoder.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/decoder.h b/include/decoder.h index 56ea647..9aee34d 100644 --- a/include/decoder.h +++ b/include/decoder.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace radio_controller { @@ -33,6 +34,18 @@ public: return size_; } + __attribute__((noinline)) + uint32_t extract_bits(int start, int count) + { + if (start + count > 32) { + halt(); + } + + uint32_t value = a_ >> start; + auto mask = uint32_t((1 << count + 1) - 1); + return value & mask; + } + uint32_t u32(int i) { switch (i) { -- cgit v1.2.3