#include "flash.h"
#include "mb91465k.h"
-static unsigned int IFlag;
-
void FLASH_PrepareWriteHalfWordMode()
{
/* Set FLASH Access Mode via BootROM Routine */
{
unsigned char flag = 0;
- /*Disable Interrupts if necessary*/
- IFlag = FLASH_SaveDisableInterruptFlag();
-
/*Set FLASH access mode to 16Bit Write Mode*/
FLASH_PrepareWriteHalfWordMode();
/*Set FLASH access mode to 32Bit Read Mode*/
FLASH_PrepareReadMode();
- /*Restore the original Interrupt Flag*/
- FLASH_RestoreInterruptFlag(IFlag);
-
return flag;
}
unsigned char flag = 0;
volatile unsigned int value = 0;
- /* Disable Interrupts if necessary */
- IFlag = FLASH_SaveDisableInterruptFlag();
-
/* Set FLASH access mode to 16Bit Write Mode */
FLASH_PrepareWriteHalfWordMode();
/* Set FLASH access mode to 32Bit Read Mode */
FLASH_PrepareReadMode();
- /* Restore the original Interrupt Flag */
- FLASH_RestoreInterruptFlag(IFlag);
-
/* Keep on checking for pending Interrupts */
while( FLASH_CheckPendingInterrupt() ) HWWD_CL = 0;
- /* Disable Interrupts if necessary */
- IFlag = FLASH_SaveDisableInterruptFlag();
-
/* Set FLASH access mode to 16Bit Write Mode */
FLASH_PrepareWriteHalfWordMode();
/* Set FLASH access mode to 32Bit Read Mode */
FLASH_PrepareReadMode();
- /* Restore the original Interrupt Flag */
- FLASH_RestoreInterruptFlag(IFlag);
-
/* Keep on checking for pending Interrupts */
while( FLASH_CheckPendingInterrupt() ) HWWD_CL = 0;
-
- /* Disable Interrupts if necessary */
- IFlag = FLASH_SaveDisableInterruptFlag();
/* Set FLASH access mode to 16Bit Write Mode */
FLASH_PrepareWriteHalfWordMode();
}
}
}
-
-
- /* Restore the original Interrupt Flag */
- FLASH_RestoreInterruptFlag(IFlag);
-
/* Set FLASH access mode to 32Bit Read Mode */
FLASH_PrepareReadMode();
{
unsigned char flag = 0;
- /* Disable Interrupts if necessary */
- IFlag = FLASH_SaveDisableInterruptFlag();
-
/* Set FLASH access mode to 16Bit Write Mode */
FLASH_PrepareWriteHalfWordMode();
/* Set FLASH access mode to 32Bit Read Mode */
FLASH_PrepareReadMode();
- /* Restore the original Interrupt Flag */
- FLASH_RestoreInterruptFlag(IFlag);
-
return flag;
}
return 1;
}
-#pragma asm
-_FLASH_SaveDisableInterruptFlag:
- STM0 (R0)
- MOV PS,R4
- LDI #0x00000010,R0
- AND R0,R4 ; Store Original Flag
- ANDCCR #0xFFFFFFEF ; Clear Interrupt Flag
- LDM0 (R0)
- RET
-#pragma endasm
-
-
-#pragma asm
-_FLASH_RestoreInterruptFlag:
- STM0 (R0)
- MOV PS,R0 ; Get current PS
- OR R4,R0 ; Set Flag as saved
- MOV R0,PS ; Write back PS
- LDM0 (R0)
- RET
-#pragma endasm
-
unsigned char FLASH_SuspendSectorErase(unsigned int secaddr)
{