## Using the Device Tree

Kernel device drivers are managed by the device tree at boot time using the configuration file
`/boot/config.txt`

You can setup a default configuration to load device drivers for I2C and SPI using raspi-config from the command line.

    sudo raspi-config

Under 'Advanced Options' you can enable the drivers for I2C and SPI

After this is complete you should find the following at the end of /boot/config.txt

    dtparam=spi=on
    dtparam=i2c_arm=on

Full instructions for entries in /boot/config.txt can be found at:

    https://www.raspberrypi.org/documentation/configuration/device-tree.md
    https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README

The following provides brief instructions for common additional settings

### I2C device driver

The i2c peripheral on the Broadcom chip at the centre of the Pi does not support clock stretching or repeated start conditions. You can get a good description of these two features at http://www.i2c-bus.org/

If you have an i2c device that needs repeated start conditions, yopu cannot communicate with it using the kernal device drivers. You will need to use HiPi::BCM2835::I2C

For clock stretching devices although we cannot support this directly we can slow the whole i2c bus down so that the device does not need to clock stretch. Lowering the i2c baudrate from the default 100000 can often allow a clock stretching device to work.

To set the i2c device driver baud rate to 32000, add the following to /boot/config.txt

    i2c_arm_baudrate=32000

### 1 Wire device driver

We can load the 1 Wire kernel driver by adding the following to /boot/config.txt

    dtoverlay=w1-gpio

HiPi Modules Copyright © 2013 - 2016 Mark Dootson