Checkpoint commit renaming some functions for clarity.
[apps/agl-service-can-low-level.git] / src / canutil / read.c
1 #include <canutil/read.h>
2 #include <bitfield/bitfield.h>
3 #include <bitfield/8byte.h>
4
5 float eightbyte_parse_float(uint64_t data, uint8_t bit_offset, uint8_t bit_size,
6         float factor, float offset) {
7     uint64_t raw = eightbyte_get_bit_field(data, bit_offset, bit_size, true);
8     return raw * factor + offset;
9 }
10
11 bool eightbyte_parse_bool(uint64_t data, uint8_t bit_offset, uint8_t bit_size,
12         float factor, float offset) {
13     float value = eightbyte_parse_float(data, bit_offset, bit_size, factor, offset);
14     return value == 0.0 ? false : true;
15 }
16
17 float bitfield_parse_float(const uint8_t data[], const uint16_t size,
18         const uint8_t bit_offset, const uint8_t bit_size, const float factor,
19         const float offset) {
20     //TODO
21     return 0;
22 }