[riot-notifications] [RIOT-OS/RIOT] drivers/ina220: Changed to comply with RIOT's driver design goals & SAUL adaption (#11350)

Marian Buschsieweke notifications at github.com
Fri Apr 5 19:28:01 CEST 2019


### Contribution description
This PR contains some major changes to the INA220 power/current monitor driver

1. Rename to INA2XX, as the same driver works for (at least) the INA220 and the INA219, most likely for a bunch of other I2C power/current monitors of the same family
2. Brought the API in compliance with RIOT's driver API goals
    - Use standard RIOT driver initialization/configuration via `ina2xx_params_t` instead of custom API
    - Perform a device reset and connectivity test upon initialization as required by the design goals stated in [RIOT's driver guide][guide]
    - Convert the results directly to reasonable physical units  as required by the design goals stated in [RIOT's driver guide][guide]
3. Integrated the driver into SAUL

[guide]: https://github.com/RIOT-OS/RIOT/wiki/Guide:-Writing-a-device-driver-in-RIOT

### Testing procedure

You'll need an INA219 or INA220 device, ideally hooked up at I2C interface 0 with the address inputs set to zero and a shunt resistor of 100 mΩ, as then the default configuration will work out of the box. (This default config will work for the popular INA219 break out boards, e.g. the ones by Adafruit or any clone.)

The default config is optimized to measure power/current for high-power USB devices (500mA @ 5V) with a comfortable margin (up to 655mA and up to 16V). This would also work for 12V power supplies as are popular e.g. with the Arduino boards.

1. Flash `examples/saul` with `USEMODULE=ina2xx make BOARD=<foo> flash` and interact with the saul shell command
2. Flash `tests/driver_ina2xx` and check the output. The values shown should be plausible

### Issues/PRs references
None


You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/11350

-- Commit Summary --

  * drivers: Renamed ina220 --> ina2xx
  * drivers/ina2xx: Match RIOT's driver design goals
  * sys/phydat: Added unit Watt
  * drivers/saul: Added power sensor
  * drivers/ina2xx: Added SAUL integration

-- File Changes --

    M drivers/Makefile.dep (6)
    M drivers/Makefile.include (4)
    D drivers/ina220/ina220.c (109)
    D drivers/ina220/include/ina220-regs.h (50)
    R drivers/ina2xx/Makefile (2)
    A drivers/ina2xx/ina2xx.c (190)
    A drivers/ina2xx/ina2xx_saul.c (86)
    A drivers/ina2xx/include/ina2xx_defines.h (66)
    A drivers/ina2xx/include/ina2xx_params.h (128)
    D drivers/include/ina220.h (233)
    A drivers/include/ina2xx.h (261)
    M drivers/include/saul.h (1)
    M drivers/saul/saul_str.c (1)
    M examples/default/Makefile (1)
    M makefiles/pseudomodules.inc.mk (4)
    M sys/auto_init/auto_init.c (4)
    A sys/auto_init/saul/auto_init_ina2xx.c (88)
    M sys/include/phydat.h (1)
    M sys/phydat/phydat_str.c (1)
    D tests/driver_ina220/Makefile (14)
    D tests/driver_ina220/main.c (102)
    A tests/driver_ina2xx/Makefile (6)
    R tests/driver_ina2xx/README.md (3)
    A tests/driver_ina2xx/main.c (160)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11350.patch
https://github.com/RIOT-OS/RIOT/pull/11350.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11350
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190405/857356b3/attachment-0001.html>


More information about the notifications mailing list