| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Defines | Functions
C:/pdl_v10/library/driver/flash/flash.c File Reference
`#include "flash.h"`
Include dependency graph for flash.c:

Go to the source code of this file.

## Defines
#define | Flash_Read(addr) *(volatile uint16_t*)((uint32_t)(addr))
| Read a half word data from Flash.
#define | Flash_Write(addr, data) *(volatile uint16_t*)((uint32_t)(addr)) = ( uint16_t)(data)
| Wirte a half word data into Flash.
## Functions
static __ramfunc uint8_t | MFlash_CheckToggle (uint16_t *pu16Addr)
| automatic algorithm of flash memory execution
static __ramfunc void | MFlash_ReadResetCmd (uint16_t *pu16ResetSecAddr)
| Issue read/reset command.
__ramfunc en_result_t | MFlash_ChipErase (boolean_t bCrRemain)
| Flash chip erase.
__ramfunc en_result_t | MFlash_SectorErase (uint16_t *pu16SecAddr)
| Flash sector erase.
__ramfunc en_result_t | MFlash_Write (uint16_t *pu16WriteAddr, uint16_t *pu16WriteData, uint32_t u32Size)
| Flash half-word write.

## Detailed Description

A detailed description is available at Main Flash Module description

History:

- 2014-02-21 0.1 Edison Zhang First version.

Definition in file flash.c.

## Define Documentation

#define Flash_Read | ( |  | addr | ) | *(volatile uint16_t*)((uint32_t)(addr))

Read a half word data from Flash.

Parameters:

  addr | Pointer to read data address

Definition at line 65 of file 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.

Parameters:

  addr | Pointer to read data address
  data | Write data

Definition at line 74 of file flash.c.

Referenced by MFlash_ChipErase(), MFlash_ReadResetCmd(), MFlash_SectorErase(), and MFlash_Write().

## Function Documentation

static __ramfunc uint8_t MFlash_CheckToggle | ( | uint16_t * | pu16Addr | ) | `[static]`

automatic algorithm of flash memory execution

Parameters:

  pu16Addr | address of flash data

Return values:

  MFLASH_RET_OK |
  MFLASH_RET_ABNORMAL |
  MFLASH_RET_INVALID_PARA |

Definition at line 310 of file 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().

Here is the caller graph for this function:

__ramfunc en_result_t MFlash_ChipErase | ( | boolean_t | bCrRemain | ) |

Flash chip erase.

Parameters:

  bCrRemain | CR remain flag

Return values:

  Ok | Flash chip erase normally
  ErrorInvalidParameter | bCrRemain > 1
  Error | Flash erase failure

Definition at line 129 of file flash.c.

References CR_DATA_ADDR, Error, ErrorInvalidParameter, Flash_Read, Flash_Write, MFlash_CheckToggle(), MFLASH_CHK_TOGG_ABNORMAL, MFLASH_CODE1, MFLASH_CODE2, MFlash_ReadResetCmd(), Ok, and TRUE.

Here is the call graph for this function:

static __ramfunc void MFlash_ReadResetCmd | ( | uint16_t * | pu16ResetSecAddr | ) | `[static]`

Issue read/reset command.

Parameters:

  pu16ResetSecAddr | address of reset sector

Returns:
  None

Definition at line 102 of file flash.c.

References Flash_Read, and Flash_Write.

Referenced by MFlash_ChipErase(), MFlash_SectorErase(), and MFlash_Write().

Here is the caller graph for this function:

__ramfunc en_result_t MFlash_SectorErase | ( | uint16_t * | pu16SecAddr | ) |

Flash sector erase.

Parameters:

  pu16SecAddr | address of flash sector

Return values:

  Ok | Flash sector erase successfully
  Error | Flash sector erase failure

Definition at line 212 of file flash.c.

References Error, Flash_Write, MFlash_CheckToggle(), MFLASH_CHK_TOGG_ABNORMAL, MFLASH_CODE1, MFLASH_CODE2, MFlash_ReadResetCmd(), and Ok.

Here is the call graph for this function:

__ramfunc en_result_t MFlash_Write | ( | uint16_t * | pu16WriteAddr,
|  | uint16_t * | pu16WriteData,
|  | uint32_t | u32Size
| ) |  |

Flash half-word write.

Parameters:

  pu16WriteAddr | address of flash data
  pu16WriteData | pointer to write data
  u32Size | data size, 1 indicates 1 16-bit data

Return values:

  Ok | Flash half-word write normally
  Error | Flash half-word write failure

Definition at line 256 of file flash.c.

References Error, Flash_Read, Flash_Write, MFlash_CheckToggle(), MFLASH_CHK_TOGG_ABNORMAL, MFLASH_CODE1, MFLASH_CODE2, MFlash_ReadResetCmd(), and Ok.

Here is the call graph for this function: