Skip to content

Commit 84f0421

Browse files
committed
stm32h7/clk: work in progress
1 parent 6161fec commit 84f0421

33 files changed

Lines changed: 2237 additions & 1509 deletions

arch/arm/src/armv7-m/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ set(SRCS
3434
arm_initialstate.c
3535
arm_itm.c
3636
arm_memfault.c
37-
arm_perf.c
3837
arm_schedulesigaction.c
3938
arm_sigdeliver.c
4039
arm_svcall.c
@@ -45,6 +44,11 @@ set(SRCS
4544
arm_vectors.c
4645
arm_dbgmonitor.c)
4746

47+
48+
if(CONFIG_ARCH_HAVE_PERF_EVENTS)
49+
arm_perf.c
50+
endif()
51+
4852
if(CONFIG_ARMV7M_SYSTICK)
4953
list(APPEND SRCS arm_systick.c)
5054
endif()

arch/arm/src/armv7-m/Make.defs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CMN_ASRCS += arm_exception.S arm_saveusercontext.S
2828

2929
CMN_CSRCS += arm_busfault.c arm_cache.c arm_cpuinfo.c arm_doirq.c
3030
CMN_CSRCS += arm_hardfault.c arm_initialstate.c arm_itm.c
31-
CMN_CSRCS += arm_memfault.c arm_perf.c
31+
CMN_CSRCS += arm_memfault.c
3232
CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c
3333
CMN_CSRCS += arm_svcall.c arm_systemreset.c arm_tcbinfo.c
3434
CMN_CSRCS += arm_trigger_irq.c arm_usagefault.c arm_dbgmonitor.c
@@ -37,6 +37,10 @@ ifneq ($(CONFIG_ARCH_HAVE_CUSTOM_VECTORS),y)
3737
CMN_CSRCS += arm_vectors.c
3838
endif
3939

40+
ifeq ($(CONFIG_ARCH_HAVE_PERF_EVENTS),y)
41+
CMN_CSRDS += arm_perf.c
42+
endif
43+
4044
ifeq ($(CONFIG_ARMV7M_SYSTICK),y)
4145
CMN_CSRCS += arm_systick.c
4246
endif

arch/arm/src/armv7-m/arm_perf.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include "itm.h"
3333
#include "nvic.h"
3434

35-
#ifdef CONFIG_ARCH_HAVE_PERF_EVENTS
36-
3735
/****************************************************************************
3836
* Private Data
3937
****************************************************************************/
@@ -78,4 +76,3 @@ void up_perf_convert(clock_t elapsed, struct timespec *ts)
7876
left = elapsed - ts->tv_sec * g_cpu_freq;
7977
ts->tv_nsec = NSEC_PER_SEC * (uint64_t)left / g_cpu_freq;
8078
}
81-
#endif

arch/arm/src/stm32h7/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ list(
3030
stm32_gpio.c
3131
stm32_irq.c
3232
stm32_start.c
33-
stm32_rcc.c
3433
stm32_lowputc.c
3534
stm32_serial.c
3635
stm32_uid.c)
3736

37+
if(CONFIG_CLK)
38+
list(APPEND SRCS stm32_clk.c)
39+
endif()
40+
3841
if(CONFIG_STM32H7_PROGMEM)
3942
list(APPEND SRCS stm32_flash.c)
4043
endif()

arch/arm/src/stm32h7/Make.defs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ endif
4646
# Required STM32H7 files
4747

4848
CHIP_CSRCS += stm32_allocateheap.c stm32_exti_gpio.c stm32_gpio.c stm32_irq.c
49-
CHIP_CSRCS += stm32_start.c stm32_rcc.c stm32_lowputc.c stm32_serial.c
49+
CHIP_CSRCS += stm32_start.c stm32_serial.c
5050
CHIP_CSRCS += stm32_uid.c
5151

52+
ifeq ($(CONFIG_CLK),y)
53+
CHIP_CSRCS += stm32_clk.c
54+
endif
55+
5256
ifeq ($(CONFIG_SCHED_TICKLESS),y)
5357
CHIP_CSRCS += stm32_tickless.c
5458
else

arch/arm/src/stm32h7/hardware/stm32h7x3xx_rcc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,17 @@
431431

432432
/* Bit definitions for RCC_PLL1DIVR register */
433433

434+
#define RCC_PLLDIVR_N_SHIFT (0ul)
435+
#define RCC_PLLDIVR_N(x) (((x) - 1) << RCC_PLL1DIVR_N_SHIFT) /* Multiplication factor for VCO: 4 - 512 */
436+
#define RCC_PLLDIVR_P_SHIFT (9ul)
437+
#define RCC_PLLDIVR_P(x) (((x) - 1) << RCC_PLL1DIVR_P_SHIFT) /* DIVP division factor: 2 - 128, must be even */
438+
#define RCC_PLLDIVR_Q_SHIFT (16ul)
439+
#define RCC_PLLDIVR_Q(x) (((x) - 1) << RCC_PLL1DIVR_Q_SHIFT) /* DIVQ division factor: 2 - 128 */
440+
#define RCC_PLLDIVR_R_SHIFT (24ul)
441+
#define RCC_PLLDIVR_R(x) (((x) - 1) << RCC_PLL1DIVR_R_SHIFT) /* DIVR division factor: 2 - 128 */
442+
443+
/* Bit definitions for RCC_PLL1DIVR register */
444+
434445
#define RCC_PLL1DIVR_N1_SHIFT (0ul)
435446
#define RCC_PLL1DIVR_N1(x) (((x) - 1) << RCC_PLL1DIVR_N1_SHIFT) /* Multiplication factor for VCO: 4 - 512 */
436447
#define RCC_PLL1DIVR_P1_SHIFT (9ul)

0 commit comments

Comments
 (0)