apps/twr_node_tdma/src/main.c
static void 
slot_cb(struct dpl_event * ev)
{
    static uint16_t timeout = 0;
    assert(ev);

    tdma_slot_t * slot = (tdma_slot_t *) dpl_event_get_arg(ev);
    tdma_instance_t * tdma = slot->parent;
    struct uwb_ccp_instance *ccp = tdma->ccp;
    struct uwb_dev *inst = tdma->dev_inst;
    uint16_t idx = slot->idx;
    struct uwb_rng_instance * rng = (struct uwb_rng_instance*)slot->arg;
    g_angle.azimuth = g_angle.zenith = NAN;
    //printf("idx%d\n", idx);

    /* Avoid colliding with the ccp in case we've got out of sync */
    if (dpl_sem_get_count(&ccp->sem) == 0) {
        return;
    }

    if (uwb_config_updated) {
        uwb_mac_config(inst, NULL);
        uwb_txrf_config(inst, &inst->config.txrf);
#if MYNEWT_VAL(UWB_DEVICE_1)
        uwb_mac_config(uwb_dev_idx_lookup(1), NULL);
        uwb_txrf_config(uwb_dev_idx_lookup(1), &uwb_dev_idx_lookup(1)->config.txrf);
#endif
        uwb_config_updated = false;
        timeout = 0;
        return;
    }

    /* Only recalculate timeout if needed */
    if (!timeout) {
        timeout = uwb_phy_frame_duration(inst, sizeof(ieee_rng_response_frame_t))
            + rng->config.rx_timeout_delay;
    }

#if MYNEWT_VAL(UWB_DEVICE_0) && MYNEWT_VAL(UWB_DEVICE_1)
{   
    struct uwb_dev * inst = uwb_dev_idx_lookup(0);
    uwb_set_delay_start(inst, tdma_rx_slot_start(tdma, idx));
    uwb_set_rx_timeout(inst, timeout);
    cir_enable(uwb_dev_idx_lookup(0)->cir, true);
    uwb_set_rxauto_disable(inst, true);
    uwb_start_rx(inst);  // RX enabled but frames handled as unsolicited inbound          
}
{   
    struct uwb_dev * inst = uwb_dev_idx_lookup(1);
    struct uwb_rng_instance * rng = (struct uwb_rng_instance*)uwb_mac_find_cb_inst_ptr(inst, UWBEXT_RNG);
    uwb_set_delay_start(inst, tdma_rx_slot_start(tdma, idx));
    uwb_set_rx_timeout(inst, timeout);  
    cir_enable(uwb_dev_idx_lookup(1)->cir, true);
    uwb_rng_listen(rng, UWB_BLOCKING);
}
#else
    uwb_set_delay_start(inst, tdma_rx_slot_start(tdma, idx));
    uwb_set_rx_timeout(inst, timeout);
    uwb_rng_listen(rng, UWB_BLOCKING);
#endif

}
/*! 
 * @fn slot_cb(struct dpl_event * ev)
 * 
 * In this example, slot_cb schedules the turning of the transceiver to receive mode at the desired epoch. 
 * The precise timing is under the control of the DW1000, and the dw_time variable defines this epoch. 
 * Note the slot_cb itself is scheduled MYNEWT_VAL(OS_LATENCY) in advance of the epoch to set up the transceiver accordingly.
 * 
 * Note: The epoch time is referenced to the Rmarker symbol, it is therefore necessary to advance the rxtime by the SHR_duration such 
 * that the preamble are received. The transceiver, when transmitting adjust the txtime accordingly.
 *
 * input parameters
 * @param inst - struct dpl_event *
 *
 * output parameters
 *
 * returns none 
 */


In this example, slot_cb schedules the turning of the transceiver to receive mode at the desired epoch.
The precise timing is under the control of the DW1000, and the dw_time variable defines this epoch.
Note the slot_cb itself is scheduled MYNEWT_VAL(OS_LATENCY) in advance of the epoch to set up the transceiver accordingly.

The epoch time is referenced to the Rmarker symbol, it is therefore necessary to advance the rxtime by the SHR_duration such
that the preamble are received. The transceiver, when transmitting adjust the txtime accordingly.

input parameters
@param inst - struct dpl_event

output parameters

