62. Decode Status Register into Human-Readable Flags

In embedded systems, status registers often represent multiple flags using each bit. You are given an 8-bit status register. Each bit corresponds to a different condition.

Bit-to-Flag Mapping

BitMeaning
0Power On
1Error
2Tx Ready
3Rx Ready
4Overheat
5Undervoltage
6Timeout
7Reserved

You must write a function that:

  • Accepts a uint8_t status_reg
  • Decodes which flags are set (bits = 1)
  • Prints only the enabled flag names, one per line, in the order of bits from LSB to MSB (0 to 7)
     

Example-1

Input: 13
Output:
Power On
Tx Ready
Rx Ready

 

Example-2

Input: 48
Output:
Overheat
Undervoltage

 

Example-3

Input: 255
Output:
Power On
Error
Tx Ready
Rx Ready
Overheat
Undervoltage
Timeout
Reserved


 

Loading...

Input

13

Expected Output

Power On Tx Ready Rx Ready