arch/dev/radio/dw1000/tsm/trex-tsm.c
/* Trex driver will call this function to notify of a completed action */
Trex driver will call this function to notify of a completed action
Trex driver will call this function to notify of a completed action
static void driver_slot_callback(const trexd_slot_t* slot) {
  DBGF();
  switch (context.slot_action) {
    case TSM_ACTION_TX:
      if (slot->status != TREX_TX_DONE) {
        ERR("Unexpected status %u for TX action", slot->status);
        return;
      }
      break;
    case TSM_ACTION_RX: case TSM_ACTION_SCAN:
      if (!TREX_IS_RX_STATUS(slot->status)) {
        ERR("Unexpected status %u for action %u", slot->status, context.slot_action);
        return;
      }
      break;
    default:
      ERR("Unexpected callback, action=%u", context.slot_action);
      return;
  }
  context.slot_status = slot->status;
  if (slot->status == TREX_RX_SUCCESS) {
    struct tsm_header hdr;
    if (slot->payload_len >= sizeof(hdr)) {
      TSM_HDR_RETRIEVE(slot->buffer, &hdr);
      if (hdr.crc != TSM_CRC_OK) {
          context.slot_status = TREX_RX_MALFORMED;
      }
      else {
        context.tentative_slot_tref = slot->trx_sfd_time_4ns - hdr.tx_delay;
        context.tentative_slot_idx = hdr.slot_idx;
      }
    }
    else { 
      context.slot_status = TREX_RX_MALFORMED;
    }
  }
  tsm_prev_action.payload_len = slot->payload_len - sizeof(struct tsm_header);
  tsm_prev_action.buffer = slot->buffer;
  tsm_slot_event();
}
static void driver_slot_callback ( const trexd_slot_t * slot ) { DBGF ( ) ; switch ( context . slot_action ) { case TSM_ACTION_TX : if ( slot -> status != TREX_TX_DONE ) { ERR ( " " , slot -> status ) ; return ; } break ; case TSM_ACTION_RX : case TSM_ACTION_SCAN : if ( ! TREX_IS_RX_STATUS ( slot -> status ) ) { ERR ( " " , slot -> status , context . slot_action ) ; return ; } break ; default : ERR ( " " , context . slot_action ) ; return ; } context . slot_status = slot -> status ; if ( slot -> status == TREX_RX_SUCCESS ) { struct tsm_header hdr ; if ( slot -> payload_len >= sizeof ( hdr ) ) { TSM_HDR_RETRIEVE ( slot -> buffer , & hdr ) ; if ( hdr . crc != TSM_CRC_OK ) { context . slot_status = TREX_RX_MALFORMED ; } else { context . tentative_slot_tref = slot -> trx_sfd_time_4ns - hdr . tx_delay ; context . tentative_slot_idx = hdr . slot_idx ; } } else { context . slot_status = TREX_RX_MALFORMED ; } } tsm_prev_action . payload_len = slot -> payload_len - sizeof ( struct tsm_header ) ; tsm_prev_action . buffer = slot -> buffer ; tsm_slot_event ( ) ; }
Trex driver will call this function to notify of a completed action
Trex driver will call this function to notify of a completed action
// memorise the sync information from the received packet in case // the higher layer decides to use it // This code is useful to debug mismatches /*
        int16_t idx_diff = context.slot_idx - context.tentative_slot_idx;
        size_t i = 0;
        if (context.slot_idx > 0 && idx_diff != 0) {
            printf("E %u, A %d R %d\n", logging_context, context.slot_idx, context.tentative_slot_idx);

            printf("E %u, B", logging_context);
            for (; i < slot->payload_len ; i ++) {
                printf(" %x", slot->buffer[i]);
            }
            printf("\n");

        }
        */ // received an uncompliant packet