summaryrefslogtreecommitdiffstats
path: root/src/bitfield/bitfield.h
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2013-12-28 15:42:10 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2013-12-28 15:42:10 -0500
commit0b00bb6c3c5df70317775efd12b6fff418ff4540 (patch)
tree918bd162c66ad2ff5f3adc568d84401810b4fbd3 /src/bitfield/bitfield.h
parent04a4db7d336ae2cae94ac3234086b22fbf1339f0 (diff)
Draft work making the bitfield functions more generic.
Diffstat (limited to 'src/bitfield/bitfield.h')
-rw-r--r--src/bitfield/bitfield.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/bitfield/bitfield.h b/src/bitfield/bitfield.h
index 7d9f3995..ce68b949 100644
--- a/src/bitfield/bitfield.h
+++ b/src/bitfield/bitfield.h
@@ -8,6 +8,21 @@
extern "C" {
#endif
+typedef enum {
+ ENDIANNESS_LITTLE_ENDIAN,
+ ENDIANNESS_BIG_ENDIAN
+} Endianness;
+
+uint8_t getNibble(const uint8_t nibble_index, const uint8_t data[],
+ const uint8_t length, Endianness endianness);
+
+uint8_t getByte(const uint8_t byte_index, const uint8_t data[],
+ const uint8_t length, Endianness endianness);
+
+void getBits(const uint16_t start_index, const uint16_t field_size,
+ const uint8_t data[], const uint8_t length, Endianness endianness,
+ uint8_t* result);
+
/* Public: Reads a subset of bits from a byte array.
*
* data - the bytes in question.
@@ -40,7 +55,7 @@ extern "C" {
*
* Returns the value of the requested bit field.
*/
-uint64_t getBitField(uint64_t data, int startPos, int numBits, bool bigEndian);
+uint64_t getBitField(uint64_t data, const uint16_t startPos, const uint16_t numBits, bool bigEndian);
/* Public: Set the bit field in the given data array to the new value.
*