]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - embedded/arch/arm/mach-lpc21xx/libs/iap/iap.c
Update of system-less architecture and board support code to actual uLAN.sf.net version.
[lincan.git] / embedded / arch / arm / mach-lpc21xx / libs / iap / iap.c
index 9403f688b44cf2aa89d0c7517cca1cef488ee4c3..23f7bc0261a8fd3ac5392939f2e6bfcc1e869ed1 100644 (file)
@@ -10,8 +10,8 @@
 #define IAP_CMD_ERASE          52
 #define IAP_CMD_READ_PARTID    54
 
-uint32_t command[5];
-uint32_t result[2];
+unsigned int command[5];
+unsigned int result[2];
 
 extern void iap_asm_entry (unsigned int *,unsigned int *);
 #define iap_entry iap_asm_entry
@@ -21,7 +21,7 @@ inline int addr2sec(unsigned long addr)
 {
   return addr/0x2000;
 }
-#elif defined INC_LPC214x_H
+#elif defined INC_LPC214x_H || defined INC_LPC2348_H
 inline int addr2sec(unsigned long addr)
 {
   if (addr<0x8000) return (addr>>12);
@@ -44,7 +44,7 @@ int lpcisp_prepare_sectors(unsigned char start, unsigned char end)
   command[0] = IAP_CMD_PREPARE;
   command[1] = start;
   command[2] = end;
-  command[3] = FOSC/1000;
+  command[3] = system_frequency/1000;
 
   iap_entry(command, result);
 
@@ -56,7 +56,7 @@ int lpcisp_erase_sectors(unsigned char start, unsigned char end)
   command[0] = IAP_CMD_ERASE;
   command[1] = start;
   command[2] = end;
-  command[3] = FOSC/1000;
+  command[3] = system_frequency/1000;
 
   iap_entry(command, result);
 
@@ -74,14 +74,12 @@ int lpcisp_erase(void *addr, int len)
   if (end<start) return 0;
 
   save_and_cli(flags);
-  lpc_pll_off();
 
   lpcisp_prepare_sectors(start,end);
   if (CMD_SUCCESS != *result) return 0;
 
   lpcisp_erase_sectors(start,end);
 
-  lpc_pll_on();
   restore_flags(flags);
 
   return (CMD_SUCCESS == *result);
@@ -96,7 +94,6 @@ int lpcisp_write(void *addr_des, const void *addr_src, int len)
   end=start;
 
   save_and_cli(flags);
-  lpc_pll_off();
 
   lpcisp_prepare_sectors(start,end);
   if (CMD_SUCCESS != *result) return 0;
@@ -105,11 +102,10 @@ int lpcisp_write(void *addr_des, const void *addr_src, int len)
   command[1] = (unsigned int)addr_des;
   command[2] = (unsigned int)addr_src;
   command[3] = len;
-  command[4] = FOSC/1000;
+  command[4] = system_frequency/1000;
 
   iap_entry(command, result);
 
-  lpc_pll_on();
   restore_flags(flags);
 
   return (CMD_SUCCESS == *result);