Close

More driver improvements

A project log for Viam Sonus 2.0

An audio router board with integrated volume control and buffered output

j-ian-lindsayJ. Ian Lindsay 11/30/2019 at 22:310 Comments

The drivers had a tremendous amount of technical debt cleared away last night. Bus references are no longer hard-coded to "Wire", but are instead passed in as an argument to init(), and is then retained by classes that need it. This costs an extra 30 bytes of resting memory load for ViamSonus, but paves the way for the linux TwoWire abstraction, and makes life generally easier for anyone using the board with (suppose) "Wire1".

Additionally, every driver in the glueball (the driver for the DS1881, and the ADG2128), and the glueball itself now support state serialization and restore. It needs some more testing, but it should allow state restore before or after init(), allowing for "profiles" and easy management of preferred settings, default states, etc. Buffers written this way are versioned so that new driver features can be gracefully migrated in. Those APIs are essentially finished, so they are now safe to code against. All of the example sketches are updated, tested, committed, and pushed.

Unrelated to the above feature is another feature that is important for the linux port: preserve-on-destroy. When the driver instance for the switch is destroyed, the default behavior is to put the hardware into a known state (reset). This opens all routes. Use-cases that want the hardware state to outlive the driver's life cycle are now possible again.

Lots of sloppy private boolean class variables were condensed into something more efficient and manageable (int member with flags).

Next Steps:

The ViamSonus driver is about to undergo mitosis into four separate classes to fully separate concerns and make the API stable and sensible to use.

The linux TwoWire and GPIO abstractions are all that stand in the path of linux SBC support. The Makefile and example program are committed, but won't compile until those issues are resolved.

Hardware availability projections

Once I get the boards from OSHPark, I will assemble them that night. I should have 3 tested units available for sale, and at a lower price (so hold tight for the price cut). If those disappear quickly, I'll restock at about 3 weeks out.

Discussions