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