代码拉取完成,页面将自动刷新
package devices
import (
"errors"
"fmt"
"os"
)
const (
GPIO = "/sys/class/gpio"
GPIO_EXPORT = GPIO + "/export"
GPIO_UNEXPORT = GPIO + "/unexport"
// GPIO_FMT_DIRECTION = GPIO + "/direction"
)
var (
// GPIO_ERROR_NOT_EXPORTED
ErrGPIONotExported error = errors.New("GPIO Not Exported")
ErrGPIODirectionNotValue error = errors.New("GPIO Direction Not Value")
)
// GPIO Direction Mode
type GPIOMode int
const (
DIRECTION_IN GPIOMode = iota
DIRECTION_OUT
)
// GPIO Level Value
type GPIOValue int
const (
LEVEL_LOW GPIOValue = iota
LEVEL_HIGH
)
func GPIOExport(gpio int) error {
buffer := fmt.Sprintf("%d", gpio)
return os.WriteFile(GPIO_EXPORT, []byte(buffer), os.ModePerm)
}
func GPIOUnExport(gpio int) error {
buffer := fmt.Sprintf("%d", gpio)
return os.WriteFile(GPIO_UNEXPORT, []byte(buffer), os.ModePerm)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。