Callback events

The RF core generates multiple interrupts during command execution. The RF driver maps these interrupts to callback events that execute in softare interrupt context. Callback events are divided into 3 groups:

  • Generic events, defined for all radio operation commands and originating on the RF core. These are RF_EventCmdDone and RF_EventLastCmdDone as shown in Figure 16.. Both events indicate the termination of a radio operation command and are always generated at the same time.
  • Generic events, defined for all radio operation commands and originating in the RF driver. These are explained in the RF driver API documentation.
  • Command-specific events, explained in the RF commands reference for each command. These events occur during the ACTIVE phase. An example for CMD_PROP_RX is given below in Figure 16..

@startuml
scale 0.8
hide footbox

participant Application as app
participant "RF Driver" as driver
participant "RF Core" as rf

activate app
app -> driver : RF_runCmd(CMD_PROP_RX);
activate driver
driver -> rf : start op
activate rf
driver <-- rf

...CMD_PROP_RX executes...

driver <- rf : IRQ_RX_ENTRY_DONE
activate driver
driver --> rf
deactivate driver
driver -> driver : post Swi
activate driver
app <- driver : callback(RF_EventRxEntryDone);
activate app
note left
    Callback executes
    in Swi context
end note
app --> driver
deactivate app
deactivate driver

...CMD_PROP_RX proceeds...

driver <- rf : IRQ_CMD_DONE\n| IRQ_LAST_CMD_DONE
activate driver
driver --> rf
deactivate rf
deactivate driver
driver -> driver : post Swi
activate driver
app <- driver : callback(RF_EventCmdDone\n| RF_EventLastCmdDone);
activate app
note left
    Callback executes
    in Swi context
end note
app --> driver
deactivate app
deactivate driver

app <-- driver
deactivate driver

@enduml

Figure 16. Example callback events for CMD_PROP_RX when 3 events are subscribed: RF_EventRxEntryDone, RF_EventCmdDone and RF_EventLastCmdDone.

Note that all callback events execute in software interrupt context. Whether they are really executed or not, depends on the bmEvent parameter in RF_postCmd() or RF_runCmd(). The following code snippet gives an example for CMD_PROP_RX:

// Run a CMD_PROP_RX and register a callback for RF_EventCmdDone and RF_EventRxEntryDone
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &rxCallback,
        RF_EventCmdDone | RF_EventRxEntryDone);


// RX callback handler
// Multiple events might occur at the same time.
void rxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
    if (e & RF_EventRxEntryDone)
    {
        // Do something, for instance post a semaphore.
    }
    if (e & RF_EventCmdDone)
    {
        // Do something
    }
}