libDaisy
Hardware Library for Daisy
daisy::QSPIHandle Class Reference

Detailed Description

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 ConfigGetConfig () 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
 
QSPIHandleoperator= (const QSPIHandle &other)=default
 

Member Enumeration Documentation

◆ Result

Enumerator
OK 
ERR 

◆ Status

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.

Parameters
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 

Constructor & Destructor Documentation

◆ QSPIHandle() [1/2]

daisy::QSPIHandle::QSPIHandle ( )
inline

◆ QSPIHandle() [2/2]

daisy::QSPIHandle::QSPIHandle ( const QSPIHandle other)
default

Member Function Documentation

◆ DeInit()

Result daisy::QSPIHandle::DeInit ( )

Deinitializes the peripheral This should be called before reinitializing QSPI in a different mode.

Returns
Result::OK or Result::ERR

◆ Erase()

Result daisy::QSPIHandle::Erase ( uint32_t  start_addr,
uint32_t  end_addr 
)

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*)

Parameters
start_addrAddress to begin erasing from
end_addrAddress to stop erasing at
Returns
Result::OK or Result::ERR

◆ EraseSector()

Result daisy::QSPIHandle::EraseSector ( uint32_t  address)

Erases a single sector of the chip.
TODO: Document the size of this function.

Parameters
addressAddress of sector to erase
Returns
Result::OK or Result::ERR

◆ GetConfig()

const Config & daisy::QSPIHandle::GetConfig ( ) const

Returns the current config.

◆ GetData()

void * daisy::QSPIHandle::GetData ( uint32_t  offset = 0)

Returns a pointer to the actual memory used The memory at this address is read-only to write to it use the Write function.

Parameters
offsetreturns the pointer starting this many bytes into the memory

◆ GetStatus()

Status daisy::QSPIHandle::GetStatus ( )

Returns the current class status. Useful for debugging.

Returns
Status

◆ Init()

Result daisy::QSPIHandle::Init ( const Config config)

Initializes QSPI peripheral, and Resets, and prepares memory for access.

Parameters
configshould be populated with the mode, device and pin_config before calling this function.
Returns
Result::OK or Result::ERR

◆ operator=()

QSPIHandle & daisy::QSPIHandle::operator= ( const QSPIHandle other)
default

◆ Write()

Result daisy::QSPIHandle::Write ( uint32_t  address,
uint32_t  size,
uint8_t *  buffer 
)

Writes data in buffer to to the QSPI. Starting at address to address+size

Parameters
addressAddress to write to
sizeBuffer size
bufferBuffer to write
Returns
Result::OK or Result::ERR

◆ WritePage()

Result daisy::QSPIHandle::WritePage ( uint32_t  address,
uint32_t  size,
uint8_t *  buffer 
)

Writes a single page to to the specified address on the QSPI chip. For IS25LP*, page size is 256 bytes.

Parameters
addressAddress to write to
sizeBuffer size
bufferBuffer to write
Returns
Result::OK or Result::ERR

The documentation for this class was generated from the following file: