Go·Hardware·Lean - Device drivers
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
M-A 1dea5dac5c doc: add code style, note about lack of affiliation with Go. (#10)
Fixes #7
10 years ago
devices make the i2c address of bme280 configurable (#5) 10 years ago
experimental/devices Change copyright from Google Inc to The PIO Authors. (#3) 10 years ago
AUTHORS make the i2c address of bme280 configurable (#5) 10 years ago
CONTRIBUTORS make the i2c address of bme280 configurable (#5) 10 years ago
LICENSE Initial commit of pio. 10 years ago
README.md doc: add code style, note about lack of affiliation with Go. (#10) 10 years ago

README.md

pio - Peripherals I/O in Go

  • doc/users/ for ready-to-use tools.
  • doc/apps/ to use pio as a library. The complete API documentation, including examples, is at GoDoc.
  • doc/drivers/ to expand the list of supported hardware.

Users

pio includes many ready-to-use tools! See doc/users/ for more info on configuring the host and using the included tools.

go get github.com/google/pio/cmd/...
pio-info
headers-list

Application developpers

For application developpers, pio provides OS-independent bus interfacing. The following gets the current temperature, barometric pressure and relative humidity using a bme280:

package main

import (
    "fmt"
    "log"

    "github.com/google/pio/devices"
    "github.com/google/pio/devices/bme280"
    "github.com/google/pio/host"
)

func main() {
    // Load all the drivers:
    if _, err := host.Init(); err != nil {
        log.Fatal(err)
    }

    // Open a handle to the first available I²C bus. It could be a via FT232H
    // over USB or an I²C bus exposed on the host's headers, it doesn't matter.
    bus, err := i2c.New(-1)
    if err != nil {
        log.Fatal(err)
    }
    defer bus.Close()

    // Open a handle to a bme280 connected on the I²C bus using default settings:
    dev, err := bme280.NewI2C(bus, nil)
    if err != nil {
        log.Fatal(err)
    }
    defer dev.Close()

    // Read temperature from the sensor:
    var env devices.Environment
    if err = dev.Sense(&env); err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%8s %10s %9s\n", env.Temperature, env.Pressure, env.Humidity)
}

See more examples at doc/apps/SAMPLES.md!

Contributions

pio provides an extensible driver registry and common bus interfaces which are explained in more details at doc/drivers/. pio is designed to work well with drivers living in external repositories so you are not required to fork to load drivers for your platform.

We gladly accept contributions from device driver developpers via GitHub pull requests, as long as the author has signed the Google Contributor License. Please see doc/drivers/CONTRIBUTING.md for more details.

Philosophy

  1. Optimize for simplicity, correctness and usability in that order.
    • e.g. everything, interfaces and structs, uses strict typing, there's no interface{} in sight.
  2. OS agnostic. Clear separation of interfaces in conn/, enablers in host/ and device drivers in devices/.
    • e.g. no devfs or sysfs path in sight.
    • e.g. conditional compilation enables only the relevant drivers to be loaded on each platform.
  3. ... yet doesn't get in the way of platform specific code.
  4. The user can chose to optimize for performance instead of usability.
  5. Use a divide and conquer approach. Each component has exactly one responsibility.
    • e.g. instead of having a driver per "platform", there's a driver per "component": one for the CPU, one for the board headers, one for each buses and sensors, etc.
  6. Extensible via a driver registry.
    • e.g. a user can inject a custom driver to expose more pins, headers, etc. An USB device (like an FT232H) can expose headers in addition to the headers found on the host.
  7. The drivers must use the fastest possible implementation.
    • e.g. both allwinner and bcm283x leverage sysfs gpio to expose interrupt driven edge detection, yet use memory mapped GPIO registers to single-cycle reads and writes.

Authors

The main author is Marc-Antoine Ruel. The full list is in AUTHORS and CONTRIBUTORS.

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

This project is not affiliated with the Go project.