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.

[参考译文] AM62P:在 WKUP 域中启用 UART_回 调模式

Guru**** 2556870 points


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

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1569736/am62p-enabling-uart_callback-mode-in-wkup-domain

部件号:AM62P


工具/软件:

您好、

我尝试在 WKUP 域中启用 uart_callback 模式、但我发现这里没有这种示例工程。 因此、我创建了一个空的 WKUP 工程并将“uart_echo_callback.c"复制“复制到这个工程中。 我选择的 UART 通道是 WKUP_UART0、我发现程序在第 50 行被阻止、断点不能插入到函数“uart_echo_write_callback “中。 我只想仔细检查 WKUP 域中的 UART_callback 模式是可行的、还是这种 现象导致了我的编码错误。

我附上了下面的相关代码和数字。

BR、

Bomiao

#include <string.h>
#include <kernel/dpl/DebugP.h>
#include "ti_drivers_config.h"
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"

#define APP_UART_BUFSIZE              (200U)
#define APP_UART_RECEIVE_BUFSIZE      (8U)

uint8_t gUartBuffer[APP_UART_BUFSIZE];
uint8_t gUartReceiveBuffer[APP_UART_RECEIVE_BUFSIZE];
volatile uint32_t gNumBytesRead = 0U, gNumBytesWritten = 0U;

/* Semaphore to indicate Write/Read completion used in callback api's */
static SemaphoreP_Object gUartWriteDoneSem;
static SemaphoreP_Object gUartReadDoneSem;

#define APP_UART_ASSERT_ON_FAILURE(transferOK, transaction) \
    do { \
        if((SystemP_SUCCESS != (transferOK)) || (UART_TRANSFER_STATUS_SUCCESS != transaction.status)) \
        { \
            DebugP_assert(FALSE); /* UART TX/RX failed!! */ \
        } \
    } while(0) \

void uart_echo_callback(void *args)
{
    int32_t          transferOK, status;
    UART_Transaction trans;

    DebugP_log("[UART] Echo callback example started ...\r\n");

    status = SemaphoreP_constructBinary(&gUartWriteDoneSem, 0);
    DebugP_assert(SystemP_SUCCESS == status);

    status = SemaphoreP_constructBinary(&gUartReadDoneSem, 0);
    DebugP_assert(SystemP_SUCCESS == status);

    UART_Transaction_init(&trans);

    /* Send entry string */
    gNumBytesWritten = 0U;
    trans.buf   = &gUartBuffer[0U];
    strncpy(trans.buf,"This is uart echo test callback mode\r\nReceives 8 characters then echo's back. Please input..\r\n", APP_UART_BUFSIZE);
    trans.count = strlen(trans.buf);
    transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
    APP_UART_ASSERT_ON_FAILURE(transferOK, trans);

    /* Wait for write completion */
    SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
    DebugP_assert(gNumBytesWritten == strlen(trans.buf));

    /* Read 8 chars */
    gNumBytesRead = 0U;
    trans.buf   = &gUartReceiveBuffer[0U];
    trans.count = APP_UART_RECEIVE_BUFSIZE;
    transferOK = UART_read(gUartHandle[CONFIG_UART_CONSOLE], &trans);
    APP_UART_ASSERT_ON_FAILURE(transferOK, trans);

    /* Wait for read completion */
    SemaphoreP_pend(&gUartReadDoneSem, SystemP_WAIT_FOREVER);
    DebugP_assert(gNumBytesRead == APP_UART_RECEIVE_BUFSIZE);

    /* Echo chars entered */
    gNumBytesWritten = 0U;
    trans.buf   = &gUartReceiveBuffer[0U];
    trans.count = APP_UART_RECEIVE_BUFSIZE;
    transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
    APP_UART_ASSERT_ON_FAILURE(transferOK, trans);

    /* Wait for write completion */
    SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
    DebugP_assert(gNumBytesWritten == APP_UART_RECEIVE_BUFSIZE);

    /* Send exit string */
    gNumBytesWritten = 0U;
    trans.buf   = &gUartBuffer[0U];
    strncpy(trans.buf, "\r\nAll tests have passed!!\r\n", APP_UART_BUFSIZE);
    trans.count = strlen(trans.buf);
    transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
    APP_UART_ASSERT_ON_FAILURE(transferOK, trans);

    /* Wait for write completion */
    SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
    DebugP_assert(gNumBytesWritten == strlen(trans.buf));

    SemaphoreP_destruct(&gUartWriteDoneSem);
    SemaphoreP_destruct(&gUartReadDoneSem);

    DebugP_log("All tests have passed!!\r\n");

    return;
}

void uart_echo_write_callback(UART_Handle handle, UART_Transaction *trans)
{
    DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
    gNumBytesWritten = trans->count;
    SemaphoreP_post(&gUartWriteDoneSem);

    return;
}

