]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - embedded/arch/arm/mach-lpc21xx/libs/iap/iap.c
Embedded code-base updated to actual version from uLan repository.
[lincan.git] / embedded / arch / arm / mach-lpc21xx / libs / iap / iap.c
index 9403f688b44cf2aa89d0c7517cca1cef488ee4c3..cc39097139694eeb8479623a5015a44a869ca7f5 100644 (file)
@@ -2,6 +2,8 @@
 #include <cpu_def.h>
 #include <hal_machperiph.h>
 
 #include <cpu_def.h>
 #include <hal_machperiph.h>
 
+#define IAP_PLL_FULL_SPEED      1
+
 #define CMD_SUCCESS 0
 #define BUSY 11
 
 #define CMD_SUCCESS 0
 #define BUSY 11
 
@@ -21,7 +23,7 @@ inline int addr2sec(unsigned long addr)
 {
   return addr/0x2000;
 }
 {
   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);
 inline int addr2sec(unsigned long addr)
 {
   if (addr<0x8000) return (addr>>12);
@@ -74,14 +76,18 @@ int lpcisp_erase(void *addr, int len)
   if (end<start) return 0;
 
   save_and_cli(flags);
   if (end<start) return 0;
 
   save_and_cli(flags);
+ #ifndef IAP_PLL_FULL_SPEED
   lpc_pll_off();
   lpc_pll_off();
+ #endif
 
   lpcisp_prepare_sectors(start,end);
   if (CMD_SUCCESS != *result) return 0;
 
   lpcisp_erase_sectors(start,end);
 
 
   lpcisp_prepare_sectors(start,end);
   if (CMD_SUCCESS != *result) return 0;
 
   lpcisp_erase_sectors(start,end);
 
+ #ifndef IAP_PLL_FULL_SPEED
   lpc_pll_on();
   lpc_pll_on();
+ #endif
   restore_flags(flags);
 
   return (CMD_SUCCESS == *result);
   restore_flags(flags);
 
   return (CMD_SUCCESS == *result);
@@ -96,7 +102,9 @@ int lpcisp_write(void *addr_des, const void *addr_src, int len)
   end=start;
 
   save_and_cli(flags);
   end=start;
 
   save_and_cli(flags);
+ #ifndef IAP_PLL_FULL_SPEED
   lpc_pll_off();
   lpc_pll_off();
+ #endif
 
   lpcisp_prepare_sectors(start,end);
   if (CMD_SUCCESS != *result) return 0;
 
   lpcisp_prepare_sectors(start,end);
   if (CMD_SUCCESS != *result) return 0;
@@ -109,7 +117,9 @@ int lpcisp_write(void *addr_des, const void *addr_src, int len)
 
   iap_entry(command, result);
 
 
   iap_entry(command, result);
 
+ #ifndef IAP_PLL_FULL_SPEED
   lpc_pll_on();
   lpc_pll_on();
+ #endif
   restore_flags(flags);
 
   return (CMD_SUCCESS == *result);
   restore_flags(flags);
 
   return (CMD_SUCCESS == *result);