From 3124bf3b4492d9cd608d4b933db88ca34ec425b7 Mon Sep 17 00:00:00 2001 From: laforge Date: Wed, 20 Sep 2006 00:45:05 +0000 Subject: move flash code into dfu git-svn-id: https://svn.openpcd.org:2342/trunk@200 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- firmware/src/dfu/flash.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ firmware/src/os/flash.c | 45 --------------------------------------------- 2 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 firmware/src/dfu/flash.c delete mode 100644 firmware/src/os/flash.c (limited to 'firmware') diff --git a/firmware/src/dfu/flash.c b/firmware/src/dfu/flash.c new file mode 100644 index 0000000..2aaf760 --- /dev/null +++ b/firmware/src/dfu/flash.c @@ -0,0 +1,45 @@ + + +#define EFCS_CMD_WRITE_PAGE 0x01 +#define EFCS_CMD_SET_LOCK_BIT 0x02 +#define EFCS_CMD_WRITE_PAGE_LOCK 0x03 +#define EFCS_CMD_CLEAR_LOCK 0x04 +#define EFCS_CMD_ERASE_ALL 0x08 +#define EFCS_CMD_SET_NVM_BIT 0x0b +#define EFCS_CMD_CLEAR_NVM_BIT 0x0d +#define EFCS_CMD_SET_SECURITY_BIT 0x0f + + +int unlock_page(u_int16_t page) +{ + AT91C_MC_FCMD_UNLOCK | AT91C_MC_CORRECT_KEY | + +} + +int flash_sector(unsigned int sector, const u_int8_t *data, unsigned int len) +{ + volatile u_int32_t *p = (volatile u_int32_t *)0; + u_int32_t *src32 = (u_int32_t *)data; + int i; + + /* hand-code memcpy because we need to make sure only 32bit accesses + * are used */ + for (i = 0; i < len/4; i++) + p[i] = src32[i]; + + AT91F_MC_EFC_PerformCmd(pmc , AT91C_MC_FCMD_START_PROG| + AT91C_MC_CORRECT_KEY | ); +} + + +void flash_init(void) +{ + unsigned int fmcn = AT91F_MC_EFC_ComputerFMCN(48000000); + + AT91F_MC_EFC_CfgModeReg(ff, fmcn << 16 | AT91C_MC_FWS_3FWS | + AT91C_MC_FRDY | AT91C_MC_LOCKE | + AT91C_MC_PROGE); + + AT91F_AIC_EnableIt(); + +} diff --git a/firmware/src/os/flash.c b/firmware/src/os/flash.c deleted file mode 100644 index 2aaf760..0000000 --- a/firmware/src/os/flash.c +++ /dev/null @@ -1,45 +0,0 @@ - - -#define EFCS_CMD_WRITE_PAGE 0x01 -#define EFCS_CMD_SET_LOCK_BIT 0x02 -#define EFCS_CMD_WRITE_PAGE_LOCK 0x03 -#define EFCS_CMD_CLEAR_LOCK 0x04 -#define EFCS_CMD_ERASE_ALL 0x08 -#define EFCS_CMD_SET_NVM_BIT 0x0b -#define EFCS_CMD_CLEAR_NVM_BIT 0x0d -#define EFCS_CMD_SET_SECURITY_BIT 0x0f - - -int unlock_page(u_int16_t page) -{ - AT91C_MC_FCMD_UNLOCK | AT91C_MC_CORRECT_KEY | - -} - -int flash_sector(unsigned int sector, const u_int8_t *data, unsigned int len) -{ - volatile u_int32_t *p = (volatile u_int32_t *)0; - u_int32_t *src32 = (u_int32_t *)data; - int i; - - /* hand-code memcpy because we need to make sure only 32bit accesses - * are used */ - for (i = 0; i < len/4; i++) - p[i] = src32[i]; - - AT91F_MC_EFC_PerformCmd(pmc , AT91C_MC_FCMD_START_PROG| - AT91C_MC_CORRECT_KEY | ); -} - - -void flash_init(void) -{ - unsigned int fmcn = AT91F_MC_EFC_ComputerFMCN(48000000); - - AT91F_MC_EFC_CfgModeReg(ff, fmcn << 16 | AT91C_MC_FWS_3FWS | - AT91C_MC_FRDY | AT91C_MC_LOCKE | - AT91C_MC_PROGE); - - AT91F_AIC_EnableIt(); - -} -- cgit v1.2.3