AI工具写的环形缓冲区

This commit is contained in:
2025-08-11 20:11:46 +08:00
parent c6c90800d4
commit 4a488429bf
13 changed files with 470 additions and 154 deletions

View File

@@ -37,6 +37,15 @@ OF SUCH DAMAGE.
#include "uart.h"
#include "led.h"
#include <stdio.h>
#include "board_config.h"
#include "uart_ring_buffer.h"
#include "command.h"
void uart_puts(const char *s) {
while (*s) {
usart_data_transmit(RS485_PHY, (uint8_t)*s++);
}
}
/*!
\brief main function
@@ -46,17 +55,28 @@ OF SUCH DAMAGE.
*/
int main(void)
{
systick_config();
uart0_init();
// uart1_init(115200); // 如需使用USART1请初始化
// printf("Hello USART0!\r\n");
// uart_set_printf_port(UART_PRINTF_USART1); // 切换printf到USART1
// uart_set_printf_port(UART_PRINTF_BOTH); // 同时输出到USART0和USART1
setbuf(stdout, NULL);
systick_config();
rs485_init();
// rcu_periph_clock_enable(RCU_GPIOA);
// gpio_mode_set(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_1);
// gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_1);
// gpio_bit_set(GPIOA, GPIO_PIN_1);
led_init();
printf("Hello USART0!");
led_off();
while(1){
led_toggle();
delay_ms(200);
// led_toggle();
// 发送数据到 USART0
// usart_data_transmit(RS485_PHY, (uint8_t)'H');
// printf("Hello USART0!");
delay_ms(100);
command_process();
}
}