* \brief Convert BCD digits, little-endian, to a long long (e.g. frequency in Hz) * \param bcd_data * \param bcd_len * \return 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/ th
| 190 | * \sa from_bcd_be() |
| 191 | */ |
| 192 | unsigned long long HAMLIB_API from_bcd(const unsigned char bcd_data[], |
| 193 | unsigned bcd_len) |
| 194 | { |
| 195 | int i; |
| 196 | freq_t f = 0; |
| 197 | |
| 198 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 199 | |
| 200 | if (bcd_len & 1) |
| 201 | { |
| 202 | f = bcd_data[bcd_len / 2] & 0x0f; |
| 203 | } |
| 204 | |
| 205 | for (i = (bcd_len / 2) - 1; i >= 0; i--) |
| 206 | { |
| 207 | f *= 10; |
| 208 | f += bcd_data[i] >> 4; |
| 209 | f *= 10; |
| 210 | f += bcd_data[i] & 0x0f; |
| 211 | } |
| 212 | |
| 213 | return f; |
| 214 | } |
| 215 | |
| 216 | |
| 217 | /** |