Make the bcd2dec() function available to all backends.
This commit is contained in:
parent
1d69b8c021
commit
97652c6c62
@ -132,3 +132,9 @@ array_uint16_le (const unsigned char data[])
|
||||
{
|
||||
return data[0] + (data[1] << 8);
|
||||
}
|
||||
|
||||
unsigned char
|
||||
bcd2dec (unsigned char value)
|
||||
{
|
||||
return ((value >> 4) & 0x0f) * 10 + (value & 0x0f);
|
||||
}
|
||||
|
||||
@ -61,6 +61,9 @@ array_uint16_be (const unsigned char data[]);
|
||||
unsigned short
|
||||
array_uint16_le (const unsigned char data[]);
|
||||
|
||||
unsigned char
|
||||
bcd2dec (unsigned char value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@ -54,16 +54,6 @@ iceil (unsigned int x, unsigned int n)
|
||||
}
|
||||
|
||||
|
||||
static unsigned char
|
||||
bcd (unsigned char value)
|
||||
{
|
||||
unsigned char lower = (value ) & 0x0F;
|
||||
unsigned char upper = (value >> 4) & 0x0F;
|
||||
|
||||
return lower + 10 * upper;
|
||||
}
|
||||
|
||||
|
||||
static unsigned int
|
||||
get_profile_first (const unsigned char data[], const oceanic_common_layout_t *layout)
|
||||
{
|
||||
@ -155,7 +145,7 @@ oceanic_common_device_foreach (oceanic_common_device_t *device, const oceanic_co
|
||||
device_devinfo_t devinfo;
|
||||
devinfo.model = array_uint16_be (id + 8);
|
||||
devinfo.firmware = 0;
|
||||
devinfo.serial = bcd (id[10]) * 10000 + bcd (id[11]) * 100 + bcd (id[12]);
|
||||
devinfo.serial = bcd2dec (id[10]) * 10000 + bcd2dec (id[11]) * 100 + bcd2dec (id[12]);
|
||||
device_event_emit (abstract, DEVICE_EVENT_DEVINFO, &devinfo);
|
||||
|
||||
// Read the pointer data.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user