Skip to content

Commit 160d64b

Browse files
committed
minor clean up. ch32v307 has issue with uart LOG=2 (skipping characters)
1 parent 3cf21c6 commit 160d64b

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

hw/bsp/ch32v307/boards/ch32v307v-r1-1v0/debug_uart.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -77,34 +77,34 @@ void uart_sync(void)
7777

7878
void usart_printf_init(uint32_t baudrate)
7979
{
80-
GPIO_InitTypeDef GPIO_InitStructure;
81-
USART_InitTypeDef USART_InitStructure;
82-
83-
tx_produce = 0;
84-
tx_consume = 0;
85-
86-
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
87-
88-
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
89-
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
90-
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
91-
GPIO_Init(GPIOA, &GPIO_InitStructure);
92-
93-
USART_InitStructure.USART_BaudRate = baudrate;
94-
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
95-
USART_InitStructure.USART_StopBits = USART_StopBits_1;
96-
USART_InitStructure.USART_Parity = USART_Parity_No;
97-
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
98-
USART_InitStructure.USART_Mode = USART_Mode_Tx;
99-
100-
USART_Init(USART1, &USART_InitStructure);
101-
USART_ITConfig(USART1, USART_IT_TC, ENABLE);
102-
USART_Cmd(USART1, ENABLE);
103-
104-
NVIC_InitTypeDef NVIC_InitStructure = {0};
105-
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
106-
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
107-
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
108-
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
109-
NVIC_Init(&NVIC_InitStructure);
80+
GPIO_InitTypeDef GPIO_InitStructure;
81+
USART_InitTypeDef USART_InitStructure;
82+
83+
tx_produce = 0;
84+
tx_consume = 0;
85+
86+
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
87+
88+
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
89+
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
90+
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
91+
GPIO_Init(GPIOA, &GPIO_InitStructure);
92+
93+
USART_InitStructure.USART_BaudRate = baudrate;
94+
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
95+
USART_InitStructure.USART_StopBits = USART_StopBits_1;
96+
USART_InitStructure.USART_Parity = USART_Parity_No;
97+
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
98+
USART_InitStructure.USART_Mode = USART_Mode_Tx;
99+
100+
USART_Init(USART1, &USART_InitStructure);
101+
USART_ITConfig(USART1, USART_IT_TC, ENABLE);
102+
USART_Cmd(USART1, ENABLE);
103+
104+
NVIC_InitTypeDef NVIC_InitStructure = { 0 };
105+
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
106+
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
107+
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
108+
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
109+
NVIC_Init(&NVIC_InitStructure);
110110
}

hw/bsp/ch32v307/family.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,22 @@ void board_init(void) {
106106
volatile uint32_t system_ticks = 0;
107107

108108
/* Small workaround to support HW stack save/restore */
109-
void SysTick_Handler(void) __attribute__((naked));
110-
void SysTick_Handler(void) {
111-
__asm volatile ("call SysTick_Handler_impl; mret");
109+
void SysTick_Handler (void) __attribute__((naked));
110+
void SysTick_Handler (void)
111+
{
112+
__asm volatile ("call SysTick_Handler_impl; mret");
112113
}
113114

114-
__attribute__((used)) void SysTick_Handler_impl(void) {
115-
SysTick->SR=0;
115+
__attribute__((used)) void SysTick_Handler_impl (void)
116+
{
117+
SysTick->SR = 0;
116118
system_ticks++;
117119
}
118120

119-
uint32_t board_millis(void) { return system_ticks; }
121+
uint32_t board_millis (void)
122+
{
123+
return system_ticks;
124+
}
120125

121126
#endif
122127

hw/bsp/ch32v307/family.mk

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ CH32V307_SDK_SRC = $(CH32V307_SDK)/EVT/EXAM/SRC
1313

1414
include $(TOP)/$(BOARD_PATH)/board.mk
1515

16-
SKIP_NANOLIB = 1
17-
1816
CFLAGS += \
1917
-flto \
2018
-march=rv32imac \
@@ -30,9 +28,6 @@ CFLAGS += \
3028
-Xlinker --gc-sections \
3129
-DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
3230

33-
LDFLAGS += \
34-
-Xlinker --gc-sections --specs=nano.specs --specs=nosys.specs
35-
3631
SRC_C += \
3732
src/portable/wch/ch32v307/dcd_usbhs.c \
3833
$(CH32V307_SDK_SRC)/Core/core_riscv.c \

0 commit comments

Comments
 (0)