Driver for QSPI peripheral to interface with external flash memory.
Currently supported QSPI Devices:
IS25LP080D
#include <qspi.h>
Classes | |
struct | Config |
Public Types | |
enum | Result { OK = 0 , ERR } |
enum | Status { GOOD = 0 , E_HAL_ERROR , E_SWITCHING_MODES , E_INVALID_MODE } |
Public Member Functions | |
Result | Init (const Config &config) |
const Config & | GetConfig () const |
Result | DeInit () |
Result | WritePage (uint32_t address, uint32_t size, uint8_t *buffer) |
Result | Write (uint32_t address, uint32_t size, uint8_t *buffer) |
Result | Erase (uint32_t start_addr, uint32_t end_addr) |
Result | EraseSector (uint32_t address) |
Status | GetStatus () |
void * | GetData (uint32_t offset=0) |
QSPIHandle () | |
QSPIHandle (const QSPIHandle &other)=default | |
QSPIHandle & | operator= (const QSPIHandle &other)=default |
Indicates the current status of the module. Warnings are indicated by a leading W. Errors are indicated by a leading E and cause an immediate exit.
GOOD | - No errors have been reported. |
E_HAL_ERROR | - HAL code did not return HAL_OK. |
E_SWITCHING_MODES | - An error was encountered while switching QSPI peripheral mode. |
E_INVALID_MODE | - QSPI should not be written to while the program is executing from it. |
Enumerator | |
---|---|
GOOD | |
E_HAL_ERROR | |
E_SWITCHING_MODES | |
E_INVALID_MODE |
|
inline |
|
default |
Result daisy::QSPIHandle::DeInit | ( | ) |
Deinitializes the peripheral This should be called before reinitializing QSPI in a different mode.
Erases the area specified on the chip. Erasures will happen by 4K, 32K or 64K increments. Smallest erase possible is 4kB at a time. (on IS25LP*)
start_addr | Address to begin erasing from |
end_addr | Address to stop erasing at |
Erases a single sector of the chip.
TODO: Document the size of this function.
address | Address of sector to erase |
Returns a pointer to the actual memory used The memory at this address is read-only to write to it use the Write function.
offset | returns the pointer starting this many bytes into the memory |
Status daisy::QSPIHandle::GetStatus | ( | ) |
Returns the current class status. Useful for debugging.
Initializes QSPI peripheral, and Resets, and prepares memory for access.
config | should be populated with the mode, device and pin_config before calling this function. |
|
default |
Writes data in buffer to to the QSPI. Starting at address to address+size
address | Address to write to |
size | Buffer size |
buffer | Buffer to write |
Writes a single page to to the specified address on the QSPI chip. For IS25LP*, page size is 256 bytes.
address | Address to write to |
size | Buffer size |
buffer | Buffer to write |