diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-02 17:56:20 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2014-01-02 17:56:45 -0500 |
commit | 31caa9c77dbfc438a104fbcab6db5165528c0f89 (patch) | |
tree | 62f4d0741eb47dc09db717f6cc40432163cb5b7d /README.mkd | |
parent | 4af52c415f1668fbd168da74d0aca903c592463f (diff) |
Clarify when you need to specify endianness.
Diffstat (limited to 'README.mkd')
-rw-r--r-- | README.mkd | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -9,6 +9,8 @@ started, here are examples using the API: ## Bitfield Manipulation +The bitfields are stored in `uint8_t[]`. + uint8_t data[4] = {0x12, 0x34, 0x56, 0x78}; uint8_t result = get_byte(data, sizeof(data), 0); // result = 0x12; @@ -19,7 +21,13 @@ started, here are examples using the API: // result[0] == 0x2 // result[1] == 0x34 -## 8 Byte Bitfield Decoding +## 8 Byte Helpers + +If you are dealing with 8 byte CAN messages as `uint64_t`, there are some +additional functions prefixed with `eightbyte_` that may be faster or more +useful. + +### 8 Byte Decoding uint64_t data = 0x8000000000000000; uint64_t result = get_bit_field(data, 0, 1, false); @@ -39,16 +47,14 @@ started, here are examples using the API: result = eightbyte_get_nibble(data, 10, false); //result = 0x4; -## 8 Byte Bitfield Encoding +### 8 Byte Encoding uint64_t data = 0; fail_unless(set_bit_field(&data, 1, 0, 1)); uint64_t result = get_bit_field(data, 0, 1, false); ck_assert_int_eq(result, 0x1); -TODO setting bit fields is just copying - -## CAN Signal Encoding +### CAN Signal Encoding The library supports encoding floating point CAN signals as well as booleans into a uint64_t payload. @@ -59,7 +65,7 @@ into a uint64_t payload. payload = bitfield_encode_bool(true, 1, 3); // payload == 0x1000000000000000 -## CAN Signal Decoding +### CAN Signal Decoding The library supports parsing floating point CAN signals as well as booleans. |