semf
|
This Class is for read and write data in the internal flash from the Stm32. More...
#include <stm32flash.h>
Public Types | |
enum class | ErrorCode : uint8_t { Write_IsBusy = 0 , Write_DataIsNullptr , Write_DataSizeIsZero , Write_DataNot8ByteAligned , Write_DataNot4ByteAligned , Write_DataNot2ByteAligned , Write_HalError , Write_HalBusy , Write_HalTimeout , Read_IsBusy = 0 , Read_BufferIsNullptr , Read_BufferSizeIsZero , Erase_IsBusy , Erase_SectorOutOfBounds , Erase_IsHalError , Erase_IsHalBusy , Erase_IsHalTimeout , Isr_HalError , Isr_HalBusy , Isr_HalTimeout , IsrError_InterruptError } |
Public Member Functions | |
Stm32Flash (uint16_t size, uint32_t voltageRange, uint32_t bank) | |
Constructor. More... | |
Stm32Flash (uint16_t size, uint32_t bank) | |
Constructor. More... | |
Stm32Flash (uint16_t size) | |
Constructor. More... | |
Stm32Flash (const Stm32Flash &other)=delete | |
virtual | ~Stm32Flash ()=default |
void | write (uint32_t address, const uint8_t data[], size_t dataSize) override |
Writes data into the storage. More... | |
void | read (uint32_t address, uint8_t buffer[], size_t bufferSize) override |
Reads data from the storage into a given read buffer. More... | |
void | erase (size_t sector, size_t numOfSectors=1) override |
Erase sector(s). More... | |
bool | isBusy () const override |
Returns if the storage is busy reading, writing or e.g. erasing. More... | |
Public Member Functions inherited from semf::app::Flash | |
virtual | ~Flash ()=default |
virtual void | erase (size_t sector, size_t numOfSectors=1)=0 |
Erase sector(s). More... | |
virtual size_t | sector (uint32_t address) const =0 |
Return in which sector an address is located. More... | |
virtual uint32_t | address (size_t sector) const =0 |
Return on which address a sector starts. More... | |
virtual size_t | sectorSize (size_t sector) const =0 |
Return the size of a sector in bytes. More... | |
virtual size_t | numberOfSectors () const =0 |
Return the number/amount of sectors of a flash memory. More... | |
Public Member Functions inherited from semf::app::Storage | |
virtual | ~Storage ()=default |
virtual void | write (uint32_t address, const uint8_t data[], size_t dataSize)=0 |
Writes data into the storage. More... | |
virtual void | read (uint32_t address, uint8_t buffer[], size_t bufferSize)=0 |
Reads data from the storage into a given read buffer. More... | |
virtual bool | isBusy () const =0 |
Returns if the storage is busy reading, writing or e.g. erasing. More... | |
Static Public Member Functions | |
static void | isr () |
This function must be called from isr. More... | |
static void | isrError () |
This function is call from isr when an error has occurred. More... | |
Protected Member Functions | |
uint16_t | size () const |
Returns the size of the flash in kBytes. More... | |
Additional Inherited Members | |
Public Attributes inherited from semf::app::Flash | |
Signal | erased |
Public Attributes inherited from semf::app::Storage | |
Signal | dataAvailable |
Signal | dataWritten |
Signal< Error > | error |
This Class is for read and write data in the internal flash from the Stm32.
Definition at line 25 of file stm32flash.h.
|
strong |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).
Definition at line 29 of file stm32flash.h.
semf::Stm32Flash::Stm32Flash | ( | uint16_t | size, |
uint32_t | voltageRange, | ||
uint32_t | bank | ||
) |
Constructor.
size | Flash size in kBytes. |
voltageRange | Operating voltage range. See microcontroller user manual for HAL and LL drivers in flash extension driver section. |
bank | Flash bank which is used. |
Definition at line 31 of file stm32flash.cpp.
semf::Stm32Flash::Stm32Flash | ( | uint16_t | size, |
uint32_t | bank | ||
) |
Constructor.
size | Flash size in kBytes. |
bank | Flash bank which is used. |
Definition at line 39 of file stm32flash.cpp.
|
explicit |
|
explicitdelete |
|
virtualdefault |
|
overridevirtual |
Erase sector(s).
sector | The numerical order of the targeted sector. |
numOfSectors | Amount of sectors to be erased. |
Erase_IsBusy | If this is busy |
Erase_SectorOutOfBounds | If sector does not exist |
Erase_IsHalError | If the ST-HAL returns hal error. |
Erase_IsHalBusy | If the ST-HAL returns hal busy. |
Erase_IsHalTimeout | If the ST-HAL returns hal timeout. |
Implements semf::app::Flash.
Definition at line 145 of file stm32flash.cpp.
|
overridevirtual |
Returns if the storage is busy reading, writing or e.g. erasing.
true
for busy, otherwise false
. Implements semf::app::Storage.
Definition at line 205 of file stm32flash.cpp.
|
static |
This function must be called from isr.
Isr_HalError | If the ST-HAL returns hal error. |
Isr_HalBusy | If the ST-HAL returns hal busy. |
Isr_HalTimeout | If the ST-HAL returns hal timeout. |
Definition at line 288 of file stm32flash.cpp.
|
static |
This function is call from isr when an error has occurred.
IsrError_InterruptError | If a unexpected error occurres. |
Definition at line 382 of file stm32flash.cpp.
|
overridevirtual |
Reads data from the storage into a given read buffer.
dataAvailable
signal will be emitted for all data are read. error
signal will be emitted if an error occurred.address | The address from which the data will be read. |
buffer | Pointer at which the read data is stored. |
bufferSize | Size of the data to be read in bytes. |
Read_IsBusy | If this is busy. |
Read_BufferIsNullptr | If buffer is a nullptr |
Read_BufferSizeIsZero | If bufferSize is zero. |
Implements semf::app::Storage.
Definition at line 86 of file stm32flash.cpp.
|
protected |
Returns the size of the flash in kBytes.
Definition at line 390 of file stm32flash.cpp.
|
overridevirtual |
Writes data into the storage.
dataWritten
signal will be emitted for all data are written. error
signal will be emitted if an error occurred.address | The address where the data will be written to. |
data | Pointer to the data to be written. |
dataSize | Size of data to be written in bytes. |
Write_IsBusy | If this is busy. |
Write_DataIsNullptr | If data is a nullptr. |
Write_DataSizeIsZero | If dataSize is zero. |
Write_DataNot4ByteAligned | If the dataSize is not a multiple of 4 (only STM32L0) |
Write_DataNot2byteAligned | If the dataSize is not a multiple of 2 (only STM32F1 & STM32F3) |
Write_HalError | If the ST-HAL returns hal error. |
Write_HalBusy | If the ST-HAL returns hal busy. |
Write_HalTimeout | If the ST-HAL returns hal timeout. |
Implements semf::app::Storage.
Definition at line 55 of file stm32flash.cpp.