Logo Search packages:      
Sourcecode: hamlib version File versions  Download package

unsigned char* HAMLIB_API to_bcd_be ( unsigned char  bcd_data[],
unsigned long long  freq,
unsigned  bcd_len 
)

Convert from binary to 4-bit BCD digits, big-endian.

Parameters:
bcd_data 
freq 
bcd_len 
Returns:
bcd_data
Same as to_bcd, but in big-endian order (e.g. byte order 12 34 56 78 90 for 1234567890 Hz)

See also:
to_bcd

Definition at line 143 of file misc.c.

{
      int i;
      unsigned char a;

      /* '450'/4 -> 0,4;5,0 */
      /* '450'/3 -> 4,5;0,x */

      if (bcd_len&1) {
            bcd_data[bcd_len/2] &= 0x0f;
            bcd_data[bcd_len/2] |= (freq%10)<<4;      /* NB: low nibble is left uncleared */
            freq /= 10;
      }
      for (i=(bcd_len/2)-1; i >= 0; i--) {
            a = freq%10;
            freq /= 10;
            a |= (freq%10)<<4;
            freq /= 10;
            bcd_data[i] = a;
      }

      return bcd_data;
}


Generated by  Doxygen 1.6.0   Back to index