-rw-r--r-- 1 lewurm lewurm 4244 2009-12-14 14:17 pkernel/pkernel.mhx
authorBernhard Urban <lewurm@gmx.net>
Mon, 14 Dec 2009 13:18:13 +0000 (14:18 +0100)
committerBernhard Urban <lewurm@gmx.net>
Mon, 14 Dec 2009 13:18:13 +0000 (14:18 +0100)
pkernel/flash.c
pkernel/flash.h
pkernel/main.c

index a86c20541244bfed54502c1c6e51d88691f58091..e7d1188cbe22dac91de6f100d3970e8c2bc1444e 100644 (file)
@@ -93,102 +93,7 @@ unsigned char FLASH_ChipErase(void)
        return flag;
 }
        
-unsigned char FLASH_SectorErase(unsigned int secadr)
-{
-       unsigned char flag = 0;
-       volatile unsigned int value = 0;
-       
-       /*      Set FLASH access mode to 16Bit Write Mode       */
-       FLASH_PrepareWriteHalfWordMode();
-                                       
-       secadr |= 0x0003;
-       
-       /*      Start FLASH Sector Erase Sequence       */
-       *hseq_1 = 0x00AA;
-       *hseq_2 = 0x0055;
-       *hseq_1 = 0x0080;
-       *hseq_1 = 0x00AA;
-       *hseq_2 = 0x0055;
-       *(unsigned  short int *)secadr = 0x0030;
-
-       /*      Wait for the Auto Algorithm to start    */
-       while( !( *(unsigned  short int *)secadr & SETIMR ) )
-       {
-               /*      Feed the Hardware Watchdog      */
-               HWWD_CL = 0;
-               
-               /*      Check for Pending Interrupts    */
-               if( FLASH_CheckPendingInterrupt() )
-               {               
-                       /*      Wait for Sector Erase Suspend   */
-                       FLASH_SuspendSectorErase(secadr);
-                       
-               /*      Set FLASH access mode to 32Bit Read Mode        */
-               FLASH_PrepareReadMode();
-                       
-                       /*      Keep on checking for pending Interrupts */
-                       while( FLASH_CheckPendingInterrupt() ) HWWD_CL = 0;
-                       
-                       /*      Set FLASH access mode to 16Bit Write Mode       */
-               FLASH_PrepareWriteHalfWordMode();
-                                               
-                       /*      Sector Erase Resume     */
-                       FLASH_ResumeSectorErase(secadr);
-               }               
-       }
-
-       /*      Wait for the Auto Algorithm to finish   */
-       while( flag == 0 )
-       {
-               /* Feed Hardware Watchdog */
-               HWWD_CL = 0;
-
-               /*      Check for Pending Interrupts    */
-               if( FLASH_CheckPendingInterrupt() )
-               {               
-                       /*      Sector Erase Suspend    */
-                       FLASH_SuspendSectorErase(secadr);
-                       
-               /*      Set FLASH access mode to 32Bit Read Mode        */
-               FLASH_PrepareReadMode();
-                                       
-                       /*      Keep on checking for pending Interrupts */
-                       while( FLASH_CheckPendingInterrupt() ) HWWD_CL = 0;
-                       
-                       /*      Set FLASH access mode to 16Bit Write Mode       */
-               FLASH_PrepareWriteHalfWordMode();
-                                               
-                       /*      Sector Erase Resume     */
-                       FLASH_ResumeSectorErase(secadr);
-               }               
-               
-                       
-               /*      Check the Hardware Sequence Flags       */                              
-               if( ( *(unsigned short int *)secadr /* value */ & DPOLL ) )
-               {
-                       flag = 1;
-               }
-               if( ( *(unsigned short int *)secadr /* value */ & TLOVER ) )
-               {
-                       if( ( *(unsigned short int *)secadr /* value */ & DPOLL ) )
-                       {
-                               flag = 1;
-                       }
-                       else
-                       {
-                               /*      Reset FLASH     */
-                               FLASH_ReadReset();
-                               
-                               flag = 2;
-                       }
-               }
-       }
-       /*      Set FLASH access mode to 32Bit Read Mode        */
-       FLASH_PrepareReadMode();
-               
-       return flag;
-}
-
+#if 0 //maybe implement this check too!
 unsigned char FLASH_SectorBlankCheck(unsigned int secaddr, unsigned int size)
 {
        unsigned int count;
@@ -216,6 +121,7 @@ unsigned char FLASH_SectorBlankCheck(unsigned int secaddr, unsigned int size)
        
        return 1;
 }
