lib/uwb_ccp/src/uwb_ccp.c
/**
 * @fn ccp_master_timer_ev_cb(struct os_event *ev)
 * @brief The OS scheduler is not accurate enough for the timing requirement of an RTLS system.
 * Instead, the OS is used to schedule events in advance of the actual event.
 * The UWB delay start mechanism then takes care of the actual event. This removes the non-deterministic
 * latencies of the OS implementation.
 *
 * @param ev  Pointer to os_events.
 * @return void
 */
@fn ccp_master_timer_ev_cb(struct os_event *ev)
@brief The OS scheduler is not accurate enough for the timing requirement of an RTLS system.
Instead, the OS is used to schedule events in advance of the actual event.
The UWB delay start mechanism then takes care of the actual event. This removes the non-deterministic
latencies of the OS implementation.

@param ev  Pointer to os_events.
@return void
@fn ccp_master_timer_ev_cb ( struct os_event * ev ) @brief The OS scheduler is not accurate enough for the timing requirement of an RTLS system . Instead the OS is used to schedule events in advance of the actual event . The UWB delay start mechanism then takes care of the actual event . This removes the non - deterministic latencies of the OS implementation . @param ev Pointer to os_events . @return void
static void
ccp_master_timer_ev_cb(struct dpl_event *ev)
{
    int rc;
    assert(ev != NULL);
    assert(dpl_event_get_arg(ev));
    struct uwb_ccp_instance * ccp = (struct uwb_ccp_instance *) dpl_event_get_arg(ev);
    if (!ccp->status.enabled) {
        return;
    }
    CCP_STATS_INC(master_cnt);
    ccp->status.timer_restarted = 0;
    if (ccp_send(ccp, UWB_BLOCKING).start_tx_error) {
        if (!ccp->status.enabled) {
            goto disabled;
        }
    }
    if (!ccp->status.timer_restarted && ccp->status.enabled) {
        rc = dpl_cputime_timer_start(&ccp->timer, ccp->os_epoch
            - dpl_cputime_usecs_to_ticks(MYNEWT_VAL(OS_LATENCY))
            + dpl_cputime_usecs_to_ticks(uwb_dwt_usecs_to_usecs(ccp->period))
        );
        if (rc == 0) ccp->status.timer_restarted = 1;
    }
disabled:
    return;
}
static void ccp_master_timer_ev_cb ( struct dpl_event * ev ) { int rc ; assert ( ev != NULL ) ; assert ( dpl_event_get_arg ( ev ) ) ; struct uwb_ccp_instance * ccp = ( struct uwb_ccp_instance * ) dpl_event_get_arg ( ev ) ; if ( ! ccp -> status . enabled ) { return ; } CCP_STATS_INC ( master_cnt ) ; ccp -> status . timer_restarted = 0 ; if ( ccp_send ( ccp , UWB_BLOCKING ) . start_tx_error ) { if ( ! ccp -> status . enabled ) { goto disabled ; } } if ( ! ccp -> status . timer_restarted && ccp -> status . enabled ) { rc = dpl_cputime_timer_start ( & ccp -> timer , ccp -> os_epoch - dpl_cputime_usecs_to_ticks ( MYNEWT_VAL ( OS_LATENCY ) ) + dpl_cputime_usecs_to_ticks ( uwb_dwt_usecs_to_usecs ( ccp -> period ) ) ) ; if ( rc == 0 ) ccp -> status . timer_restarted = 1 ; } disabled : return ; }
@fn ccp_master_timer_ev_cb(struct os_event *ev)
 @brief The OS scheduler is not accurate enough for the timing requirement of an RTLS system.
@fn ccp_master_timer_ev_cb ( struct os_event * ev ) @brief The OS scheduler is not accurate enough for the timing requirement of an RTLS system .
/* CCP failed to send, probably because os_latency wasn't enough
         * margin to get in to prep the frame for sending.
         * NOTE that os_epoch etc will be updated in ccp_send if it fails
         * to send so timer update below will still point to next beacon time */