Functions
Local Flash Functions
SYSTEM » Non-Volatile Data Storage
Collaboration diagram for Local Flash Functions:

## Functions
bool | local_hal_flash_erase_chip (void)
| Flash operation API based on hal flash. More...
bool | local_hal_flash_erase (const uint32_t addr, const uint32_t size)
| Erase flash region. More...
uint32_t | local_hal_flash_write (const uint32_t addr, const uint8_t *buf, const uint32_t size)
| Write flash Memory. More...
uint32_t | local_hal_flash_read (const uint32_t addr, uint8_t *buf, const uint32_t size)
| Read flash Memory. More...
void | local_hal_flash_get_info (uint32_t *id, uint32_t *size)
| Get Flash information. More...
bool | local_hal_flash_get_security (void)
| Get encrypted and decrypted status in write-read operations. More...
void | local_hal_flash_set_security (bool enable)
| Enable encrypted and decrypted in write-read operations. More...
uint32_t | local_hal_flash_write_r (const uint32_t addr, const uint8_t *buf, const uint32_t size)
| Write flash Memory reliably. More...

## Detailed Description

## Function Documentation

## ◆ local_hal_flash_erase()

bool local_hal_flash_erase | ( | const uint32_t | addr,
|  | const uint32_t | size
| ) |  |

Erase flash region.

Note
  All sectors that have address in range of [addr, addr+len] will be erased. If addr is not sector aligned, preceding data on the sector that addr belongs to will also be erased. If (addr + size) is not sector aligned, the whole sector will also be erased.

Parameters

  [in] | addr | start address in flash to write data to.
  [in] | size | number of bytes to write.

Returns
  true if successful.
  false if not successful.

## ◆ local_hal_flash_erase_chip()

bool local_hal_flash_erase_chip | ( | void |  | ) |

Flash operation API based on hal flash.

Erase flash chip.

Returns
  true if successful.
  false if not successful.

## ◆ local_hal_flash_get_info()

void local_hal_flash_get_info | ( | uint32_t * | id,
|  | uint32_t * | size
| ) |  |

Get Flash information.

Parameters

  [in,out] | id | Pointer to flash id.
  [in,out] | size | Pointer to flash size.

## ◆ local_hal_flash_get_security()

bool local_hal_flash_get_security | ( | void |  | ) |

Get encrypted and decrypted status in write-read operations.

Returns
  true Enable encrypted and decrypted.
  false Disable encrypted and decrypted.

## ◆ local_hal_flash_read()

uint32_t local_hal_flash_read | ( | const uint32_t | addr,
|  | uint8_t * | buf,
|  | const uint32_t | size
| ) |  |

Read flash Memory.

Parameters

  [in] | addr | start address in flash to read data.
  [in,out] | buf | buffer to read data to.
  [in] | size | number of bytes to read.

Returns
  number of bytes read

## ◆ local_hal_flash_set_security()

void local_hal_flash_set_security | ( | bool | enable | ) |

Enable encrypted and decrypted in write-read operations.

Parameters

  [in] | enable | control encrypted and decrypte.

## ◆ local_hal_flash_write()

uint32_t local_hal_flash_write | ( | const uint32_t | addr,
|  | const uint8_t * | buf,
|  | const uint32_t | size
| ) |  |

Write flash Memory.

Parameters

  [in] | addr | start address in flash to write data to.
  [in,out] | buf | buffer of data to write.
  [in] | size | number of bytes to write.

Returns
  number of bytes written

## ◆ local_hal_flash_write_r()

uint32_t local_hal_flash_write_r | ( | const uint32_t | addr,
|  | const uint8_t * | buf,
|  | const uint32_t | size
| ) |  |

Write flash Memory reliably.

Note
  It's possible that the data was not written into Flash Memory successfully. This function reads the data from Flash Memory to check the reliability of programming Flash Memory.

Parameters

  [in] | addr | start address in flash to write data to.
  [in,out] | buf | buffer of data to write.
  [in] | size | number of bytes to write.

Returns
  number of bytes written