From 387d1ffc16ce9e050403baee0ed07f3d9accf632 Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期五, 04 七月 2025 14:55:15 +0800 Subject: [PATCH] 初步移植完成0.6.8SDK,但发送有len太长未找到原因 --- keil/include/drivers/mk_uart.h | 96 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 83 insertions(+), 13 deletions(-) diff --git a/keil/include/drivers/mk_uart.h b/keil/include/drivers/mk_uart.h index bcf654e..d6c4a21 100644 --- a/keil/include/drivers/mk_uart.h +++ b/keil/include/drivers/mk_uart.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2023 Beijing Hanwei Innovation Technology Ltd. Co. and + * Copyright (c) 2019-2025 Beijing Hanwei Innovation Technology Ltd. Co. and * its subsidiaries and affiliates (collectly called MKSEMI). * * All rights reserved. @@ -65,7 +65,7 @@ #define UART_ERR_LINE 0x40000000 #define UART_ERR_TIMEOUT 0x20000000 #define UART_ERR_BUSY 0x10000000 -//脪脝脰虏 +//ò??2 #define SerialPutString(x) Serial_PutString((uint8_t*)(x)) #define Serial0PutString(x) Serial0_PutString((uint8_t*)(x)) uint32_t SerialKeyPressed(uint8_t *key); @@ -294,6 +294,18 @@ void uart_baud_set(enum UART_DEV_T id, enum UART_BAUD_T baud); /** + * @brief UART busy + * @param[in] id UART device ID. \n + * This parameter should be one of the UART_DEV_T enum values as below + * @arg UART_ID0 uart0 + * @arg UART_ID1 uart1 + * @return + * @arg true UART TX or RX in progress on the interface, or TX data or RX data present in FIFO + @arg false UART idle or inactive + */ +bool uart_is_busy(enum UART_DEV_T id); + +/** * @brief check whether the UART TX in progress * @param[in] id UART device ID. \n * This parameter should be one of the UART_DEV_T enum values as below @@ -306,16 +318,16 @@ bool uart_tx_in_progress(enum UART_DEV_T id); /** - * @brief UART busy + * @brief check whether the UART TX FIFO is empty * @param[in] id UART device ID. \n * This parameter should be one of the UART_DEV_T enum values as below * @arg UART_ID0 uart0 * @arg UART_ID1 uart1 * @return - * @arg true UART TX or RX in progress on the interface, or TX data or RX data present in FIFO - @arg false UART idle or inactive + * @arg true UART TX FIFO empty + * @arg false UART TX FIFO not empty */ -bool uart_fifo_busy(enum UART_DEV_T id); +bool uart_tx_fifo_is_empty(enum UART_DEV_T id); /** * @brief Clear UART RX FIFO @@ -372,6 +384,56 @@ int uart_receive(enum UART_DEV_T id, uint8_t *rx_buf, uint32_t len, drv_callback_t callback); /** + * @brief Receive an amount of data using DMA with LLP (link list pointer) feature. + * @param[in] id UART device ID. \n + * This parameter should be one of the UART_DEV_T enum values as below + * @arg UART_ID0 uart0 + * @arg UART_ID1 uart1 + * @param[out] rx_buf Pointer to data buffer + * @param[in] len Bytes of data to be received + * @param[in] desc Pointer to link list descriptor + * @param[in] callback Pointer to UART Rx Callback function. + * @return + * @arg DRV_ERROR error id + * @arg DRV_BUSY send failed because of UART Tx is busy + * @arg DEV_OK send succeed + */ +int uart_dma_receive_with_llp(enum UART_DEV_T id, uint8_t *rx_buf, uint32_t len, struct DMA_LINK_DESC_T *desc, drv_callback_t callback); + +/** + * @brief Sends an amount of data over internal FIFO + * @param[in] id UART device ID. \n + * This parameter should be one of the UART_DEV_T enum values as below + * @arg UART_ID0 uart0 + * @arg UART_ID1 uart1 + * @param[in] tx_buf Pointer to data buffer + * @param[in] len Bytes of data to be sent + * @return void + * @note This is an unsafe interface thus the USER MUST ensure that following things \n + * 1. @P len MUST NOT exceeds 16 bytes \n + * 2. DO NOT call this interface while HW is sending data \n + * 3. The uart @p id MUST be opened before this interface gets called \n + * 4. DO NOT enable \ref UART_HANDLE_T::int_tx while uart @p id gets opened + */ +void uart_send_over_fifo(enum UART_DEV_T id, uint8_t *tx_buf, uint32_t len); + +/** + * @brief Receive an amount of data from internal FIFO + * @param[in] id UART device ID. \n + * This parameter should be one of the UART_DEV_T enum values as below + * @arg UART_ID0 uart0 + * @arg UART_ID1 uart1 + * @param[in] tx_buf Pointer to data buffer + * @param[in] len Bytes of data to be sent + * @return The bytes of data receive from interval FIFO + * @note This is an unsafe interface thus the USER MUST ensure that following things \n + * 1. @P len MUST NOT exceeds 16 bytes \n + * 2. The uart @p id MUST be opened before this interface gets called \n + * 3. DO NOT enable \ref UART_HANDLE_T::int_rx while uart @p id gets opened + */ +uint32_t uart_receive_from_fifo(enum UART_DEV_T id, uint8_t *rx_buf, uint32_t len); + +/** * @brief Abort ongoing Transmit transfer. * @note This function is used to abort the ongoing uart TX transfer, if the * TX transfer is completed before uart dma abort, the abort_tx_callback @@ -400,6 +462,20 @@ * @arg DEV_OK Disable UART DMA RX request succeed */ int uart_rx_abort_dma(enum UART_DEV_T id, drv_callback_t abort_rx_callback); + +/** + * @brief Force abort ongoing Receive transfer. + * @note This function is used to abort the ongoing uart RX transfer and call + * abort_rx_callback immediately. + * @param[in] id UART device ID. \n + * This parameter should be one of the UART_DEV_T enum values as below + * @arg UART_ID0 uart0 + * @arg UART_ID1 uart1 + * @param[in] abort_rx_callback DMA UART RX transfer abort callback + * @return @arg DRV_ERROR Abort error + * @arg DEV_OK Disable UART DMA RX request succeed + */ +int uart_rx_force_abort_dma(enum UART_DEV_T id, drv_callback_t abort_rx_callback); /** * @brief Handles interrupt request. @@ -443,13 +519,7 @@ * @return None */ void uart_printf(enum UART_DEV_T id, const char *fmt, ...); -/** - * @brief This function get USART1 rxcount to DMA handler - * @param[in] id void default usart1 - * @param[in] fmt - * @return rx count from usart1 - */ -uint32_t get_rx_count_from_uart1(void); + #ifdef __cplusplus } #endif -- Gitblit v1.9.3