Loading...
Searching...
No Matches
cpu_common.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Freie Universität Berlin
3 * 2017 OTA keys S.A.
4 *
5 * This file is subject to the terms and conditions of the GNU Lesser
6 * General Public License v2.1. See the file LICENSE in the top level
7 * directory for more details.
8 */
9
21#ifndef PERIPH_CPU_COMMON_H
22#define PERIPH_CPU_COMMON_H
23
24#include <stdint.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#ifdef Doxygen
35#define STM32_BOOTLOADER_ADDR
36#endif
37
43#define CPUID_LEN (12U)
44
48#ifndef CPUID_ADDR
49#define CPUID_ADDR (UID_BASE)
50#endif
51
55#if defined(CPU_FAM_STM32F0) || defined (CPU_FAM_STM32F1) || \
56 defined(CPU_FAM_STM32F3)
57#define CLOCK_LSI (40000U)
58#elif defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)
59#define CLOCK_LSI (37000U)
60#elif defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4) || \
61 defined(CPU_FAM_STM32F7) || defined(CPU_FAM_STM32L4) || \
62 defined(CPU_FAM_STM32WB) || defined(CPU_FAM_STM32G4) || \
63 defined(CPU_FAM_STM32G0) || defined(CPU_FAM_STM32L5) || \
64 defined(CPU_FAM_STM32U5) || defined(CPU_FAM_STM32MP1) || \
65 defined(CPU_FAM_STM32WL) || defined(CPU_FAM_STM32C0)
66#define CLOCK_LSI (32000U)
67#else
68#error "error: LSI clock speed not defined for your target CPU"
69#endif
70
74typedef enum {
77#if defined(CPU_FAM_STM32WL) || defined(CPU_FAM_STM32U5)
78 APB3,
79#endif
80#if defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32WB) || \
81 defined(CPU_FAM_STM32G4) || defined(CPU_FAM_STM32G0) || \
82 defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32U5) || \
83 defined(CPU_FAM_STM32WL) || defined(CPU_FAM_STM32C0)
84 APB12,
85#endif
86#if defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32G0) || \
87 defined(CPU_FAM_STM32C0)
88 AHB,
89 IOP,
90#elif defined(CPU_FAM_STM32L1) || defined(CPU_FAM_STM32F1) || \
91 defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F3)
92 AHB,
93#elif defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4) || \
94 defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32F7) || \
95 defined(CPU_FAM_STM32WB) || defined(CPU_FAM_STM32G4) || \
96 defined(CPU_FAM_STM32L5) || defined(CPU_FAM_STM32U5) || \
97 defined(CPU_FAM_STM32WL)
98 AHB1,
99 AHB2,
100#if defined(CPU_FAM_STM32U5)
101 AHB22,
102#endif
103 AHB3,
104#elif defined(CPU_FAM_STM32MP1)
105 AHB1,
106 AHB2,
107 AHB3,
108#else
109#warning "unsupported stm32XX family"
110#endif
111#if defined(CPU_FAM_STM32WB) || defined(CPU_FAM_STM32MP1)
112 AHB4,
113#endif
114} bus_t;
115
123uint32_t periph_apb_clk(bus_t bus);
124
133
140void periph_clk_en(bus_t bus, uint32_t mask);
141
148void periph_clk_dis(bus_t bus, uint32_t mask);
149
156void periph_lpclk_en(bus_t bus, uint32_t mask);
157
164void periph_lpclk_dis(bus_t bus, uint32_t mask);
165
166#ifdef __cplusplus
167}
168#endif
169
170#endif /* PERIPH_CPU_COMMON_H */
bus_t
On-Chip buses.
Definition periph_cpu.h:77
@ AHB
Advanced High-performance Bus.
Definition periph_cpu.h:78
uint32_t periph_apb_clk(bus_t bus)
Get the actual bus clock frequency for the APB buses.
void periph_lpclk_en(bus_t bus, uint32_t mask)
Enable the given peripheral clock in low power mode.
void periph_clk_en(bus_t bus, uint32_t mask)
Enable the given peripheral clock.
void periph_clk_dis(bus_t bus, uint32_t mask)
Disable the given peripheral clock.
uint32_t periph_timer_clk(bus_t bus)
Get the actual timer clock frequency.
void periph_lpclk_dis(bus_t bus, uint32_t mask)
Disable the given peripheral clock in low power mode.
bus_t
CPU specific LSI clock speed.
Definition cpu_common.h:74
@ APB1
APB1 bus.
Definition cpu_common.h:75
@ APB2
APB2 bus.
Definition cpu_common.h:76