From 199a171e3ef6216b8836088937fdd48b68574f5a Mon Sep 17 00:00:00 2001 From: Mark Frost Date: Fri, 14 Jul 2023 11:43:40 -0500 Subject: [PATCH] Remove references to the deprecated SYSTEM_CORE_CLOCK and clean up unnecessary APB_CLOCK #defines SYSTEM_CORE_CLOCK went away in favor of FUNCONF_SYSTEM_CORE_CLOCK APB_CLOCK is only used in the i2c_slave.h and ch32v003_SPI.h files so the references there have been maintained. --- attic/external_crystal_run_from_ram_turbo.c | 2 -- examples/MCOtest/MCOtest.c | 3 --- examples/bootload/bootload.c | 5 ----- examples/cpp_virtual_methods/cpp_virtual_methods.cpp | 4 ---- examples/dma_gpio/dma_gpio.c | 3 --- examples/self_modify_code/self_modify_code.c | 1 - examples/spi_24L01_rx/nrf24l01_low_level.c | 2 -- examples/spi_24L01_tx/nrf24l01_low_level.c | 2 -- examples/standby_autowake/standby_autowake.c | 4 ---- examples/standby_btn/standby_btn.c | 4 ---- examples/ws2812bdemo/ws2812bdemo.c | 4 ---- extralibs/ch32v003_GPIO_branchless.h | 8 -------- extralibs/ch32v003_SPI.h | 5 +++++ 13 files changed, 5 insertions(+), 42 deletions(-) diff --git a/attic/external_crystal_run_from_ram_turbo.c b/attic/external_crystal_run_from_ram_turbo.c index cd2a0bbc..89512528 100644 --- a/attic/external_crystal_run_from_ram_turbo.c +++ b/attic/external_crystal_run_from_ram_turbo.c @@ -4,8 +4,6 @@ #include "ch32v003fun.h" #include -#define APB_CLOCK SYSTEM_CORE_CLOCK - uint32_t count; void RamFunction() __attribute__((naked)); diff --git a/examples/MCOtest/MCOtest.c b/examples/MCOtest/MCOtest.c index aaf3b343..61002a95 100644 --- a/examples/MCOtest/MCOtest.c +++ b/examples/MCOtest/MCOtest.c @@ -1,6 +1,3 @@ -#define SYSTEM_CORE_CLOCK 48000000 -#define APB_CLOCK SYSTEM_CORE_CLOCK - #include "ch32v003fun.h" #include diff --git a/examples/bootload/bootload.c b/examples/bootload/bootload.c index 5032b555..f54ea9d8 100644 --- a/examples/bootload/bootload.c +++ b/examples/bootload/bootload.c @@ -1,11 +1,6 @@ -// Could be defined here, or in the processor defines. -#define SYSTEM_CORE_CLOCK 48000000 - #include "ch32v003fun.h" #include -#define APB_CLOCK SYSTEM_CORE_CLOCK - uint32_t count; // You can override the interrupt vector this way: diff --git a/examples/cpp_virtual_methods/cpp_virtual_methods.cpp b/examples/cpp_virtual_methods/cpp_virtual_methods.cpp index f6f1fc30..93837776 100644 --- a/examples/cpp_virtual_methods/cpp_virtual_methods.cpp +++ b/examples/cpp_virtual_methods/cpp_virtual_methods.cpp @@ -3,10 +3,6 @@ * 05/21/2023 A. Mandera */ -// Could be defined here, or in the processor defines. -#define SYSTEM_CORE_CLOCK 48000000 -#define APB_CLOCK SYSTEM_CORE_CLOCK - #include "ch32v003fun.h" #include "example.h" #include diff --git a/examples/dma_gpio/dma_gpio.c b/examples/dma_gpio/dma_gpio.c index 5f7a6988..07fcd234 100644 --- a/examples/dma_gpio/dma_gpio.c +++ b/examples/dma_gpio/dma_gpio.c @@ -8,13 +8,10 @@ // The interrupt fires once at the beginning and // once at the end. // -#define SYSTEM_CORE_CLOCK 48000000 #include "ch32v003fun.h" #include -#define APB_CLOCK SYSTEM_CORE_CLOCK - volatile uint32_t count; #define MBSAMPS 1024 diff --git a/examples/self_modify_code/self_modify_code.c b/examples/self_modify_code/self_modify_code.c index c0155eaf..abb6890a 100644 --- a/examples/self_modify_code/self_modify_code.c +++ b/examples/self_modify_code/self_modify_code.c @@ -1,7 +1,6 @@ /* Small example showing how to use the SWIO programming pin to do printf through the debug interface */ -#define SYSTEM_CORE_CLOCK 24000000 #include "ch32v003fun.h" #include diff --git a/examples/spi_24L01_rx/nrf24l01_low_level.c b/examples/spi_24L01_rx/nrf24l01_low_level.c index a69547b3..54096f6f 100644 --- a/examples/spi_24L01_rx/nrf24l01_low_level.c +++ b/examples/spi_24L01_rx/nrf24l01_low_level.c @@ -1,5 +1,3 @@ -#define SYSTEM_CORE_CLOCK 48000000 -#define APB_CLOCK SYSTEM_CORE_CLOCK #include "ch32v003fun.h" diff --git a/examples/spi_24L01_tx/nrf24l01_low_level.c b/examples/spi_24L01_tx/nrf24l01_low_level.c index a69547b3..54096f6f 100644 --- a/examples/spi_24L01_tx/nrf24l01_low_level.c +++ b/examples/spi_24L01_tx/nrf24l01_low_level.c @@ -1,5 +1,3 @@ -#define SYSTEM_CORE_CLOCK 48000000 -#define APB_CLOCK SYSTEM_CORE_CLOCK #include "ch32v003fun.h" diff --git a/examples/standby_autowake/standby_autowake.c b/examples/standby_autowake/standby_autowake.c index 301e163f..4cfaaf34 100644 --- a/examples/standby_autowake/standby_autowake.c +++ b/examples/standby_autowake/standby_autowake.c @@ -1,12 +1,8 @@ // based on https://paste.sr.ht/blob/b9b4fb45cbc70f2db7e31a77a6ef7dd2a7f220fb -// Could be defined here, or in the processor defines. -#define SYSTEM_CORE_CLOCK 48000000 #include "ch32v003fun.h" #include -#define APB_CLOCK SYSTEM_CORE_CLOCK - /* somehow this ISR won't get called?? void AWU_IRQHandler( void ) __attribute__((interrupt)); void AWU_IRQHandler( void ) { diff --git a/examples/standby_btn/standby_btn.c b/examples/standby_btn/standby_btn.c index 2c86bc19..33f55a89 100644 --- a/examples/standby_btn/standby_btn.c +++ b/examples/standby_btn/standby_btn.c @@ -1,12 +1,8 @@ // based on https://paste.sr.ht/blob/b9b4fb45cbc70f2db7e31a77a6ef7dd2a7f220fb -// Could be defined here, or in the processor defines. -#define SYSTEM_CORE_CLOCK 48000000 #include "ch32v003fun.h" #include -#define APB_CLOCK SYSTEM_CORE_CLOCK - void EXTI7_0_IRQHandler( void ) __attribute__((interrupt)); void EXTI7_0_IRQHandler( void ) { //GPIOD->OUTDR ^= (1 << 4); diff --git a/examples/ws2812bdemo/ws2812bdemo.c b/examples/ws2812bdemo/ws2812bdemo.c index f1b1a60b..a931fa22 100644 --- a/examples/ws2812bdemo/ws2812bdemo.c +++ b/examples/ws2812bdemo/ws2812bdemo.c @@ -1,7 +1,3 @@ -// Could be defined here, or in the processor defines. -#define SYSTEM_CORE_CLOCK 48000000 -#define APB_CLOCK SYSTEM_CORE_CLOCK - // NOTE: CONNECT WS2812's to PC6 #include "ch32v003fun.h" diff --git a/extralibs/ch32v003_GPIO_branchless.h b/extralibs/ch32v003_GPIO_branchless.h index 40aa3765..c8071e17 100644 --- a/extralibs/ch32v003_GPIO_branchless.h +++ b/extralibs/ch32v003_GPIO_branchless.h @@ -290,14 +290,6 @@ static inline void GPIO_tim2_init(); #define GPIO_timer_prescaler TIM_CKD_DIV2 // APB_CLOCK / 1024 / 2 = 23.4kHz #endif -// maintenance define -#if !defined(SYSTEM_CORE_CLOCK) -#define SYSTEM_CORE_CLOCK 48000000 -#define APB_CLOCK SYSTEM_CORE_CLOCK -#endif - - - //######## define requirements / maintenance defines diff --git a/extralibs/ch32v003_SPI.h b/extralibs/ch32v003_SPI.h index f7263fa9..83e055d9 100644 --- a/extralibs/ch32v003_SPI.h +++ b/extralibs/ch32v003_SPI.h @@ -16,6 +16,11 @@ in the .c files that use this library, you'll need to #define some configuration SYSTEM_CORE_CLOCK and APB_CLOCK should be defined already as APB_CLOCK is used by this library + +#ifndef APB_CLOCK + #define APB_CLOCK FUNCONF_SYSTEM_CORE_CLOCK +#endif + to enable using the functions of this library: #define CH32V003_SPI_IMPLEMENTATION