MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / to_bcd

Function to_bcd

src/misc.c:145–172  ·  view source on GitHub ↗

* \brief Convert from binary to 4-bit BCD digits, little-endian * \param bcd_data * \param freq * \param bcd_len * \return bcd_data * * Convert a long long (e.g. frequency in Hz) to 4-bit BCD digits, * packed two digits per octet, in little-endian order * (e.g. byte order 90 78 56 34 12 for 1234567890 Hz). * * bcd_len is the number of BCD digits, usually 10 or 8 in 1-Hz units, * and 6 d

Source from the content-addressed store, hash-verified

143 * \sa to_bcd_be()
144 */
145unsigned char *HAMLIB_API to_bcd(unsigned char bcd_data[],
146 unsigned long long freq,
147 unsigned bcd_len)
148{
149 int i;
150
151 rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
152
153 /* '450'/4-> 5,0;0,4 */
154 /* '450'/3-> 5,0;x,4 */
155
156 for (i = 0; i < bcd_len / 2; i++)
157 {
158 unsigned char a = freq % 10;
159 freq /= 10;
160 a |= (freq % 10) << 4;
161 freq /= 10;
162 bcd_data[i] = a;
163 }
164
165 if (bcd_len & 1)
166 {
167 bcd_data[i] &= 0xf0;
168 bcd_data[i] |= freq % 10; /* NB: high nibble is left uncleared */
169 }
170
171 return bcd_data;
172}
173
174
175/**

Callers 15

icom_set_freqFunction · 0.85
icom_set_it_newFunction · 0.85
icom_set_dsp_fltFunction · 0.85
icom_set_levelFunction · 0.85
icom_get_levelFunction · 0.85
icom_set_rptr_offsFunction · 0.85
icom_set_split_freqFunction · 0.85
icom_set_clockFunction · 0.85
icom_get_freq_rangeFunction · 0.85
omni6_set_ritFunction · 0.85
id5100_set_freqFunction · 0.85
id5100_set_split_freqFunction · 0.85

Calls 1

rig_debugFunction · 0.85

Tested by 1

mainFunction · 0.68