關注+星標公眾號,不錯過精彩內容

作者?|?strongerHuang
微信公眾號 | strongerHuang


在春節假期,我也試著在?DeepSeek 上問了一些嵌入式相關的問題,給出的答案,會明顯的比國內其他工具要好的多。那么,利用Deepseek學習嵌入式技術,合適嗎?
比如問:學習嵌入式的路線


QueueHandle_t uart_rx_queue;QueueHandle_t uart_tx_queue;typedef struct {uint8_t length;uint8_t data[256];uint8_t checksum;} uart_frame_t;void uart_rx_task(void *pvParameters) {uint8_t rx_byte;uart_frame_t rx_frame;uint8_t state = 0;uint8_t index = 0;uint8_t checksum = 0;while (1) {if (xQueueReceive(uart_rx_queue, &rx_byte, portMAX_DELAY) == pdPASS) {switch (state) {case 0: // 等待起始字節if (rx_byte == START_BYTE) {state = 1;}break;case 1: // 讀取長度rx_frame.length = rx_byte;checksum = rx_byte;state = 2;index = 0;break;case 2: // 讀取數據rx_frame.data[index++] = rx_byte;checksum += rx_byte;if (index >= rx_frame.length) {state = 3;}break;case 3: // 讀取校驗和rx_frame.checksum = rx_byte;if (checksum == rx_frame.checksum) {// 校驗成功,處理數據process_rx_frame(&rx_frame);}state = 0;break;default:state = 0;break;}}}}void uart_tx_task(void *pvParameters) {uart_frame_t tx_frame;while (1) {if (xQueueReceive(uart_tx_queue, &tx_frame, portMAX_DELAY) == pdPASS) {// 發送起始字節USART_SendData(USART1, START_BYTE);while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);// 發送長度USART_SendData(USART1, tx_frame.length);while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);// 發送數據for (uint8_t i = 0; i < tx_frame.length; i++) {USART_SendData(USART1, tx_frame.data[i]);while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);}// 計算并發送校驗和uint8_t checksum = tx_frame.length;for (uint8_t i = 0; i < tx_frame.length; i++) {checksum += tx_frame.data[i];}USART_SendData(USART1, checksum);while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);}}}void process_rx_frame(uart_frame_t *frame) {// 在這里處理接收到的數據幀// 例如:打印數據、響應命令等}void USART1_IRQHandler(void) {if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) {uint8_t rx_byte = USART_ReceiveData(USART1);xQueueSendFromISR(uart_rx_queue, &rx_byte, NULL);}}int main(void) {// 初始化硬件和外設USART_Init();NVIC_Init();// 創建隊列uart_rx_queue = xQueueCreate(UART_RX_QUEUE_SIZE, sizeof(uint8_t));uart_tx_queue = xQueueCreate(UART_TX_QUEUE_SIZE, sizeof(uart_frame_t));// 創建任務xTaskCreate(uart_rx_task, "UART_RX", configMINIMAL_STACK_SIZE, NULL, 1, NULL);xTaskCreate(uart_tx_task, "UART_TX", configMINIMAL_STACK_SIZE, NULL, 1, NULL);// 啟動調度器vTaskStartScheduler();while (1);}

------------?END?------------

●專欄《嵌入式工具》
●專欄《嵌入式開發》
●專欄《Keil教程》
●嵌入式專欄精選教程
點擊“閱讀原文”查看更多分享。