This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2340R2:UART 读取功能问题

Guru**** 2487425 points
Other Parts Discussed in Thread: SYSCONFIG

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1556686/cc2340r2-uart-read-function-issue

器件型号:CC2340R2
主题:SysConfig 中讨论的其他器件

工具/软件:

我目前正在使用 CC2340 BLE 模块并使用 SDK 中的 basic_ble 示例。 在开发过程中、我正在测试 UART 通信、希望器件在从 Docklight 接收到数据时发送响应。

在现有示例中、UART 配置为显示 UART (CONFIG_DISPLAY_UART). 我无法在代码中找到合适的 UART 读取函数。 我还回顾了 SDK 中的 uart_echo 示例、并在 basic_bleproject 中尝试了类似的实现。 当我尝试使用打开 UARTUART2_open() 时、它无法初始化。 您能帮助我们解决这个问题吗?

Pin_Configuration:

TX - DIO20
RX - DIO22

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    打印文本时、软件必须选择它想要使用的 UART 实例。 在 basic_ble 工程中、示例使用的菜单模块会打开一个显示驱动程序实例、其中设置为 Display_Type_ ANY、该实例将使用它找到的第一个显示器件。
      

    在本例中、第一个显示设备将是 SysConfig 中的第一个 UART 设备。

    如果要选择要使用的显示、则需要自己打开显示驱动程序实例、并使用此实例的句柄调用 UART 写入函数。 您可以通过 此链接找到有关如何执行此操作的指南和 API

    简而言之,您的代码将如下所示:

    // Import the UART2 driver definitions
    #include <ti/drivers/UART2.h>
    
    // Open the UART
    UART2_Handle uart;
    // Depends on your SysConfig names
    uart_0 = UART2_open(CONFIG_UART2_0, UART2_config[CONFIG_UART2_0]);
    
    // Write to the UART
    int16_t BUFSIZE = 2;
    int32_t status;
    uint8_t buffer[BUFSIZE];
    size_t  bytesRead;
    status = UART2_read(uart_0, buffer, BUFSIZE, &bytesRead);
    
    // Close the UART
    UART2_close(uart_0);

    您可以在 SysConfig 中设置 UART 器件。 如果您在如何使用此代码方面有问题、请在此处回复。

    此致、
    Maxence