diff options
author | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-11-11 02:08:38 +0000 |
---|---|---|
committer | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-11-11 02:08:38 +0000 |
commit | 13be0cd28e3e41a2415cd0d01bad8ecb0909e637 (patch) | |
tree | 3379ae180c0ab7d44c0cea2c4ab5c68b4e9217eb /openpicc/application | |
parent | 39cb47ed0951074afb24687fcb6e66947b4f8ef8 (diff) |
Revert 313 and 315 again, I'm too stupid to get DFU working, focus on the application code first
git-svn-id: https://svn.openpcd.org:2342/trunk@316 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application')
-rw-r--r-- | openpicc/application/flash.c | 68 | ||||
-rw-r--r-- | openpicc/application/flash.h | 5 | ||||
-rw-r--r-- | openpicc/application/main.c | 2 |
3 files changed, 1 insertions, 74 deletions
diff --git a/openpicc/application/flash.c b/openpicc/application/flash.c deleted file mode 100644 index c729ff8..0000000 --- a/openpicc/application/flash.c +++ /dev/null @@ -1,68 +0,0 @@ -#include <sys/types.h> -#include <lib_AT91SAM7.h> -#include <AT91SAM7.h> -#include <dfu/dbgu.h> -#include <board.h> - -#define EFCS_CMD_WRITE_PAGE 0x1 -#define EFCS_CMD_SET_LOCK_BIT 0x2 -#define EFCS_CMD_WRITE_PAGE_LOCK 0x3 -#define EFCS_CMD_CLEAR_LOCK 0x4 -#define EFCS_CMD_ERASE_ALL 0x8 -#define EFCS_CMD_SET_NVM_BIT 0xb -#define EFCS_CMD_CLEAR_NVM_BIT 0xd -#define EFCS_CMD_SET_SECURITY_BIT 0xf - -static u_int16_t page_from_ramaddr(const void *addr) -{ - u_int32_t ramaddr = (u_int32_t) addr; - ramaddr -= (u_int32_t) AT91C_IFLASH; - return ((ramaddr >> AT91C_IFLASH_PAGE_SHIFT)); -} -#define PAGES_PER_LOCKREGION (AT91C_IFLASH_LOCK_REGION_SIZE>>AT91C_IFLASH_PAGE_SHIFT) -#define IS_FIRST_PAGE_OF_LOCKREGION(x) ((x % PAGES_PER_LOCKREGION) == 0) -#define LOCKREGION_FROM_PAGE(x) (x / PAGES_PER_LOCKREGION) - -static int is_page_locked(u_int16_t page) -{ - u_int16_t lockregion = LOCKREGION_FROM_PAGE(page); - - return (AT91C_BASE_MC->MC_FSR & (lockregion << 16)); -} - -static void unlock_page(u_int16_t page) -{ - page &= 0x3ff; - AT91F_MC_EFC_PerformCmd(AT91C_BASE_MC, AT91C_MC_FCMD_UNLOCK | - AT91C_MC_CORRECT_KEY | (page << 8)); -} - -void flash_page(u_int8_t *addr) -{ - u_int16_t page = page_from_ramaddr(addr) & 0x3ff; - u_int32_t fsr = AT91F_MC_EFC_GetStatus(AT91C_BASE_MC); - DEBUGP("flash_page(0x%x=%u) ", addr, page); - - if (is_page_locked(page)) { - DEBUGP("unlocking "); - unlock_page(page); - } - - if (!(fsr & AT91C_MC_FRDY)) { - DEBUGP("NOT_FLASHING "); - return; - } - - DEBUGP("performing start_prog "); - - AT91F_MC_EFC_PerformCmd(AT91C_BASE_MC, AT91C_MC_FCMD_START_PROG | - AT91C_MC_CORRECT_KEY | (page << 8)); -} - -void flash_init(void) -{ - unsigned int fmcn = AT91F_MC_EFC_ComputeFMCN(MCK); - - AT91F_MC_EFC_CfgModeReg(AT91C_BASE_MC, (fmcn&0xff) << 16 | - AT91C_MC_FWS_3FWS); -} diff --git a/openpicc/application/flash.h b/openpicc/application/flash.h deleted file mode 100644 index b812714..0000000 --- a/openpicc/application/flash.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _FLASH_H -#define _FLASH_H -extern void flash_page(u_int8_t *addr); -extern void flash_init(void); -#endif diff --git a/openpicc/application/main.c b/openpicc/application/main.c index d69fc1e..9af44bf 100644 --- a/openpicc/application/main.c +++ b/openpicc/application/main.c @@ -39,7 +39,7 @@ #include "env.h" #include "cmd.h" #include "da.h" -#include "pll.h" +//#include "pll.h" /**********************************************************************/ static inline void prvSetupHardware (void) |