Loading...
Searching...
No Matches
cpu_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Freie Universität Berlin
3 * SPDX-FileCopyrightText: 2016 Inria
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
19
20#include <stdint.h>
21#include "cpu_conf_common.h"
22
23#if defined(CPU_LINE_STM32F030x4)
24#include "vendor/stm32f030x4.h"
25#elif defined(CPU_LINE_STM32MP157Cxx)
26#include "vendor/stm32mp157cxx_cm4.h"
27#else
28#include "stm32_irqs.h"
29#endif
30
31/* add unused backup RAM as extra heap */
32#if !defined(NUM_HEAPS) && CPU_HAS_BACKUP_RAM
33#define NUM_HEAPS 2
34#endif
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
48#define CORTEXM_ISB_REQUIRED_AFTER_WFI 1
49
54#define CPU_DEFAULT_IRQ_PRIO (1U)
55/* STM32MP1 family has no flash */
56#if !defined(CPU_FAM_STM32MP1)
57#define CPU_FLASH_BASE FLASH_BASE
58#endif
59
60/* CPU_IRQ_NUMOF cannot be determined automatically from cmsis header */
61#if defined(CPU_LINE_STM32F030x4)
62#define CPU_IRQ_NUMOF (28U)
63#elif defined(CPU_MODEL_STM32MP157CAC)
64#define CPU_IRQ_NUMOF (150U)
65#endif
67
72#if defined(CPU_FAM_STM32U5)
73#define FLASHPAGE_SIZE (8192U)
74#elif defined(CPU_FAM_STM32WB)
75#define FLASHPAGE_SIZE (4096U)
76#elif defined(CPU_LINE_STM32F091xC) || defined(CPU_LINE_STM32F072xB) \
77 || defined(CPU_LINE_STM32F030xC) || defined(CPU_LINE_STM32F103xE) \
78 || defined(CPU_FAM_STM32F3) || defined(CPU_FAM_STM32L4) \
79 || defined(CPU_FAM_STM32G4) || defined(CPU_FAM_STM32G0) \
80 || defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32WL) \
81 || defined(CPU_FAM_STM32C0)
82#define FLASHPAGE_SIZE (2048U)
83#elif defined(CPU_LINE_STM32F051x8) || defined(CPU_LINE_STM32F042x6) \
84 || defined(CPU_LINE_STM32F070xB) || defined(CPU_LINE_STM32F030x8) \
85 || defined(CPU_LINE_STM32F030x4) || defined(CPU_LINE_STM32F103xB) \
86 || defined(CPU_LINE_STM32F031x6)
87#define FLASHPAGE_SIZE (1024U)
88#elif defined(CPU_FAM_STM32L1)
89#define FLASHPAGE_SIZE (256U)
90#elif defined(CPU_FAM_STM32L0)
91#define FLASHPAGE_SIZE (128U)
92#endif
93
94#if defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)
95#define FLASHPAGE_ERASE_STATE (0x00U)
96#endif
97
98#ifdef FLASHPAGE_SIZE
99#define FLASHPAGE_NUMOF (STM32_FLASHSIZE / FLASHPAGE_SIZE)
100#endif
101
102#if defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4) || \
103 defined(CPU_FAM_STM32F7)
104#define PERIPH_FLASHPAGE_CUSTOM_PAGESIZES
105#define PERIPH_FLASHPAGE_NEEDS_FLASHPAGE_ADDR
106
118#if (defined(FLASH_OPTCR_DB1M) && (STM32_FLASHSIZE >= (1024 * 1024)))
119#define FLASHPAGE_DUAL_BANK 1
120#else
121#define FLASHPAGE_DUAL_BANK 0
122#endif
123
124/* stm32f7 uses single bank with 32KB to 256KB sectors on a number of devices */
125#if defined(CPU_FAM_STM32F7)
126#if defined(CPU_LINE_STM32F745xx) || \
127 defined(CPU_LINE_STM32F746xx) || \
128 defined(CPU_LINE_STM32F750xx) || \
129 defined(CPU_LINE_STM32F756xx) || \
130 defined(CPU_LINE_STM32F765xx) || \
131 defined(CPU_LINE_STM32F767xx) || \
132 defined(CPU_LINE_STM32F769xx) || \
133 defined(CPU_LINE_STM32F777xx) || \
134 defined(CPU_LINE_STM32F779xx)
135#define FLASHPAGE_MIN_SECTOR_SIZE (32 * 1024)
136#elif defined(CPU_LINE_STM32F722xx) || \
137 defined(CPU_LINE_STM32F723xx) || \
138 defined(CPU_LINE_STM32F730xx) || \
139 defined(CPU_LINE_STM32F732xx) || \
140 defined(CPU_LINE_STM32F733xx)
141#define FLASHPAGE_MIN_SECTOR_SIZE (16 * 1024)
142#else
143/* Intentionally error on an unknown line to prevent flashpage errors */
144#error Unknown STM32F7 Line, unable to determine FLASHPAGE_MIN_SECTOR_SIZE
145#endif
146
147#else /* CPU_FAM_STM32F7 */
148#define FLASHPAGE_MIN_SECTOR_SIZE (16 * 1024)
149#endif
150
151#if FLASHPAGE_DUAL_BANK
152/* Number of "large" sectors + 4 for the small sectors that together equal a
153 * single large sector. Times two to account for the two banks */
154#define FLASHPAGE_NUMOF ((STM32_FLASHSIZE / \
155 (8 * FLASHPAGE_MIN_SECTOR_SIZE)) + 8)
156#else
157/* Number of "large" sectors + 4 for the small sectors that together equal a
158 * single large sector, eg: 1 MB = 7 * 128 KB sectors + 1 64 KB and 4 16 KB
159 * sectors */
160#define FLASHPAGE_NUMOF ((STM32_FLASHSIZE / \
161 (8 * FLASHPAGE_MIN_SECTOR_SIZE)) + 4)
162#endif
163
164#endif
165
166/* The minimum block size which can be written depends on the family.
167 * However, the erase block is always FLASHPAGE_SIZE.
168 */
169#if defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32WB) || \
170 defined(CPU_FAM_STM32G4) || defined(CPU_FAM_STM32G0) || \
171 defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32U5) || \
172 defined(CPU_FAM_STM32WL) || defined(CPU_FAM_STM32C0)
173#define FLASHPAGE_WRITE_BLOCK_SIZE (8U)
174typedef uint64_t stm32_flashpage_block_t;
175#elif defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1) || \
176 defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4) || \
177 defined(CPU_FAM_STM32F7)
178#define FLASHPAGE_WRITE_BLOCK_SIZE (4U)
179typedef uint32_t stm32_flashpage_block_t;
180#else
181#define FLASHPAGE_WRITE_BLOCK_SIZE (2U)
182typedef uint16_t stm32_flashpage_block_t;
183#endif
184
185#if defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32WB) || \
186 defined(CPU_FAM_STM32G4) || defined(CPU_FAM_STM32G0) || \
187 defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32U5) || \
188 defined(CPU_FAM_STM32WL) || defined(CPU_FAM_STM32C0)
189#define FLASHPAGE_WRITE_BLOCK_ALIGNMENT (8U)
190#else
191/* Writing should be always 4 bytes aligned */
192#define FLASHPAGE_WRITE_BLOCK_ALIGNMENT (4U)
193#endif
195
200#ifdef SRAM_BB_BASE
201#define CPU_HAS_BITBAND 1
202#endif
204
205#ifdef __cplusplus
206}
207#endif
208