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.

[参考译文] LAUNCHXL-CC1310:能否在射频回调(SWI)函数中调用 RF_postCmd ()函数?

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

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1177144/launchxl-cc1310-can-i-call-rf_postcmd-function-in-the-rf-callback-swi-function

器件型号:LAUNCHXL-CC1310

我希望通过无线电连续发送数据、因此我键入以下代码、对吧?

在 main()函数中:

RF_postCmd(rfHandle, (RF_Op*)RF_pCmdTxHS, RF_PriorityNormal, &tx_callback, RF_EventLastCmdDone);

回调函数:

static void tx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
    if (e & RF_EventLastCmdDone)
    {
        /* For TC_HSM, the packet length and a pointer to the first byte in the payload can be found as follows:
         *
         * uint8_t packetLength      = ((*(uint8_t*)(&currentDataEntry->data + 1)) << 8) | (*(uint8_t*)(&currentDataEntry->data));
         * uint8_t* packetDataPointer = (uint8_t*)(&currentDataEntry->data + 2);
         *
         * For the other test cases (TC_LRM, TC_OOK and TC_FSK), the packet length and first payload byte is found here:
         *
         * uint8_t packetLength      = *(uint8_t*)(&currentDataEntry->data);
         * uint8_t* packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);
         */
        packetTransfered = true;
    }
}

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

    抱歉、回调函数粘贴错误、

    static void tx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        if (e & RF_EventLastCmdDone)
        {
            /* For TC_HSM, the packet length and a pointer to the first byte in the payload can be found as follows:
             *
             * uint8_t packetLength      = ((*(uint8_t*)(&currentDataEntry->data + 1)) << 8) | (*(uint8_t*)(&currentDataEntry->data));
             * uint8_t* packetDataPointer = (uint8_t*)(&currentDataEntry->data + 2);
             *
             * For the other test cases (TC_LRM, TC_OOK and TC_FSK), the packet length and first payload byte is found here:
             *
             * uint8_t packetLength      = *(uint8_t*)(&currentDataEntry->data);
             * uint8_t* packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);
             */
            
            RF_postCmd(rfHandle, (RF_Op*)RF_pCmdTxHS, RF_PriorityNormal, &tx_callback, RF_EventLastCmdDone);
            
        }
    }

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

    您好 Chunkai、

    回调函数在 SWI 上下文中执行、如源代码(RFCC26X2.h)中所示:

    All callback functions run in software interrupt (SWI) context. 

    此外、作为 RF_postCmd 状态的源代码、您可以在 SWI 上下文中使用 RF_postCmd。

    /**
     *  @brief  Appends RF operation commands to the driver's command queue and returns a
     *          command handle.
     *
     *  The RF operation \a pOp may either represent a single operation or may be the first
     *  operation in a chain.
     *  If the command queue is empty, the \a pCmd is dispatched immediately. If there are
     *  other operations pending, then \a pCmd is processed after all other commands have been
     *  finished.
     *  The RF operation command must be compatible to the RF_Mode selected by RF_open(), e.g.
     *  proprietary commands can only be used when the RF core is configured for proprietary mode.
     *
     *  The returned command handle is an identifier that can be used to control command execution
     *  later on, for instance with RF_pendCmd() or RF_cancelCmd().
     *  It is a 16 Bit signed integer value, incremented on every new command.
     *  If the RF driver runs out of command containers, RF_ALLOC_ERROR is returned.
     *
     *  The priority \a ePri is only relevant in multi-client applications where commands of distinct
     *  clients may interrupt each other.
     *  Only commands started by RF_scheduleCmd() can preempt
     *  running commands. #RF_postCmd() or RF_runCmd() do never interrupt a running command.
     *  In single-client applications, \a ePri is ignored and should be set to ::RF_PriorityNormal.
     *
     *  A callback function \a pCb might be specified to get notified about events during command
     *  execution. Events are subscribed by the bit mask \a bmEvent.
     *  Valid event flags are specified in @ref RF_Core_Events and @ref RF_Driver_Events.
     *  If no callback is set, RF_pendCmd() can be used to synchronize the current task to command
     *  execution. For this it is necessary to subscribe all relevant events.
     *  The termination events ::RF_EventLastCmdDone, ::RF_EventCmdCancelled, ::RF_EventCmdAborted and
     *  ::RF_EventCmdStopped are always implicitly subscribed.
     *
     *  The following limitations apply to the execution of command chains:
     *
     *  - If TRIG_ABSTIME is used as a start trigger for the first command, TRIG_REL_FIRST_START
     *    can not be used for any other command. This is because the RF driver may insert a
     *    frequency-select command (CMD_FS) at the front of the chain when it performs an
     *    automatic power-up.
     *  - If a command chain has more than one CMD_FS, the first CMD_FS in the chain is cached.
     *    This CMD_FS is used on the next automatic power-up.
     *  - To avoid execution of cached CMD_FS and directly use a new CMD_FS on power up, place CMD_FS
     *    at the head of the command chain.
     *
     *  @note Calling context : Task/SWI

    这样做是安全的。 以下是实际的文档: https://dev.ti.com/tirex/explore/content/simplelink_cc13x0_sdk_4_20_02_07/docs/tidrivers/doxygen/html/_r_f_8h.html#a2b0ee444fcb74917df94eefea804ecbb

    此致、

    Arthur

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

    非常感谢 Arthur R.