radio

package module
v0.0.0-...-a0856dd Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MegaHertz

func MegaHertz(freq uint32) string

MegaHertz converts a frequency in Hertz into a string denoting that frequency in MegaHertz, with 3 decimal places (kiloHertz).

Types

type Hardware

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

Hardware represents an SPI radio device.

func Open

func Open(flavor HardwareFlavor) *Hardware

Open opens the SPI radio module described by the given flavor.

func (*Hardware) AwaitInterrupt

func (h *Hardware) AwaitInterrupt(timeout time.Duration)

AwaitInterrupt waits with the given timeout for a receive interrupt.

func (*Hardware) Close

func (h *Hardware) Close()

Close closes the radio device.

func (*Hardware) Device

func (h *Hardware) Device() string

Device returns the radio's SPI device pathname.

func (*Hardware) Error

func (h *Hardware) Error() error

Error returns the error state of the radio device.

func (*Hardware) ReadBurst

func (h *Hardware) ReadBurst(addr byte, n int) []byte

ReadBurst reads a burst of n bytes from given address on the radio device.

func (*Hardware) ReadInterrupt

func (h *Hardware) ReadInterrupt() bool

ReadInterrupt returns the state of the receive interrupt.

func (*Hardware) ReadRegister

func (h *Hardware) ReadRegister(addr byte) byte

ReadRegister reads the given address on the radio device.

func (*Hardware) SPIDevice

func (h *Hardware) SPIDevice() *spi.Device

SPIDevice returns the radio's SPI device.

func (*Hardware) SetError

func (h *Hardware) SetError(err error)

SetError sets the error state of the radio device.

func (*Hardware) WriteBurst

func (h *Hardware) WriteBurst(addr byte, data []byte)

WriteBurst writes data in burst mode to the given address on the radio device.

func (*Hardware) WriteEach

func (h *Hardware) WriteEach(data []byte)

WriteEach writes each address-value pairs in data to the radio device.

func (*Hardware) WriteRegister

func (h *Hardware) WriteRegister(addr byte, value byte)

WriteRegister writes the given value to the given address on the radio device.

type HardwareFlavor

type HardwareFlavor interface {
	SPIDevice() string
	Speed() int
	CustomCS() int
	InterruptPin() int
	ReadSingleAddress(byte) byte
	ReadBurstAddress(byte) byte
	WriteSingleAddress(byte) byte
	WriteBurstAddress(byte) byte
}

HardwareFlavor is the interface satisfied by a particular SPI device. It specifies how to open the device and how to encode common I/O operations.

type HardwareVersionError

type HardwareVersionError struct {
	Actual   uint16
	Expected uint16
}

HardwareVersionError indicates a hardware version mismatch.

func (HardwareVersionError) Error

func (e HardwareVersionError) Error() string

type Interface

type Interface interface {
	Init(frequency uint32)
	Reset()
	Close()

	Frequency() uint32
	SetFrequency(uint32)

	Send([]byte)
	Receive(time.Duration) ([]byte, int)
	SendAndReceive([]byte, time.Duration) ([]byte, int)

	State() string

	Error() error
	SetError(error)

	Name() string
	Device() string
}

Interface is the interface satisfied by a radio device.

Jump to

Keyboard shortcuts

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