summaryrefslogtreecommitdiff
path: root/src/cortexelf-v1/ao_flip_bits.5c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-04-02 20:33:49 -0700
committerKeith Packard <keithp@keithp.com>2017-04-02 20:33:49 -0700
commit5bb9cf38c84663713c178f54b684d40b6c00b11d (patch)
tree84b904b14d38a04dc8d6a372c4c082ac2314ddc5 /src/cortexelf-v1/ao_flip_bits.5c
parent8c1478b55f5dbe9711b31a34d4f5e3563f1f42d2 (diff)
cortexelf-v1: Add bit flipping array generator
Someone hooked up the data lines between the systems backwards, so we get to swizzle the bits in software. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/cortexelf-v1/ao_flip_bits.5c')
-rw-r--r--src/cortexelf-v1/ao_flip_bits.5c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cortexelf-v1/ao_flip_bits.5c b/src/cortexelf-v1/ao_flip_bits.5c
new file mode 100644
index 00000000..26900893
--- /dev/null
+++ b/src/cortexelf-v1/ao_flip_bits.5c
@@ -0,0 +1,19 @@
+#!/usr/bin/nickle
+
+int flip_bits(int a)
+{
+ int result = 0;
+ for (int pos = 0; pos < 8; pos++)
+ if ((a & (1 << pos)) != 0)
+ result |= (1 << (7 - pos));
+ return result;
+}
+
+printf ("static uint8_t ao_flip_bits[256] = {\n");
+
+for (int i = 0; i < 256; i++) {
+ printf (" 0x%02x,", flip_bits(i));
+ if ((i & 0xf) == 0xf)
+ printf("\n");
+}
+printf("};\n");