PER Firmware
Loading...
Searching...
No Matches
flash_priv.h File Reference

STM32G4 internal-flash register-level implementation interface. More...

#include <stdbool.h>
#include <stdint.h>
Include dependency graph for flash_priv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  flash_operation_context_t
 

Functions

bool FLASH_PRIV_begin_read (void)
 Acquire the flash operation lock, wait for idle, and clear status.
 
bool FLASH_PRIV_end_read (void)
 Finish a read operation and release the operation lock.
 
bool FLASH_PRIV_begin_operation (flash_operation_context_t *context)
 Prepare the controller for programming or page erase.
 
bool FLASH_PRIV_end_operation (const flash_operation_context_t *context)
 Finalize a completed operation, restore cache state, lock the controller, and release the operation lock.
 
uint32_t FLASH_PRIV_get_size_bytes (void)
 Read the device-reported internal flash capacity.
 
uint32_t FLASH_PRIV_get_page_size_bytes (void)
 Determine the active page size from the dual-bank option bit.
 
bool FLASH_PRIV_program_double_word (uint32_t address, uint64_t data)
 Program one STM32G4 double word.
 
bool FLASH_PRIV_erase_page (uint32_t page_address)
 Erase one complete flash page.
 

Detailed Description

STM32G4 internal-flash register-level implementation interface.

Author
Ronak Jain (jain7.nosp@m.17@p.nosp@m.urdue.nosp@m..edu)

Only flash.c and flash_priv.c should include this header. The public API operates on byte ranges; this interface owns controller lock, cache, bank, page, and status-register details.

Function Documentation

◆ FLASH_PRIV_begin_operation()

bool FLASH_PRIV_begin_operation ( flash_operation_context_t * context)

Prepare the controller for programming or page erase.

This validates the operating voltage, waits for idle, disables data cache, unlocks the controller, and clears stale status flags.

Parameters
contextOutput cache state restored by FLASH_PRIV_end_operation().
Returns
true when the controller is ready; false when unavailable or invalid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_PRIV_begin_read()

bool FLASH_PRIV_begin_read ( void )

Acquire the flash operation lock, wait for idle, and clear status.

Returns
true when a read operation may proceed; false if already in use or the busy wait times out.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_PRIV_end_operation()

bool FLASH_PRIV_end_operation ( const flash_operation_context_t * context)

Finalize a completed operation, restore cache state, lock the controller, and release the operation lock.

Parameters
contextCache state returned by FLASH_PRIV_begin_operation().
Returns
true when the controller is idle, error-free, and locked again.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_PRIV_end_read()

bool FLASH_PRIV_end_read ( void )

Finish a read operation and release the operation lock.

Returns
true when no flash error flags were set.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_PRIV_erase_page()

bool FLASH_PRIV_erase_page ( uint32_t page_address)

Erase one complete flash page.

The page number and bank are derived from the absolute page address and the current device bank configuration.

Parameters
page_addressAddress of the page start.
Returns
true when erase completes without a flash error.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_PRIV_get_page_size_bytes()

uint32_t FLASH_PRIV_get_page_size_bytes ( void )

Determine the active page size from the dual-bank option bit.

Returns
2 KiB for dual-bank mode or 4 KiB for single-bank mode.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_PRIV_get_size_bytes()

uint32_t FLASH_PRIV_get_size_bytes ( void )

Read the device-reported internal flash capacity.

Returns
Flash size in bytes, using the supported-device fallback if invalid.
Here is the caller graph for this function:

◆ FLASH_PRIV_program_double_word()

bool FLASH_PRIV_program_double_word ( uint32_t address,
uint64_t data )

Program one STM32G4 double word.

Parameters
address8-byte-aligned flash destination.
data64-bit value written low word first.
Returns
true when programming completes without a flash error.
Here is the call graph for this function:
Here is the caller graph for this function: