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.

CC1311P3: How to setup RF callback function

Part Number: CC1311P3

Hi,

I have a question about RF callback function. I add callback function in rfPacketTx

        RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, txCallback, 0);

which case is correct?

1. execute RF_runCmd --> txCallback --> transmit packet --> transmit packet finish

2. execute RF_runCmd --> transmit packet --> transmit packet finish --> txCallback

3. execute RF_runCmd --> txCallback --> transmit packet --> transmit packet finish --> txCallback

if I want to use case - 3, how to config it?

  • Hi Kimi,

    If I understand correctly you want one callback event when the runCmd command has been called, then another one when the packet has been transmitted? What will you use the first event for?

    Cheers,

    Marie H

  • Hi Kimi

    Please see the documentation of the RF_runCmd:

    /**
     *  @brief  Runs synchronously an RF operation command or a chain of commands and returns
     *          the termination reason.
     *
     *  This function appends an RF operation command or a chain of commands to the RF driver's
     *  command queue and then waits for it to complete.
     *  A command is completed if one of the termination events ::RF_EventLastCmdDone,
     *  ::RF_EventCmdCancelled, ::RF_EventCmdAborted, ::RF_EventCmdStopped occurred.
     *
     *  This function is a combination of RF_postCmd() and RF_pendCmd().
     *  All options and limitations for RF_postCmd() apply here as well.
     *
     *  An application should always ensure that the command completed in the expected way and
     *  with an expected status code.
     *
     *  @note Calling context : Task
     *
     *  @param h         Driver handle previously returned by RF_open()
     *  @param pOp       Pointer to the RF operation command.
     *  @param ePri      Priority of this RF command (used for arbitration in multi-client systems)
     *  @param pCb       Callback function called during command execution and upon completion.
     *                   If RF_runCmd() fails, no callback is made.
     *  @param bmEvent   Bitmask of events that will trigger the callback or that can be pended on.
     *  @return          The relevant termination event.
     *
     *  @sa RF_postCmd(), RF_pendCmd(), RF_cancelCmd(), RF_flushCmd()
     */
    extern RF_EventMask RF_runCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);

    You need to select the events that you want to trigger your callback. 

    Possible event are:

    /**
     *  @name RF Core Events
     *  @anchor RF_Core_Events
     *
     *  Events originating on the RF core and caused during command execution.
     *  They are aliases for the corresponding interrupt flags.
     *  RF Core Events are command-specific and are explained in the Technical Reference Manual.
     *
     *  @sa RF_postCmd(), RF_pendCmd(), RF_runCmd()
     *  @{
     */
    #define   RF_EventCmdDone             (1 << 0)   ///< A radio operation command in a chain finished.
    #define   RF_EventLastCmdDone         (1 << 1)   ///< A stand-alone radio operation command or the last radio operation command in a chain finished.
    #define   RF_EventFGCmdDone           (1 << 2)   ///< A IEEE-mode radio operation command in a chain finished.
    #define   RF_EventLastFGCmdDone       (1 << 3)   ///< A stand-alone IEEE-mode radio operation command or the last command in a chain finished.
    #define   RF_EventTxDone              (1 << 4)   ///< Packet transmitted
    #define   RF_EventTXAck               (1 << 5)   ///< ACK packet transmitted
    #define   RF_EventTxCtrl              (1 << 6)   ///< Control packet transmitted
    #define   RF_EventTxCtrlAck           (1 << 7)   ///< Acknowledgement received on a transmitted control packet
    #define   RF_EventTxCtrlAckAck        (1 << 8)   ///< Acknowledgement received on a transmitted control packet, and acknowledgement transmitted for that packet
    #define   RF_EventTxRetrans           (1 << 9)   ///< Packet retransmitted
    #define   RF_EventTxEntryDone         (1 << 10)  ///< Tx queue data entry state changed to Finished
    #define   RF_EventTxBufferChange      (1 << 11)  ///< A buffer change is complete
    #define   RF_EventPaChanged           (1 << 14)  ///< The PA was reconfigured on the fly.
    #define   RF_EventSamplesEntryDone    (1 << 15)  ///< CTE data has been copied, only valid if autocopy feature is enabled
    #define   RF_EventRxOk                (1 << 16)  ///< Packet received with CRC OK, payload, and not to be ignored
    #define   RF_EventRxNOk               (1 << 17)  ///< Packet received with CRC error
    #define   RF_EventRxIgnored           (1 << 18)  ///< Packet received with CRC OK, but to be ignored
    #define   RF_EventRxEmpty             (1 << 19)  ///< Packet received with CRC OK, not to be ignored, no payload
    #define   RF_EventRxCtrl              (1 << 20)  ///< Control packet received with CRC OK, not to be ignored
    #define   RF_EventRxCtrlAck           (1 << 21)  ///< Control packet received with CRC OK, not to be ignored, then ACK sent
    #define   RF_EventRxBufFull           (1 << 22)  ///< Packet received that did not fit in the Rx queue
    #define   RF_EventRxEntryDone         (1 << 23)  ///< Rx queue data entry changing state to Finished
    #define   RF_EventDataWritten         (1 << 24)  ///< Data written to partial read Rx buffer
    #define   RF_EventNDataWritten        (1 << 25)  ///< Specified number of bytes written to partial read Rx buffer
    #define   RF_EventRxAborted           (1 << 26)  ///< Packet reception stopped before packet was done
    #define   RF_EventRxCollisionDetected (1 << 27)  ///< A collision was indicated during packet reception
    #define   RF_EventModulesUnlocked     (1 << 29)  ///< As part of the boot process, the CM0 has opened access to RF core modules and memories
    #define   RF_EventInternalError       (uint32_t)(1 << 31) ///< Internal error observed
    #define   RF_EventMdmSoft             0x0000002000000000  ///< Synchronization word detected (MDMSOFT interrupt flag)
    /** @}*/
    
    /**
     *  @name RF Driver Events
     *  @anchor RF_Driver_Events
     *
     *  Event flags generated by the RF Driver.
     *  @{
     */
    #define   RF_EventCmdCancelled        0x1000000000000000  ///< Command canceled before it was started.
    #define   RF_EventCmdAborted          0x2000000000000000  ///< Abrupt command termination caused by RF_cancelCmd() or RF_flushCmd().
    #define   RF_EventCmdStopped          0x4000000000000000  ///< Graceful command termination caused by RF_cancelCmd() or RF_flushCmd().
    #define   RF_EventRatCh               0x0800000000000000  ///< A user-programmable RAT channel triggered an event.
    #define   RF_EventPowerUp             0x0400000000000000  ///< RF power up event. \deprecated This event is deprecated. Use #RF_ClientEventPowerUpFinished instead.
    #define   RF_EventError               0x0200000000000000  ///< Event flag used for error callback functions to indicate an error. See RF_Params::pErrCb.
    #define   RF_EventCmdPreempted        0x0100000000000000  ///< Command preempted by another command with higher priority. Applies only to multi-client applications.
    /** @}*/
    

    Siri