在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:stianeikeland/go-rpio开源软件地址:https://github.com/stianeikeland/go-rpio开源编程语言:Go 100.0%开源软件介绍:go-rpioNative GPIO-Gophers for your Pi! go-rpio is a Go library for accessing GPIO-pins on the Raspberry Pi. It requires no external c libraries such as WiringPI or bcm2835. There's a tiny bit of additional information over at my blog. Releases
Usageimport "github.com/stianeikeland/go-rpio/v4" If you're using an older go.mod incompatible you should instead use: import "github.com/stianeikeland/go-rpio" Open memory range for GPIO access in /dev/mem err := rpio.Open() Initialize a pin, run basic operations. Pin refers to the bcm2835 pin, not the physical pin on the raspberry pi header. Pin 10 here is exposed on the pin header as physical pin 19. pin := rpio.Pin(10)
pin.Output() // Output mode
pin.High() // Set pin High
pin.Low() // Set pin Low
pin.Toggle() // Toggle pin (Low -> High -> Low)
pin.Input() // Input mode
res := pin.Read() // Read state from pin (High / Low)
pin.Mode(rpio.Output) // Alternative syntax
pin.Write(rpio.High) // Alternative syntax Pull up/down/off can be set using: pin.PullUp()
pin.PullDown()
pin.PullOff()
pin.Pull(rpio.PullUp) Unmap memory when done rpio.Close() Also see example examples/blinker/blinker.go SPIsetup/teardown
transferring data
settings
OtherCurrently, it supports basic functionality such as:
It works by memory-mapping the bcm2835 gpio range, and therefore require root/administrative-rights to run. Using without rootThis library can utilize the new /dev/gpiomem memory range if available. You will probably need to upgrade to the latest kernel (or wait for the next raspbian release) if you're missing /dev/gpiomem. You will also need to add a PWM modes will still require root. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论