Documentation
¶
Overview ¶
Package gpio allows to configure and controll General Purpose I/O ports and their pins.
Index ¶
- type AIN
- type Config
- type DetectMode
- type PSEL
- type Pin
- func (p Pin) AIN() AIN
- func (p Pin) Clear()
- func (p Pin) ClearDetect()
- func (p Pin) Config() Config
- func (p Pin) Detect() bool
- func (p Pin) IsValid() bool
- func (p Pin) Load() int
- func (p Pin) LoadOut() int
- func (p Pin) Mask() Pins
- func (p Pin) Num() int
- func (p Pin) PSEL() PSEL
- func (p Pin) Port() *Port
- func (p Pin) Set()
- func (p Pin) Setup(cfg Config)
- func (p Pin) Store(val int)
- type Pins
- type Port
- func (p *Port) ClearDetect(pins Pins)
- func (p *Port) ClearPins(pins Pins)
- func (p *Port) Detect() Pins
- func (p *Port) DetectMode() DetectMode
- func (p *Port) Load() Pins
- func (p *Port) LoadOut() Pins
- func (p *Port) Num() int
- func (p *Port) Pin(n int) Pin
- func (p *Port) PinConfig(n int) Config
- func (p *Port) Pins(pins Pins) Pins
- func (p *Port) PinsOut(pins Pins) Pins
- func (p *Port) SetDetectMode(mode DetectMode)
- func (p *Port) SetDirIn(pins Pins)
- func (p *Port) SetDirOut(pins Pins)
- func (p *Port) SetPins(pins Pins)
- func (p *Port) Setup(pins Pins, cfg Config)
- func (p *Port) SetupPin(n int, cfg Config)
- func (p *Port) Store(val Pins)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIN ¶ added in v0.1.2
type AIN int8
AIN is an analog input number.
const ( ANC AIN = 0 // Not connected. AIN0 AIN = 1 // Analog input 0. AIN1 AIN = 2 // Analog input 1. AIN2 AIN = 3 // Analog input 2. AIN3 AIN = 4 // Analog input 3. AIN4 AIN = 5 // Analog input 4. AIN5 AIN = 6 // Analog input 5. AIN6 AIN = 7 // Analog input 6. AIN7 AIN = 8 // Analog input 7. VDD AIN = 9 // VDD VDDH1_5 AIN = 0xD // VDDH / 5 )
type Config ¶
type Config uint32
Config is configuration word of GPIO pin.
const ( ModeIn Config = 0 // Input buffer connected, output disabled. ModeInOut Config = 1 // Input buffer connected, output enabled. ModeDiscon Config = 2 // Input buffer disconnected, output disabled. ModeOut Config = 3 // Input buffer disconnected, output enabled. PullNone Config = 0 << 2 // Disable pull-up/down resistance. PullDown Config = 1 << 2 // Enable pull-down resistance. PullUp Config = 3 << 2 // Enable pull-up resistance. DriveS0S1 Config = 0 << 8 // Standard 0, standard 1. DriveH0S1 Config = 1 << 8 // High drive 0, standard 1. DriveS0H1 Config = 2 << 8 // Standard 0, high drive 1. DriveH0H1 Config = 3 << 8 // High drive 0, high drive 1. DriveD0S1 Config = 4 << 8 // Disconnect 0, standard 1. DriveD0H1 Config = 5 << 8 // Disconnect 0, high drive 1. DriveS0D1 Config = 6 << 8 // Standard 0, disconnect 1. DriveH0D1 Config = 7 << 8 // High drive 0, disconnect 1. SenseNone Config = 0 << 16 // Sense disabled. SenseHigh Config = 2 << 16 // Sense for high level. SenseLow Config = 3 << 16 // Sense for low level. )
type DetectMode ¶ added in v0.1.3
type DetectMode uint8
const ( Direct DetectMode = 0 // DETECT directly connected to PIN DETECT signals. Latched DetectMode = 1 // Use the latched LDETECT behaviour. )
type PSEL ¶ added in v0.1.2
type PSEL uint32
PSEL is numerical representation of GPIO pin used as peripheral digital signal. It can have two states: connected or disconnected to the peripheral.
func (PSEL) IsConnected ¶ added in v0.1.2
IsConnected reports the connection state of ps.
type Pin ¶
type Pin struct {
// contains filtered or unexported fields
}
Pin represents one phisical pin (specific pin in specific port).
func (Pin) AIN ¶ added in v0.1.2
AIN retruns analog intput number that corresponds to p or -1 if pin can not be used as analog input.
func (Pin) Clear ¶
func (p Pin) Clear()
Clear sets output value of the pin to 0 in one atomic operation.
func (Pin) ClearDetect ¶ added in v0.1.3
func (p Pin) ClearDetect()
ClearDetect clears the detect state for pin. nRF52.
func (Pin) Detect ¶ added in v0.1.3
Detect reports whether the pin have met the criteria set by Sense* configuration options. nRF52.
type Port ¶
type Port struct {
// contains filtered or unexported fields
}
Port represents a GPIO port.
func (*Port) ClearDetect ¶ added in v0.1.3
ClearDetect clears the detect state for specified pins. nRF52.
func (*Port) Detect ¶ added in v0.1.3
Detect returns pins that have met the criteria set by Sense* configuration options. nRF52.
func (*Port) DetectMode ¶ added in v0.1.3
func (p *Port) DetectMode() DetectMode
DetectMode returns current DETECT mode. nRF52.
func (*Port) SetDetectMode ¶ added in v0.1.3
func (p *Port) SetDetectMode(mode DetectMode)
DetectMode sets DETECT mode. nRF52.