generated from hulk/gd32e23x_template
for debug
This commit is contained in:
parent
a546f7bf83
commit
1dacace57a
@ -48,6 +48,7 @@
|
||||
#define USART_RX_PIN GPIO_PIN_3
|
||||
#define USART_PHY USART1
|
||||
#define USART_PHY_BAUDRATE 115200U
|
||||
#define USART_PHY_IRQ USART1_IRQn
|
||||
#define RS485_EN_PORT GPIOA
|
||||
#define RS485_EN_PIN GPIO_PIN_4
|
||||
|
||||
|
@ -15,7 +15,7 @@ void watchdog_init(void) {
|
||||
rcu_osci_stab_wait(RCU_IRC40K);
|
||||
|
||||
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
|
||||
fwdgt_config(6250, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
|
||||
fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
|
||||
|
||||
/* Enable FWDGT */
|
||||
fwdgt_enable();
|
||||
|
@ -159,18 +159,19 @@ void EXTI0_1_IRQHandler(void) {
|
||||
}
|
||||
|
||||
void USART1_IRQHandler(void) {
|
||||
static uint8_t rx_index = 0;
|
||||
static uint8_t rx_buffer[RX_BUFFER_SIZE];
|
||||
// static uint8_t rx_index = 0;
|
||||
// static uint8_t rx_buffer[RX_BUFFER_SIZE];
|
||||
|
||||
if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)) {
|
||||
usart_interrupt_flag_clear(USART0, USART_INT_FLAG_RBNE);
|
||||
uint8_t received_data = (uint8_t) usart_data_receive(USART0);
|
||||
if (RESET != usart_interrupt_flag_get(USART_PHY, USART_INT_FLAG_RBNE)) {
|
||||
usart_interrupt_flag_clear(USART_PHY, USART_INT_FLAG_RBNE);
|
||||
uint8_t received_data = (uint8_t) usart_data_receive(USART_PHY);
|
||||
|
||||
printf("%c", received_data);
|
||||
// // 将接收到的数据存储到缓冲区
|
||||
// if (rx_index < RX_BUFFER_SIZE - 1) {
|
||||
// rx_buffer[rx_index++] = received_data;
|
||||
// }
|
||||
store_char(received_data, &rx_buffer);
|
||||
// store_char(received_data, &rx_buffer);
|
||||
}
|
||||
//
|
||||
// if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) {
|
||||
|
@ -31,7 +31,7 @@ void usart_config(void)
|
||||
usart_baudrate_set(USART_PHY, 115200U);
|
||||
usart_receive_config(USART_PHY, USART_RECEIVE_ENABLE);
|
||||
usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE);
|
||||
nvic_irq_enable(USART1_IRQn, 0);
|
||||
nvic_irq_enable(USART_PHY_IRQ, 0);
|
||||
usart_interrupt_enable(USART_PHY, USART_INT_RBNE);
|
||||
// usart_interrupt_enable(USART_PHY, USART_INT_IDLE);
|
||||
usart_enable(USART_PHY);
|
||||
|
Loading…
x
Reference in New Issue
Block a user