cpu_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Freie Universität Berlin
3  * 2016 Inria
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
21 #ifndef CPU_CONF_H
22 #define CPU_CONF_H
23 
24 #include <stdint.h>
25 #include "cpu_conf_common.h"
26 
27 #if defined(CPU_LINE_STM32F030x4)
28 #include "vendor/stm32f030x4.h"
29 #elif defined(CPU_LINE_STM32MP157Cxx)
30 #include "vendor/stm32mp157cxx_cm4.h"
31 #elif CPU_FAM_STM32F0
32 #include "stm32f0xx.h"
33 #include "irqs/f0/irqs.h"
34 #elif CPU_FAM_STM32F1
35 #include "stm32f1xx.h"
36 #include "irqs/f1/irqs.h"
37 #elif CPU_FAM_STM32F2
38 #include "stm32f2xx.h"
39 #include "irqs/f2/irqs.h"
40 #elif CPU_FAM_STM32F3
41 #include "stm32f3xx.h"
42 #include "irqs/f3/irqs.h"
43 #elif CPU_FAM_STM32F4
44 #include "stm32f4xx.h"
45 #include "irqs/f4/irqs.h"
46 #elif CPU_FAM_STM32F7
47 #include "stm32f7xx.h"
48 #include "irqs/f7/irqs.h"
49 #elif CPU_FAM_STM32G0
50 #include "stm32g0xx.h"
51 #include "irqs/g0/irqs.h"
52 #elif CPU_FAM_STM32G4
53 #include "stm32g4xx.h"
54 #include "irqs/g4/irqs.h"
55 #elif CPU_FAM_STM32L0
56 #include "stm32l0xx.h"
57 #include "irqs/l0/irqs.h"
58 #elif CPU_FAM_STM32L1
59 #include "stm32l1xx.h"
60 #include "irqs/l1/irqs.h"
61 #elif CPU_FAM_STM32L4
62 #include "stm32l4xx.h"
63 #include "irqs/l4/irqs.h"
64 #elif CPU_FAM_STM32L5
65 #include "stm32l5xx.h"
66 #include "irqs/l5/irqs.h"
67 #elif CPU_FAM_STM32WB
68 #include "stm32wbxx.h"
69 #include "irqs/wb/irqs.h"
70 #else
71 #error Not supported CPU family
72 #endif
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
82 #define CPU_DEFAULT_IRQ_PRIO (1U)
83 /* STM32MP1 family has no flah */
84 #if !defined(CPU_FAM_STM32MP1)
85 #define CPU_FLASH_BASE FLASH_BASE
86 #endif
87 
88 /* CPU_IRQ_NUMOF cannot be determined automatically from cmsis header */
89 #if defined(CPU_LINE_STM32F030x4)
90 #define CPU_IRQ_NUMOF (28U)
91 #elif defined(CPU_MODEL_STM32MP157CAC)
92 #define CPU_IRQ_NUMOF (150U)
93 #endif
94 
100 #if defined(CPU_FAM_STM32WB)
101 #define FLASHPAGE_SIZE (4096U)
102 #elif defined(CPU_LINE_STM32F091xC) || defined(CPU_LINE_STM32F072xB) \
103  || defined(CPU_LINE_STM32F030xC) || defined(CPU_LINE_STM32F103xE) \
104  || defined(CPU_FAM_STM32F3) || defined(CPU_FAM_STM32L4) \
105  || defined(CPU_FAM_STM32G4) || defined(CPU_FAM_STM32G0) \
106  || defined(CPU_FAM_STM32L5)
107 #define FLASHPAGE_SIZE (2048U)
108 #elif defined(CPU_LINE_STM32F051x8) || defined(CPU_LINE_STM32F042x6) \
109  || defined(CPU_LINE_STM32F070xB) || defined(CPU_LINE_STM32F030x8) \
110  || defined(CPU_LINE_STM32F030x4) || defined(CPU_LINE_STM32F103xB) \
111  || defined(CPU_LINE_STM32F031x6)
112 #define FLASHPAGE_SIZE (1024U)
113 #elif defined(CPU_FAM_STM32L1)
114 #define FLASHPAGE_SIZE (256U)
115 #elif defined(CPU_FAM_STM32L0)
116 #define FLASHPAGE_SIZE (128U)
117 #endif
118 
119 #define FLASHPAGE_NUMOF (STM32_FLASHSIZE / FLASHPAGE_SIZE)
120 
121 /* The minimum block size which can be written depends on the family.
122  * However, the erase block is always FLASHPAGE_SIZE.
123  */
124 #if defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32WB) || \
125  defined(CPU_FAM_STM32G4) || defined(CPU_FAM_STM32G0) || \
126  defined(CPU_FAM_STM32L5)
127 #define FLASHPAGE_WRITE_BLOCK_SIZE (8U)
128 typedef uint64_t stm32_flashpage_block_t;
129 #elif defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)
130 #define FLASHPAGE_WRITE_BLOCK_SIZE (4U)
131 typedef uint32_t stm32_flashpage_block_t;
132 #else
133 #define FLASHPAGE_WRITE_BLOCK_SIZE (2U)
134 typedef uint16_t stm32_flashpage_block_t;
135 #endif
136 
137 #if defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32WB) || \
138  defined(CPU_FAM_STM32G4) || defined(CPU_FAM_STM32G0) || \
139  defined(CPU_FAM_STM32L5)
140 #define FLASHPAGE_WRITE_BLOCK_ALIGNMENT (8U)
141 #else
142 /* Writing should be always 4 bytes aligned */
143 #define FLASHPAGE_WRITE_BLOCK_ALIGNMENT (4U)
144 #endif
145 
151 #ifdef SRAM_BB_BASE
152 #define CPU_HAS_BITBAND 1
153 #endif
154 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* CPU_CONF_H */
161