L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
flash_at25.h File Reference
#include "stm32wlxx_hal.h"
Include dependency graph for flash_at25.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  flash_at25CS_t
 Configuration and state descriptor for one AT25EU0041A flash chip. Pass a pointer to this struct to every flash_at25_XXX function. Populate the IN fields before calling flash_at25_Init(); the OUT fields are filled by the initialisation routine. More...

Macros

#define AT25_MANUFACTURER_ID   0x1F
#define AT25_MEMSIZE   (1<<19)

Functions

int8_t flash_at25_Is (flash_at25CS_t *s, int8_t tryInit)
 
  • check if flash chip is present or not

HAL_StatusTypeDef flash_at25_Init (flash_at25CS_t *s)
 Initialization for AT25EU0041A flash chip Performs proper device identification and verification Suitable for frequent operations with improved error checking.
HAL_StatusTypeDef flash_at25_Read (const flash_at25CS_t *s, uint32_t addr, void *buffer, uint16_t size)
 Fast read from flash memory Uses fast read command (0x0B) for improved performance in frequent read operations Includes boundary checking and ready state verification.
HAL_StatusTypeDef flash_at25_Write (const flash_at25CS_t *s, uint32_t addr, const void *data, uint16_t size)
 Write to flash memory with sector preservation Handles page-aligned writes efficiently with proper verification Preserves existing data in flash sectors by reading, modifying, and writing back.

Macro Definition Documentation

◆ AT25_MANUFACTURER_ID

#define AT25_MANUFACTURER_ID   0x1F

Definition at line 23 of file flash_at25.h.

Referenced by flash_at25_Init().

◆ AT25_MEMSIZE

#define AT25_MEMSIZE   (1<<19)

Definition at line 24 of file flash_at25.h.

Referenced by flash_at25_Init(), and mens_MainBlockInit().

Function Documentation

◆ flash_at25_Init()

HAL_StatusTypeDef flash_at25_Init ( flash_at25CS_t * s)

Initialization for AT25EU0041A flash chip Performs proper device identification and verification Suitable for frequent operations with improved error checking.

Parameters
sPointer to flash configuration structure
Return values
HAL_OKif device identified correctly, HAL_ERROR otherwise

Definition at line 98 of file flash_at25.c.

References AT25_MANUFACTURER_ID, AT25_MEMSIZE, CMD_READ_ID, flash_Select(), flash_Unselect(), flash_at25CS_t::Is, flash_at25CS_t::Size, and flash_at25CS_t::Spi.

Referenced by flash_at25_Is(), and mems_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flash_at25_Is()

int8_t flash_at25_Is ( flash_at25CS_t * s,
int8_t tryInit )

  • check if flash chip is present or not

Parameters
tryInit- in case sensor is not yet initialized, 1 - attempt to initialize again, 0 - no

Definition at line 133 of file flash_at25.c.

References flash_at25_Init(), and flash_at25CS_t::Is.

Here is the call graph for this function:

◆ flash_at25_Read()

HAL_StatusTypeDef flash_at25_Read ( const flash_at25CS_t * s,
uint32_t addr,
void * buffer,
uint16_t size )

Fast read from flash memory Uses fast read command (0x0B) for improved performance in frequent read operations Includes boundary checking and ready state verification.

Parameters
sPointer to flash configuration structure
addrStarting address to read from (24-bit address, 0x000000 to 0x07FFFF for 512KB)
bufferPointer to destination buffer
sizeNumber of bytes to read
Return values
HAL_OKon success, HAL_ERROR on failure, HAL_TIMEOUT on timeout

Definition at line 140 of file flash_at25.c.

References CMD_FAST_READ, flash_Select(), flash_Unselect(), flashNew_WaitReadyWithTimeout(), flash_at25CS_t::Is, and flash_at25CS_t::Spi.

Referenced by flash_at25_Write(), flash_WritePage(), mems_Check(), mems_GetLastData(), and mems_ReadMainBlock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flash_at25_Write()

HAL_StatusTypeDef flash_at25_Write ( const flash_at25CS_t * s,
uint32_t addr,
const void * data,
uint16_t size )

Write to flash memory with sector preservation Handles page-aligned writes efficiently with proper verification Preserves existing data in flash sectors by reading, modifying, and writing back.

This function implements a read-modify-write approach:

  1. Calculates which 256 Page needs to be erased based on addr & size
  2. For each affected Page: reads it, resets bytes to 0xFF where new data will be written
  3. Erases the sector and writes back the modified sector data
  4. Then writes the new data to the prepared sectors

Handles sector boundaries automatically - if data crosses sector boundary, both sectors are processed

Includes boundary checking, write enable verification, and proper timeout handling

Parameters
sPointer to flash configuration structure
addrStarting address to write to (24-bit address, 0x000000 to 0x07FFFF for 512KB)
dataPointer to source data buffer
sizeNumber of bytes to write
Return values
HAL_OKon success, HAL_ERROR on failure, HAL_TIMEOUT on timeout

Definition at line 229 of file flash_at25.c.

References Error_Handler(), flash_at25_Read(), flash_WritePage(), and writeLog().

Referenced by mems_AddData(), mems_Reset(), and mems_WriteMainBlock().

Here is the call graph for this function:
Here is the caller graph for this function: