From a87ddfd43ed21ce3227b41624066d2b4ea468e7e Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 2 Mar 2008 11:26:02 +0100 Subject: * digital/avr/modules/spi, digital/avr/modules/flash: - master should drive SS. - to receive, master should send something. - testing SPIF before the first sent does not work. - fixed flash test. --- digital/avr/modules/flash/test/Makefile | 7 +------ digital/avr/modules/flash/test/test-flash.c | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) (limited to 'digital/avr/modules/flash/test') diff --git a/digital/avr/modules/flash/test/Makefile b/digital/avr/modules/flash/test/Makefile index 9fcc8790..ff34bc7f 100644 --- a/digital/avr/modules/flash/test/Makefile +++ b/digital/avr/modules/flash/test/Makefile @@ -1,5 +1,5 @@ BASE = ../../.. -PROGS = test_flash +AVR_PROGS = test_flash test_flash_SOURCES = test-flash.c MODULES = utils spi flash proto uart CONFIGFILE = avrconfig.h @@ -9,9 +9,4 @@ AVR_MCU = atmega128 # -Os : size OPTIMIZE = -O2 -# Test compilations. -#TEST_MCU = atmega8 atmega8535 atmega128 -#TEST_CONFIGFILES = avrconfig_ring.h avrconfig_polling.h avrconfig_twoports.h -#avrconfig_twoports_TEST_MCU = atmega128 - include $(BASE)/make/Makefile.gen diff --git a/digital/avr/modules/flash/test/test-flash.c b/digital/avr/modules/flash/test/test-flash.c index e90db20f..08417f64 100644 --- a/digital/avr/modules/flash/test/test-flash.c +++ b/digital/avr/modules/flash/test/test-flash.c @@ -26,19 +26,37 @@ #include "io.h" #include "../flash.h" #include "modules/proto/proto.h" +#include "modules/utils/utils.h" +#include "modules/uart/uart.h" void proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) { - //TODO Still don't know what to to +#define c(cmd, size) (cmd << 8 | size) + switch (c (cmd, size)) + { + case c ('z', 0): + /* Reset */ + utils_reset (); + break; + default: + /* Error */ + proto_send0 ('?'); + return; + } + /* Acknowledge what has been done */ + proto_send (cmd, size, args); } int main (void) { + uart0_init (); proto_send0 ('z'); + proto_send0 ('c'); flash_init (); - - while (1); + proto_send0 ('f'); + while (1) + proto_accept (uart0_getc ()); } -- cgit v1.2.3