修复SPI通道错误的问题,增加看门狗功能

This commit is contained in:
cbb
2025-10-02 23:50:12 +08:00
parent 20fbb30067
commit d755715363
9 changed files with 152 additions and 113 deletions
+15 -1
View File
@@ -95,7 +95,6 @@ void GPIO_config(void) {
rcu_periph_clock_enable(RCU_GPIOB);
// 配置PB2为输入引脚,用于读取电机状态
gpio_init(GPIOB, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_2);
}
/* retarget the C library printf function to the USART */
@@ -104,6 +103,21 @@ u8 USART0_init() {
return 1;
}
/*!
\brief configure the watchdog peripheral
\param[in] none
\param[out] none
\retval none
*/
u8 watchdog_init(u32 time) {
u8 status = 0;
/* configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
/* time = reload_value / clock_frequency */
status = fwdgt_config(time * 0.625, FWDGT_PSC_DIV64);
fwdgt_enable();
return status;
}
int fputc(int ch, FILE *f) throw() {
usart_data_transmit(EVAL_COM0, (uint8_t)ch);
while (RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE))