libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
stm32/l0/memorymap.h
Go to the documentation of this file.
1/*
2 * This file is part of the libopencm3 project.
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef LIBOPENCM3_MEMORYMAP_H
19#define LIBOPENCM3_MEMORYMAP_H
20
22
23/* --- STM32 specific peripheral definitions ------------------------------- */
24
25/* Memory map for all busses */
26#define FLASH_BASE (0x08000000U)
27#define PERIPH_BASE (0x40000000U)
28#define IOPORT_BASE (0x50000000U)
29#define INFO_BASE (0x1ff80000U)
30#define PERIPH_BASE_APB1 (PERIPH_BASE + 0x00000)
31#define PERIPH_BASE_APB2 (PERIPH_BASE + 0x10000)
32#define PERIPH_BASE_AHB (PERIPH_BASE + 0x20000)
33
34/* Register boundary addresses */
35
36/* APB1 */
37#define TIM2_BASE (PERIPH_BASE_APB1 + 0x0000)
38#define TIM3_BASE (PERIPH_BASE_APB1 + 0x0400)
39#define TIM6_BASE (PERIPH_BASE_APB1 + 0x1000)
40#define TIM7_BASE (PERIPH_BASE_APB1 + 0x1400)
41#define LCD_BASE (PERIPH_BASE_APB1 + 0x2400)
42#define RTC_BASE (PERIPH_BASE_APB1 + 0x2800)
43#define WWDG_BASE (PERIPH_BASE_APB1 + 0x2c00)
44#define IWDG_BASE (PERIPH_BASE_APB1 + 0x3000)
45#define SPI2_BASE (PERIPH_BASE_APB1 + 0x3800)
46#define USART2_BASE (PERIPH_BASE_APB1 + 0x4400)
47#define LPUART1_BASE (PERIPH_BASE_APB1 + 0x4800)
48#define USART4_BASE (PERIPH_BASE_APB1 + 0x4c00)
49#define USART5_BASE (PERIPH_BASE_APB1 + 0x5000)
50#define I2C1_BASE (PERIPH_BASE_APB1 + 0x5400)
51#define I2C2_BASE (PERIPH_BASE_APB1 + 0x5800)
52#define USB_DEV_FS_BASE (PERIPH_BASE_APB1 + 0x5c00)
53#define USB_PMA_BASE (PERIPH_BASE_APB1 + 0x6000)
54#define CRS_BASE (PERIPH_BASE_APB1 + 0x6C00)
55#define POWER_CONTROL_BASE (PERIPH_BASE_APB1 + 0x7000)
56#define DAC_BASE (PERIPH_BASE_APB1 + 0x7400)
57#define I2C3_BASE (PERIPH_BASE_APB1 + 0x7800)
58#define LPTIM1_BASE (PERIPH_BASE_APB1 + 0x7c00)
59
60
61/* APB2 */
62#define SYSCFG_BASE (PERIPH_BASE_APB2 + 0x0000)
63#define EXTI_BASE (PERIPH_BASE_APB2 + 0x0400)
64#define TIM21_BASE (PERIPH_BASE_APB2 + 0x0800)
65#define TIM22_BASE (PERIPH_BASE_APB2 + 0x1400)
66#define FIREWALL_BASE (PERIPH_BASE_APB2 + 0x1C00)
67#define ADC1_BASE (PERIPH_BASE_APB2 + 0x2400)
68#define SPI1_BASE (PERIPH_BASE_APB2 + 0x3000)
69#define USART1_BASE (PERIPH_BASE_APB2 + 0x3800)
70#define DBGMCU_BASE (PERIPH_BASE_APB2 + 0x5800)
71
72/* AHB */
73#define DMA1_BASE (PERIPH_BASE_AHB + 0x00000)
74#define RCC_BASE (PERIPH_BASE_AHB + 0x01000)
75#define FLASH_MEM_INTERFACE_BASE (PERIPH_BASE_AHB + 0x02000)
76#define CRC_BASE (PERIPH_BASE_AHB + 0x03000)
77#define TSC_BASE (PERIPH_BASE_AHB + 0x04000)
78#define RNG_BASE (PERIPH_BASE_AHB + 0x05000)
79#define AES_BASE (PERIPH_BASE_AHB + 0x06000)
80
81#define GPIO_PORT_A_BASE (IOPORT_BASE + 0x00000)
82#define GPIO_PORT_B_BASE (IOPORT_BASE + 0x00400)
83#define GPIO_PORT_C_BASE (IOPORT_BASE + 0x00800)
84#define GPIO_PORT_D_BASE (IOPORT_BASE + 0x00c00)
85#define GPIO_PORT_E_BASE (IOPORT_BASE + 0x01000)
86#define GPIO_PORT_H_BASE (IOPORT_BASE + 0x01C00)
87
88/* Device Electronic Signature */
89#define DESIG_FLASH_SIZE_BASE (INFO_BASE + 0x7C)
90#define DESIG_UNIQUE_ID_BASE (INFO_BASE + 0x50)
91#define DESIG_UNIQUE_ID0 MMIO32(DESIG_UNIQUE_ID_BASE)
92#define DESIG_UNIQUE_ID1 MMIO32(DESIG_UNIQUE_ID_BASE + 4)
93#define DESIG_UNIQUE_ID2 MMIO32(DESIG_UNIQUE_ID_BASE + 0x14)
94
95/* ST provided factory calibration values @ 3.0V */
96#define ST_VREFINT_CAL MMIO16((INFO_BASE + 0x78))
97#define ST_TSENSE_CAL1_30C MMIO16((INFO_BASE + 0x7A))
98#define ST_TSENSE_CAL2_110C MMIO16((INFO_BASE + 0x7E))
99
100#endif