Hacker News new | ask | show | jobs
by SAI_Peregrinus 1589 days ago
It's also extremely useful for bit-mapped registers in embedded code.

EG the TI bq25155[1] battery charge controller PCHRGCTRL register (page 52) is divided into 3 fields. It can be quite helpful to show the layout before code to set the range.

   /*
    * ┌───────────────┬──────────┬─────────┐
    * │ ICHARGE_RANGE │ RESERVED │ IPRECHG │
    * │      7        │   6-5    |   4-0   |
    * └───────────────┴──────────┴─────────┘
    * This function sets the precharge current
    *  and fast-charge current step size the
    *  nearest 1.25mA (<= 318.75mA) or 
    *  2.5mA (<= 500mA).
    */
etc, etc.

[1] https://www.ti.com/lit/ds/symlink/bq25155.pdf