Expand description
The C ABI for the actuator drivers that run over an I2C bus.
A PamojaPca9685 drives the PCA9685’s sixteen PWM channels over a PamojaI2cBus. It
puts the oscillator to sleep, writes the prescale for its frequency, sets the output
wiring, wakes the oscillator, waits the 500 us it needs, and restarts the channels; then it
loads a channel’s four registers in one transfer. It holds a share of the bus, so the
caller may free its own bus handle straight after building the driver, or keep it to read
the part back.
pamoja_pca9685_sim_part is a PCA9685 that is not there. It holds the part’s power-on
registers and keeps its datasheet’s rules, so what a driver wrote reads back off a
simulated bus the way the part would hold it.
A failure is PamojaStatus::Io when the bus failed and
PamojaStatus::InvalidArgument for a command the part cannot take, such as a channel past
15, with the reason in the last error message.
Structs§
- Pamoja
Pca9685 - A PCA9685 driver. Opaque; release it with
pamoja_pca9685_free. - Pamoja
Pca9685 Outputs - How a PCA9685’s sixteen outputs are wired, the MODE2 register.
- Pamoja
Pca9685 Settings - How a PCA9685 driver programs the part.
Constants§
- PAMOJA_
PCA9685_ DEFAULT_ FREQUENCY_ HZ - The frequency a PCA9685 driver runs at unless given another, in hertz: the part’s own power-on 200 Hz.
Functions§
- pamoja_
pca9685_ ⚠channel - Reads one channel’s counts back from the part, one register a transfer, so the read works whatever MODE1 holds and changes nothing on the part.
- pamoja_
pca9685_ ⚠free - Releases a driver and its share of the bus. A null pointer is ignored.
- pamoja_
pca9685_ ⚠frequency - Returns the frequency the part runs at once the prescaler has rounded the one asked for.
- pamoja_
pca9685_ ⚠init - Puts the oscillator to sleep, writes the prescale and the output wiring, wakes it, waits the 500 us it needs, and restarts the channels.
- pamoja_
pca9685_ ⚠new - Creates a PCA9685 driver on a bus. Nothing is sent until
pamoja_pca9685_initor the first channel is loaded. - pamoja_
pca9685_ ⚠prescale - Returns the prescale value the driver writes for its frequency.
- pamoja_
pca9685_ ⚠set_ all - Loads every channel with the same counts in one transfer, through the ALL_LED registers.
- pamoja_
pca9685_ ⚠set_ channel - Loads one channel’s on and off counts, initializing the part first if it has not been.
- pamoja_
pca9685_ settings_ default - Returns the settings a PCA9685 driver takes when given none: 200 Hz on the internal oscillator with totem-pole outputs, the part’s own power-on state.
- pamoja_
pca9685_ sim_ part - Creates a simulated PCA9685 as it powers up: asleep at 200 Hz with every output off, keeping its datasheet’s rules for writes, reads, and its register pointer.
- pamoja_
pca9685_ ⚠sleep - Stops the oscillator. The channel registers keep their values, and a channel still running when the part sleeps sets its RESTART bit.
- pamoja_
pca9685_ ⚠software_ reset - Sends the general-call software reset, which returns every PCA9685 on the bus to its
power-on state, not only this one. It goes to address
0x00, which nothing on a simulated bus answers. - pamoja_
pca9685_ ⚠wake - Wakes the oscillator, waits the 500 us it needs, and restarts every channel that was running before the sleep.