From dba3e59e5ad02c89450e01bb5b5f9c05a383900f Mon Sep 17 00:00:00 2001 From: Maxint R&D Date: Tue, 1 Jul 2025 17:28:56 +0200 Subject: [PATCH] No PortB on CH32V002 --- system/CH32VM00X/SRC/Peripheral/inc/ch32v00X.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/system/CH32VM00X/SRC/Peripheral/inc/ch32v00X.h b/system/CH32VM00X/SRC/Peripheral/inc/ch32v00X.h index 65d279b..32a7cf7 100644 --- a/system/CH32VM00X/SRC/Peripheral/inc/ch32v00X.h +++ b/system/CH32VM00X/SRC/Peripheral/inc/ch32v00X.h @@ -413,7 +413,10 @@ typedef struct #define AFIO_BASE (PB2PERIPH_BASE + 0x0000) #define EXTI_BASE (PB2PERIPH_BASE + 0x0400) #define GPIOA_BASE (PB2PERIPH_BASE + 0x0800) -#define GPIOB_BASE (PB2PERIPH_BASE + 0x0C00) +#ifndef CH32V002F4 // MMOLE 250625: V002 has no port B (same for V004), not having GPIOB_BASE makes flash size a bit smaller. + // TODO: other V002 and V004 + #define GPIOB_BASE (PB2PERIPH_BASE + 0x0C00) +#endif #define GPIOC_BASE (PB2PERIPH_BASE + 0x1000) #define GPIOD_BASE (PB2PERIPH_BASE + 0x1400) #define ADC1_BASE (PB2PERIPH_BASE + 0x2400) @@ -445,7 +448,10 @@ typedef struct #define AFIO ((AFIO_TypeDef *)AFIO_BASE) #define EXTI ((EXTI_TypeDef *)EXTI_BASE) #define GPIOA ((GPIO_TypeDef *)GPIOA_BASE) -#define GPIOB ((GPIO_TypeDef *)GPIOB_BASE) +#if defined(GPIOB_BASE) + // MMOLE 250625: V002 and V004 have no port B + #define GPIOB ((GPIO_TypeDef *)GPIOB_BASE) +#endif #define GPIOC ((GPIO_TypeDef *)GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *)GPIOD_BASE) #define ADC1 ((ADC_TypeDef *)ADC1_BASE)