Expand description
A driver for the register interface on the Nuvoton NAU88C22 CODEC
Works in I²C mode only, for now.
use core::fmt::Write;
let mut uart = hal.uart();
let i2c = hal.i2c();
let mut codec = nau88c22::Codec::new(i2c);
// Do a Software Reset on the chip to put registers into a known state. This
// fails if we don't get an I2C ACK:
codec.reset()?;
// You can then either poll a register for a known value, or just wait for
// the reset sequence to complete:
hal.delay_ms(100);
// First you should check the Device ID is correct:
codec.check_device_id()?;
// Every register has a `read_xxx()` method:
let pm1 = codec.read_powermanagement1()?;
// You can view the fields with a debug print:
writeln!(uart, "powermanagement1 = {:?}", pm1).unwrap();
// Or access them individually:
writeln!(uart, "powermanagement1.dcbufen = {}", pm1.dcbufen()).unwrap();
// You can also modify registers with a closure:
codec.modify_powermanagement1(|mut w| {
// the closure is given a proxy object, usually called `w`
// use it to turn the fields on or off
w.iobufen_set(true);
w.dcbufen_set(true);
// you must return the proxy object from the closure
w
})?;
Modules§
- Register constants for the NAU88C22
Structs§
- Represents the NAU882CC CODEC
Enums§
- Represents the ways that this library can fail
- The list of registers on the chip