driverskeleton

package
v3.3.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package driverskeleton is an example that can be copy pasted to help write a new driver, either in devices/ or in host/.

You must remove all comments with FIXME. This also proves you read the instructions! :)

FIXME: Include additional information relevant to users, including configuring the device if relevant.

Datasheet

FIXME: Please include a link to a datasheet as per the guideline in doc/drivers/. This helps everyone when the driver needs to be improved.

Example
package main

import (
	"fmt"
	"log"

	"periph.io/x/periph/conn/i2c/i2creg"
	"periph.io/x/periph/experimental/driverskeleton"
	"periph.io/x/periph/host"
)

func main() {
	// Make sure periph is initialized.
	if _, err := host.Init(); err != nil {
		log.Fatal(err)
	}

	// FIXME: Make sure to expose a simple use case.
	b, err := i2creg.Open("")
	if err != nil {
		log.Fatalf("failed to open I²C: %v", err)
	}
	defer b.Close()

	dev, err := driverskeleton.New(b)
	if err != nil {
		log.Fatalf("failed to initialize: %v", err)
	}
	fmt.Println(dev.Read())
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dev

type Dev struct {
	// contains filtered or unexported fields
}

Dev is a handle to the device. FIXME.

func New

func New(i i2c.Bus) (*Dev, error)

New opens a handle to the device. FIXME.

func (*Dev) Read

func (d *Dev) Read() string

Read is a method on your device. FIXME.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL