#include <stdio.h> #include <stdint.h> #define POWER_ON (1U << 0) #define ERROR (1U << 1) #define TX_READY (1U << 2) #define RX_READY (1U << 3) #define OVERHEAT (1U << 4) #define UNDERVOLTAGE (1U << 5) #define TIMEOUT (1U << 6) #define RESERVED (1U << 7) void decode_status(uint8_t status_reg) { // Your logic here if (status_reg & POWER_ON) printf("Power On\n"); if (status_reg & ERROR) printf("Error\n"); if (status_reg & TX_READY) printf("Tx Ready\n"); if (status_reg & RX_READY) printf("Rx Ready\n"); if (status_reg & OVERHEAT) printf("Overheat\n"); if (status_reg & UNDERVOLTAGE) printf("Undervoltage\n"); if (status_reg & TIMEOUT) printf("Timeout\n"); if (status_reg & RESERVED) printf("Reserved\n"); } int main() { uint8_t reg; scanf("%hhu", ®); decode_status(reg); return 0; }
Solving Approach
Test Cases
Test Results
Input
13
Expected Output
Power On Tx Ready Rx Ready