aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/hal/ports/STM32/STM32G0xx/hal_efl_lld.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/hal/ports/STM32/STM32G0xx/hal_efl_lld.h')
-rw-r--r--lib/chibios/os/hal/ports/STM32/STM32G0xx/hal_efl_lld.h144
1 files changed, 144 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/STM32/STM32G0xx/hal_efl_lld.h b/lib/chibios/os/hal/ports/STM32/STM32G0xx/hal_efl_lld.h
new file mode 100644
index 000000000..1b647abd2
--- /dev/null
+++ b/lib/chibios/os/hal/ports/STM32/STM32G0xx/hal_efl_lld.h
@@ -0,0 +1,144 @@
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 STM32G07/8nxx 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 STM32G0xx 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(STM32G070xx) || defined(STM32G071xx) || \
55 defined(STM32G081xx) || \
56 defined(__DOXYGEN__)
57
58/* Flash size register. */
59#define STM32_FLASH_SIZE_REGISTER 0x1FFF75E0
60#define STM32_FLASH_SIZE_SCALE 1024U
61
62/*
63 * Flash size is organised as 32 or 64 x 2K pages.
64 *
65 */
66#define STM32_FLASH_SIZE_64K 64U
67#define STM32_FLASH_SIZE_128K 128U
68#define STM32_FLASH_SECTORS_TOTAL_64K 32
69#define STM32_FLASH_SECTORS_TOTAL_128K 64
70
71/* 64K flash.*/
72#define STM32_FLASH_SECTOR_SIZE_64K ((STM32_FLASH_SIZE_64K \
73 * STM32_FLASH_SIZE_SCALE) \
74 / STM32_FLASH_SECTORS_TOTAL_64K)
75/* 128K flash.*/
76#define STM32_FLASH_SECTOR_SIZE_128K ((STM32_FLASH_SIZE_128K \
77 * STM32_FLASH_SIZE_SCALE) \
78 / STM32_FLASH_SECTORS_TOTAL_128K)
79
80#else
81#error "This EFL driver does not support the selected device"
82#endif
83
84/*===========================================================================*/
85/* Driver data structures and types. */
86/*===========================================================================*/
87
88/* A flash size declaration. */
89typedef struct {
90 const flash_descriptor_t* desc;
91} efl_lld_size_t;
92
93/*===========================================================================*/
94/* Driver macros. */
95/*===========================================================================*/
96
97/**
98 * @brief Low level fields of the embedded flash driver structure.
99 */
100#define efl_lld_driver_fields \
101 /* Flash registers.*/ \
102 FLASH_TypeDef *flash; \
103 const flash_descriptor_t *descriptor;
104
105/**
106 * @brief Low level fields of the embedded flash configuration structure.
107 */
108#define efl_lld_config_fields \
109 /* Dummy configuration, it is not needed.*/ \
110 uint32_t dummy
111
112/*===========================================================================*/
113/* External declarations. */
114/*===========================================================================*/
115
116#if !defined(__DOXYGEN__)
117extern EFlashDriver EFLD1;
118#endif
119
120#ifdef __cplusplus
121extern "C" {
122#endif
123 void efl_lld_init(void);
124 void efl_lld_start(EFlashDriver *eflp);
125 void efl_lld_stop(EFlashDriver *eflp);
126 const flash_descriptor_t *efl_lld_get_descriptor(void *instance);
127 flash_error_t efl_lld_read(void *instance, flash_offset_t offset,
128 size_t n, uint8_t *rp);
129 flash_error_t efl_lld_program(void *instance, flash_offset_t offset,
130 size_t n, const uint8_t *pp);
131 flash_error_t efl_lld_start_erase_all(void *instance);
132 flash_error_t efl_lld_start_erase_sector(void *instance,
133 flash_sector_t sector);
134 flash_error_t efl_lld_query_erase(void *instance, uint32_t *msec);
135 flash_error_t efl_lld_verify_erase(void *instance, flash_sector_t sector);
136#ifdef __cplusplus
137}
138#endif
139
140#endif /* HAL_USE_EFL == TRUE */
141
142#endif /* HAL_EFL_LLD_H */
143
144/** @} */