From 50233fff403da32473aa499ad45ab4770471966a Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 29 Mar 2018 21:26:53 -0400 Subject: [PATCH] new initrd format work, bigger keypad --- Makefile | 2 +- boot | 3 +++ include/script.h | 2 +- initrd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ initrd/calc | 8 -------- initrd/init | 11 ++++++++--- rba | Bin 0 -> 14664 bytes src/keypad.c | 36 +++++++++++++++++++++--------------- src/main.c | 2 +- src/script.c | 5 ++--- 10 files changed, 79 insertions(+), 32 deletions(-) create mode 100644 boot create mode 100644 initrd.c delete mode 100644 initrd/calc create mode 100755 rba diff --git a/Makefile b/Makefile index 0b9e19a..9620aa4 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ STRIP = strip MCUFLAGS = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 AFLAGS = $(MCUFLAGS) CFLAGS = $(MCUFLAGS) -ggdb \ - -Iinclude -Iinclude/it -Iinclude/cmsis \ + -Iinclude -Iinclude/cmsis \ -fno-builtin -fsigned-char -ffreestanding \ -Wall -Werror -Wextra -pedantic \ -Wno-overlength-strings -Wno-discarded-qualifiers diff --git a/boot b/boot new file mode 100644 index 0000000..13e5876 --- /dev/null +++ b/boot @@ -0,0 +1,3 @@ +choice = filemenu +print("\nChoice: ") +print(choice) diff --git a/include/script.h b/include/script.h index 971cccf..bddb872 100644 --- a/include/script.h +++ b/include/script.h @@ -21,7 +21,7 @@ #ifndef SCRIPT_H_ #define SCRIPT_H_ -#include +#include /** * Loads the library for the given interpreter instance. diff --git a/initrd.c b/initrd.c new file mode 100644 index 0000000..3f36cd9 --- /dev/null +++ b/initrd.c @@ -0,0 +1,42 @@ +#include +#include + +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; +} + diff --git a/initrd/calc b/initrd/calc deleted file mode 100644 index 7359f16..0000000 --- a/initrd/calc +++ /dev/null @@ -1,8 +0,0 @@ -while (1) { - print("> ") - input = gets() - answer = solve(input) - print("\n") - print(answer) - print("\n") -} diff --git a/initrd/init b/initrd/init index 13e5876..7359f16 100644 --- a/initrd/init +++ b/initrd/init @@ -1,3 +1,8 @@ -choice = filemenu -print("\nChoice: ") -print(choice) +while (1) { + print("> ") + input = gets() + answer = solve(input) + print("\n") + print(answer) + print("\n") +} diff --git a/rba b/rba new file mode 100755 index 0000000000000000000000000000000000000000..52f37cb59cac5d5e55e8bb84700b1e522d162270 GIT binary patch literal 14664 zcmeHOe{@t;et(l>LVz$cx}Z@|o;YA45N1Mx34-P)ywO2Z5-i6G&tYbgj80~$( zNoD})k*{U*7z--1N|th?^(4fK%)ZGzf`;ZZ7F1>xL0#N`LB;rJZ1nlIMd-D@rG-dO zkxk898sY{86@B~>^s=sVne!3R-}z+D*R~)US+}TqK{PZ!8j1Dx&F`ySG=EWbWinoA zNtE*$_=Yyhk8*s(yh*!UcU~mj%CHLHbMg7*d!hEkQ^ku{9C~5oM>Bf%IX)jfJZ)!b z6PogtzkuP3$7wyD2X94Qj3@sv92*Z`j|mwM-+(@6jnnTtz{ZpRQ679#9zPG{k$)-= zeq|p2zl(ex&!3}t?C5#MyEBh`Qy%+s^Y}9_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bd=L#KB1RzI)~FmoG#<^ zHcmS@UC-$jP9Ng*QBL=AI?SmEium1%;PIQI#d3LbcwHnAldr49&yVJNt18TzBvmH6 z@Nh*7tdlAuG5ij+N2=_M^;UKTl3h||Xk#q7vD>70+QVAb;}=blcxpV)5kIc1M76RrjtYKkiEsQgGyUmk)XRs z8HM~O8^V9WsQB=qHlZ)}LqWxUDEb%rV*G7fzY&y**k1(|j*~v^!MXZtfKg1u^*~&Y z1Qq)>L|Ea|Az1bd&8k1d_bWl!Grp|!x!=pt^D!zxe60E-d>;^0_{)UxC3r#U8K6~P zoSOt)DK2c>faq7)OXTQ_>#v~VIwa(C$KS{G#r)Ot>$jlveAQZn-vaALg+zqDB7;E@ zG-R^b@7(^kqs6MfM>a(T^$5e*%bM%kSG6e;_mFo$TGaTvXXrN2D$WL)zDVt|% za>+}B%8ptQnzxe&2hwJaiaX8oBze1OCU+9bLviQF< zk-sADLSKxlGpB#?JIj#;Xh89pB>OG&1wDcmtN#)|PYFeOUTiHwPtgC$(J%ALOuWo% zYKeWq #include -#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 { @@ -42,17 +44,21 @@ 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', '+' } }; diff --git a/src/main.c b/src/main.c index c9d3789..d21407a 100644 --- a/src/main.c +++ b/src/main.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/script.c b/src/script.c index 518edc5..049608b 100644 --- a/src/script.c +++ b/src/script.c @@ -20,7 +20,7 @@ #include -#include +#include #include #include #include @@ -29,10 +29,9 @@ #include #include #include +#include #include -#include - #define igetarg_integer(it, n) ((int)igetarg(it, n)->value.f) int script_puts(instance *it);