+#endif
 
 unsigned char FLASH_WriteHalfWord(unsigned int adr, unsigned short int data)
 {
@@ -262,7 +168,6 @@ unsigned char FLASH_WriteHalfWord(unsigned int adr, unsigned short int data)
        return flag;
 }
 
-
 unsigned char FLASH_ReadReset()
 {
        *hseq_1 = 0x00F0;
@@ -270,35 +175,6 @@ unsigned char FLASH_ReadReset()
        return 1;
 }
 
-
-unsigned char FLASH_SuspendSectorErase(unsigned int secaddr)
-{              
-       /* Write Sector Erase Suspend Command   */
-       *(volatile unsigned short int *)secaddr = 0x00B0;
-
-       /*      Wait for the FLASH macro to suspend sector erase        */              
-       while(!(*(unsigned short int *)secaddr /* value */ & DPOLL) && (*(unsigned short int *)secaddr /* value */ & SETIMR))
-       {
-               HWWD_CL=0;
-       }
-       
-       return 1;
-}
-
-unsigned char FLASH_ResumeSectorErase(unsigned int secaddr)
-{
-       /*      Write the Sector Erase Resume Command   */
-       *(volatile unsigned short int *)secaddr = 0x0030;
-       
-       /*      Wait for the FLASH Macro to resume sector erase */              
-       while((*(unsigned short int *)secaddr /*value */ & DPOLL) && !(*(unsigned short int *)secaddr /*value */ & SETIMR))
-       {
-               HWWD_CL=0;
-       }
-       
-       return 1;               
-}
-
 unsigned char FLASH_CheckPendingInterrupt()
 {
        /*      Poll for Pending Interrupts which are needed here       */
@@ -307,3 +183,4 @@ unsigned char FLASH_CheckPendingInterrupt()
        /*      and return 1 when an Interrupt is pending       */
        return 0;
 }
+
index 654430fa9438d4f2a24c516af3581b846d2ab337..de9edb6cc109a07393a9d74c6172d45797f09720 100644 (file)
@@ -6,7 +6,6 @@
 #define hseq_1 ((volatile unsigned short int *)0x000A1557)
 #define hseq_2 ((volatile unsigned short int *)0x000A0AAF)
 
-
 #define DPOLL 0x0080
 #define TLOVER 0x0020
 #define SETIMR 0x0008
 void FLASH_PrepareWriteHalfWordMode();
 void FLASH_PrepareReadMode();
 unsigned char FLASH_WriteHalfWord(unsigned int adr, unsigned short int data);
-unsigned char FLASH_SectorErase(unsigned int sec_adr);
 unsigned char FLASH_ChipErase(void);
 unsigned char FLASH_SectorBlankCheck(unsigned int secaddr, unsigned int size);
 unsigned char FLASH_ReadReset(void);
-unsigned char FLASH_SuspendSectorErase(unsigned int secaddr);
-unsigned char FLASH_ResumeSectorErase(unsigned int secaddr);
-unsigned int FLASH_SaveDisableInterruptFlag(void);
-void FLASH_RestoreInterruptFlag(unsigned int flag);
 unsigned char FLASH_CheckPendingInterrupt(void);
 
 #endif
index 20334cda7c8d435e042866d25b564e869aa68d76..74d1659ee066accd8f347946e4e05cc78a57b34c 100644 (file)
@@ -75,24 +75,6 @@ void main(void)
                                Putch4(0x23);
                                break;
 
-                       case 0x12: //erase
-                               Putch4(0x11);
-                               address = recvdword();
-                               increaseled();
-
-                               size = recvword();
-                               increaseled();
-
-                               PDR14 = 0xff;
-                               for(i=0; i<(size+4); i+=4) { /* erase */
-                                       if(FLASH_SectorErase(address + i) != 1) {
-                                               panic();
-                                       }
-                                       increaseled();
-                               }
-                               Putch4(0x18); //Erasing done.
-                               break;
-
                        case 0x13: //receive
                                Putch4(0x37);
                                increaseled();