void uart_echo_read_callback(UART_Handle handle, UART_Transaction *trans)
{
    DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
    gNumBytesRead = trans->count;
    SemaphoreP_post(&gUartReadDoneSem);

    return;
}

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

    您好、

    请参阅以下常见问题解答、了解不同 UART 端口的用法: e2e.ti.com/.../4839735

    在开始使用回波回调之前、请验证使用 wkup 示例+ wkup uart0 的正常 UART 回波

    请查看您是否能够为阻塞回声示例在控制台上输入字符、然后我们可以查看回调实现。

    此外、请参阅: software-dl.ti.com/.../DEVELOP_AND_DEBUG_DMR5.html

    谢谢、

    Vaibhav

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

    您好、

    现在、我尝试测试示例工程“uart_echo_callback_am62px-sk_mcu-R5fss0-0_freertos_ti-arm-clang"。“。 我注意到代码引入了“Semaphore_Object"以“以监控 UART 写入/读取的传输状态。 当我评论与 信标相关的代码时、我发现工程无法正常运行、并报告“UART Write Failed“。  我想知道我们是否可以放弃那些信 标,因为我认为信标只是一个奖金来监视转移过程和代码应该正常运行没有信标 .

    我在下面附上了我的代码。

    #include <string.h>
    #include <kernel/dpl/DebugP.h>
    #include "ti_drivers_config.h"
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.h"
    
    #define APP_UART_BUFSIZE              (200U)
    #define APP_UART_RECEIVE_BUFSIZE      (8U)
    
    uint8_t gUartBuffer[APP_UART_BUFSIZE];
    uint8_t gUartReceiveBuffer[APP_UART_RECEIVE_BUFSIZE];
    volatile uint32_t gNumBytesRead = 0U, gNumBytesWritten = 0U;
    
    /* Semaphore to indicate Write/Read completion used in callback api's */
    // static SemaphoreP_Object gUartWriteDoneSem;
    // static SemaphoreP_Object gUartReadDoneSem;
    
    #define APP_UART_ASSERT_ON_FAILURE(transferOK, transaction) \
        do { \
            if((SystemP_SUCCESS != (transferOK)) || (UART_TRANSFER_STATUS_SUCCESS != transaction.status)) \
            { \
                DebugP_assert(FALSE); /* UART TX/RX failed!! */ \
            } \
        } while(0) \
    
    void uart_echo_callback(void *args)
    {
        int32_t          transferOK, status;
        UART_Transaction trans;
    
        DebugP_log("[UART] Echo callback example started ...\r\n");
    
        // status = SemaphoreP_constructBinary(&gUartWriteDoneSem, 0);
        // DebugP_assert(SystemP_SUCCESS == status);
    
        // status = SemaphoreP_constructBinary(&gUartReadDoneSem, 0);
        // DebugP_assert(SystemP_SUCCESS == status);
    
        UART_Transaction_init(&trans);
    
        /* Send entry string */
        gNumBytesWritten = 0U;
        trans.buf   = &gUartBuffer[0U];
        strncpy(trans.buf,"This is uart echo test callback mode\r\nReceives 8 characters then echo's back. Please input..\r\n", APP_UART_BUFSIZE);
        trans.count = strlen(trans.buf);
        transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
        APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
    
        /* Wait for write completion */
        // SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
        // DebugP_assert(gNumBytesWritten == strlen(trans.buf));
    
        /* Read 8 chars */
        gNumBytesRead = 0U;
        trans.buf   = &gUartReceiveBuffer[0U];
        trans.count = APP_UART_RECEIVE_BUFSIZE;
        transferOK = UART_read(gUartHandle[CONFIG_UART_CONSOLE], &trans);
        APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
    
        /* Wait for read completion */
        // SemaphoreP_pend(&gUartReadDoneSem, SystemP_WAIT_FOREVER);
        // DebugP_assert(gNumBytesRead == APP_UART_RECEIVE_BUFSIZE);
    
        /* Echo chars entered */
        gNumBytesWritten = 0U;
        trans.buf   = &gUartReceiveBuffer[0U];
        trans.count = APP_UART_RECEIVE_BUFSIZE;
        transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
        APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
    
        /* Wait for write completion */
        // SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
        // DebugP_assert(gNumBytesWritten == APP_UART_RECEIVE_BUFSIZE);
    
        /* Send exit string */
        gNumBytesWritten = 0U;
        trans.buf   = &gUartBuffer[0U];
        strncpy(trans.buf, "\r\nAll tests have passed!!\r\n", APP_UART_BUFSIZE);
        trans.count = strlen(trans.buf);
        transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
        APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
    
        /* Wait for write completion */
        // SemaphoreP_pend(&gUartWriteDoneSem, SystemP_WAIT_FOREVER);
        // DebugP_assert(gNumBytesWritten == strlen(trans.buf));
    
        // SemaphoreP_destruct(&gUartWriteDoneSem);
        // SemaphoreP_destruct(&gUartReadDoneSem);
    
        DebugP_log("All tests have passed!!\r\n");
    
        return;
    }
    
    void uart_echo_write_callback(UART_Handle handle, UART_Transaction *trans)
    {
        DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
        gNumBytesWritten = trans->count;
        //SemaphoreP_post(&gUartWriteDoneSem);
    
        return;
    }
    
    void uart_echo_read_callback(UART_Handle handle, UART_Transaction *trans)
    {
        DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
        gNumBytesRead = trans->count;
        //SemaphoreP_post(&gUartReadDoneSem);
    
        return;
    }

    BR、

    Bomiao

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

    尊敬的 Bomiao:

    我在阻塞模式下测试了 WKUP UART、结果就顺利了。

    对于回调模式、我也看到问题。 如果您自上次实验以来对此有任何更新、请告知我。

    我也提出了一个内部错误。

    谢谢、

    Vaibhav