The source code contains some examples in the ./src/examples directory. The examples can be compiled once librpip has been installed. See the Install page for details.
The basic example simply initialises librpip and then prints out what hardware was found and its current config. Its is useful for testing peripheral configuration.
This example uses a Midas MCCOG22005A i2c lcd display. I like these displays for two reasons:
- they use i2c instead of a 4/8 bit parallel data connection. The timing nuances are pretty much all catered for by the lcd’s i2c module so implementation is much simpler in code (no more bodgy bit banging – in user space this can be bit of a problem as the cpu can go off to another thread without warning).
- They are a 3.3v module – so they are safe to read from.
They are the only lcd module I use with a rPi now.
The i2c-mpu6500 sample uses transactions to get accelerometer readings from a mpu6500 across the I2C bus. The datasheets for this device are here and here.
The i2c-th02 sample uses transactions to get temperature and humidity readings from a h02 module. The datasheet is here. This device needs to be polled for output once the request has been made and so several transactions are used to read it.
The pwm example configures both pwm devices, pwm0 brightens and dims a led, pwm1 moves a server between -45° & 45°.
The spi-3002 reads the voltage from channel 0 of a mcp3002 10bit A2D converter over the SPI bus. It also uses transactions to achieve this. The example prints out the sample (as an int), the sample covered to volts (assumes 3.3v) and average volts (to suppress any jitter).
The spi-3002 reads the voltage from channel 0 of a mcp3202 12bit A2D converter over the SPI bus. Again it uses transactions to achieve this. The example prints out the sample (as an int), the sample covered to volts (assumes 3.3v) and average volts (to suppress any jitter).