From c6547c6e6fa381a7811d0c47603291d82be7e440 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 11 Jan 2019 22:02:14 +0900 Subject: Basic command comm works --- driver_fw/Makefile | 2 +- driver_fw/main.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'driver_fw') diff --git a/driver_fw/Makefile b/driver_fw/Makefile index 2d74acd..5ad3b23 100644 --- a/driver_fw/Makefile +++ b/driver_fw/Makefile @@ -9,7 +9,7 @@ OBJCOPY := arm-none-eabi-objcopy OBJDUMP := arm-none-eabi-objdump SIZE := arm-none-eabi-size -CFLAGS = -g -Wall -std=gnu11 -O1 -fdump-rtl-expand -Wno-discarded-qualifiers +CFLAGS = -g -Wall -std=gnu11 -O0 -fdump-rtl-expand -Wno-discarded-qualifiers CFLAGS += -mlittle-endian -mcpu=cortex-m3 -mthumb #CFLAGS += -ffunction-sections -fdata-sections LDFLAGS = -nostartfiles diff --git a/driver_fw/main.c b/driver_fw/main.c index 838ca9d..df2eaa7 100644 --- a/driver_fw/main.c +++ b/driver_fw/main.c @@ -79,12 +79,24 @@ int main(void) { NVIC_EnableIRQ(TIM1_UP_IRQn); NVIC_SetPriority(TIM1_UP_IRQn, 3<<4); - uint8_t txbuf[128]; + +unsigned char x, a, b, c; +unsigned char random() { + x++; //x is incremented every round and is not affected by any other variable + a = (a ^ c ^ x); //note the mix of addition and XOR + b = (b + a); //And the use of very few instructions + c = ((c + (b >> 1) ^ a)); // the AES S-Box Operation ensures an even distributon of entropy + return (c); +} + + + uint8_t txbuf[3] = {0x01, 0x05, 0x01}; int txpos = -1; /* FIXME test code */ - for (int i=0; i= sizeof(txbuf)/sizeof(txbuf[0])) + if (txpos >= sizeof(txbuf)/sizeof(txbuf[0])) { txpos = -1; + + i++; + if (i == 2) { + //txbuf[2] = random(); + //txbuf[2] <<= 1; + //if (!txbuf[2] & 0xff) + // txbuf[2] = 0x01; + i = 0; + } + } } } } -- cgit