Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
FlashVariableSectors Struct Reference

Strategy module for finding flash erase sector numbers when the sectors are different sizes. More...

#include <Stm32Flash.hxx>

Inheritance diagram for FlashVariableSectors:
Stm32Flash< FlashVariableSectors >

Public Member Functions

constexpr FlashVariableSectors (uint32_t *bank_config)
 bank_config is an array of uint32 addresses, containing the start of each sector.
 
uint32_t next_sector_address (uint32_t addr)
 Aligns an address to the next possible sector start (i.e., rounds up to sector boundary).
 
std::pair< unsigned, uint32_t > lookup_sector (uint32_t addr)
 Lookup the next sector for an address, and return the {sector number, address} pair.
 

Protected Attributes

unsigned lastIndex_ {0}
 1-element cache on where to start looking for sectors.
 

Private Attributes

uint32_t * bankConfig_
 Contains an array of the start addresses of the erase sectors.
 

Detailed Description

Strategy module for finding flash erase sector numbers when the sectors are different sizes.

Definition at line 73 of file Stm32Flash.hxx.

Constructor & Destructor Documentation

◆ FlashVariableSectors()

constexpr FlashVariableSectors::FlashVariableSectors ( uint32_t *  bank_config)
inlineconstexpr

bank_config is an array of uint32 addresses, containing the start of each sector.

The sector number is the index in this array. As a sentinel, the element after the last shall be 0xfffffffful.

Definition at line 78 of file Stm32Flash.hxx.

Member Function Documentation

◆ lookup_sector()

std::pair< unsigned, uint32_t > FlashVariableSectors::lookup_sector ( uint32_t  addr)
inline

Lookup the next sector for an address, and return the {sector number, address} pair.

Definition at line 110 of file Stm32Flash.hxx.

◆ next_sector_address()

uint32_t FlashVariableSectors::next_sector_address ( uint32_t  addr)
inline

Aligns an address to the next possible sector start (i.e., rounds up to sector boundary).

Parameters
addran address in the flash address space.
Returns
If addr is the first byte of a sector, then returns addr unmodified. Otherwise returns the starting address of the next sector.

Definition at line 87 of file Stm32Flash.hxx.

Member Data Documentation

◆ bankConfig_

uint32_t* FlashVariableSectors::bankConfig_
private

Contains an array of the start addresses of the erase sectors.

Definition at line 123 of file Stm32Flash.hxx.

◆ lastIndex_

unsigned FlashVariableSectors::lastIndex_ {0}
protected

1-element cache on where to start looking for sectors.

bankConfig_[lastIndex_] <= last address that was queried.

Definition at line 119 of file Stm32Flash.hxx.


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