cc111x

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

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 10 Imported by: 1

README

cc111x

The cc111x package provides a Go interface to a CC1110 or CC1111 radio module flashed with subg_rfspy firmware.

The spi or uart build tag should be used to indicate how the radio is connected.

Documentation

Index

Constants

View Source
const (
	FXOSC = 24000000 // Crystal frequency in Hz

	FREQ2 = 0x09 // Frequency control word, high byte
	FREQ1 = 0x0A // Frequency control word, middle byte
	FREQ0 = 0x0B // Frequency control word, low byte
)

CC111x hardware-related constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command byte

Command represents a command used by subg_rfspy firmware running on CC111x. See https://github.com/ps2/subg_rfspy

const (
	CmdGetState       Command = 1
	CmdGetVersion     Command = 2
	CmdGetPacket      Command = 3
	CmdSendPacket     Command = 4
	CmdSendAndListen  Command = 5
	CmdUpdateRegister Command = 6
	CmdReset          Command = 7
	CmdLED            Command = 8
	CmdReadRegister   Command = 9
)

subg_rfspy commands.

func (Command) String

func (i Command) String() string

type ErrorCode

type ErrorCode byte

ErrorCode represents an error that can be returned by subg_rfspy firmware.

const (
	ErrorRXTimeout      ErrorCode = 0xaa
	ErrorCmdInterrupted ErrorCode = 0xbb
	ErrorZeroData       ErrorCode = 0xcc
)

subg_rfspy error codes.

func (ErrorCode) String

func (i ErrorCode) String() string

type Radio

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

Radio represents an open radio device.

func Open

func Open() *Radio

Open opens the radio device.

func (*Radio) Close

func (r *Radio) Close()

Close closes the radio device.

func (*Radio) Device

func (*Radio) Device() string

Device returns the pathname of the radio's device.

func (*Radio) Error

func (r *Radio) Error() error

Error returns the error state of the radio device.

func (*Radio) Frequency

func (r *Radio) Frequency() uint32

Frequency returns the radio's current frequency, in Hertz.

func (*Radio) Init

func (r *Radio) Init(frequency uint32)

Init initializes the radio device.

func (*Radio) Name

func (*Radio) Name() string

Name returns the radio's name.

func (*Radio) ReadRegister

func (r *Radio) ReadRegister(addr byte) byte

ReadRegister returns the value of a CC111x register. This is only available on subg_rfspy 1.0 or later.

func (*Radio) Receive

func (r *Radio) Receive(timeout time.Duration) ([]byte, int)

Receive listens with the given timeout for an incoming packet. It returns the packet and the associated RSSI.

func (*Radio) Reset

func (r *Radio) Reset()

Reset resets the CC111x hardware.

func (*Radio) Send

func (r *Radio) Send(data []byte)

Send transmits the given packet.

func (*Radio) SendAndReceive

func (r *Radio) SendAndReceive(p []byte, timeout time.Duration) ([]byte, int)

SendAndReceive sends the given packet, then listens with the given timeout for an incoming packet. It returns the packet and the associated RSSI.

func (*Radio) SetError

func (r *Radio) SetError(err error)

SetError sets the error state of the radio device.

func (*Radio) SetFrequency

func (r *Radio) SetFrequency(freq uint32)

SetFrequency sets the radio to the given frequency, in Hertz.

func (*Radio) State

func (r *Radio) State() string

State returns the radio's state.

func (*Radio) Version

func (r *Radio) Version() string

Version returns the radio's firmware version.

func (*Radio) WriteRegister

func (r *Radio) WriteRegister(addr byte, value byte)

WriteRegister writes a value to a CC111x register.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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