![]() |
PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
|
What should be done before using these APIs? Before using the Main Flash operation APIs, please make sure the code is operated in RAM area. In the IAR environment, the key word "__ramfunc" makes sure that the code is implemented from RAM. In the Keil environment, user has to place the code to RAM area manually. 1) Right click main_flash.c 2) [Options for main_flash.c]->[code/const]->select a RAM area. More...
Macros | |
| #define | Flash_Read(addr) *(volatile uint16_t*)((uint32_t)(addr)) |
| Read a half word data from Flash. More... | |
| #define | Flash_Write(addr, data) *(volatile uint16_t*)((uint32_t)(addr)) = ( uint16_t)(data) |
| Wirte a half word data into Flash. More... | |
| #define | MFLASH_CODE1 0x0AA8 |
| #define | MFLASH_CODE2 0x0554 |
| #define | MFLASH_RET_OK 0 |
| #define | MFLASH_RET_INVALID_PARA 1 |
| #define | MFLASH_RET_ABNORMAL 2 |
| #define | MFLASH_CHK_TOGG_NORMAL 0 |
| #define | MFLASH_CHK_TOGG_ABNORMAL 1 |
| #define | MFLASH_CHK_DPOL_NORMAL 0 |
| #define | MFLASH_CHK_DPOL_ABNORMAL 1 |
| #define | MFLASH_CHK_DPOL_MASK (uint16_t)0x0080 |
| #define | MFLASH_CHK_TOGG_MASK (uint16_t)0x0040 |
| #define | MFLASH_CHK_TLOV_MASK (uint16_t)0x0020 |
| #define | CR_DATA_ADDR (0x00402000) |
Functions | |
| static uint8_t | MFlash_CheckToggle (uint16_t *pu16Addr) |
| automatic algorithm of flash memory execution More... | |
| static void | MFlash_ReadResetCmd (uint16_t *pu16ResetSecAddr) |
| Issue read/reset command. More... | |
| uint8_t | MFlash_ChipErase (boolean_t bCrRemain) |
| Flash chip erase. More... | |
| uint8_t | MFlash_SectorErase (uint16_t *pu16SecAddr) |
| Flash sector erase. More... | |
| uint8_t | MFlash_Write (uint16_t *pu16WriteAddr, uint16_t *pu16WriteData, uint32_t u32EvenSize, boolean_t bVerifyAndEccCheck) |
| Flash half-word write with ECC. More... | |
What should be done before using these APIs? Before using the Main Flash operation APIs, please make sure the code is operated in RAM area. In the IAR environment, the key word "__ramfunc" makes sure that the code is implemented from RAM. In the Keil environment, user has to place the code to RAM area manually. 1) Right click main_flash.c 2) [Options for main_flash.c]->[code/const]->select a RAM area.
Provided functions of Main Flash operation:
How to use Main Flash module? MFlash_ChipErase() can erase whole chip space of Main Flash, whether CR data remains after chip erase depends on the parameter bCrRemain. MFlash_SectorErase() can erase one selected sector. MFlash_Write() writes data into Flash area with word align, as ECC is equipped in the Flash module. Whether data verify and ECC check is done depends on the parameter bVerifyAndEccCheck.
| #define CR_DATA_ADDR (0x00402000) |
Definition at line 112 of file main_flash.h.
Referenced by MFlash_ChipErase().
| #define Flash_Read | ( | addr | ) | *(volatile uint16_t*)((uint32_t)(addr)) |
Read a half word data from Flash.
| addr | Pointer to read data address |
Definition at line 71 of file main_flash.c.
Referenced by MFlash_CheckToggle(), MFlash_ChipErase(), MFlash_ReadResetCmd(), and MFlash_Write().
| #define Flash_Write | ( | addr, | |
| data | |||
| ) | *(volatile uint16_t*)((uint32_t)(addr)) = ( uint16_t)(data) |
Wirte a half word data into Flash.
| addr | Pointer to read data address |
| data | Write data |
Definition at line 80 of file main_flash.c.
Referenced by MFlash_ChipErase(), MFlash_ReadResetCmd(), MFlash_SectorErase(), and MFlash_Write().
| #define MFLASH_CHK_DPOL_ABNORMAL 1 |
Definition at line 106 of file main_flash.h.
| #define MFLASH_CHK_DPOL_MASK (uint16_t)0x0080 |
Definition at line 108 of file main_flash.h.
| #define MFLASH_CHK_DPOL_NORMAL 0 |
Definition at line 105 of file main_flash.h.
| #define MFLASH_CHK_TLOV_MASK (uint16_t)0x0020 |
Definition at line 110 of file main_flash.h.
Referenced by MFlash_CheckToggle().
| #define MFLASH_CHK_TOGG_ABNORMAL 1 |
Definition at line 103 of file main_flash.h.
Referenced by MFlash_CheckToggle(), MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().
| #define MFLASH_CHK_TOGG_MASK (uint16_t)0x0040 |
Definition at line 109 of file main_flash.h.
Referenced by MFlash_CheckToggle().
| #define MFLASH_CHK_TOGG_NORMAL 0 |
Definition at line 102 of file main_flash.h.
Referenced by MFlash_CheckToggle().
| #define MFLASH_CODE1 0x0AA8 |
Definition at line 95 of file main_flash.h.
Referenced by MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().
| #define MFLASH_CODE2 0x0554 |
Definition at line 96 of file main_flash.h.
Referenced by MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().
| #define MFLASH_RET_ABNORMAL 2 |
Definition at line 100 of file main_flash.h.
Referenced by MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().
| #define MFLASH_RET_INVALID_PARA 1 |
Definition at line 99 of file main_flash.h.
Referenced by MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().
| #define MFLASH_RET_OK 0 |
Definition at line 98 of file main_flash.h.
Referenced by MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().
|
static |
automatic algorithm of flash memory execution
| [in] | pu16Addr | Address of flash data |
| MFLASH_RET_OK | |
| MFLASH_RET_ABNORMAL | |
| MFLASH_RET_INVALID_PARA |
Definition at line 394 of file main_flash.c.
References Flash_Read, MFLASH_CHK_TLOV_MASK, MFLASH_CHK_TOGG_ABNORMAL, MFLASH_CHK_TOGG_MASK, and MFLASH_CHK_TOGG_NORMAL.
Referenced by MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().

