Combining two uint8_t as uint16_t

c

Solution

You can use bitwise operators:

uint16_t wd = ((uint16_t)d2 << 8) | d1;

Because:

 (0x0002 << 8) | 0x01 = 0x0200 | 0x0001 = 0x0201

Problem

I have the following data ``` uint8_t d1=0x01; uint8_t d2=0x02; ``` I want to combine them as `uint16_t` as ``` uint16_t wd = 0x0201; ``` How can I do it?

Original source