Skip to main content

Module actuators_driver

Module actuators_driver 

Source
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§

PamojaPca9685
A PCA9685 driver. Opaque; release it with pamoja_pca9685_free.
PamojaPca9685Outputs
How a PCA9685’s sixteen outputs are wired, the MODE2 register.
PamojaPca9685Settings
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_init or 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.