Skip to content

Constants are possibly incorrect #5

Closed
@ghost

Description

I think these are wrong:

_CONFIG_BADCRES_MASK             = const(0x0780)  # Bus ADC Resolution Mask
_CONFIG_BADCRES_9BIT             = const(0x0080)  # 9-bit bus res = 0..511
_CONFIG_BADCRES_10BIT            = const(0x0100)  # 10-bit bus res = 0..1023
_CONFIG_BADCRES_11BIT            = const(0x0200)  # 11-bit bus res = 0..2047
_CONFIG_BADCRES_12BIT            = const(0x0400)  # 12-bit bus res = 0..4097

Based on Table 5 in the IN219 datasheet, they should probably be the following, inserting 0 for all X (don't-cares), and changing 4097 to 4095 in the comment.

_CONFIG_BADCRES_MASK             = const(0x0780)  # Bus ADC Resolution Mask
_CONFIG_BADCRES_9BIT             = const(0x0000)  # 9-bit bus res = 0..511
_CONFIG_BADCRES_10BIT            = const(0x0080)  # 10-bit bus res = 0..1023
_CONFIG_BADCRES_11BIT            = const(0x0100)  # 11-bit bus res = 0..2047
_CONFIG_BADCRES_12BIT            = const(0x0180)  # 12-bit bus res = 0..4095

Also, for the "BADCRES" bits, you've left off the rest of Table 5, even though it is included for the "SADCRES" bits. The averaging features area available for both. Perhaps all those constants should be refactored to use offsets so they can be shared between BADCRES and SADCRES.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions