Memory class.
More...
#include <hV_Memory.h>
|
| Memory (uint8_t kind=1, uint8_t bus=24) |
| Constructor.
|
|
void | begin (uint8_t pin) |
| Initialisation.
|
|
bool | test (uint32_t address=0, uint8_t data=0x5a) |
| Test memory and set number of dummy reads.
|
|
void | reset () |
| Reset default mode for SRAM and FRAM.
|
|
void | set (uint32_t address, uint8_t data) |
| Write one value.
|
|
void | writeEnableOnce () |
| Enable write for FRAM.
|
|
void | writeEnable () |
| Enable write for FRAM.
|
|
void | writeDisable () |
| Disable write for FRAM.
|
|
void | write (uint32_t address, const void *buffer, uint32_t length) |
| Write a buffer.
|
|
void | setMemory (uint32_t address, uint8_t data, uint32_t length) |
| Write one value on range.
|
|
void | copyMemory (uint32_t destination, uint32_t source, uint32_t length) |
| Write one value on range.
|
|
uint8_t | get (uint32_t address) |
| Read one value.
|
|
void | read (void *buffer, uint32_t address, uint32_t length) |
| Read a buffer.
|
|
void | clearBit (uint32_t address, uint8_t bit) |
| Clear bit in place.
|
|
void | setBit (uint32_t address, uint8_t bit) |
| Set bit in place.
|
|
uint8_t | readBit (uint32_t address, uint8_t bit) |
| Read bit in place.
|
|
void | debug (STRING_TYPE text, uint32_t address, uint32_t length=512, uint8_t line=32, uint8_t mark=8) |
| Debug memory.
|
|
Memory class.
for Flash, SRAM and FRAM
- Warning
- Does not manage SPI
◆ Memory()
Memory::Memory |
( |
uint8_t | kind = 1, |
|
|
uint8_t | bus = 24 ) |
Constructor.
- Parameters
-
kind | kind, default = MEMORY_FLASH |
kind | bus, default = BUS_24_BITS |
◆ begin()
void Memory::begin |
( |
uint8_t | pin | ) |
|
Initialisation.
- Parameters
-
pin | /CS pin, default = MEMORY_FLASH |
- Warning
- begin() does not initialise SPI
- Note
- begin() does not call SPI
Expected SPI parameters
- BitOrder: MSBFIRST
- DataMode: SPI_MODE0
- ClockDivider: SPI_CLOCK_DIV4 to get 4 MHz with SPI_CLOCK_MAX = 16000000
◆ clearBit()
void Memory::clearBit |
( |
uint32_t | address, |
|
|
uint8_t | bit ) |
Clear bit in place.
- Parameters
-
address | 16- or 24-bit address |
bit | bit to clear |
- Note
- For SRAM and FRAM only, not available for Flash
◆ copyMemory()
void Memory::copyMemory |
( |
uint32_t | destination, |
|
|
uint32_t | source, |
|
|
uint32_t | length ) |
Write one value on range.
- Parameters
-
destination | destination address starting 16- or 24-bit address |
source | source address starting 16- or 24-bit address |
length | number of bytes |
- Note
- Similar to memcpy
-
Not available for Flash
◆ debug()
void Memory::debug |
( |
STRING_TYPE | text, |
|
|
uint32_t | address, |
|
|
uint32_t | length = 512, |
|
|
uint8_t | line = 32, |
|
|
uint8_t | mark = 8 ) |
Debug memory.
- Parameters
-
text | message |
address | 16- or 24-bit address |
length | default = 512 bytes to read |
line | default = 32 bytes per line |
mark | display : every default = 8 bytes |
◆ get()
uint8_t Memory::get |
( |
uint32_t | address | ) |
|
Read one value.
- Parameters
-
address | 16- or 24-bit address |
- Returns
- uint8_t value
◆ read()
void Memory::read |
( |
void * | buffer, |
|
|
uint32_t | address, |
|
|
uint32_t | length ) |
Read a buffer.
- Parameters
-
[out] | buffer | buffer |
| address | starting 24-bit address |
| length | number of bytes |
◆ readBit()
uint8_t Memory::readBit |
( |
uint32_t | address, |
|
|
uint8_t | bit ) |
Read bit in place.
- Parameters
-
address | 16- or 24-bit address |
bit | bit to set |
◆ reset()
Reset default mode for SRAM and FRAM.
- Note
- Just in case
◆ set()
void Memory::set |
( |
uint32_t | address, |
|
|
uint8_t | data ) |
Write one value.
- Parameters
-
address | 24-bit address |
data | uint8_t value |
- Note
- For SRAM and FRAM only, not available for Flash
◆ setBit()
void Memory::setBit |
( |
uint32_t | address, |
|
|
uint8_t | bit ) |
Set bit in place.
- Parameters
-
address | 16- or 24-bit address |
bit | bit to set |
- Note
- For SRAM and FRAM only, not available for Flash
◆ setMemory()
void Memory::setMemory |
( |
uint32_t | address, |
|
|
uint8_t | data, |
|
|
uint32_t | length ) |
Write one value on range.
- Parameters
-
address | starting 16- or 24-bit address |
data | uint8_t value |
length | number of bytes |
- Note
- Similar to memset
-
For SRAM and FRAM only, not available for Flash
◆ test()
bool Memory::test |
( |
uint32_t | address = 0, |
|
|
uint8_t | data = 0x5a ) |
Test memory and set number of dummy reads.
- Parameters
-
address | address to test, default = 0 |
data | value to test, default = 0x5a = Z |
- Returns
- RESULT_SUCCESS if write-read successful, RESULT_FAILURE otherwise
- Note
- Not available for Flash
-
Number of dummy reads
- Flash: one
- FRAM: none
- SRAM: one, sometimes zero
◆ write()
void Memory::write |
( |
uint32_t | address, |
|
|
const void * | buffer, |
|
|
uint32_t | length ) |
Write a buffer.
- Parameters
-
| address | starting 16- or 24-bit address |
[in] | buffer | buffer |
| length | number of bytes |
- Note
- For SRAM and FRAM only, not available for Flash
◆ writeEnable()
void Memory::writeEnable |
( |
| ) |
|
Enable write for FRAM.
- Note
- Only valid for the next write
◆ writeEnableOnce()
void Memory::writeEnableOnce |
( |
| ) |
|
Enable write for FRAM.
- Note
- Valid for all next writes
The documentation for this class was generated from the following file: