aboutsummaryrefslogtreecommitdiffhomepage
path: root/S100App/Src/Flash.c
blob: ce7ca2e48a9fb33db8e640c2bc695ab121aac16b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/********************* (C) COPYRIGHT 2015 e-Design Co.,Ltd. ********************
 File Name : Flash.c
 Version   :                                        Author : bure
*******************************************************************************/
#include "APP_Version.h"
#include "Flash.h"
#include "Bios.h"

u8   ExtFlashSendByte(u8 byte);
void ExtFlashWaitForWriteEnd(void);

/*******************************************************************************
 FLASH_Prog:
*******************************************************************************/
u8 FLASH_Prog(u32 Address, u16 Data)
{
    if(FLASH_WaitForLastOperation(WAIT_TIMES)!=FLASH_TIMEOUT)
        FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_PGERR|FLASH_FLAG_WRPRTERR);
    return FLASH_ProgramHalfWord(Address, Data);
}
/*******************************************************************************
 FLASH_Erase:
*******************************************************************************/
void FLASH_Erase(u32 Address)
{
    if(Address%FLASH_PAGE == 0) {                  // FLASH Page start (1K/Page)
        if(FLASH_WaitForLastOperation(WAIT_TIMES)!=FLASH_TIMEOUT)
            FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_PGERR|FLASH_FLAG_WRPRTERR);
        FLASH_ErasePage(Address);                   // FLASH Page erase
    }
}
/*********************************  END OF FILE  ******************************/