CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
stm32_internal_flash_drivers.h File Reference
#include <stdint.h>
#include "stm32l4xx_hal.h"
#include "stm32l4xx_hal_flash.h"
Include dependency graph for stm32_internal_flash_drivers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  STM32_Internal_Flash_Write_Status_t
 

Enumerations

enum  STM32_INTERNAL_FLASH_memory_region_addresses_t {
  STM32_INTERNAL_FLASH_MEMORY_REGION_RAM_ADDRESS = 0x20000000 , STM32_INTERNAL_FLASH_MEMORY_REGION_RAM_2_ADDRESS = 0x10000000 , STM32_INTERNAL_FLASH_MEMORY_REGION_RAM_3_ADDRESS = 0x20040000 , STM32_INTERNAL_FLASH_MEMORY_REGION_FLASH_ADDRESS = 0x8000000 ,
  STM32_INTERNAL_FLASH_MEMORY_REGION_GOLDEN_COPY_ADDRESS = 0x08100000
}
 Flash Partitions. More...
 

Functions

uint8_t STM32_internal_flash_write (uint32_t address, uint8_t *data, uint32_t length, STM32_Internal_Flash_Write_Status_t *status)
 Writes data to the flash memory in chunks of 8 bytes.
 
uint8_t STM32_internal_flash_read (uint32_t address, uint8_t *buffer, uint32_t length)
 Reads data from the flash memory.
 
uint8_t STM32_internal_flash_erase (uint16_t start_page_erase, uint16_t number_of_pages_to_erase, uint32_t *page_error)
 Erase pages from bank 2 of flash memory which is located at 0x08100000.
 
uint8_t STM32_internal_flash_get_option_bytes (FLASH_OBProgramInitTypeDef *ob_data)
 Gets option bytes configuration from the stm32 internal flash memory.
 
uint8_t STM32_internal_flash_set_active_flash_bank (uint8_t wanted_active_flash_bank)
 Sets the active flash bank to either 1 or 2 (only if it is different than the current active flash bank).
 
uint8_t STM32_internal_flash_get_active_flash_bank ()
 Returns active flash bank.
 

Enumeration Type Documentation

◆ STM32_INTERNAL_FLASH_memory_region_addresses_t

Flash Partitions.

Note
look in the STM32L4R5ZITx_FLASH.ld file to see the address of each partition, update this as needed
Enumerator
STM32_INTERNAL_FLASH_MEMORY_REGION_RAM_ADDRESS 
STM32_INTERNAL_FLASH_MEMORY_REGION_RAM_2_ADDRESS 
STM32_INTERNAL_FLASH_MEMORY_REGION_RAM_3_ADDRESS 
STM32_INTERNAL_FLASH_MEMORY_REGION_FLASH_ADDRESS 
STM32_INTERNAL_FLASH_MEMORY_REGION_GOLDEN_COPY_ADDRESS 

Function Documentation

◆ STM32_internal_flash_erase()

uint8_t STM32_internal_flash_erase ( uint16_t start_page_erase,
uint16_t number_of_pages_to_erase,
uint32_t * page_error )

Erase pages from bank 2 of flash memory which is located at 0x08100000.

Parameters
start_page_erasewhat page to start erasing from
number_of_pages_to_erasehow many pages to erase
page_erroraddress of page which failed on error, defaults to UINT32_MAX on success
Returns
0 on success, 1 if HAL_FLASH_Unlock() failed, 2 if HAL_FLASH_Lock() failed
Here is the caller graph for this function:

◆ STM32_internal_flash_get_active_flash_bank()

uint8_t STM32_internal_flash_get_active_flash_bank ( )

Returns active flash bank.

Returns
1 is Flash Bank 1, 2 is Flash Bank 2
Here is the caller graph for this function:

◆ STM32_internal_flash_get_option_bytes()

uint8_t STM32_internal_flash_get_option_bytes ( FLASH_OBProgramInitTypeDef * ob_data)

Gets option bytes configuration from the stm32 internal flash memory.

Parameters
ob_datapointer to an FLASH_OBProgramInitTypeDef structure that contains the configuration information for the programming.
Returns
0 always
Here is the caller graph for this function:

◆ STM32_internal_flash_read()

uint8_t STM32_internal_flash_read ( uint32_t address,
uint8_t * buffer,
uint32_t length )

Reads data from the flash memory.

Parameters
addressaddress to start reading from
bufferbuffer to store the read data, must be length long
lengthnumber of bytes to read
Returns
0 on success, > 0 on error
Here is the caller graph for this function:

◆ STM32_internal_flash_set_active_flash_bank()

uint8_t STM32_internal_flash_set_active_flash_bank ( uint8_t wanted_active_flash_bank)

Sets the active flash bank to either 1 or 2 (only if it is different than the current active flash bank).

On Success, will load application in desired flash bank

By Default, the active flash bank is 1

Parameters
wanted_active_flash_bank1 or 2
Returns
0 on success, > 0 otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ STM32_internal_flash_write()

uint8_t STM32_internal_flash_write ( uint32_t address,
uint8_t * data,
uint32_t length,
STM32_Internal_Flash_Write_Status_t * status )

Writes data to the flash memory in chunks of 8 bytes.

Parameters
addressAddress in the flash memory where the data will be written.
datauint8_t buffer containing the data to be written.
lengthLength of the data to be written.
Returns
0 on success, > 0 on error
Note
Currently, only allowed to write to golden copy region
Writes data in chunks of 8 bytes. Ex: Suppose we wanted to write to address 0x00, and suppose that at address 0x00, the first 8 bytes looks like the following: [1,2,3,4,5,6,7,8]. If we wanted to write [25,26,27,28], it would result in the following: [25,26,27,28,0,0,0,0], clearing the rest of the bytes.
Here is the caller graph for this function: