mirror of
https://gitlab.com/manzerbredes/ina260-sysfs-driver.git
synced 2025-04-19 04:09:45 +00:00
Change permissions and update README
This commit is contained in:
parent
d43c92e2a1
commit
63656e1bd8
2 changed files with 16 additions and 5 deletions
17
README.md
17
README.md
|
@ -1,12 +1,23 @@
|
||||||
# INA260-sysfs-driver
|
# INA260-sysfs-driver
|
||||||
|
|
||||||
|
Link to the [ina260 datasheet](https://www.ti.com/lit/gpn/INA260).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
$ make
|
$ make
|
||||||
$ sudo insmod ina260.ko
|
$ sudo insmod ina260.ko
|
||||||
|
|
||||||
## Usage
|
## Managing INA260 devices
|
||||||
|
- Add device: `echo ina260 [devaddr] > /sys/bus/i2c/devices/<bus>/new_device`
|
||||||
|
- Delete device: `echo [devaddr] > /sys/bus/i2c/devices/<bus>/delete_device`
|
||||||
|
|
||||||
- Add device: `echo ina260 <devaddr> > /sys/bus/i2c/devices/<busid>/new_device`
|
## Sysfs structure
|
||||||
|
- Overview: `tree /sys/kernel/ina260`
|
||||||
|
- You can access to each device registers in `/sys/kernel/ina260/<device>/registers/`
|
||||||
|
- You can access to each device register fields in `/sys/kernel/ina260/<device>/fields/`
|
||||||
|
- You can access to the currently measured current, voltage and power via `/sys/kernel/ina260/<device>/<power|current|voltage>` (units are watts, amperes and volts respectively)
|
||||||
|
|
||||||
- Next, run: `tree /sys/kernel/ina260`
|
For more informations on the registers/fields, please refer to the [ina260 datasheet](https://www.ti.com/lit/gpn/INA260).
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
- Tested so far on a [Beaglebone Black](https://www.beagleboard.org/boards/beaglebone-black) with a [Mikrobus Cape](https://www.mikroe.com/beaglebone-mikrobus-cape) with up to four ina260 devices attached.
|
4
ina260.c
4
ina260.c
|
@ -371,9 +371,9 @@ static const struct attribute_group registers_group = {
|
||||||
};
|
};
|
||||||
// ----- Metrics -----
|
// ----- Metrics -----
|
||||||
static struct kobj_attribute metric_power_attribute =
|
static struct kobj_attribute metric_power_attribute =
|
||||||
__ATTR(power, 0664, attr_metric_show, NULL);
|
__ATTR(power, 0444, attr_metric_show, NULL);
|
||||||
static struct kobj_attribute metric_voltage_attribute =
|
static struct kobj_attribute metric_voltage_attribute =
|
||||||
__ATTR(voltage, 0664, attr_metric_show, NULL);
|
__ATTR(voltage, 0444, attr_metric_show, NULL);
|
||||||
static struct kobj_attribute metric_current_attribute = {
|
static struct kobj_attribute metric_current_attribute = {
|
||||||
.attr = {.name = "current", // current is a defined macro so need to do it manually
|
.attr = {.name = "current", // current is a defined macro so need to do it manually
|
||||||
.mode = VERIFY_OCTAL_PERMISSIONS(0444) },
|
.mode = VERIFY_OCTAL_PERMISSIONS(0444) },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue