summaryrefslogtreecommitdiff
path: root/digital/avr/modules/flash
diff options
context:
space:
mode:
authorNicolas Schodet2008-03-02 11:26:02 +0100
committerNicolas Schodet2008-03-02 11:26:02 +0100
commita87ddfd43ed21ce3227b41624066d2b4ea468e7e (patch)
treeecacfaa3b54ecf8417dc6b0c2609331df2c67bab /digital/avr/modules/flash
parenta276fe77c7289d4955b947250a778cf780287147 (diff)
* 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.
Diffstat (limited to 'digital/avr/modules/flash')
-rw-r--r--digital/avr/modules/flash/flash.c9
-rw-r--r--digital/avr/modules/flash/test/Makefile7
-rw-r--r--digital/avr/modules/flash/test/test-flash.c24
3 files changed, 27 insertions, 13 deletions
diff --git a/digital/avr/modules/flash/flash.c b/digital/avr/modules/flash/flash.c
index e964728b..990fac26 100644
--- a/digital/avr/modules/flash/flash.c
+++ b/digital/avr/modules/flash/flash.c
@@ -68,13 +68,13 @@ flash_init (void)
uint8_t rsp[3];
flash_global.addr = 0x0;
- /* send the read-ID instruction. */
AC_FLASH_PORT |= _BV(AC_FLASH_BIT_SS);
AC_FLASH_DDR |= _BV(AC_FLASH_BIT_SS);
- spi_init (SPI_IT_DISABLE | SPI_ENABLE | SPI_MASTER | SPI_MSB_FIRST |
- SPI_CPOL_FALLING | SPI_CPHA_SETUP | SPI_FOSC_DIV16);
-
+ /* send the read-ID instruction. */
+ spi_init (SPI_IT_DISABLE | SPI_ENABLE | SPI_MASTER | SPI_MSB_FIRST
+ | SPI_MASTER | SPI_CPOL_FALLING | SPI_CPHA_SETUP
+ | SPI_FOSC_DIV16);
AC_FLASH_PORT &= ~_BV(AC_FLASH_BIT_SS);
spi_send (FLASH_READ_ID);
rsp[0] = spi_recv ();
@@ -83,6 +83,7 @@ flash_init (void)
AC_FLASH_PORT |= _BV(AC_FLASH_BIT_SS);
proto_send3b ('f',rsp[0], rsp[1], rsp[2]);
+ /* TODO: disable flash usage if no flash is found? */
/* Search for the next address to start writting. */
/*for (flash_global.addr = 0, rsp = 0xFF; rsp != 0xFF; flash_global.addr +=
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 ());
}