summaryrefslogtreecommitdiffstats
path: root/src/bitfield/bitfield.h
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2013-12-31 11:40:15 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2013-12-31 11:40:15 -0500
commit4af52c415f1668fbd168da74d0aca903c592463f (patch)
tree977c8b9ea758c0b7f54f48a19611d4eaf2e71a36 /src/bitfield/bitfield.h
parentcd74b88432054107c439c4e565bea14840dd9ea5 (diff)
Fix byte alignment for right aligned functions.
Diffstat (limited to 'src/bitfield/bitfield.h')
-rw-r--r--src/bitfield/bitfield.h27
1 files changed, 27 insertions, 0 deletions
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