Skip to content

Commit 865e348

Browse files
authored
Merge pull request #3014 from deshipu/master
Allow different port and mode for LED on ch32v boards
2 parents b4252c4 + 1f2f92d commit 865e348

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

hw/bsp/ch32v20x/boards/ch32v203c_r0_1v0/board.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extern "C" {
1313
#define LED_PORT GPIOA
1414
#define LED_PIN GPIO_Pin_0
1515
#define LED_STATE_ON 0
16+
#define LED_CLOCK_EN() RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE)
17+
#define LED_MODE GPIO_Mode_Out_OD
1618

1719
#define UART_DEV USART1
1820
#define UART_CLOCK_EN() RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE)

hw/bsp/ch32v20x/boards/ch32v203g_r0_1v0/board.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extern "C" {
1313
#define LED_PORT GPIOA
1414
#define LED_PIN GPIO_Pin_0
1515
#define LED_STATE_ON 0
16+
#define LED_CLOCK_EN() RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE)
17+
#define LED_MODE GPIO_Mode_Out_OD
1618

1719
#define UART_DEV USART2
1820
#define UART_CLOCK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE)

hw/bsp/ch32v20x/boards/nanoch32v203/board.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extern "C" {
1313
#define LED_PORT GPIOA
1414
#define LED_PIN GPIO_Pin_15
1515
#define LED_STATE_ON 0
16+
#define LED_CLOCK_EN() RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE)
17+
#define LED_MODE GPIO_Mode_Out_OD
1618

1719
#define UART_DEV USART1
1820
#define UART_CLOCK_EN() RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE)

hw/bsp/ch32v20x/family.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ void board_init(void) {
9696
SysTick_Config(SystemCoreClock / 1000);
9797
#endif
9898

99-
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
99+
LED_CLOCK_EN();
100100

101101
GPIO_InitTypeDef GPIO_InitStructure = {
102102
.GPIO_Pin = LED_PIN,
103-
.GPIO_Mode = GPIO_Mode_Out_OD,
103+
.GPIO_Mode = LED_MODE,
104104
.GPIO_Speed = GPIO_Speed_10MHz,
105105
};
106106
GPIO_Init(LED_PORT, &GPIO_InitStructure);

0 commit comments

Comments
 (0)