ch32-rs / wchisp

Rust-based Command Line Tool for WCH MCU USB-ISP Programming
https://ch32-rs.github.io/wchisp/
GNU General Public License v2.0
173 stars 29 forks source link

Please comment on "config_registers ... bit_range: [x, y] " is 'x' included ? (possible bug): #2

Closed Pe3ucTop closed 2 years ago

Pe3ucTop commented 2 years ago

Hi, great work ! I looked for example of bit definition and get confused :

      - bit_range: [7, 0]
        name: RDPR
        description: Read Protection. 0xA5 for unprotected, otherwise read-protected(ignoring WRP)
        explaination:
          0xa5: Unprotected
          _: Protected

in compare to:

      - bit_range: [23, 21]
        name: SRAM_CODE_MODE
        description: SRAM Code Mode
        explaination:
          0b00: CODE-192KB + RAM-128KB
          0b01: CODE-224KB + RAM-96KB
          0b10: CODE-256KB + RAM-64KB
          0b11: CODE-228KB + RAM-32KB

So question: 'bit_range: [x , y]' is 'x' included in range ? Is second part 3 bit or 2 bit ? Which one is correct way?

andelf commented 2 years ago

Thanks, it's a typo in offset calculation.

andelf commented 2 years ago

It's an experiment in config register parsing. Currently, it uses RangeInclusive type to represent bit offsets. I made a mistake in calculation.