L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
flash_if.h
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4 * @file flash_if.h
5 * @author MCD Application Team
6 * @brief This file contains definitions for FLASH Interface functionalities.
7 ******************************************************************************
8 * @attention
9 *
10 * Copyright (c) 2026 STMicroelectronics.
11 * All rights reserved.
12 *
13 * This software is licensed under terms that can be found in the LICENSE file
14 * in the root directory of this software component.
15 * If no LICENSE file comes with this software, it is provided AS-IS.
16 *
17 ******************************************************************************
18 */
19/* USER CODE END Header */
20
21/* Define to prevent recursive inclusion -------------------------------------*/
22#ifndef __FLASH_IF_H__
23#define __FLASH_IF_H__
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/* Includes ------------------------------------------------------------------*/
30#include "platform.h"
31
32/* USER CODE BEGIN Includes */
33
34/* USER CODE END Includes */
35
36/* Exported types ------------------------------------------------------------*/
37/**
38 * @brief Flash status
39 */
40typedef enum
41{
42 FLASH_IF_PARAM_ERROR = -6, /*!< Error Flash invalid parameter */
43 FLASH_IF_LOCK_ERROR = -5, /*!< Error Flash not locked */
44 FLASH_IF_WRITE_ERROR = -4, /*!< Error Flash write not possible */
45 FLASH_IF_READ_ERROR = -3, /*!< Error Flash read not possible */
46 FLASH_IF_ERASE_ERROR = -2, /*!< Error Flash erase not possible */
47 FLASH_IF_ERROR = -1, /*!< Error Flash generic */
48 FLASH_IF_OK = 0, /*!< Flash Success */
49 FLASH_IF_BUSY = 1 /*!< Flash not available */
51
52/* USER CODE BEGIN ET */
53
54/* USER CODE END ET */
55
56/* Exported constants --------------------------------------------------------*/
57#define FLASH_IF_BUFFER_SIZE 0x00000800U /*!< FLASH Page Size, 2 KBytes */
58
59/* USER CODE BEGIN EC */
60
61/* USER CODE END EC */
62
63/* External variables --------------------------------------------------------*/
64/* USER CODE BEGIN EV */
65
66/* USER CODE END EV */
67
68/* Exported macro ------------------------------------------------------------*/
69/* USER CODE BEGIN EM */
70
71/* USER CODE END EM */
72
73/* Exported functions prototypes ---------------------------------------------*/
74/**
75 * @brief This function initializes the internal and external flash interface
76 *
77 * @param pAllocRamBuffer pointer used to store a FLASH page in RAM when partial replacement is needed
78 * @return FLASH_IF_StatusTypedef status
79 */
80FLASH_IF_StatusTypedef FLASH_IF_Init(void *pAllocRamBuffer);
81
82/**
83 * @brief This function de-initializes the internal and external flash interface
84 *
85 * @return FLASH_IF_StatusTypedef status
86 */
88
89/**
90 * @brief This function writes a data buffer in internal or external flash
91 *
92 * @param pDestination pointer of flash address to write. It has to be 8 bytes aligned.
93 * @param pSource pointer on buffer with data to write
94 * @param uLength length of data buffer in bytes. It has to be 8 bytes aligned.
95 * @return FLASH_IF_StatusTypedef status
96 */
97FLASH_IF_StatusTypedef FLASH_IF_Write(void *pDestination, const void *pSource, uint32_t uLength);
98
99/**
100 * @brief This function reads a amount of data from flash and copy into the output data buffer
101 *
102 * @param pDestination pointer of target location to copy the flash sector
103 * @param pSource pointer of flash address to read
104 * @param uLength number of bytes to read
105 * @return FLASH_IF_StatusTypedef status
106 */
107FLASH_IF_StatusTypedef FLASH_IF_Read(void *pDestination, const void *pSource, uint32_t uLength);
108
109/**
110 * @brief This function erases a amount of internal or external flash pages depending of the length
111 *
112 * @param pStart pointer of flash address to erase
113 * @param uLength number of bytes to erase
114 * @return FLASH_IF_StatusTypedef status
115 */
116FLASH_IF_StatusTypedef FLASH_IF_Erase(void *pStart, uint32_t uLength);
117
118/* USER CODE BEGIN EFP */
119
120/* USER CODE END EFP */
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif /* __FLASH_IF_H__ */
FLASH_IF_StatusTypedef FLASH_IF_Write(void *pDestination, const void *pSource, uint32_t uLength)
This function writes a data buffer in internal or external flash.
Definition flash_if.c:143
FLASH_IF_StatusTypedef
Flash status.
Definition flash_if.h:41
@ FLASH_IF_READ_ERROR
Definition flash_if.h:45
@ FLASH_IF_ERASE_ERROR
Definition flash_if.h:46
@ FLASH_IF_OK
Definition flash_if.h:48
@ FLASH_IF_LOCK_ERROR
Definition flash_if.h:43
@ FLASH_IF_BUSY
Definition flash_if.h:49
@ FLASH_IF_PARAM_ERROR
Definition flash_if.h:42
@ FLASH_IF_ERROR
Definition flash_if.h:47
@ FLASH_IF_WRITE_ERROR
Definition flash_if.h:44
FLASH_IF_StatusTypedef FLASH_IF_DeInit(void)
This function de-initializes the internal and external flash interface.
Definition flash_if.c:129
FLASH_IF_StatusTypedef FLASH_IF_Erase(void *pStart, uint32_t uLength)
This function erases a amount of internal or external flash pages depending of the length.
Definition flash_if.c:175
FLASH_IF_StatusTypedef FLASH_IF_Read(void *pDestination, const void *pSource, uint32_t uLength)
This function reads a amount of data from flash and copy into the output data buffer.
Definition flash_if.c:159
FLASH_IF_StatusTypedef FLASH_IF_Init(void *pAllocRamBuffer)
This function initializes the internal and external flash interface.
Definition flash_if.c:115
Header for General HW instances configuration.