mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 00:23:30 +00:00
Organize companion code and materials by book part: part-01/ Foundations part-02/ Kernel & driver fundamentals part-03/ Character & block devices part-04/ Networking & storage part-05/ Buses & advanced topics part-06/ Debugging & performance part-07/ Real-world drivers appendices/ Supplementary material README.md Overview and build instructions
24 lines
862 B
C
24 lines
862 B
C
#include "flags.h"
|
|
|
|
/*
|
|
* Print both the hex value and a friendly list of which flags are set.
|
|
* This mirrors how driver debug output often looks in practice.
|
|
*
|
|
* The `first` variable tracks whether we are printing the first flag
|
|
* (no leading comma) or a later one (comma separator).
|
|
*/
|
|
void
|
|
print_state(uint32_t st)
|
|
{
|
|
int first = 1;
|
|
|
|
printf("State: 0x%08x [", st);
|
|
if (test_flag(st, DF_ENABLED)) { printf("%sENABLED", first ? "" : ","); first = 0; }
|
|
if (test_flag(st, DF_OPEN)) { printf("%sOPEN", first ? "" : ","); first = 0; }
|
|
if (test_flag(st, DF_ERROR)) { printf("%sERROR", first ? "" : ","); first = 0; }
|
|
if (test_flag(st, DF_TX_BUSY)) { printf("%sTX_BUSY", first ? "" : ","); first = 0; }
|
|
if (test_flag(st, DF_RX_READY)) { printf("%sRX_READY", first ? "" : ","); first = 0; }
|
|
if (first)
|
|
printf("none");
|
|
printf("]\n");
|
|
}
|