![]() |
PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
|
What is Work Flash? Work Flash have independent area, which is sperated from Main Flash, thus the Flash operation API can be called derectly from Main Flash. 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 | WFLASH_CODE1 0x0AA8 |
| #define | WFLASH_CODE2 0x0554 |
| #define | WFLASH_RET_OK 0 |
| #define | WFLASH_RET_INVALID_PARA 1 |
| #define | WFLASH_RET_ABNORMAL 2 |
| #define | WFLASH_CHK_TOGG_NORMAL 0 |
| #define | WFLASH_CHK_TOGG_ABNORMAL 1 |
| #define | WFLASH_CHK_DPOL_NORMAL 0 |
| #define | WFLASH_CHK_DPOL_ABNORMAL 1 |
| #define | WFLASH_CHK_DPOL_MASK (uint16_t)0x0080 |
| #define | WFLASH_CHK_TOGG_MASK (uint16_t)0x0040 |
| #define | WFLASH_CHK_TLOV_MASK (uint16_t)0x0020 |
| #define | WFLASH_BASE_ADDR (0x200C0000) |
Functions | |
| static uint8_t | WFlash_CheckToggle (uint16_t *pu16Addr) |
| automatic algorithm of flash memory execution More... | |
| static void | WFlash_ReadResetCmd (uint16_t *pu16ResetSecAddr) |
| Issue read/reset command. More... | |
| uint8_t | WFlash_ChipErase (void) |
| Flash chip erase. More... | |
| uint8_t | WFlash_SectorErase (uint16_t *pu16SecAddr) |
| Flash sector erase. More... | |
| uint8_t | WFlash_Write (uint16_t *pu16WriteAddr, uint16_t *pu16WriteData, uint32_t u32Size) |
| Flash half-word write with ECC. More... | |
What is Work Flash? Work Flash have independent area, which is sperated from Main Flash, thus the Flash operation API can be called derectly from Main Flash.
Provided functions of Work Flash operation:
How to use Work Flash module? WFlash_ChipErase() can erase whole chip space of Work Flash. WFlash_SectorErase() can erase one selected sector. WFlash_Write() writes data into Flash area with half-word align.
| #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 work_flash.c.
Referenced by WFlash_CheckToggle(), WFlash_ReadResetCmd(), and WFlash_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 work_flash.c.
Referenced by WFlash_ChipErase(), WFlash_ReadResetCmd(), WFlash_SectorErase(), and WFlash_Write().
| #define WFLASH_BASE_ADDR (0x200C0000) |
Definition at line 101 of file work_flash.h.
Referenced by WFlash_ChipErase(), WFlash_SectorErase(), and WFlash_Write().
| #define WFLASH_CHK_DPOL_ABNORMAL 1 |
Definition at line 95 of file work_flash.h.
| #define WFLASH_CHK_DPOL_MASK (uint16_t)0x0080 |
Definition at line 97 of file work_flash.h.
| #define WFLASH_CHK_DPOL_NORMAL 0 |
Definition at line 94 of file work_flash.h.
| #define WFLASH_CHK_TLOV_MASK (uint16_t)0x0020 |
Definition at line 99 of file work_flash.h.
Referenced by WFlash_CheckToggle().
| #define WFLASH_CHK_TOGG_ABNORMAL 1 |
Definition at line 92 of file work_flash.h.
Referenced by WFlash_CheckToggle(), WFlash_ChipErase(), WFlash_SectorErase(), and WFlash_Write().
| #define WFLASH_CHK_TOGG_MASK (uint16_t)0x0040 |
Definition at line 98 of file work_flash.h.
Referenced by WFlash_CheckToggle().
| #define WFLASH_CHK_TOGG_NORMAL 0 |
Definition at line 91 of file work_flash.h.
Referenced by WFlash_CheckToggle().
| #define WFLASH_CODE1 0x0AA8 |
Definition at line 84 of file work_flash.h.
Referenced by WFlash_ChipErase(), WFlash_SectorErase(), and WFlash_Write().
| #define WFLASH_CODE2 0x0554 |
Definition at line 85 of file work_flash.h.
Referenced by WFlash_ChipErase(), WFlash_SectorErase(), and WFlash_Write().
| #define WFLASH_RET_ABNORMAL 2 |
Definition at line 89 of file work_flash.h.
Referenced by WFlash_ChipErase(), WFlash_SectorErase(), and WFlash_Write().
| #define WFLASH_RET_INVALID_PARA 1 |
Definition at line 88 of file work_flash.h.
Referenced by WFlash_SectorErase(), and WFlash_Write().
| #define WFLASH_RET_OK 0 |
Definition at line 87 of file work_flash.h.
Referenced by WFlash_ChipErase(), WFlash_SectorErase(), and WFlash_Write().
|
static |
automatic algorithm of flash memory execution
| pu16Addr | address of flash data |
| MFLASH_RET_OK | |
| MFLASH_RET_ABNORMAL | |
| MFLASH_RET_INVALID_PARA |
Definition at line 284 of file work_flash.c.
References Flash_Read, WFLASH_CHK_TLOV_MASK, WFLASH_CHK_TOGG_ABNORMAL, WFLASH_CHK_TOGG_MASK, and WFLASH_CHK_TOGG_NORMAL.
Referenced by WFlash_ChipErase(), WFlash_SectorErase(), and WFlash_Write().

| uint8_t WFlash_ChipErase | ( | void | ) |
Flash chip erase.
| MFLASH_RET_OK | |
| MFLASH_RET_ABNORMAL | |
| MFLASH_RET_INVALID_PARA |
Definition at line 121 of file work_flash.c.
References Flash_Write, WFLASH_BASE_ADDR, WFlash_CheckToggle(), WFLASH_CHK_TOGG_ABNORMAL, WFLASH_CODE1, WFLASH_CODE2, WFlash_ReadResetCmd(), WFLASH_RET_ABNORMAL, and WFLASH_RET_OK.

|
static |
Issue read/reset command.
| pu16ResetSecAddr | address of reset sector |
Definition at line 98 of file work_flash.c.
References Flash_Read, and Flash_Write.
Referenced by WFlash_ChipErase(), WFlash_SectorErase(), and WFlash_Write().

| uint8_t WFlash_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 167 of file work_flash.c.
References Flash_Write, WFLASH_BASE_ADDR, WFlash_CheckToggle(), WFLASH_CHK_TOGG_ABNORMAL, WFLASH_CODE1, WFLASH_CODE2, WFlash_ReadResetCmd(), WFLASH_RET_ABNORMAL, WFLASH_RET_INVALID_PARA, and WFLASH_RET_OK.

| uint8_t WFlash_Write | ( | uint16_t * | pu16WriteAddr, |
| uint16_t * | pu16WriteData, | ||
| uint32_t | u32Size | ||
| ) |
Flash half-word write with ECC.
| pu16WriteAddr | address of flash data |
| pu16WriteData | pointer to write data |
| u32Size | data size, 1 indicates 1 16-bit data, always set it to even |
| MFLASH_RET_OK | |
| MFLASH_RET_ABNORMAL | |
| MFLASH_RET_INVALID_PARA |
Definition at line 219 of file work_flash.c.
References Flash_Read, Flash_Write, WFLASH_BASE_ADDR, WFlash_CheckToggle(), WFLASH_CHK_TOGG_ABNORMAL, WFLASH_CODE1, WFLASH_CODE2, WFlash_ReadResetCmd(), WFLASH_RET_ABNORMAL, WFLASH_RET_INVALID_PARA, and WFLASH_RET_OK.
