* @brief Write up to 8 bits at an arbitrary bit offset. * * The stored value is at most 8 bits, but can be stored at an offset of between 0 and 7 bits so * may span two separate bytes in memory. * * @param value The value to write. * @param bitcount The number of bits to write, starting from LSB. * @param bitoffset The bit offset to store at, between 0 and
| 79 | * @param[in,out] ptr The data pointer to write to. |
| 80 | */ |
| 81 | static inline void write_bits( |
| 82 | int value, |
| 83 | int bitcount, |
| 84 | int bitoffset, |
| 85 | uint8_t* ptr |
| 86 | ) { |
| 87 | int mask = (1 << bitcount) - 1; |
| 88 | value &= mask; |
| 89 | ptr += bitoffset >> 3; |
| 90 | bitoffset &= 7; |
| 91 | value <<= bitoffset; |
| 92 | mask <<= bitoffset; |
| 93 | mask = ~mask; |
| 94 | |
| 95 | ptr[0] &= mask; |
| 96 | ptr[0] |= value; |
| 97 | ptr[1] &= mask >> 8; |
| 98 | ptr[1] |= value >> 8; |
| 99 | } |
| 100 | |
| 101 | /* See header for documentation. */ |
| 102 | void symbolic_to_physical( |
no outgoing calls
no test coverage detected