APM:Libraries
stm32.h
Go to the documentation of this file.
1 /******************************************************************************
2  * The MIT License
3  *
4  * Copyright (c) 2010 LeafLabs, LLC.
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use, copy,
10  * modify, merge, publish, distribute, sublicense, and/or sell copies
11  * of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24  * SOFTWARE.
25  *****************************************************************************/
26 
32 #ifndef _STM32_H_
33 #define _STM32_H_
34 
35 
36 #define STM32_NR_INTERRUPTS 60
37 #define NR_INTERRUPTS STM32_NR_INTERRUPTS
38 
39 #if defined(MCU_STM32F103RB)
40  /* e.g., LeafLabs Maple */
41 
42  #define STM32_NR_GPIO_PORTS 4
43  #define STM32_DELAY_US_MULT 12
44  #define STM32_SRAM_END ((void*)0x20005000)
45 
46  #define NR_GPIO_PORTS STM32_NR_GPIO_PORTS
47  #define DELAY_US_MULT STM32_DELAY_US_MULT
48 
49 #elif defined(MCU_STM32F103ZE)
50  /* e.g., LeafLabs Maple Native */
51 
52  #define STM32_NR_GPIO_PORTS 7
53  #define STM32_DELAY_US_MULT 12
54  #define STM32_SRAM_END ((void*)0x20010000)
55 
56  #define NR_GPIO_PORTS STM32_NR_GPIO_PORTS
57  #define DELAY_US_MULT STM32_DELAY_US_MULT
58 
59 #elif defined(MCU_STM32F103CB)
60  /* e.g., LeafLabs Maple Mini */
61 
62  /* This STM32_NR_GPIO_PORTS value is not, strictly speaking, true.
63  * But only pins 0 and 1 exist, and they're used for OSC on the
64  * Mini, so we'll live with this for now. */
65  #define STM32_NR_GPIO_PORTS 3
66  #define STM32_DELAY_US_MULT 12
67  #define STM32_SRAM_END ((void*)0x20005000)
68 
69  #define NR_GPIO_PORTS STM32_NR_GPIO_PORTS
70  #define DELAY_US_MULT STM32_DELAY_US_MULT
71 
72 #elif defined(MCU_STM32F103RE)
73  /* e.g., LeafLabs Maple RET6 edition */
74 
75  #define STM32_NR_GPIO_PORTS 4
76  #define STM32_DELAY_US_MULT 12
77  #define STM32_SRAM_END ((void*)0x20010000)
78 
79  #define NR_GPIO_PORTS STM32_NR_GPIO_PORTS
80  #define DELAY_US_MULT STM32_DELAY_US_MULT
81 
82 #elif defined(MCU_STM32F103VE)
83  /* e.g., LeafLabs Maple Native */
84 
85  #define STM32_NR_GPIO_PORTS 5
86  #define STM32_DELAY_US_MULT 12
87  #define STM32_SRAM_END ((void*)0x20010000)
88 
89  #define NR_GPIO_PORTS STM32_NR_GPIO_PORTS
90  #define DELAY_US_MULT STM32_DELAY_US_MULT
91 
92 #elif defined(MCU_STM32F205VE)
93  #define STM32_TICKS_PER_US (SystemCoreClock / 1000000)
94  #define STM32_NR_GPIO_PORTS 5
95  #define STM32_DELAY_US_MULT (STM32_TICKS_PER_US/3)
96  #define STM32_SRAM_END ((void*)0x20010000)
97 
98  #define NR_GPIO_PORTS STM32_NR_GPIO_PORTS
99  #define DELAY_US_MULT STM32_DELAY_US_MULT
100 
101 #elif defined(MCU_STM32F406VG)
102  #define STM32_TICKS_PER_US (SystemCoreClock / 1000000)
103  #define STM32_NR_GPIO_PORTS 5
104  #define STM32_DELAY_US_MULT (STM32_TICKS_PER_US/3)
105  #define STM32_SRAM_END ((void*)0x20020000)
106 
107  #define NR_GPIO_PORTS STM32_NR_GPIO_PORTS
108  #define DELAY_US_MULT STM32_DELAY_US_MULT
109 
110 #elif defined(MCU_STM32F407VG) || defined(stm32f407vg) || defined(mcu_stm32f405rg) || defined(MCU_STM32F405RG)
111  #define STM32_TICKS_PER_US (SystemCoreClock / 1000000)
112  #define STM32_NR_GPIO_PORTS 5
113  #define STM32_DELAY_US_MULT (STM32_TICKS_PER_US/3)
114  #define STM32_SRAM_END ((void*)0x20020000)
115  #define STM32_CCM_END ((void*)0x10010000)
116 
117  #define NR_GPIO_PORTS STM32_NR_GPIO_PORTS
118  #define DELAY_US_MULT STM32_DELAY_US_MULT
119 
120 #else
121 
122 #error "No MCU type specified. Add something like -DMCU_STM32F103RB " \
123  "to your compiler arguments (probably in a Makefile)."
124 
125 #endif
126 
127 #endif /* _STM32_H_ */