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, little-endian, to a long long (e.g. frequency in Hz).

Parameters:
bcd_data 
bcd_len 
Returns:
binary result (e.g. frequency)
Convert BCD digits, little-endian, (byte order 90 78 56 34 12 for 1234567890 Hz) to a long long (e.g. 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)

Returns frequency in Hz an unsigned long long integer.

See also:
from_bcd_be

Definition at line 113 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