28. Bit Field Operations-i

Question.5

A developer packs three fields into a 16-bit SPI config register:

1514131211109876543210
CPOLCPHADIVCS

He writes:

uint16_t reg = 0;
uint8_t cpol = 1, cpha = 0, div = 18, cs = 3;

reg |= (cpol & 0x01) << 15;
reg |= (cpha & 0x01) << 14;
reg |= (div  & 0x3F) << 8;
reg |= (cs   & 0x0F);

What is the value of reg in hexadecimal?

Need Help? Refer to the Quick Guide below

Select Answer