diff options
Diffstat (limited to 'lib/chibios/os/hal/ports/STM32/STM32F4xx/hal_efl_lld.h')
-rw-r--r-- | lib/chibios/os/hal/ports/STM32/STM32F4xx/hal_efl_lld.h | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/STM32/STM32F4xx/hal_efl_lld.h b/lib/chibios/os/hal/ports/STM32/STM32F4xx/hal_efl_lld.h new file mode 100644 index 000000000..21614b461 --- /dev/null +++ b/lib/chibios/os/hal/ports/STM32/STM32F4xx/hal_efl_lld.h | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2019 Giovanni Di Sirio | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file hal_efl_lld.h | ||
19 | * @brief STM32F4xx Embedded Flash subsystem low level driver header. | ||
20 | * | ||
21 | * @addtogroup HAL_EFL | ||
22 | * @{ | ||
23 | */ | ||
24 | |||
25 | #ifndef HAL_EFL_LLD_H | ||
26 | #define HAL_EFL_LLD_H | ||
27 | |||
28 | #if (HAL_USE_EFL == TRUE) || defined(__DOXYGEN__) | ||
29 | |||
30 | /*===========================================================================*/ | ||
31 | /* Driver constants. */ | ||
32 | /*===========================================================================*/ | ||
33 | |||
34 | /*===========================================================================*/ | ||
35 | /* Driver pre-compile time settings. */ | ||
36 | /*===========================================================================*/ | ||
37 | |||
38 | /** | ||
39 | * @name STM32F412/413 EFL driver configuration options | ||
40 | * @{ | ||
41 | */ | ||
42 | /** | ||
43 | * @brief Suggested wait time during erase operations polling. | ||
44 | */ | ||
45 | #if !defined(STM32_FLASH_WAIT_TIME_MS) || defined(__DOXYGEN__) | ||
46 | #define STM32_FLASH_WAIT_TIME_MS 5 | ||
47 | #endif | ||
48 | /** @} */ | ||
49 | |||
50 | /*===========================================================================*/ | ||
51 | /* Derived constants and error checks. */ | ||
52 | /*===========================================================================*/ | ||
53 | |||
54 | #if defined(STM32F413xx) || defined(STM32F412xx) || defined(STM32F40_41xxx) \ | ||
55 | || defined(__DOXYGEN__) | ||
56 | |||
57 | /* Flash size register. */ | ||
58 | #define STM32_FLASH_SIZE_REGISTER 0x1FFF7A22 | ||
59 | #define STM32_FLASH_SIZE_SCALE 1024U | ||
60 | |||
61 | /* | ||
62 | * Device flash size... | ||
63 | * | ||
64 | */ | ||
65 | #define STM32_FLASH_NUMBER_OF_BANKS 1 | ||
66 | #define STM32_FLASH1_SIZE 1536U | ||
67 | #define STM32_FLASH2_SIZE 1024U | ||
68 | #define STM32_FLASH1_SECTORS_TOTAL 16 | ||
69 | #define STM32_FLASH2_SECTORS_TOTAL 12 | ||
70 | #else | ||
71 | #error "This EFL driver does not support the selected device" | ||
72 | #endif | ||
73 | |||
74 | /*===========================================================================*/ | ||
75 | /* Driver data structures and types. */ | ||
76 | /*===========================================================================*/ | ||
77 | |||
78 | /* A flash size declaration. */ | ||
79 | typedef struct { | ||
80 | const flash_descriptor_t* desc; | ||
81 | } efl_lld_size_t; | ||
82 | |||
83 | /*===========================================================================*/ | ||
84 | /* Driver macros. */ | ||
85 | /*===========================================================================*/ | ||
86 | |||
87 | /** | ||
88 | * @brief Low level fields of the embedded flash driver structure. | ||
89 | */ | ||
90 | #define efl_lld_driver_fields \ | ||
91 | /* Flash registers.*/ \ | ||
92 | FLASH_TypeDef *flash; \ | ||
93 | const flash_descriptor_t *descriptor; | ||
94 | |||
95 | /** | ||
96 | * @brief Low level fields of the embedded flash configuration structure. | ||
97 | */ | ||
98 | #define efl_lld_config_fields \ | ||
99 | /* Dummy configuration, it is not needed.*/ \ | ||
100 | uint32_t dummy | ||
101 | |||
102 | /*===========================================================================*/ | ||
103 | /* External declarations. */ | ||
104 | /*===========================================================================*/ | ||
105 | |||
106 | #if !defined(__DOXYGEN__) | ||
107 | extern EFlashDriver EFLD1; | ||
108 | #endif | ||
109 | |||
110 | #ifdef __cplusplus | ||
111 | extern "C" { | ||
112 | #endif | ||
113 | void efl_lld_init(void); | ||
114 | void efl_lld_start(EFlashDriver *eflp); | ||
115 | void efl_lld_stop(EFlashDriver *eflp); | ||
116 | const flash_descriptor_t *efl_lld_get_descriptor(void *instance); | ||
117 | flash_error_t efl_lld_read(void *instance, flash_offset_t offset, | ||
118 | size_t n, uint8_t *rp); | ||
119 | flash_error_t efl_lld_program(void *instance, flash_offset_t offset, | ||
120 | size_t n, const uint8_t *pp); | ||
121 | flash_error_t efl_lld_start_erase_all(void *instance); | ||
122 | flash_error_t efl_lld_start_erase_sector(void *instance, | ||
123 | flash_sector_t sector); | ||
124 | flash_error_t efl_lld_query_erase(void *instance, uint32_t *msec); | ||
125 | flash_error_t efl_lld_verify_erase(void *instance, flash_sector_t sector); | ||
126 | #ifdef __cplusplus | ||
127 | } | ||
128 | #endif | ||
129 | |||
130 | #endif /* HAL_USE_EFL == TRUE */ | ||
131 | |||
132 | #endif /* HAL_EFL_LLD_H */ | ||
133 | |||
134 | /** @} */ | ||