From 4af52c415f1668fbd168da74d0aca903c592463f Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Tue, 31 Dec 2013 11:40:15 -0500 Subject: Fix byte alignment for right aligned functions. --- src/bitfield/bitfield.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/bitfield/bitfield.h') diff --git a/src/bitfield/bitfield.h b/src/bitfield/bitfield.h index 990482fc..ef04d9ca 100644 --- a/src/bitfield/bitfield.h +++ b/src/bitfield/bitfield.h @@ -110,9 +110,36 @@ bool copy_bits_right_aligned(const uint8_t source[], const uint16_t source_lengt const uint16_t offset, const uint16_t bit_count, uint8_t* destination, const uint16_t destination_length); +/* Public: Copy a range of bytes from one byte array to another. + * + * The source and destination do not have to be the same size (as long as the + * desitnation has enough room to fit the range). + * + * source_origin - the source array. + * source_length - the total length of the source array in bytes, + * for range checking. + * source_offset - a byte offset to start the copy from the source array. + * Specify 0 to start from source_origin. + * byte_count - the number of bytes to copy. + * destination_origin - the destination array. + * desitnation_length - the total length of the destination array in bytes, + * for range checking. + * destination_offset - an offset in bytes to start placing the copied range into + * the destination array. Specify 0 to start from the beginning of the + * destination. + * + * Returns true if the copy was successful and false if the range exceeded the + * size of the source or destination, or if the range size negative or 0. + */ +bool copy_bytes_right_aligned(const uint8_t source[], const uint16_t source_length, + const uint16_t offset, const uint16_t byte_count, + uint8_t* destination, const uint16_t destination_length); + bool set_nibble(const uint16_t nibble_index, const uint8_t value, uint8_t* destination, const uint16_t destination_length); +uint16_t bits_to_bytes(uint32_t bits); + #ifdef __cplusplus } #endif -- cgit 1.2.3-korg