11 /* Public: Encode a floating point number into a fixed point, fixed bit width
12 * field in a bit array.
14 * value - the floating point value to encode.
15 * bit_offset - the starting point for the encoded bits in the returned value.
16 * bit_size - The max width of the field in the resulting bit array. If bit_size
17 * isn't big enough to store the fixed point version of the value, the bitfeld
18 * will *not* be set. TODO some error reporting would be nice.
19 * factor - a factor used to transform from floating to fixed point before
20 * encoding. Use 1.0 for no factor.
21 * offset - an offset used to transform from floating to fixed point before
22 * encoding. Use 0 for no offset.
24 * Returns a big-endian uint64_t with the value encoded as a bitfield.
26 uint64_t bitfield_encode_float(float value, uint8_t bit_offset, uint8_t bit_size,
27 float factor, float offset);
29 /* Public: Encode a boolean into fixed bit width field in a bit array.
31 * value - the boolean value to encode - true will be 1, false will be 0.
32 * bit_offset - the starting point for the encoded bits in the returned value.
33 * bit_size - The max width of the field in the resulting bit array. If bit_size
34 * isn't big enough to store the fixed point version of the value, the bitfeld
35 * will *not* be set. TODO some error reporting would be nice.
37 * Returns a big-endian uint64_t with the value encoded as a bitfield.
39 uint64_t bitfield_encode_bool(const bool value, const uint8_t bit_offset, const uint8_t bit_size);