# `BMI323.Config`

Encoding and decoding of the BMI323 `ACC_CONF` (0x20) and `GYR_CONF` (0x21)
configuration words.

Both registers share the same bit layout:

```text
|15|14 13 12| 11 |10  9  8|  7 | 6  5  4 | 3  2  1  0|
|re|  mode  | re | avg    | bw |  range  |    odr    |
```

Encoders return a 2-byte little-endian binary suitable for
`BMI323.Registers.write_acc_conf/2` and `BMI323.Registers.write_gyr_conf/2`.
Invalid inputs raise `ArgumentError`.

# `accelerometer_range`

```elixir
@type accelerometer_range() :: 2 | 4 | 8 | 16
```

Accelerometer measurement range in g.

# `averaging`

```elixir
@type averaging() :: 1 | 2 | 4 | 8 | 16 | 32 | 64
```

Number of samples averaged per output sample (low-power mode only).

# `bandwidth`

```elixir
@type bandwidth() :: :odr_div_2 | :odr_div_4
```

Low-pass filter cut-off relative to the configured ODR. Has no effect in
low-power mode or when the synchronous timing control mode of I3C is enabled.

# `gyroscope_range`

```elixir
@type gyroscope_range() :: 125 | 250 | 500 | 1000 | 2000
```

Gyroscope measurement range in °/s.

# `odr`

```elixir
@type odr() :: number()
```

Output data rate in Hz. Valid values: 0.78125, 1.5625, 3.125, 6.25, 12.5,
25, 50, 100, 200, 400, 800, 1600, 3200, 6400. Sub-12.5 Hz rates are valid
only in `:low_power` mode; rates ≥ 800 Hz require `:high_performance` mode.

# `power_mode`

```elixir
@type power_mode() :: :disabled | :low_power | :normal | :high_performance
```

Sensor power mode.

* `:disabled` — sensor off (data registers and FIFO frames are invalid).
* `:low_power` — duty-cycled operation with on-chip averaging. ODR ≤ 400 Hz.
* `:normal` — continuous low-power operation. 12.5 Hz ≤ ODR ≤ 6400 Hz.
* `:high_performance` — continuous full-performance operation.

# `decode_acc_conf`

```elixir
@spec decode_acc_conf(&lt;&lt;_::16&gt;&gt;) :: %{
  mode: power_mode(),
  averaging: averaging(),
  bandwidth: bandwidth(),
  range: accelerometer_range(),
  odr: odr()
}
```

Decode an `ACC_CONF` binary into a map of its fields.

# `decode_gyr_conf`

```elixir
@spec decode_gyr_conf(&lt;&lt;_::16&gt;&gt;) :: %{
  mode: power_mode(),
  averaging: averaging(),
  bandwidth: bandwidth(),
  range: gyroscope_range(),
  odr: odr()
}
```

Decode a `GYR_CONF` binary into a map of its fields.

# `encode_acc_conf`

```elixir
@spec encode_acc_conf(keyword()) :: &lt;&lt;_::16&gt;&gt;
```

Encode an `ACC_CONF` value from keyword options.

## Options

  * `:mode` — `t:power_mode/0` (required).
  * `:odr` — `t:odr/0` (required).
  * `:range` — `t:accelerometer_range/0` (default `8`).
  * `:bandwidth` — `t:bandwidth/0` (default `:odr_div_2`).
  * `:averaging` — `t:averaging/0` (default `1`).

# `encode_gyr_conf`

```elixir
@spec encode_gyr_conf(keyword()) :: &lt;&lt;_::16&gt;&gt;
```

Encode a `GYR_CONF` value from keyword options.

## Options

  * `:mode` — `t:power_mode/0` (required).
  * `:odr` — `t:odr/0` (required).
  * `:range` — `t:gyroscope_range/0` (default `2000`).
  * `:bandwidth` — `t:bandwidth/0` (default `:odr_div_2`).
  * `:averaging` — `t:averaging/0` (default `1`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
