1 /* USER CODE BEGIN Header */ 2 /** 3 ****************************************************************************** 4 * @file flash_manager.h 5 * @author MCD Application Team 6 * @brief Header for flash_manager.c module 7 ****************************************************************************** 8 * @attention 9 * 10 * Copyright (c) 2024 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_MANAGER_H 23 #define FLASH_MANAGER_H 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /* Includes ------------------------------------------------------------------*/ 30 #include "utilities_common.h" 31 #include "stm_list.h" 32 33 /* Exported types ------------------------------------------------------------*/ 34 35 /* Flash Manager command status */ 36 typedef enum 37 { 38 FM_OK, /* The Flash Manager is available and a window request is scheduled */ 39 FM_BUSY, /* The Flash Manager is busy and the caller will be called back when it is available */ 40 FM_ERROR /* An error occurred while processing the command */ 41 } FM_Cmd_Status_t; 42 43 /* Flash operation status */ 44 typedef enum 45 { 46 FM_OPERATION_COMPLETE, /* The requested flash operation is complete */ 47 FM_OPERATION_AVAILABLE /* A flash operation can be requested */ 48 } FM_FlashOp_Status_t; 49 50 /** 51 * @brief Flash Manager callback node type to store them in a chained list 52 */ 53 typedef struct FM_CallbackNode 54 { 55 tListNode NodeList; /* Next and previous nodes in the list */ 56 void (*Callback)(FM_FlashOp_Status_t Status); /* Callback function pointer for Flash Manager caller */ 57 }FM_CallbackNode_t; 58 59 /* Exported constants --------------------------------------------------------*/ 60 61 #define TIME_WINDOW_ERASE_DURATION 4000U /* Duration in us of the time window requested for Flash Erase */ 62 #define TIME_WINDOW_WRITE_DURATION 1000U /* Duration in us of the time window requested for Flash Write */ 63 #define TIME_WINDOW_MARGIN 100U /* Time margin added so to ensure timeout protection before actual closure */ 64 /* As timers use ms, amount below 1000 is removed at conversion */ 65 #define TIME_WINDOW_ERASE_REQUEST (TIME_WINDOW_ERASE_DURATION + TIME_WINDOW_MARGIN) 66 #define TIME_WINDOW_WRITE_REQUEST (TIME_WINDOW_WRITE_DURATION + TIME_WINDOW_MARGIN) 67 68 /* Exported variables --------------------------------------------------------*/ 69 /* Exported macros -----------------------------------------------------------*/ 70 /* Exported functions ------------------------------------------------------- */ 71 FM_Cmd_Status_t FM_Write(uint32_t *Src, uint32_t *Dest, int32_t Size, FM_CallbackNode_t *CallbackNode); 72 FM_Cmd_Status_t FM_Erase(uint32_t FirstSect, uint32_t NbrSect, FM_CallbackNode_t *CallbackNode); 73 void FM_BackgroundProcess (void); 74 void FM_ProcessRequest (void); 75 76 #ifdef __cplusplus 77 } 78 #endif 79 80 #endif /*FLASH_MANAGER_H */ 81