gpio

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IntLow     = 0 // interrupt is low-level sensitive
	IntHigh    = 1 // interrupt is high-level sensitive
	IntRising  = 2 // interrupt is rising-edge sensitive
	IntFalling = 3 // interrupt is falling-edge sensitive
)

Interrupt configuration constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Bit

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

Bit represents a single bit in a GPIO port.

func UsePin

func UsePin(pin iomux.Pin, fast bool) Bit

UsePin connects pin with the proper bit of GPIO port and returns this bit.

func (Bit) Clear

func (b Bit) Clear()

Clear sets the output value of the bit to 0 in one atomic operation.

func (Bit) ClearPending

func (b Bit) ClearPending()

ClearPending clears the pending state of the interrupt coresponding to b.

func (Bit) ConnectMux

func (b Bit) ConnectMux()

ConnectMux works like Port.ConnectMux(b.Mask())

func (Bit) DirOut

func (b Bit) DirOut() bool

func (Bit) IntConf

func (b Bit) IntConf() int

IntConf returns the interrupt configuration of bit.

func (Bit) IntPending

func (b Bit) IntPending() bool

IntPending reports whether the interrupt coresponding to b is pending.

func (Bit) IsValid

func (b Bit) IsValid() bool

IsValid reports whether b represents a valid bit.

func (Bit) Load

func (b Bit) Load() int

Samples the value of the connected pin (also in output mode if AltFunc.SION is set).

func (Bit) LoadOut

func (b Bit) LoadOut() int

LoadOut returns the bit value. In output mode it is the value stored in DR register. In input mode it works like Load.

func (Bit) Mask

func (b Bit) Mask() uint32

Mask returns a bitmask that represents the bit.

func (Bit) MuxConnected

func (b Bit) MuxConnected() bool

ConnectMux reports wheter the bit is connected to IOMUX.

func (Bit) Num

func (b Bit) Num() int

Num returns the bit number in the port.

func (Bit) Port

func (b Bit) Port() *Port

Port returns the port where the bit is located.

func (Bit) Set

func (b Bit) Set()

Set sets the output value of the bit to 1 in one atomic operation.

func (Bit) SetDirOut

func (b Bit) SetDirOut(out bool)

SetDirOut sets the bit direction to output if out or input otherwise.

func (Bit) SetIntConf

func (b Bit) SetIntConf(cfg int)

SetIntConf sets the interrupt configuration for bit.

func (Bit) Store

func (b Bit) Store(val int)

Store sets the bit value to the least significant bit of val.

func (Bit) Toggle

func (b Bit) Toggle()

Toggle toggles the output value of the bit in one atomic operation.

type Port

type Port struct {
	DR      Shared           // Data register. Its bits are reflected on the output pins.
	DirOut  Shared           // Sets the connected pins to the output mode.
	Sample  mmio.R32[uint32] // Samples input pins (also output pins if AltFunc.SION set)
	IntCfg  [2]Shared        // Interrupt configuration (2 bits for one input)
	IntEna  Shared           // Enables connected pins as an interrupt source.
	Pending Shared           // Interrupt pending register. Write to clear.
	EdgeSel Shared           // Configures the edge detector (subset of IntCfg)

	SetDR    mmio.R32[uint32] // Use to set bits in data register.
	ClearDR  mmio.R32[uint32] // Use to clear bits in data register.
	ToggleDR mmio.R32[uint32] // Use to toggle bits in data register.
	// contains filtered or unexported fields
}

func P

func P(n int) *Port

P returns n-th GPIO port. Ports 1 to 5 are slow, ports 6 to 9 are fast.

func (*Port) Bit

func (p *Port) Bit(n int) Bit

func (*Port) ConnectMux

func (p *Port) ConnectMux(mask uint32)

ConnectMux connects the bits specified in mask to the IOMUX. All bits in port 5 are always connected. In case of the following ports the connection is mutually exclusive: 1 and 6, 2 and 7, 3 and 8, 4 and 9. For example, if the bit 2 in port 3 has been connected to the IOMUX then at the same time the bit 2 in port 8 has been disconnected.

func (*Port) DisableClock

func (p *Port) DisableClock()

DisableClock disables clock for port p.

func (*Port) EnableClock

func (p *Port) EnableClock(lp bool)

EnableClock enables clock for port p. lp determines whether the clock remains on in low power WAIT mode.

func (*Port) MuxConnected

func (p *Port) MuxConnected() uint32

MuxConnected returns bits connected to IOMUX.

func (*Port) Num

func (p *Port) Num() int

Num returns the GPIO port number.

type Shared

type Shared struct{ mmio.R32[uint32] }

func (*Shared) ClearBits

func (b *Shared) ClearBits(mask uint32)

func (*Shared) SetBits

func (b *Shared) SetBits(mask uint32)

func (*Shared) StoreBits

func (b *Shared) StoreBits(mask, bits uint32)

Jump to

Keyboard shortcuts

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