| uint8_t MFlash_ChipErase | ( | boolean_t | bCrRemain | ) |
Flash chip erase.
| bCrRemain | CR remaim flag |
| MFLASH_RET_OK | |
| MFLASH_RET_ABNORMAL | |
| MFLASH_RET_INVALID_PARA |
Definition at line 133 of file main_flash.c.
References CR_DATA_ADDR, Flash_Read, Flash_Write, MFlash_CheckToggle(), MFLASH_CHK_TOGG_ABNORMAL, MFLASH_CODE1, MFLASH_CODE2, MFlash_ReadResetCmd(), MFLASH_RET_ABNORMAL, MFLASH_RET_INVALID_PARA, MFLASH_RET_OK, and TRUE.

|
static |
Issue read/reset command.
| [in] | pu16ResetSecAddr | Address of reset sector |
Definition at line 105 of file main_flash.c.
References Flash_Read, and Flash_Write.
Referenced by MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().

| uint8_t MFlash_SectorErase | ( | uint16_t * | pu16SecAddr | ) |
Flash sector erase.
| pu16SecAddr | Address of flash sector |
| MFLASH_RET_OK | |
| MFLASH_RET_ABNORMAL | |
| MFLASH_RET_INVALID_PARA |
Definition at line 226 of file main_flash.c.
References Flash_Write, MFlash_CheckToggle(), MFLASH_CHK_TOGG_ABNORMAL, MFLASH_CODE1, MFLASH_CODE2, MFlash_ReadResetCmd(), MFLASH_RET_ABNORMAL, MFLASH_RET_INVALID_PARA, and MFLASH_RET_OK.

| uint8_t MFlash_Write | ( | uint16_t * | pu16WriteAddr, |
| uint16_t * | pu16WriteData, | ||
| uint32_t | u32EvenSize, | ||
| boolean_t | bVerifyAndEccCheck | ||
| ) |
Flash half-word write with ECC.
| [in] | pu16WriteAddr | Address of flash data |
| [in] | pu16WriteData | Pointer to write data |
| [in] | u32EvenSize | Data size, 1 indicates 1 16-bit data, always set it to even |
| [in] | bVerifyAndEccCheck | TRUE: Verify and check ECC, FALSE: No verification |
| MFLASH_RET_OK | |
| MFLASH_RET_ABNORMAL | |
| MFLASH_RET_INVALID_PARA |
Definition at line 289 of file main_flash.c.
References Flash_Read, Flash_Write, MFlash_CheckToggle(), MFLASH_CHK_TOGG_ABNORMAL, MFLASH_CODE1, MFLASH_CODE2, MFlash_ReadResetCmd(), MFLASH_RET_ABNORMAL, MFLASH_RET_INVALID_PARA, and MFLASH_RET_OK.
