|
L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
|
Go to the source code of this file.
Macros | |
| #define | CMD_READ_ID 0x9F |
| #define | CMD_READ_DATA 0x03 |
| #define | CMD_FAST_READ 0x0B |
| #define | CMD_PAGE_PROG 0x02 |
| #define | CMD_WRITE_ENABLE 0x06 |
| #define | CMD_WRITE_DISABLE 0x04 |
| #define | CMD_READ_STATUS 0x05 |
| #define | CMD_PAGE_ERASE 0x81 |
| #define | SR_WIP 0x01 |
| #define | SR_WEL 0x02 |
| #define | FLASH_TIMEOUT 10000 |
Functions | |
| static void | flash_Select (const flash_at25CS_t *s) |
| static void | flash_Unselect (const flash_at25CS_t *s) |
| static HAL_StatusTypeDef | flashNew_WaitReadyWithTimeout (const flash_at25CS_t *s) |
| Helper function to wait for flash ready with timeout protection Optimized for frequent operations with proper timeout and CS handling. | |
| static HAL_StatusTypeDef | flashNew_WriteEnableVerified (const flash_at25CS_t *s) |
| Helper function to enable write with verification Ensures write enable latch is properly set. | |
| 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. | |
| int8_t | flash_at25_Is (flash_at25CS_t *s, int8_t tryInit) |
| |
| 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. | |
| static HAL_StatusTypeDef | flash_WritePage (const flash_at25CS_t *s, uint32_t addr, const uint8_t *data, uint16_t size) |
| write data to 256 bounder with erase of page | |
| 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. | |
Variables | |
| static uint8_t | _buffer256 [256] = {} |
| #define CMD_FAST_READ 0x0B |
Definition at line 8 of file flash_at25.c.
Referenced by flash_at25_Read().
| #define CMD_PAGE_ERASE 0x81 |
Definition at line 13 of file flash_at25.c.
Referenced by flash_WritePage().
| #define CMD_PAGE_PROG 0x02 |
Definition at line 9 of file flash_at25.c.
Referenced by flash_WritePage().
| #define CMD_READ_DATA 0x03 |
Definition at line 7 of file flash_at25.c.
| #define CMD_READ_ID 0x9F |
Definition at line 6 of file flash_at25.c.
Referenced by flash_at25_Init().
| #define CMD_READ_STATUS 0x05 |
Definition at line 12 of file flash_at25.c.
Referenced by flashNew_WaitReadyWithTimeout(), and flashNew_WriteEnableVerified().
| #define CMD_WRITE_DISABLE 0x04 |
Definition at line 11 of file flash_at25.c.
| #define CMD_WRITE_ENABLE 0x06 |
Definition at line 10 of file flash_at25.c.
Referenced by flashNew_WriteEnableVerified().
| #define FLASH_TIMEOUT 10000 |
Definition at line 20 of file flash_at25.c.
Referenced by flashNew_WaitReadyWithTimeout().
| #define SR_WEL 0x02 |
Definition at line 17 of file flash_at25.c.
Referenced by flashNew_WriteEnableVerified().
| #define SR_WIP 0x01 |
Definition at line 16 of file flash_at25.c.
Referenced by flashNew_WaitReadyWithTimeout().
| 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.
| s | Pointer to flash configuration structure |
| HAL_OK | if 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().
| int8_t flash_at25_Is | ( | flash_at25CS_t * | s, |
| int8_t | tryInit ) |
| 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.
| 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.
| s | Pointer to flash configuration structure |
| addr | Starting address to read from (24-bit address, 0x000000 to 0x07FFFF for 512KB) |
| buffer | Pointer to destination buffer |
| size | Number of bytes to read |
| HAL_OK | on 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().
| 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:
Handles sector boundaries automatically - if data crosses sector boundary, both sectors are processed
Includes boundary checking, write enable verification, and proper timeout handling
| s | Pointer to flash configuration structure |
| addr | Starting address to write to (24-bit address, 0x000000 to 0x07FFFF for 512KB) |
| data | Pointer to source data buffer |
| size | Number of bytes to write |
| HAL_OK | on 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().
|
static |
Definition at line 27 of file flash_at25.c.
References flash_at25CS_t::CSPin, and flash_at25CS_t::CSPort.
Referenced by flash_at25_Init(), flash_at25_Read(), flash_WritePage(), flashNew_WaitReadyWithTimeout(), and flashNew_WriteEnableVerified().
|
static |
Definition at line 32 of file flash_at25.c.
References flash_at25CS_t::CSPin, and flash_at25CS_t::CSPort.
Referenced by flash_at25_Init(), flash_at25_Read(), flash_WritePage(), flashNew_WaitReadyWithTimeout(), and flashNew_WriteEnableVerified().
|
static |
write data to 256 bounder with erase of page
Definition at line 177 of file flash_at25.c.
References _buffer256, CMD_PAGE_ERASE, CMD_PAGE_PROG, Error_Handler(), flash_at25_Read(), flash_Select(), flash_Unselect(), flashNew_WaitReadyWithTimeout(), flashNew_WriteEnableVerified(), flash_at25CS_t::Is, flash_at25CS_t::Spi, and writeLog().
Referenced by flash_at25_Write().
|
static |
Helper function to wait for flash ready with timeout protection Optimized for frequent operations with proper timeout and CS handling.
| s | Pointer to flash configuration structure |
| HAL_OK | if ready, HAL_TIMEOUT if timeout, HAL_ERROR on communication error |
Definition at line 43 of file flash_at25.c.
References CMD_READ_STATUS, flash_Select(), FLASH_TIMEOUT, flash_Unselect(), flash_at25CS_t::Spi, and SR_WIP.
Referenced by flash_at25_Read(), and flash_WritePage().
|
static |
Helper function to enable write with verification Ensures write enable latch is properly set.
| s | Pointer to flash configuration structure |
| HAL_OK | if write enabled, HAL_ERROR otherwise |
Definition at line 70 of file flash_at25.c.
References CMD_READ_STATUS, CMD_WRITE_ENABLE, flash_Select(), flash_Unselect(), flash_at25CS_t::Spi, and SR_WEL.
Referenced by flash_WritePage().
|
static |
Definition at line 25 of file flash_at25.c.
Referenced by flash_WritePage().