avia,hx711-spi (on spi bus)

Description

Avia Semiconductor HX711 24-bit ADC Specialized for Load Cells / Strain Gauges on SPI bus

This driver implements the sensor interface. A trigger can be configured for data ready
events (i.e. when the DOUT line is pulled low), which is implemented through a GPIO
interrupt.

To enable the trigger, the user has to supply two pinctrl configs named "default" and
"trigger":
- "default" pinctrl should be identical to the pinctrl supplied to the parent spi node;
- "trigger" pinctrl should include only one pin that specifies the DOUT pin.

For example:

&pinctrl {
  spi0_hx711: spi0_hx711 {
    /* GPIO16 (RX) connects to DOUT, GPIO19 (TX) connects to PD_SCK */
    /* GPIO17 (CS) and GPIO19 (SCK) are not used */
    group1 {
      pinmux = <SPI0_CSN_P17>, <SPI0_SCK_P18>, <SPI0_TX_P19>;
      };

      group2 {
        pinmux = <SPI0_RX_P16>;
        input-enable;
      };
  };
  hx711_trig: hx711_trig {
    /* Assign GPIO16 (DOUT) for use as an interrupt source */
    group1 {
      pinmux = <GPIO_P16>;
      input-enable;
    };
  };
};

&spi0 {
  status = "okay";
  cs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
  pinctrl-0 = <&spi0_hx711>;

  hx711@0 {
    compatible = "avia,hx711";
    reg = <0>;
    spi-max-frequency = <1000000>; /* max 2.5 MHz, min 10 kHz */
    gain = <64>;
    avdd = <5000>; /* mV */
    pinctrl-0 = <&spi0_hx711>;
    pinctrl-1 = <&hx711_trig>;
    pinctrl-names = "default", "trigger";
    dout-trig-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
  };
};

Properties

Properties not inherited from the base binding file.

Name

Type

Details

gain

int

PGA gain for channel A

This property is required.

Legal values: 64, 128

avdd

int

AVDD value in millivolts, for converting samples to voltage

This property is required.

dout-trig-gpios

phandle-array

GPIO for DOUT and trigger signal indicating a sample is ready

spi-max-frequency

int

Maximum clock frequency of device's SPI interface in Hz

This property is required.

duplex

int

Duplex mode, full or half. By default it's always full duplex thus 0
as this is, by far, the most common mode.
Use the macros not the actual enum value, here is the concordance
list (see dt-bindings/spi/spi.h)
  0    SPI_FULL_DUPLEX
  2048 SPI_HALF_DUPLEX

Legal values: 0, 2048

frame-format

int

Motorola or TI frame format. By default it's always Motorola's,
thus 0 as this is, by far, the most common format.
Use the macros not the actual enum value, here is the concordance
list (see dt-bindings/spi/spi.h)
  0     SPI_FRAME_FORMAT_MOTOROLA
  32768 SPI_FRAME_FORMAT_TI

Legal values: 0, 32768

spi-cpol

boolean

SPI clock polarity which indicates the clock idle state.
If it is used, the clock idle state is logic high; otherwise, low.

spi-cpha

boolean

SPI clock phase that indicates on which edge data is sampled.
If it is used, data is sampled on the second edge; otherwise, on the first edge.

spi-lsb-first

boolean

The device requires least significant bit first data mode.

spi-hold-cs

boolean

In some cases, it is necessary for the master to manage SPI chip select
under software control, so that multiple spi transactions can be performed
without releasing it. A typical use case is variable length SPI packets
where the first spi transaction reads the length and the second spi transaction
reads length bytes.

spi-cs-high

boolean

The device requires the chip select to be active high.

spi-interframe-delay-ns

int

Delay in nanoseconds between SPI words.
Default of 0 is special value which will assume to mean half of the SCK period.

spi-cs-setup-delay-ns

int

Delay in nanoseconds to be introduced by the controller after CS is asserted.
Also known as enable lead time.

spi-cs-hold-delay-ns

int

Delay in nanoseconds to be introduced by the controller before the CS is de-asserted.
 Also known as enable lag time.

supply-gpios

phandle-array

GPIO specifier that controls power to the device.

This property should be provided when the device has a dedicated
switch that controls power to the device.  The supply state is
entirely the responsibility of the device driver.

Contrast with vin-supply.

vin-supply

phandle

Reference to the regulator that controls power to the device.
The referenced devicetree node must have a regulator compatible.

This property should be provided when device power is supplied
by a shared regulator.  The supply state is dependent on the
request status of all devices fed by the regulator.

Contrast with supply-gpios.  If both properties are provided
then the regulator must be requested before the supply GPIOS is
set to an active state, and the supply GPIOS must be set to an
inactive state before releasing the regulator.

friendly-name

string

Human readable string describing the sensor. It can be used to
distinguish multiple instances of the same model (e.g., lid accelerometer
vs. base accelerometer in a laptop) to a host operating system.

This property is defined in the Generic Sensor Property Usages of the HID
Usage Tables specification
(https://usb.org/sites/default/files/hut1_3_0.pdf, section 22.5).

pinctrl-0

phandles

Pin configuration/s for the first state. Content is specific to the
selected pin controller driver implementation.

pinctrl-1

phandles

Pin configuration/s for the second state. See pinctrl-0.

pinctrl-2

phandles

Pin configuration/s for the third state. See pinctrl-0.

pinctrl-3

phandles

Pin configuration/s for the fourth state. See pinctrl-0.

pinctrl-4

phandles

Pin configuration/s for the fifth state. See pinctrl-0.

pinctrl-names

string-array

Names for the provided states. The number of names needs to match the
number of states.