summaryrefslogtreecommitdiffhomepage
path: root/digital/avr/modules/flash/flash.c
diff options
context:
space:
mode:
authorNicolas Schodet2008-03-13 13:55:14 +0100
committerNicolas Schodet2008-03-13 13:55:14 +0100
commit9290d7eed268d4bd96829dcbae839b5d6b11dad1 (patch)
tree8d36a105a70b2dc62013b8fbbc2394360bcfcfa6 /digital/avr/modules/flash/flash.c
parent16ceb1a0562816c94eb6fed58c7a9acf2609c353 (diff)
* digital/avr/modules/flash:
- fixed erase command. - fixed init (actually, SR should be cleared). - merged all tests in one.
Diffstat (limited to 'digital/avr/modules/flash/flash.c')
-rw-r--r--digital/avr/modules/flash/flash.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/digital/avr/modules/flash/flash.c b/digital/avr/modules/flash/flash.c
index 61403e35..ebde71f1 100644
--- a/digital/avr/modules/flash/flash.c
+++ b/digital/avr/modules/flash/flash.c
@@ -50,8 +50,11 @@ flash_address (uint32_t addr)
void
flash_erase (uint8_t cmd, uint32_t start_addr)
{
+ flash_send_command (FLASH_WREN);
+
+ AC_FLASH_PORT &= ~_BV(AC_FLASH_BIT_SS);
/* send the command. */
- flash_send_command (cmd);
+ spi_send (cmd);
/* verify if the cmd is the full erase. */
if (cmd != FLASH_ERASE_FULL)
@@ -63,6 +66,9 @@ flash_erase (uint8_t cmd, uint32_t start_addr)
{
flash_global.addr = 0x0;
}
+ AC_FLASH_PORT |= _BV(AC_FLASH_BIT_SS);
+
+ while (flash_is_busy());
}
/** Poll the busy bit in the Software Status Register of the flash memory.
@@ -116,6 +122,11 @@ flash_init (void)
/* Enables the flash to be writable. */
flash_send_command (FLASH_WREN);
+
+ AC_FLASH_PORT &= ~_BV(AC_FLASH_BIT_SS);
+ spi_send (FLASH_WRSR);
+ spi_send (0);
+ AC_FLASH_PORT |= _BV(AC_FLASH_BIT_SS);
/* Read the flash status. */
proto_send1b ('s', flash_read_status());