summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/decoder.h13
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) {