Logo Search packages:      
Sourcecode: hamlib version File versions

unsigned long long HAMLIB_API from_bcd ( const unsigned char  bcd_data[],
unsigned  bcd_len 
)

Convert BCD digits to a long long (eg. frequency in Hz).

Parameters:
bcd_data 
bcd_len 
Returns:
binary result (e.g. frequency)
Convert BCD digits to a long long (eg. frequency in Hz) bcd_len is the number of BCD digits.

Hope the compiler will do a good job optimizing it (esp. w/ the 64bit freq)

Definition at line 100 of file misc.c.

{
      int i;
      freq_t f = 0;

      if (bcd_len&1)
            f = bcd_data[bcd_len/2] & 0x0f;

      for (i=(bcd_len/2)-1; i >= 0; i--) {
            f *= 10;
            f += bcd_data[i]>>4;
            f *= 10;
            f += bcd_data[i] & 0x0f;
      }
      
      return f;
}


Generated by  Doxygen 1.6.0   Back to index