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 mirror 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 flash memory size is 0x1000.

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 in the buffer back to the flash memory. The default flash memory size is 0x1000.

Syntax
void update(bool erase = true);

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

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 from flash memory 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 and read a word to and from specific address. If the data to be written is different from the data read, then the buffer will be erased, and rewrite the correct data back.

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

Parameters
offset: offset to the base address
data: The data to be written

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.

Please confirm that QQ communication software is installed