--- /dev/null
+#include <stdint.h>
+#include <string.h>
+
+extern uint8_t *initrd_start;
+extern uint32_t initrd_size;
+
+char *getfile(uint32_t offset)
+{
+ char *ptr = initrd_start;
+ for (uint32_t i = 0; i < offset; i++) {
+ uint32_t len = *((uint32_t *)ptr);
+ uint32_t datalen = *((uint32_t *)(ptr + 4 + len));
+ ptr += len + datalen + 8;
+ if (ptr >= (char *)(initrd_start + initrd_size))
+ return 0;
+ }
+
+ return ptr;
+}
+
+char *readfile(const char *name)
+{
+ char *ptr;
+ for (uint32_t i = 0; ptr = getfile(i), ptr != 0; i++) {
+ uint32_t len = *((uint32_t *)ptr);
+ if (!strncmp(name, ptr + 4, len))
+ return ptr + len + 8;
+ }
+ return 0;
+}
+
+uint32_t filesize(const char *name)
+{
+ char *ptr;
+ for (uint32_t i = 0; ptr = getfile(i), ptr != 0; i++) {
+ uint32_t len = *((uint32_t *)ptr);
+ if (!strncmp(name, ptr + 4, len))
+ return *((uint32_t *)ptr + len + 4);
+ }
+ return 0;
+}
+
#include <gpio.h>
#include <task.h>
-#define ROW_0 GPIO_PORT(A, 12)
-#define ROW_1 GPIO_PORT(B, 12)
-#define ROW_2 GPIO_PORT(B, 11)
-#define ROW_3 GPIO_PORT(C, 4)
-#define COL_0 GPIO_PORT(B, 13)
-#define COL_1 GPIO_PORT(B, 14)
-#define COL_2 GPIO_PORT(B, 15)
-#define COL_3 GPIO_PORT(B, 1)
-#define COL_4 GPIO_PORT(B, 2)
+#define ROW_0 GPIO_PORT(B, 2)
+#define ROW_1 GPIO_PORT(B, 1)
+#define ROW_2 GPIO_PORT(B, 15)
+#define ROW_3 GPIO_PORT(B, 14)
+#define ROW_4 GPIO_PORT(B, 13)
+#define ROW_5 GPIO_PORT(C, 4)
+#define COL_0 GPIO_PORT(B, 11)
+#define COL_1 GPIO_PORT(B, 12)
+#define COL_2 GPIO_PORT(A, 11)
+#define COL_3 GPIO_PORT(A, 12)
+#define COL_4 GPIO_PORT(C, 5)
-#define ROWS 4
+#define ROWS 6
#define COLS 5
typedef struct {
} port_t;
static const port_t keypad_rows[ROWS] = {
- { ROW_0 }, { ROW_1 }, { ROW_2 }, { ROW_3 }
+ { ROW_0 }, { ROW_1 }, { ROW_2 },
+ { ROW_3 }, { ROW_4 }, { ROW_5 }
};
static const port_t keypad_cols[COLS] = {
- { COL_0 }, { COL_1 }, { COL_2 }, { COL_3 }, { COL_4 }
+ { COL_0 }, { COL_1 }, { COL_2 },
+ { COL_3 }, { COL_4 }
};
static const int keypad_map[ROWS][COLS] = {
- { '7', '8', '9', 'x', '/' },
- { '4', '5', '6', 'y', '*' },
- { '1', '2', '3', '=', '-' },
+ { '&', '|', '^', ' ', ' ' },
+ { 'x', 'y', 'z', '=', ' ' },
+ { '7', '8', '9', '(', ')' },
+ { '4', '5', '6', '/', '%' },
+ { '1', '2', '3', '*', '-' },
{ '.', '0', '\b', '\n', '+' }
};