Efficient way to create/unpack large bitfields in C?

Posted by drhorrible on Stack Overflow See other posts from Stack Overflow or by drhorrible
Published on 2010-04-05T01:35:02Z Indexed on 2010/04/05 1:43 UTC
Read the original article Hit count: 297

Filed under:
|
|

I have one microcontroller sampling from a lot of ADC's, and sending the measurements over a radio at a very low bitrate, and bandwidth is becoming an issue.

Right now, each ADC only give us 10 bits of data, and its being stored in a 16-bit integer. Is there an easy way to pack them in a deterministic way so that the first measurement is at bit 0, second at bit 10, third at bit 20, etc?

To make matters worse, the microcontroller is little endian, and I have no control over the endianness of the computer on the other side.

© Stack Overflow or respective owner

Related posts about c

    Related posts about bitmask