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.

[参考译文] CC2652P:SDK 6.10中的 UART2 CAN#39;t 触发器发送回调

Guru**** 2466550 points


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

https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum/1120652/cc2652p-uart2-in-sdk-6-10-can-t-trigger-send-callback

器件型号:CC2652P

我的 UART 正在运行回调模式、我 准备将我的固件从 SDK6.10更新到 SDK6.20。 但我尝试使用 UART2来代替 UART、UART2发送回调从未执行过

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

    您好!

    我已经按照以下方式修改了 uart2callback、并且可以看到正在执行写入回调:

    /*
     * Copyright (c) 2020, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== uart2callback.c ========
     */
    #include <stdint.h>
    #include <stddef.h>
    
    /* POSIX Header files */
    #include <semaphore.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/UART2.h>
    
    /* Driver configuration */
    #include "ti_drivers_config.h"
    
    static sem_t sem;
    static volatile size_t numBytesRead;
    static volatile size_t numBytesWrite;
    /*
     *  ======== callbackReadFxn ========
     */
    void callbackReadFxn(UART2_Handle handle, void *buffer, size_t count,
            void *userArg, int_fast16_t status)
    {
        if (status != UART2_STATUS_SUCCESS) {
            /* RX error occured in UART2_read() */
            while (1);
        }
    
        numBytesRead = count;
        sem_post(&sem);
    }
    
    /*
     *  ======== callbackWriteFxn ========
     */
    void callbackWriteFxn(UART2_Handle handle, void *buffer, size_t count,
            void *userArg, int_fast16_t status)
    {
        if (status != UART2_STATUS_SUCCESS) {
            /* RX error occured in UART2_read() */
            while (1);
        }
    
        numBytesWrite = count;
    }
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        char              input;
        const char        echoPrompt[] = "Echoing characters:\r\n";
        UART2_Handle      uart;
        UART2_Params      uartParams;
        int32_t           semStatus;
        uint32_t          status = UART2_STATUS_SUCCESS;
    
        /* Call driver init functions */
        GPIO_init();
    
        /* Configure the LED pin */
        GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Create semaphore */
        semStatus = sem_init(&sem, 0, 0);
    
        if (semStatus != 0) {
            /* Error creating semaphore */
            while (1);
        }
    
        /* Create a UART in CALLBACK read mode */
        UART2_Params_init(&uartParams);
        uartParams.readMode = UART2_Mode_CALLBACK;
        uartParams.readCallback = callbackReadFxn;
        uartParams.writeMode = UART2_Mode_CALLBACK;
        uartParams.writeCallback = callbackWriteFxn;
        uartParams.baudRate = 115200;
    
        uart = UART2_open(CONFIG_UART2_0, &uartParams);
    
        if (uart == NULL) {
            /* UART2_open() failed */
            while (1);
        }
    
        /* Turn on user LED to indicate successful initialization */
        GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
    
        /* Pass NULL for bytesWritten since it's not used in this example */
        UART2_write(uart, echoPrompt, sizeof(echoPrompt), NULL);
    
        /* Loop forever echoing */
        while (1) {
            numBytesRead = 0;
    
            /* Pass NULL for bytesRead since it's not used in this example */
            status = UART2_read(uart, &input, 1, NULL);
    
            if (status != UART2_STATUS_SUCCESS) {
                /* UART2_read() failed */
                while (1);
            }
    
            /* Do not write until read callback executes */
            sem_wait(&sem);
    
            if (numBytesRead > 0) {
                status = UART2_write(uart, &input, 1, NULL);
    
                if (status != UART2_STATUS_SUCCESS) {
                    /* UART2_write() failed */
                    while (1);
                }
            }
        }
    }
    

    请确保已将 writeMode 配置为 UART2_Mode_callback。

    此致、

    Arthur

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

    在 SDK 6.10中,UART2 Send Callback 无法触发。 但我确实更新到了 SDK 6.20、它可以正常工作。

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

    大家好、我制作了我之前随 SDK 6.10发送的示例。 它会在发送时触发。 您可以共享源代码吗?

    此致、

    Arthur

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

    UART2_Handle cmdUartHandle;
    uint8_t* pCmdUartRxBuf;
    
    void cmd_uartReadCallback(UART2_Handle handle, void *buf, size_t count, void *userArg, int_fast16_t status);
    void cmd_uartWriteCallback(UART2_Handle handle, void *buf, size_t count, void *userArg, int_fast16_t status);
    
    void cmd_uartInit(uint32_t baud)
    {
      UART2_Params params;
      UART2_Params_init(&params);
    
      params.readMode = UART2_Mode_CALLBACK;
      params.writeMode = UART2_Mode_CALLBACK;
      params.baudRate = baud;
      params.readCallback = cmd_uartReadCallback;
      params.writeCallback = cmd_uartWriteCallback;
      params.dataLength = UART2_DataLen_8;
      params.stopBits = UART2_StopBits_1;
      params.readReturnMode = UART2_ReadReturnMode_PARTIAL; //Enable Partial Reads
    
      cmdUartHandle = UART2_open(CMD_UART_PORT, &params);
      UART2_rxEnable(cmdUartHandle);
      //UART_control(cmdUartHandle, CMD_RETURN_PARTIAL_ENABLE, NULL);
      //start rx
      MFG_CSState key;
      key = MFG_enterCS();
      pCmdUartRxBuf = MFG_malloc(CMD_UART_BUF_SIZE);
      UART2_read(cmdUartHandle, pCmdUartRxBuf, CMD_UART_BUF_SIZE, NULL);
      MFG_leaveCS(key);
    }
    
    uint8_t NullSend;
    uint8_t uartSendCnt;
    bool cmd_uartSend(uint8_t* buff, uint16_t size)
    {
      if(size == 0)
      {
        asm("NOP");
        NullSend ++;
      }
      if(UART2_STATUS_SUCCESS != UART2_write(cmdUartHandle, buff, size, &uartSendCnt))
      {
        return false;
      }
      //uartSendCnt ++;
      return true;
    }
    
    void cmd_uartReadCallback(UART2_Handle handle, void *buf, size_t count, void *userArg, int_fast16_t status)
    {
      MFG_CSState key;
      key = MFG_enterCS();
      //Input received data
      CmdPkt_RxInd(buf, count);
      //set next rx
      UART2_read(cmdUartHandle, buf, CMD_UART_BUF_SIZE, NULL);
      MFG_leaveCS(key);
    }
    
    uint8_t SendCb;
    void cmd_uartWriteCallback(UART2_Handle handle, void *buf, size_t count, void *userArg, int_fast16_t status)
    {
      SendCb ++;
      MFG_CSState key;
      key = MFG_enterCS();
      CmdPkt_TxCnf(buf);
      MFG_leaveCS(key);
    }

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

    您好!

    使用我提供的示例、您能看到正在执行发送回调吗? 例如使用断点。

    此致、

    Arthur