summaryrefslogtreecommitdiffhomepage
path: root/digital/avr/modules/flash/flash.h
diff options
context:
space:
mode:
authorNélio Laranjeiro2010-01-12 23:51:26 +0100
committerNélio Laranjeiro2010-01-12 23:51:26 +0100
commit32ed04c7e1435b8019974ac0671a6896e2786f31 (patch)
treed3e9300a81c32838a938d4b6ec827611f8871b46 /digital/avr/modules/flash/flash.h
parent0f278970130103b1df4a2b308359943520f10987 (diff)
digital/avr/modules/flash: flash sst driver
Modify flash source code to initialise the SPI interface and detect the flash type using JDEC. Once the JDEC is read the flash driver initialise functions pointers to pilot the flash memory. The final objective is to have several flash support.
Diffstat (limited to 'digital/avr/modules/flash/flash.h')
-rw-r--r--digital/avr/modules/flash/flash.h93
1 files changed, 38 insertions, 55 deletions
diff --git a/digital/avr/modules/flash/flash.h b/digital/avr/modules/flash/flash.h
index 806b97ad..0ac87596 100644
--- a/digital/avr/modules/flash/flash.h
+++ b/digital/avr/modules/flash/flash.h
@@ -27,29 +27,6 @@
#include "common.h"
#include "io.h"
-#define FLASH_SIZE 0x200000
-#define FLASH_ADDRESS_HIGH (FLASH_SIZE - 1)
-#define FLASH_ADDRESS_ERROR 0xFFFFFF
-#define FLASH_ADDRESS_INC(val) \
- ((val) + 1) & FLASH_ADDRESS_HIGH
-
-#define FLASH_ERASE_FULL 0x60
-#define FLASH_ERASE_4K 0x20
-#define FLASH_ERASE_32K 0x52
-#define FLASH_ERASE_64K 0xD8
-
-#define FLASH_READ_ID 0x9F
-#define FLASH_READ 0x03
-#define FLASH_WRITE 0x2
-#define FLASH_WRSR 0x1
-#define FLASH_RDSR 0x5
-#define FLASH_WREN 0x6
-#define FLASH_WEDI 0x4
-#define FLASH_EWSR 0x50
-#define FLASH_AAI 0xAD
-
-#define FLASH_TBP_US 10
-
#define FLASH_LOG_PAGE_SIZE 0x80000
#define FLASH_LOG_BUFFER_SIZE 16
@@ -62,67 +39,56 @@
AC_FLASH_PORT |= _BV(AC_FLASH_BIT_SS);
enum flash_cmd_t
-enum
{
FLASH_CMD_INIT,
- FLASH_CMD_READ,
- FLASH_CMD_WRITE,
FLASH_CMD_READ_BYTE,
FLASH_CMD_WRITE_BYTE,
+ FLASH_CMD_READ,
+ FLASH_CMD_WRITE,
FLASH_CMD_NB
};
typedef enum flash_cmd_t flash_cmd_t;
-/** Flash access.
- * The flash contains an address of 21 bits in a range from 0x0-0x1fffff.
- * This function shall access the memory directly by the SPI.
- * \param addr the address to provide to the flash memory.
+enum flash_erase_cmd_t
+{
+ FLASH_ERASE_PAGE,
+ FLASH_ERASE_SECTOR,
+ FLASH_ERASE_BLOCK,
+ FLASH_ERASE_FULL,
+ FLASH_ERASE_NB
+};
+typedef enum flash_erase_cmd_t flash_erase_cmd_t;
+
+/** Initialise the flash memory.
+ * \return true if the flash is present, false otherwise.
*/
-void
-flash_address (uint32_t addr);
+uint8_t
+flash_init (void);
/** Erase the memory.
* \param erase_type the erase type..
* \param start_addr the start address.
*/
void
-flash_erase (uint8_t cmd, uint32_t start_addr);
+flash_erase (flash_erase_cmd_t cmd, uint32_t start_addr);
/* Send a flash command to the flash memory (only a command).
* \param cmd the command to send.
*/
void
-flash_send_command (uint8_t cmd);
+flash_send_command (flash_cmd_t cmd);
-/** Poll the busy bit in the Software Status Register of the flash memory.
+/** Read the busy bit in the Software Status Register of the flash memory.
* \return the status register.
*/
uint8_t
flash_read_status (void);
-/** Poll the busy bit in the Software Status Register of the flash memory.
+/** Read the busy bit in the Software Status Register of the flash memory.
* \return the busy bit state.
*/
-extern inline uint8_t
-flash_is_busy (void)
-{
- return flash_read_status () & 0x1;
-}
-
-/** Return the AAI status flag of the register.
- * \return the AAI status.
- */
-extern inline uint8_t
-flash_status_aai (void)
-{
- return flash_read_status () >> 6;
-}
-
-/** Initialise the flash memory.
- * \return true if the flash is present, false otherwise.
- */
uint8_t
-flash_init (void);
+flash_is_busy (void);
/** Write in the flash byte provided in parameter.
* \param data the buffer to store the data.
@@ -165,4 +131,21 @@ flash_write_array (uint32_t addr, uint8_t *data, uint32_t length);
int8_t
flash_log (uint8_t size, uint8_t *args);
+/** Get the flash size.
+ * \return the flash size.
+ */
+uint32_t
+flash_size (void);
+
+/** Get the flash block size.
+ * \return the flash block size.
+ */
+uint32_t
+flash_block_size (void);
+
+/** Initialise all the function pointer for SST flash memory.
+ */
+void
+flash_init_sst (void);
+
#endif /* flash_h */