arch/dev/radio/dw1000/tsm/trex-tsm.c
/**
 * Compute preamble timeout expressed in PACs.
 * A value of 0 disables the timeout.
 *
 * TODO: Request to move this method to dw1000-utility
 */
Compute preamble timeout expressed in PACs.
A value of 0 disables the timeout.

Request to move this method to dw1000-utility
Compute preamble timeout expressed in PACs . A value of 0 disables the timeout . Request to move this method to dw1000 - utility
static inline uint16_t tsm_preambleto_to_pacs(const uint32_t timeout_4ns)
{
  if (timeout_4ns == 0) {
      return 0;
  }
  const dwt_config_t* config = dw1000_get_current_cfg();
  uint32_t pac_ns = 0;
  uint32_t symbol_duration = 1018;  
  if (config->prf == DWT_PRF_16M) {
      symbol_duration = 994;        
  }
  else if (config->prf == DWT_PRF_64M) {
  }
  switch (config->rxPAC) {
      case DWT_PAC8  : pac_ns = symbol_duration *  8;  break;
      case DWT_PAC16 : pac_ns = symbol_duration * 16;  break;
      case DWT_PAC32 : pac_ns = symbol_duration * 32;  break;
      case DWT_PAC64 : pac_ns = symbol_duration * 64;  break;
      default: ERR("Invalid PAC size found.");
  }
  uint16_t npacs = ((timeout_4ns * DWT_TICK_TO_NS_32) / pac_ns);
  return npacs;
}
static inline uint16_t tsm_preambleto_to_pacs ( const uint32_t timeout_4ns ) { if ( timeout_4ns == 0 ) { return 0 ; } const dwt_config_t * config = dw1000_get_current_cfg ( ) ; uint32_t pac_ns = 0 ; uint32_t symbol_duration = 1018 ; if ( config -> prf == DWT_PRF_16M ) { symbol_duration = 994 ; } else if ( config -> prf == DWT_PRF_64M ) { } switch ( config -> rxPAC ) { case DWT_PAC8 : pac_ns = symbol_duration * 8 ; break ; case DWT_PAC16 : pac_ns = symbol_duration * 16 ; break ; case DWT_PAC32 : pac_ns = symbol_duration * 32 ; break ; case DWT_PAC64 : pac_ns = symbol_duration * 64 ; break ; default : ERR ( " " ) ; } uint16_t npacs = ( ( timeout_4ns * DWT_TICK_TO_NS_32 ) / pac_ns ) ; return npacs ; }
Compute preamble timeout expressed in PACs.
Compute preamble timeout expressed in PACs .
// 1017,63 ns, assuming prf of 64MHz // 993.59 ns, assuming prf of 16MHz // already set // the function automatically adds 1 PAC more to the given value