FlashMemoryClass Class

FlashMemoryClass Class

Description
A class for Flash memory API.

Syntax
class FlashMemoryClass

Members

Public Constructors 
FlashMemoryClass::FlashMemoryClassConstructs a FlashMemoryClass object.
Public Methods 
FlashMemoryClass::beginInitialize/Re-initialize the base address and size.
FlashMemoryClass::readRead content from flash memory to buffer.
FlashMemoryClass::updateWrite the content in the buffer back to the flash memory
FlashMemoryClass::readWordRead 4 bytes from flash memory based on the new base address with specific offset.
FlashMemoryClass::writeWordWrite word to flash memory.

FlashMemoryClass::FlashMemoryClass

Description
Constructs a FlashMemoryClass object.

Syntax
FlashMemoryClass(unsigned int _base_address, unsigned int _buf_size);

Parameters
_base_address: The starting location/position of the flash memory area
_buf_size: The buf size for mirroring a copy to reduce flash memory operation

Returns
NA

Example Code
Example: FleshMemory_Basic
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/FlashMemory/examples/FlashMemory_Basic/FlashMemory_Basic.ino)

Notes and Warnings
“FlashMemory.h” must be included to use the class function.

FlashMemoryClass::begin

Description
Initialize/Re-initialize the base address and size. The default flash memory size is 0x1000.

Syntax
void begin(unsigned int _base_address, unsigned int _buf_size);

Parameters
_base_address: The starting location/position of the flash memory area
_buf_size: The desired buffer size

Returns
NA

Example Code
Example: FleshMemory_Basic
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/FlashMemory/examples/FlashMemory_Basic/FlashMemory_Basic.ino)

Notes and Warnings
“FlashMemory.h” must be included to use the class function.

FlashMemoryClass::read

Description
When read() is called, contents will be read from the flash memory and copy into a buffer. All modification of the contents will be done in the buffer before updating the flash memory. The default length of the data to read is 0x1000 (flash sector size).

Syntax
void read(void);

Parameters
NA

Returns
NA

Example Code
Example: FleshMemory_Basic
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/FlashMemory/examples/FlashMemory_Basic/FlashMemory_Basic.ino)

Notes and Warnings
“FlashMemory.h” must be included to use the class function.

FlashMemoryClass::update

Description
Write the content of the buffer into the flash memory. The default length of the data is 0x1000 (flash sector size).

Syntax
void update(bool erase = true);

Parameters
erase: It is set to true by default and erases flash memory before writing.

Returns
NA

Example Code
Example: FleshMemory_Basic
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/FlashMemory/examples/FlashMemory_Basic/FlashMemory_Basic.ino)

Notes and Warnings
“FlashMemory.h” must be included to use the class function.

FlashMemoryClass::readWord

Description
Read 4 bytes data (a word) from a flash address, based on the new base address with specific offset.

Syntax
unsigned int readWord(unsigned int offset);

Parameters
offset: offset to the base address.

Returns
This function returns the 4 bytes read data.

Example Code
Example: ReadWriteOneWord
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/FlashMemory/examples/ReadWriteOneWord/ReadWriteOneWord.ino)

Notes and Warnings
“FlashMemory.h” must be included to use the class function.

FlashMemoryClass::writeWord

Description
Write 4 bytes data (a word) to a flash address, based on the new base address with specific offset. Then read data from the address and compare with the origianl data. If there is difference. Buffer a flash sector from the new base address, then erase the sector from the flash. Replace the correct data back into buffer. Then rewrite the buffer in to the flash.

Syntax
void writeWord(unsigned int offset, unsigned int data);

Parameters
offset: offset to the base address
data: The data to be written (4 bytes / a word)

Returns
NA

Example Code
Example: ReadWriteOneWord
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/FlashMemory/examples/ReadWriteOneWord/ReadWriteOneWord.ino)

Notes and Warnings
“FlashMemory.h” must be included to use the class function.

Copyrights ©瑞晟微电子(苏州)有限公司 2021. All rights reserved. 使用条款
请先确认已安装QQ通讯软体