1 /* USER CODE BEGIN Header */
2 /**
3   ******************************************************************************
4   * @file    flash_driver.h
5   * @author  MCD Application Team
6   * @brief   Header for flash_driver.c module
7   ******************************************************************************
8   * @attention
9   *
10   * Copyright (c) 2022 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_DRIVER_H
23 #define FLASH_DRIVER_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* Includes ------------------------------------------------------------------*/
30 #include "utilities_common.h"
31 
32 /* Exported types ------------------------------------------------------------*/
33 
34 /* Bit mask to modify Flash Control status */
35 typedef uint32_t  FD_Flash_ctrl_bm_t;
36 
37 /* Flash operation status */
38 typedef enum
39 {
40   FD_FLASHOP_SUCCESS,
41   FD_FLASHOP_FAILURE
42 } FD_FlashOp_Status_t;
43 
44 /* Flash Driver commands to enable or disable flash access */
45 typedef enum
46 {
47   LL_FLASH_ENABLE,
48   LL_FLASH_DISABLE,
49 } FD_FLASH_Status_t;
50 
51 /**
52  * @brief Bit mask to modify Flash Control status
53  *
54  * @details Those bitmasks are used to enable/disable access to the flash:
55  *   - System:
56  *     -# FD_FLASHACCESS_SYSTEM: Determine whether or not the flash access is allowed from a system POV.
57  *                               This bit has a predominance over all the other bit masks, ie: No flash operation can
58  *                               be achieved without this to be set to 0, ie: LL_FLASH_ENABLE.
59  *   - RFTS:
60  *     -# FD_FLASHACCESS_RFTS: Determine whether or not the RF Timing Synchro allows flash access. This bit is set
61  *                             once a window has been allowed by the BLE LL, ie: set to 0.
62  *                             This bit has no impact when FD_FLASHACCESS_RFTS_BYPASS is set, ie: set to 0.
63  *     -# FD_FLASHACCESS_RFTS_BYPASS: Nullify the impact of FD_FLASHACCESS_RFTS when enabled, ie: set to 0. Its role is
64  *                                    to allow flash operation without the need to request a timing window to the RFTS,
65  *                                    ie: Executing flash operation without the BLE LL.
66  *
67  */
68 typedef enum FD_FlashAccess_bm
69 {
70   /* System flash access bitfield */
71   FD_FLASHACCESS_SYSTEM,
72   /* RF Timing Synchro flash access bitfield */
73   FD_FLASHACCESS_RFTS,
74   /* Bypass of RF Timing Synchro flash access bitfield */
75   FD_FLASHACCESS_RFTS_BYPASS,
76 }FD_FlashAccess_bm_t;
77 
78 /* Exported constants --------------------------------------------------------*/
79 /* Exported variables --------------------------------------------------------*/
80 /* Exported macros -----------------------------------------------------------*/
81 /* Exported functions ------------------------------------------------------- */
82 void FD_SetStatus(FD_Flash_ctrl_bm_t Flags_bm, FD_FLASH_Status_t Status);
83 FD_FlashOp_Status_t FD_WriteData(uint32_t Dest, uint32_t Payload);
84 FD_FlashOp_Status_t FD_EraseSectors(uint32_t Sect);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif /*FLASH_DRIVER_H */
91