returns none
In this example slot_cb schedules the turning of the transceiver to receive mode at the desired epoch . The precise timing is under the control of the DW1000 and the dw_time variable defines this epoch . Note the slot_cb itself is scheduled MYNEWT_VAL ( OS_LATENCY ) in advance of the epoch to set up the transceiver accordingly . The epoch time is referenced to the Rmarker symbol it is therefore necessary to advance the rxtime by the SHR_duration such that the preamble are received . The transceiver when transmitting adjust the txtime accordingly . input parameters @param inst - struct dpl_event output parameters returns none
static void 
slot_cb(struct dpl_event * ev)
{
    static uint16_t timeout = 0;
    assert(ev);
    tdma_slot_t * slot = (tdma_slot_t *) dpl_event_get_arg(ev);
    tdma_instance_t * tdma = slot->parent;
    struct uwb_ccp_instance *ccp = tdma->ccp;
    struct uwb_dev *inst = tdma->dev_inst;
    uint16_t idx = slot->idx;
    struct uwb_rng_instance * rng = (struct uwb_rng_instance*)slot->arg;
    g_angle.azimuth = g_angle.zenith = NAN;
    if (dpl_sem_get_count(&ccp->sem) == 0) {
        return;
    }
    if (uwb_config_updated) {
        uwb_mac_config(inst, NULL);
        uwb_txrf_config(inst, &inst->config.txrf);
#if MYNEWT_VAL(UWB_DEVICE_1)
        uwb_mac_config(uwb_dev_idx_lookup(1), NULL);
        uwb_txrf_config(uwb_dev_idx_lookup(1), &uwb_dev_idx_lookup(1)->config.txrf);
#endif
        uwb_config_updated = false;
        timeout = 0;
        return;
    }
    if (!timeout) {
        timeout = uwb_phy_frame_duration(inst, sizeof(ieee_rng_response_frame_t))
            + rng->config.rx_timeout_delay;
    }
#if MYNEWT_VAL(UWB_DEVICE_0) && MYNEWT_VAL(UWB_DEVICE_1)
{   
    struct uwb_dev * inst = uwb_dev_idx_lookup(0);
    uwb_set_delay_start(inst, tdma_rx_slot_start(tdma, idx));
    uwb_set_rx_timeout(inst, timeout);
    cir_enable(uwb_dev_idx_lookup(0)->cir, true);
    uwb_set_rxauto_disable(inst, true);
    uwb_start_rx(inst);  
}
{   
    struct uwb_dev * inst = uwb_dev_idx_lookup(1);
    struct uwb_rng_instance * rng = (struct uwb_rng_instance*)uwb_mac_find_cb_inst_ptr(inst, UWBEXT_RNG);
    uwb_set_delay_start(inst, tdma_rx_slot_start(tdma, idx));
    uwb_set_rx_timeout(inst, timeout);  
    cir_enable(uwb_dev_idx_lookup(1)->cir, true);
    uwb_rng_listen(rng, UWB_BLOCKING);
}
#else
    uwb_set_delay_start(inst, tdma_rx_slot_start(tdma, idx));
    uwb_set_rx_timeout(inst, timeout);
    uwb_rng_listen(rng, UWB_BLOCKING);
#endif
}
static void slot_cb ( struct dpl_event * ev ) { static uint16_t timeout = 0 ; assert ( ev ) ; tdma_slot_t * slot = ( tdma_slot_t * ) dpl_event_get_arg ( ev ) ; tdma_instance_t * tdma = slot -> parent ; struct uwb_ccp_instance * ccp = tdma -> ccp ; struct uwb_dev * inst = tdma -> dev_inst ; uint16_t idx = slot -> idx ; struct uwb_rng_instance * rng = ( struct uwb_rng_instance * ) slot -> arg ; g_angle . azimuth = g_angle . zenith = NAN ; if ( dpl_sem_get_count ( & ccp -> sem ) == 0 ) { return ; } if ( uwb_config_updated ) { uwb_mac_config ( inst , NULL ) ; uwb_txrf_config ( inst , & inst -> config . txrf ) ; #if MYNEWT_VAL ( UWB_DEVICE_1 ) uwb_mac_config ( uwb_dev_idx_lookup ( 1 ) , NULL ) ; uwb_txrf_config ( uwb_dev_idx_lookup ( 1 ) , & uwb_dev_idx_lookup ( 1 ) -> config . txrf ) ; #endif uwb_config_updated = false ; timeout = 0 ; return ; } if ( ! timeout ) { timeout = uwb_phy_frame_duration ( inst , sizeof ( ieee_rng_response_frame_t ) ) + rng -> config . rx_timeout_delay ; } #if MYNEWT_VAL ( UWB_DEVICE_0 ) && MYNEWT_VAL ( UWB_DEVICE_1 ) { struct uwb_dev * inst = uwb_dev_idx_lookup ( 0 ) ; uwb_set_delay_start ( inst , tdma_rx_slot_start ( tdma , idx ) ) ; uwb_set_rx_timeout ( inst , timeout ) ; cir_enable ( uwb_dev_idx_lookup ( 0 ) -> cir , true ) ; uwb_set_rxauto_disable ( inst , true ) ; uwb_start_rx ( inst ) ; } { struct uwb_dev * inst = uwb_dev_idx_lookup ( 1 ) ; struct uwb_rng_instance * rng = ( struct uwb_rng_instance * ) uwb_mac_find_cb_inst_ptr ( inst , UWBEXT_RNG ) ; uwb_set_delay_start ( inst , tdma_rx_slot_start ( tdma , idx ) ) ; uwb_set_rx_timeout ( inst , timeout ) ; cir_enable ( uwb_dev_idx_lookup ( 1 ) -> cir , true ) ; uwb_rng_listen ( rng , UWB_BLOCKING ) ; } #else uwb_set_delay_start ( inst , tdma_rx_slot_start ( tdma , idx ) ) ; uwb_set_rx_timeout ( inst , timeout ) ; uwb_rng_listen ( rng , UWB_BLOCKING ) ; #endif }
@fn slot_cb(struct dpl_event * ev)
@fn slot_cb ( struct dpl_event * ev )
//printf("idx%d\n", idx); /* Avoid colliding with the ccp in case we've got out of sync */ /* Only recalculate timeout if needed */ // RX enabled but frames handled as unsolicited inbound          