Documentation ¶
Overview ¶
Package periph is a peripheral I/O library.
Package periph acts as a registry of drivers. It is focused on providing high quality host drivers that provide high-speed access to the hardware on the host computer itself.
To learn more about the goals and design, visit https://periph.io/
Every device driver should register itself in its package init() function by calling periph.MustRegister().
User shall call either host.Init() or hostextra.Init() on startup to initialize all the registered drivers.
Cmd ¶
cmd/ contains executable tools to communicate directly with the devices or the buses.
cmd/ is allowed to import from conn/, devices/ and host/.
Conn ¶
conn/ contains interfaces and registries for all the supported protocols and connections (I²C, SPI, GPIO, etc).
conn/ is not allowed to import from any other package.
Devices ¶
devices/ contains devices drivers that are connected to bus, port or connection (i.e I²C, SPI, 1-wire, GPIO) that can be controlled by the host, i.e. ssd1306 (display controller), bm280 (environmental sensor), etc.
devices/ is allowed to import from conn/ and host/.
Experimental ¶
experimental/ contains the drivers that are in the experimental area, not yet considered stable. See https://periph.io/project/#driver-lifetime-management for the process to move drivers out of this area.
experimental/ is allowed to import from conn/, devices/ and host/.
Host ¶
host/ contains all the implementations relating to the host itself, the CPU and buses that are exposed by the host onto which devices can be connected, i.e. I²C, SPI, GPIO, etc.
host/ is allowed to import from conn/ only.
Example ¶
package main import ( "fmt" "log" "periph.io/x/periph/host" ) func main() { // host.Init() registers all the periph-provided host driver automatically, // so it is preferable to use than periph.Init(). // // You can also use periph.io/x/extra/hostextra.Init() for additional drivers // that depends on cgo and/or third party packages. state, err := host.Init() if err != nil { log.Fatalf("failed to initialize periph: %v", err) } // Prints the loaded driver. fmt.Printf("Using drivers:\n") for _, driver := range state.Loaded { fmt.Printf("- %s\n", driver) } // Prints the driver that were skipped as irrelevant on the platform. fmt.Printf("Drivers skipped:\n") for _, failure := range state.Skipped { fmt.Printf("- %s: %s\n", failure.D, failure.Err) } // Having drivers failing to load may not require process termination. It // is possible to continue to run in partial failure mode. fmt.Printf("Drivers failed to load:\n") for _, failure := range state.Failed { fmt.Printf("- %s: %v\n", failure.D, failure.Err) } // Use pins, buses, devices, etc. }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRegister ¶
func MustRegister(d Driver)
MustRegister calls Register() and panics if registration fails.
This is the function to call in a driver's package init() function.
Types ¶
type Driver ¶
type Driver interface { // String returns the name of the driver, as to be presented to the user. // // It must be unique in the list of registered drivers. String() string // Prerequisites returns a list of drivers that must be successfully loaded // first before attempting to load this driver. // // A driver listing a prerequisite not registered is a fatal failure at // initialization time. Prerequisites() []string // After returns a list of drivers that must be loaded first before // attempting to load this driver. // // Unlike Prerequisites(), this driver will still be attempted even if the // listed driver is missing or failed to load. // // This permits serialization without hard requirement. After() []string // Init initializes the driver. // // A driver may enter one of the three following state: loaded successfully, // was skipped as irrelevant on this host, failed to load. // // On success, it must return true, nil. // // When irrelevant (skipped), it must return false, errors.New(<reason>). // // On failure, it must return true, errors.New(<reason>). The failure must // state why it failed, for example an expected OS provided driver couldn't // be opened, e.g. /dev/gpiomem on Raspbian. Init() (bool, error) }
Driver is an implementation for a protocol.
type DriverFailure ¶
DriverFailure is a driver that wasn't loaded, either because it was skipped or because it failed to load.
func (DriverFailure) String ¶
func (d DriverFailure) String() string
type State ¶
type State struct { Loaded []Driver Skipped []DriverFailure Failed []DriverFailure }
State is the state of loaded device drivers.
Each list is sorted by the driver name.
Directories ¶
Path | Synopsis |
---|---|
Package cmd contains tools.
|
Package cmd contains tools. |
apa102
apa102 writes to a strip of APA102 LED.
|
apa102 writes to a strip of APA102 LED. |
bmxx80
bmxx80 reads environmental data from a BMP180/BME280/BMP280.
|
bmxx80 reads environmental data from a BMP180/BME280/BMP280. |
cap1xxx
cap1xxx sense touches.
|
cap1xxx sense touches. |
gpio-list
gpio-list prints out the function of each GPIO pin.
|
gpio-list prints out the function of each GPIO pin. |
gpio-read
gpio-read reads a GPIO pin.
|
gpio-read reads a GPIO pin. |
gpio-write
gpio-write sets a GPIO pin to low or high.
|
gpio-write sets a GPIO pin to low or high. |
headers-list
headers-list prints out the headers as found on the computer and print the functionality of each pin.
|
headers-list prints out the headers as found on the computer and print the functionality of each pin. |
i2c-io
i2c-io communicates to an I²C device.
|
i2c-io communicates to an I²C device. |
i2c-list
i2c-list lists all I²C buses.
|
i2c-list lists all I²C buses. |
ir
ir reads from an IR receiver via LIRC.
|
ir reads from an IR receiver via LIRC. |
led
led reads the state of a LED or change it.
|
led reads the state of a LED or change it. |
lepton
lepton captures a single image, prints metadata about the camera state or triggers a calibration.
|
lepton captures a single image, prints metadata about the camera state or triggers a calibration. |
onewire-list
onewire-list lists all onewire buses and devices.
|
onewire-list lists all onewire buses and devices. |
periph-info
periph-info prints out information about the loaded periph drivers.
|
periph-info prints out information about the loaded periph drivers. |
periph-smoketest
periph-smoketest runs all known smoke tests.
|
periph-smoketest runs all known smoke tests. |
periph-smoketest/gpiosmoketest
Package gpiosmoketest is leveraged by periph-smoketest to verify that basic GPIO pin functionality work.
|
Package gpiosmoketest is leveraged by periph-smoketest to verify that basic GPIO pin functionality work. |
periph-smoketest/i2csmoketest
Package i2csmoketest is leveraged by periph-smoketest to verify that an I²C EEPROM device and a DS2483 device can be accessed on an I²C bus.
|
Package i2csmoketest is leveraged by periph-smoketest to verify that an I²C EEPROM device and a DS2483 device can be accessed on an I²C bus. |
periph-smoketest/onewiresmoketest
Package onewiresmoketest is leveraged by periph-smoketest to verify that a 1-wire bus search returns two devices, that a ds18b20 temperature sensor can be read, and that a ds2431 eeprom can be written and read.
|
Package onewiresmoketest is leveraged by periph-smoketest to verify that a 1-wire bus search returns two devices, that a ds18b20 temperature sensor can be read, and that a ds2431 eeprom can be written and read. |
periph-smoketest/spismoketest
Package spismoketest is leveraged by periph-smoketest to verify that an EEPROM device can be accessed on a SPI port.
|
Package spismoketest is leveraged by periph-smoketest to verify that an EEPROM device can be accessed on a SPI port. |
spi-io
spi-io writes to an SPI port data from stdin and outputs to stdout or writes arguments and outputs hex encoded output.
|
spi-io writes to an SPI port data from stdin and outputs to stdout or writes arguments and outputs hex encoded output. |
spi-list
spi-list lists all SPI ports.
|
spi-list lists all SPI ports. |
ssd1306
ssd1306 writes to a display driven by a ssd1306 controler.
|
ssd1306 writes to a display driven by a ssd1306 controler. |
thermal
thermal reads the state of thermal sensors exposed via sysfs.
|
thermal reads the state of thermal sensors exposed via sysfs. |
tm1637
tm1637 writes to a digits LED display.
|
tm1637 writes to a digits LED display. |
Package conn defines core interfaces for protocols and connections.
|
Package conn defines core interfaces for protocols and connections. |
conntest
Package conntest implements fakes for package conn.
|
Package conntest implements fakes for package conn. |
display
Package display implements interfaces for visual output devices.
|
Package display implements interfaces for visual output devices. |
display/displaytest
Package displaytest contains non-hardware devices implementations for testing or emulation purpose.
|
Package displaytest contains non-hardware devices implementations for testing or emulation purpose. |
gpio
Package gpio defines digital pins.
|
Package gpio defines digital pins. |
gpio/gpioreg
Package gpioreg defines a registry for the known digital pins.
|
Package gpioreg defines a registry for the known digital pins. |
gpio/gpiostream
Package gpiostream defines digital streams.
|
Package gpiostream defines digital streams. |
gpio/gpiostream/gpiostreamtest
Package gpiostreamtest enables testing device driver using gpiostream.PinIn or PinOut.
|
Package gpiostreamtest enables testing device driver using gpiostream.PinIn or PinOut. |
gpio/gpiotest
Package gpiotest is meant to be used to test drivers using fake Pins.
|
Package gpiotest is meant to be used to test drivers using fake Pins. |
i2c
Package i2c defines the API to communicate with devices over the I²C protocol.
|
Package i2c defines the API to communicate with devices over the I²C protocol. |
i2c/i2creg
Package i2creg defines I²C bus registry to list buses present on the host.
|
Package i2creg defines I²C bus registry to list buses present on the host. |
i2c/i2ctest
Package i2ctest is meant to be used to test drivers over a fake I²C bus.
|
Package i2ctest is meant to be used to test drivers over a fake I²C bus. |
i2s
Package i2s will eventually define the API to communicate with devices over the I²S protocol.
|
Package i2s will eventually define the API to communicate with devices over the I²S protocol. |
ir
Package ir defines InfraRed codes for use with a IR remote control.
|
Package ir defines InfraRed codes for use with a IR remote control. |
jtag
Package jtag will eventually define the API to communicate with devices over the JTAG protocol.
|
Package jtag will eventually define the API to communicate with devices over the JTAG protocol. |
mmr
Package mmr defines helpers to interact with devices exposing Memory Mapped Registers protocol.
|
Package mmr defines helpers to interact with devices exposing Memory Mapped Registers protocol. |
onewire
Package onewire defines the API to communicate with devices over the Dallas Semiconductor / Maxim Integrated 1-wire protocol.
|
Package onewire defines the API to communicate with devices over the Dallas Semiconductor / Maxim Integrated 1-wire protocol. |
onewire/onewirereg
Package onewirereg defines a registry for onewire buses present on the host.
|
Package onewirereg defines a registry for onewire buses present on the host. |
onewire/onewiretest
Package onewiretest is meant to be used to test drivers over a fake 1-wire bus.
|
Package onewiretest is meant to be used to test drivers over a fake 1-wire bus. |
physic
Package physic declares types for physical input, outputs and measurement units.
|
Package physic declares types for physical input, outputs and measurement units. |
pin
Package pin declare well known pins.
|
Package pin declare well known pins. |
pin/pinreg
Package pinreg is a registry for the physical headers (made up of pins) on a host.
|
Package pinreg is a registry for the physical headers (made up of pins) on a host. |
spi
Package spi defines the API to communicate with devices over the SPI protocol.
|
Package spi defines the API to communicate with devices over the SPI protocol. |
spi/spireg
Package spireg defines the SPI registry for SPI ports discovered on the host.
|
Package spireg defines the SPI registry for SPI ports discovered on the host. |
spi/spitest
Package spitest is meant to be used to test drivers over a fake SPI port.
|
Package spitest is meant to be used to test drivers over a fake SPI port. |
uart
Package uart will eventually define the API to communicate with devices over the UART protocol.
|
Package uart will eventually define the API to communicate with devices over the UART protocol. |
Package devices is a container for device drivers.
|
Package devices is a container for device drivers. |
apa102
Package apa102 drives a strip of APA102 LEDs connected on a SPI port.
|
Package apa102 drives a strip of APA102 LEDs connected on a SPI port. |
bmxx80
Package bmxx80 controls a Bosch BMP180/BME280/BMP280 device over I²C, or SPI for the BMx280.
|
Package bmxx80 controls a Bosch BMP180/BME280/BMP280 device over I²C, or SPI for the BMx280. |
bmxx80/bmx280smoketest
Package bmx280smoketest is leveraged by periph-smoketest to verify that two BME280/BMP280, one over I²C, one over SPI, read roughly the same temperature, humidity and pressure.
|
Package bmx280smoketest is leveraged by periph-smoketest to verify that two BME280/BMP280, one over I²C, one over SPI, read roughly the same temperature, humidity and pressure. |
cap1xxx
Package cap1xxx controls a Microchip cap1105/cap1106/cap1114/cap1133/cap1126/cap1128/cap1166/cap1188 device over I²C. The cap1xxx devices are a 3/5/6/8/14 channel capacitive touch sensor with 2/3/6/8/11 LED drivers.
|
Package cap1xxx controls a Microchip cap1105/cap1106/cap1114/cap1133/cap1126/cap1128/cap1166/cap1188 device over I²C. The cap1xxx devices are a 3/5/6/8/14 channel capacitive touch sensor with 2/3/6/8/11 LED drivers. |
ds18b20
Package ds18b20 interfaces to Dallas Semi / Maxim DS18B20 and MAX31820 1-wire temperature sensors.
|
Package ds18b20 interfaces to Dallas Semi / Maxim DS18B20 and MAX31820 1-wire temperature sensors. |
ds248x
Package ds248x controls a Maxim DS2483 or DS2482-100 1-wire interface chip over I²C. More details See https://periph.io/device/ds248x/ for more details about the device.
|
Package ds248x controls a Maxim DS2483 or DS2482-100 1-wire interface chip over I²C. More details See https://periph.io/device/ds248x/ for more details about the device. |
lepton
Package lepton drives a FLIR Lepton Infra Red (IR) camera.
|
Package lepton drives a FLIR Lepton Infra Red (IR) camera. |
lepton/cci
Package cci declares the Camera Command Interface to interact with a FLIR Lepton over I²C. This protocol controls and queries the camera but is not used to read the images.
|
Package cci declares the Camera Command Interface to interact with a FLIR Lepton over I²C. This protocol controls and queries the camera but is not used to read the images. |
lepton/image14bit
Package image14bit implements 14-bit per pixel images.
|
Package image14bit implements 14-bit per pixel images. |
lirc
Package lirc implements InfraRed receiver support through native linux app lirc.
|
Package lirc implements InfraRed receiver support through native linux app lirc. |
ssd1306
Package ssd1306 controls a 128x64 monochrome OLED display via a SSD1306 controller.
|
Package ssd1306 controls a 128x64 monochrome OLED display via a SSD1306 controller. |
ssd1306/image1bit
Package image1bit implements black and white (1 bit per pixel) 2D graphics.
|
Package image1bit implements black and white (1 bit per pixel) 2D graphics. |
ssd1306/ssd1306smoketest
Package ssd1306smoketest is leveraged by periph-smoketest to verify that two SSD1306, one over I²C, one over SPI, can display the same output.
|
Package ssd1306smoketest is leveraged by periph-smoketest to verify that two SSD1306, one over I²C, one over SPI, can display the same output. |
tm1637
Package tm1637 controls a TM1637 device over GPIO pins.
|
Package tm1637 controls a TM1637 device over GPIO pins. |
experimental
|
|
cmd/hd44780
hd44780 writes to a text LCD screen.
|
hd44780 writes to a text LCD screen. |
cmd/ina219
ina219 communicates with an ina219 sensor reading voltage, current and power.
|
ina219 communicates with an ina219 sensor reading voltage, current and power. |
cmd/mfrc522
mfrc522 reads RFID tags.
|
mfrc522 reads RFID tags. |
cmd/mpu9250
mpu9250 calibrates and performs the self-test, then measures the acceleration continuously.
|
mpu9250 calibrates and performs the self-test, then measures the acceleration continuously. |
cmd/nrzled
nrzled writes to a strip of LEDs using the NRZ protocol.
|
nrzled writes to a strip of LEDs using the NRZ protocol. |
cmd/periph-web
periph-web runs a web server exposing periph's state.
|
periph-web runs a web server exposing periph's state. |
conn/analog
Package analog defines analog pins, both DAC and ADC.
|
Package analog defines analog pins, both DAC and ADC. |
conn/uart
Package uart defines the UART protocol.
|
Package uart defines the UART protocol. |
conn/uart/uartreg
Package uartreg defines the UART registry for UART ports discovered on the host.
|
Package uartreg defines the UART registry for UART ports discovered on the host. |
devices/bitbang
Package bitbang implements conn by banging on the bits (GPIO pins).
|
Package bitbang implements conn by banging on the bits (GPIO pins). |
devices/hd44780
Package hd44780 controls the Hitachi LCD display chipset HD-44780 Datasheet https://www.sparkfun.com/datasheets/LCD/HD44780.pdf
|
Package hd44780 controls the Hitachi LCD display chipset HD-44780 Datasheet https://www.sparkfun.com/datasheets/LCD/HD44780.pdf |
devices/ina219
Package ina219 controls a Texas Instruments ina219 high side current, voltage and power monitor IC over an i2c bus.
|
Package ina219 controls a Texas Instruments ina219 high side current, voltage and power monitor IC over an i2c bus. |
devices/mfrc522
Package mfrc522 controls a Mifare RFID card reader.
|
Package mfrc522 controls a Mifare RFID card reader. |
devices/mfrc522/commands
Package commands contains the command that a MFRC522 supports.
|
Package commands contains the command that a MFRC522 supports. |
devices/mpu9250
Package mpu9250 MPU-9250 is a 9-axis MotionTracking device that combines a 3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer and a Digital Motion Processor™ (DMP) Datasheet https://www.invensense.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf https://www.invensense.com/wp-content/uploads/2015/02/MPU-9250-Register-Map.pdf
|
Package mpu9250 MPU-9250 is a 9-axis MotionTracking device that combines a 3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer and a Digital Motion Processor™ (DMP) Datasheet https://www.invensense.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf https://www.invensense.com/wp-content/uploads/2015/02/MPU-9250-Register-Map.pdf |
devices/nrzled
Package nrzled is a driver for LEDs ws2811/ws2812/ws2812b and compatible devices like sk6812 and ucs1903 that uses a single wire NRZ encoded communication protocol.
|
Package nrzled is a driver for LEDs ws2811/ws2812/ws2812b and compatible devices like sk6812 and ucs1903 that uses a single wire NRZ encoded communication protocol. |
devices/piblaster
Package piblaster implements interfacing code is piblaster.
|
Package piblaster implements interfacing code is piblaster. |
devices/unicornhd
Package unicornhd implements interfacing code to Pimoroni's Unicorn HD hat.
|
Package unicornhd implements interfacing code to Pimoroni's Unicorn HD hat. |
driverskeleton
Package driverskeleton is an example that can be copy pasted to help write a new driver, either in devices/ or in host/.
|
Package driverskeleton is an example that can be copy pasted to help write a new driver, either in devices/ or in host/. |
host/pru
Package pru exposes the Programmable Real-Time Unit Subsystem and Industrial Communication Subsystem (PRU-ICSS) functionality found on many Texas Instruments processors.
|
Package pru exposes the Programmable Real-Time Unit Subsystem and Industrial Communication Subsystem (PRU-ICSS) functionality found on many Texas Instruments processors. |
host/serial
Package serial implements cross platform UART support exposed by the operating system.
|
Package serial implements cross platform UART support exposed by the operating system. |
Package host defines the host itself.
|
Package host defines the host itself. |
allwinner
Package allwinner exposes the GPIO functionality that is common to all AllWinner processors.
|
Package allwinner exposes the GPIO functionality that is common to all AllWinner processors. |
allwinner/allwinnersmoketest
Package allwinnersmoketest verifies that allwinner specific functionality work.
|
Package allwinnersmoketest verifies that allwinner specific functionality work. |
am335x
Package am335x exposes functionality for the Texas Instruments Sitara AM335x processor family.
|
Package am335x exposes functionality for the Texas Instruments Sitara AM335x processor family. |
bcm283x
Package bcm283x exposes the BCM283x GPIO functionality.
|
Package bcm283x exposes the BCM283x GPIO functionality. |
bcm283x/bcm283xsmoketest
Package bcm283xsmoketest verifies that bcm283x specific functionality work.
|
Package bcm283xsmoketest verifies that bcm283x specific functionality work. |
beagle
Package beagle regroups subpackages containing BeagleBoard/BeagleBone board family headers definition.
|
Package beagle regroups subpackages containing BeagleBoard/BeagleBone board family headers definition. |
beagle/black
Package black implements headers for the BeagleBone Black and BeagleBone Black Wireless micro-computers.
|
Package black implements headers for the BeagleBone Black and BeagleBone Black Wireless micro-computers. |
beagle/bone
Package bone implements headers J1, P8 and P9 found on many (but not all) BeagleBone micro-computer.
|
Package bone implements headers J1, P8 and P9 found on many (but not all) BeagleBone micro-computer. |
beagle/green
Package green implements headers for the BeagleBone Green and BeagleBone Green Wireless micro-computers.
|
Package green implements headers for the BeagleBone Green and BeagleBone Green Wireless micro-computers. |
chip
Package chip contains header definitions for NextThing Co's C.H.I.P. board.
|
Package chip contains header definitions for NextThing Co's C.H.I.P. board. |
chip/chipsmoketest
Package chipsmoketest is leveraged by periph-smoketest to verify that basic CHIP specific functionality works.
|
Package chipsmoketest is leveraged by periph-smoketest to verify that basic CHIP specific functionality works. |
cpu
Package cpu implements functions relating to the host CPU itself.
|
Package cpu implements functions relating to the host CPU itself. |
distro
Package distro implements common functionality to auto-detect features on the host; generally about linux distributions.
|
Package distro implements common functionality to auto-detect features on the host; generally about linux distributions. |
fs
Package fs provides access to the file system on the host.
|
Package fs provides access to the file system on the host. |
odroidc1
Package odroidc1 contains header definitions for Hardkernel's ODROID C0, C1, and C1+ boards.
|
Package odroidc1 contains header definitions for Hardkernel's ODROID C0, C1, and C1+ boards. |
odroidc1/odroidc1smoketest
Package odroidc1smoketest is leveraged by periph-smoketest to verify that basic ODROID-C1 specific functionality works.
|
Package odroidc1smoketest is leveraged by periph-smoketest to verify that basic ODROID-C1 specific functionality works. |
pine64
Package pine64 contains Pine64 hardware logic.
|
Package pine64 contains Pine64 hardware logic. |
pmem
Package pmem implements handling of physical memory for user space programs.
|
Package pmem implements handling of physical memory for user space programs. |
rpi
Package rpi contains Raspberry Pi hardware logic.
|
Package rpi contains Raspberry Pi hardware logic. |
sysfs
Package sysfs implements a sane library to interact with sysfs provided hardware access.
|
Package sysfs implements a sane library to interact with sysfs provided hardware access. |
sysfs/sysfssmoketest
Package sysfssmoketest verifies that sysfs specific functionality work.
|
Package sysfssmoketest verifies that sysfs specific functionality work. |
videocore
Package videocore interacts with the VideoCore GPU found on bcm283x.
|
Package videocore interacts with the VideoCore GPU found on bcm283x. |