diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2017-06-04 19:25:41 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2017-06-04 19:25:41 +0200 |
commit | e758988579c3bf058214bf6e4ae56cf27b52bcfb (patch) | |
tree | ab6cfb2cb6d7287ce1fd52cab4879b943d08f387 /include | |
parent | 094c977b8877d652f629260cc753aacc7000e328 (diff) | |
download | radio-controller-e758988579c3bf058214bf6e4ae56cf27b52bcfb.tar.gz radio-controller-e758988579c3bf058214bf6e4ae56cf27b52bcfb.tar.bz2 radio-controller-e758988579c3bf058214bf6e4ae56cf27b52bcfb.tar.xz radio-controller-e758988579c3bf058214bf6e4ae56cf27b52bcfb.zip |
o Decoding manufacturer and command too.
Diffstat (limited to 'include')
-rw-r--r-- | include/decoder.h | 13 |
1 files changed, 13 insertions, 0 deletions
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 <cstdint> +#include <mcu/init.h> 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) { |