diff options
Diffstat (limited to 'libs/bitfield-c/src/canutil')
-rw-r--r-- | libs/bitfield-c/src/canutil/read.c | 12 | ||||
-rw-r--r-- | libs/bitfield-c/src/canutil/read.h | 14 | ||||
-rw-r--r-- | libs/bitfield-c/src/canutil/write.c | 18 | ||||
-rw-r--r-- | libs/bitfield-c/src/canutil/write.h | 20 |
4 files changed, 32 insertions, 32 deletions
diff --git a/libs/bitfield-c/src/canutil/read.c b/libs/bitfield-c/src/canutil/read.c index d0cbb71a..5790a7a1 100644 --- a/libs/bitfield-c/src/canutil/read.c +++ b/libs/bitfield-c/src/canutil/read.c @@ -6,27 +6,27 @@ static float decode_float(uint64_t raw, float factor, float offset) { return raw * factor + offset; } -float eightbyte_parse_float(uint64_t data, uint8_t bit_offset, uint8_t bit_size, +float eightbyte_parse_float(uint64_t data, unsigned int bit_offset, unsigned int bit_size, float factor, float offset) { return decode_float(eightbyte_get_bitfield(data, bit_offset, bit_size, true), factor, offset); } -bool eightbyte_parse_bool(uint64_t data, uint8_t bit_offset, uint8_t bit_size, +bool eightbyte_parse_bool(uint64_t data, unsigned int bit_offset, unsigned int bit_size, float factor, float offset) { float value = eightbyte_parse_float(data, bit_offset, bit_size, factor, offset); return value == 0.0 ? false : true; } -float bitfield_parse_float(const uint8_t source[], const uint16_t source_length, - const uint8_t bit_offset, const uint8_t bit_size, const float factor, +float bitfield_parse_float(const uint8_t source[], const unsigned int source_length, + const unsigned int bit_offset, const unsigned int bit_size, const float factor, const float offset) { return decode_float(get_bitfield(source, source_length, bit_offset, bit_size), factor, offset); } -bool bitfield_parse_bool(const uint8_t source[], const uint16_t source_length, - const uint8_t bit_offset, const uint8_t bit_size, const float factor, +bool bitfield_parse_bool(const uint8_t source[], const unsigned int source_length, + const unsigned int bit_offset, const unsigned int bit_size, const float factor, const float offset) { float value = bitfield_parse_float(source, source_length, bit_offset, bit_size, factor, offset); diff --git a/libs/bitfield-c/src/canutil/read.h b/libs/bitfield-c/src/canutil/read.h index 86fea785..8afe4f4a 100644 --- a/libs/bitfield-c/src/canutil/read.h +++ b/libs/bitfield-c/src/canutil/read.h @@ -20,8 +20,8 @@ extern "C" { * * Returns the decoded and transformed value of the signal. */ -float eightbyte_parse_float(const uint64_t source, const uint8_t bit_offset, - const uint8_t bit_size, const float factor, const float offset); +float eightbyte_parse_float(const uint64_t source, const unsigned int bit_offset, + const unsigned int bit_size, const float factor, const float offset); /* Public: Parse a CAN signal from a message storage as a byte array and apply * required transformation. @@ -37,8 +37,8 @@ float eightbyte_parse_float(const uint64_t source, const uint8_t bit_offset, * * Returns the decoded and transformed value of the signal. */ -float bitfield_parse_float(const uint8_t source[], const uint16_t source_size, - const uint8_t bit_offset, const uint8_t bit_size, const float factor, +float bitfield_parse_float(const uint8_t source[], const unsigned int source_size, + const unsigned int bit_offset, const unsigned int bit_size, const float factor, const float offset); /* Public: Parse a CAN signal from a message and interpret it as a boolean. @@ -53,7 +53,7 @@ float bitfield_parse_float(const uint8_t source[], const uint16_t source_size, * * Returns false if the value was 0, otherwise true. */ -bool eightbyte_parse_bool(uint64_t source, uint8_t bit_offset, uint8_t bit_size, +bool eightbyte_parse_bool(uint64_t source, unsigned int bit_offset, unsigned int bit_size, float factor, float offset); /* Public: Parse a CAN signal from a message storage as a byte array and @@ -70,8 +70,8 @@ bool eightbyte_parse_bool(uint64_t source, uint8_t bit_offset, uint8_t bit_size, * * Returns false if the value was 0, otherwise true. */ -bool bitfield_parse_bool(const uint8_t source[], const uint16_t source_size, - const uint8_t bit_offset, const uint8_t bit_size, const float factor, +bool bitfield_parse_bool(const uint8_t source[], const unsigned int source_size, + const unsigned int bit_offset, const unsigned int bit_size, const float factor, const float offset); #ifdef __cplusplus diff --git a/libs/bitfield-c/src/canutil/write.c b/libs/bitfield-c/src/canutil/write.c index 7f3a3e04..317ccf04 100644 --- a/libs/bitfield-c/src/canutil/write.c +++ b/libs/bitfield-c/src/canutil/write.c @@ -14,7 +14,7 @@ uint64_t float_to_fixed_point(const float value, const float factor, return (uint64_t)raw; } -uint64_t eightbyte_encode_float(float value, uint8_t bit_offset, uint8_t bit_size, +uint64_t eightbyte_encode_float(float value, unsigned int bit_offset, unsigned int bit_size, float factor, float offset) { uint64_t result = 0; if(!eightbyte_set_bitfield(float_to_fixed_point(value, factor, offset), @@ -24,14 +24,14 @@ uint64_t eightbyte_encode_float(float value, uint8_t bit_offset, uint8_t bit_siz return result; } -uint64_t eightbyte_encode_bool(const bool value, const uint8_t bit_offset, - const uint8_t bit_size) { +uint64_t eightbyte_encode_bool(const bool value, const unsigned int bit_offset, + const unsigned int bit_size) { return eightbyte_encode_float(value, bit_offset, bit_size, 1.0, 0); } -bool bitfield_encode_float(const float value, const uint8_t bit_offset, - const uint8_t bit_size, const float factor, const float offset, - uint8_t destination[], const uint8_t destination_length) { +bool bitfield_encode_float(const float value, const unsigned int bit_offset, + const unsigned int bit_size, const float factor, const float offset, + uint8_t destination[], const unsigned int destination_length) { if(!set_bitfield(float_to_fixed_point(value, factor, offset), bit_offset, bit_size, destination, destination_length)) { // debug("%f will not fit in a %d bit field", value, bit_size); @@ -40,9 +40,9 @@ bool bitfield_encode_float(const float value, const uint8_t bit_offset, return true; } -bool bitfield_encode_bool(const bool value, const uint8_t bit_offset, - const uint8_t bit_size, uint8_t destination[], - const uint16_t destination_length) { +bool bitfield_encode_bool(const bool value, const unsigned int bit_offset, + const unsigned int bit_size, uint8_t destination[], + const unsigned int destination_length) { return bitfield_encode_float(value, bit_offset, bit_size, 1.0, 0, destination, destination_length); } diff --git a/libs/bitfield-c/src/canutil/write.h b/libs/bitfield-c/src/canutil/write.h index c2bef20e..7f653b98 100644 --- a/libs/bitfield-c/src/canutil/write.h +++ b/libs/bitfield-c/src/canutil/write.h @@ -23,15 +23,15 @@ extern "C" { * * Returns a big-endian uint64_t with the value encoded as a bitfield. */ -uint64_t eightbyte_encode_float(float value, uint8_t bit_offset, - uint8_t bit_size, float factor, float offset); +uint64_t eightbyte_encode_float(float value, unsigned int bit_offset, + unsigned int bit_size, float factor, float offset); uint64_t float_to_fixed_point(const float value, const float factor, const float offset); -bool bitfield_encode_float(const float value, const uint8_t bit_offset, - const uint8_t bit_size, const float factor, const float offset, - uint8_t destination[], const uint8_t destination_length); +bool bitfield_encode_float(const float value, const unsigned int bit_offset, + const unsigned int bit_size, const float factor, const float offset, + uint8_t destination[], const unsigned int destination_length); /* Public: Encode a boolean into fixed bit width field in a bit array. * @@ -43,12 +43,12 @@ bool bitfield_encode_float(const float value, const uint8_t bit_offset, * * Returns a big-endian uint64_t with the value encoded as a bitfield. */ -uint64_t eightbyte_encode_bool(const bool value, const uint8_t bit_offset, - const uint8_t bit_size); +uint64_t eightbyte_encode_bool(const bool value, const unsigned int bit_offset, + const unsigned int bit_size); -bool bitfield_encode_bool(const bool value, const uint8_t bit_offset, const - uint8_t bit_size, uint8_t destination[], - const uint16_t destination_length); +bool bitfield_encode_bool(const bool value, const unsigned int bit_offset, const + unsigned int bit_size, uint8_t destination[], + const unsigned int destination_length); #ifdef __cplusplus } |