radio

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package radio provides interface to universal 2.4 GHz radio peripheral that supports Bluetooth LE (Smart) and other protocols.

Index

Constants

View Source
const (
	NRF_1M   = 0
	NRF_2M   = 1
	NRF_250K = 2
	BLE_1M   = 3
	BLE_2M   = 4
)

Variables

View Source
var RADIO = (*Periph)(unsafe.Pointer(mmap.APB_BASE + 0x01000))

Functions

This section is empty.

Types

type Event

type Event byte
const (
	READY    Event = 0  // Ready event.
	ADDRESS  Event = 1  // Address event.
	PAYLOAD  Event = 2  // Payload event.
	END      Event = 3  // End event.
	DISABLED Event = 4  // Disabled event.
	DEVMATCH Event = 5  // An address match occurred on the last received pkt.
	DEVMISS  Event = 6  // No address match occurred on the last received pkt.
	RSSIEND  Event = 7  // A new RSSI sample is ready in RSSISAMPLE register.
	BCMATCH  Event = 10 // Bit counter reached bit count value specified in BCC.
)

type Freq

type Freq uint16
const (
	CM2400_2500 Freq = 0      // nRF5x
	CM2360_2460 Freq = 1 << 8 // nRF52
)

func Channel

func Channel(ch int) Freq

func (Freq) Channel

func (f Freq) Channel() int

type Mode

type Mode byte

type ModeConf0

type ModeConf0 uint32
const (
	FastRU   ModeConf0 = 1 << 0
	Tx1      ModeConf0 = 0
	Tx0      ModeConf0 = 1 << 8
	TxCenter ModeConf0 = 2 << 8
)

type Periph

type Periph struct {
	te.Regs
	// contains filtered or unexported fields
}

func (*Periph) Event

func (p *Periph) Event(e Event) *te.Event

func (*Periph) LoadBASE

func (p *Periph) LoadBASE(n int) uint32

LoadBASE returns n-th radio base address.

func (*Periph) LoadBCC

func (p *Periph) LoadBCC() int

LoadBCC returns value of bit counter compare.

func (*Periph) LoadCRCCNF

func (p *Periph) LoadCRCCNF() (length int, skipAddr bool)

LoadCRCCNF returns number of bytes in CRC field and whether address field is skipped for CRC calculation.

func (*Periph) LoadCRCINIT

func (p *Periph) LoadCRCINIT() uint32

LoadCRCINIT returns initial value for CRC calculation.

func (*Periph) LoadCRCPOLY

func (p *Periph) LoadCRCPOLY() uint32

LoadCRCPOLY returns CRC polynominal coefficients.

func (*Periph) LoadCRCSTATUS

func (p *Periph) LoadCRCSTATUS() bool

LoadCRCSTATUS returns CRC status of packet received.

func (*Periph) LoadDAB

func (p *Periph) LoadDAB(n int) uint32

LoadDAB returns n-th device address base segment (32 LSBits of device address).

func (*Periph) LoadDACNF

func (p *Periph) LoadDACNF() (match, txadd byte)

LoadDACNF returns a dap and txadd bit fields. Dap is a bit field where eache of 8 low significant bits enables or disables one device adressess (DAP-DAB pairs) for matching.

func (*Periph) LoadDAI

func (p *Periph) LoadDAI() int

LoadDAI returns index(n) of device address, see DAB[n] and DAP[n], that got an address match.

func (*Periph) LoadDAP

func (p *Periph) LoadDAP(n int) uint16

LoadDAP returns n-th device address prefix (16 MSBits of device address).

func (*Periph) LoadDATAWHITEIV

func (p *Periph) LoadDATAWHITEIV() uint32

LoadATAWHITEIV returns data whitening initial value.

func (*Periph) LoadFREQUENCY

func (p *Periph) LoadFREQUENCY() Freq

LoadFREQUENCY returns a bitmap that encodes current radio channel and channelmap.

func (*Periph) LoadMODE

func (p *Periph) LoadMODE() Mode

LoadMODE returns radio data rate and modulation setting. The radio supports Frequency-shift Keying (FSK) modulation, which depending on setting are compatible with either Nordic Semiconductor’s proprietary radios, or Bluetooth low energy.

func (*Periph) LoadMODECNF0

func (p *Periph) LoadMODECNF0() ModeConf0

LoadMODECNF0 (nRF52 only).

func (*Periph) LoadOVERRIDE

func (p *Periph) LoadOVERRIDE(n int) uint32

LoadOVERRIDE returns OVERRIDE[n] parameter. nRF51.

func (*Periph) LoadPACKETPTR

func (p *Periph) LoadPACKETPTR() uintptr

LoadPACKETPTR returns packet address to be used for the next transmission or reception. When transmitting, the packet pointed to by this address will be transmitted and when receiving, the received packet will be written to this address.

func (*Periph) LoadPCNF0

func (p *Periph) LoadPCNF0() PktCnf0

func (*Periph) LoadPCNF1

func (p *Periph) LoadPCNF1() PktCnf1

func (*Periph) LoadPOWER

func (p *Periph) LoadPOWER() bool

LoadPOWER reports whether radio is powered on.

func (*Periph) LoadPREFIX

func (p *Periph) LoadPREFIX(n int) uint32

LoadPREFIX returns prefix bytes from n-th PREFIX register.

func (*Periph) LoadRSSISAMPLE

func (p *Periph) LoadRSSISAMPLE() int

LoadRSSISAMPLE returns received signal strength [dBm].

func (*Periph) LoadRXADDRESSES

func (p *Periph) LoadRXADDRESSES() uint32

LoadRXADDRESSES returns bit field where eache of 8 low significant bits enables or disables one logical addresses for receive.

func (*Periph) LoadRXCRC

func (p *Periph) LoadRXCRC() uint32

LoadRXCRC returns CRC field of previously received packet.

func (*Periph) LoadRXMATCH

func (p *Periph) LoadRXMATCH() int

LoadRXMATCH returns logical address on which previous packet was received.

func (*Periph) LoadSHORTS

func (p *Periph) LoadSHORTS() Shorts

func (*Periph) LoadSTATE

func (p *Periph) LoadSTATE() State

LoadSTATE returns current radio state.

func (*Periph) LoadTEST

func (p *Periph) LoadTEST() (constCarrier, pllLock bool)

func (*Periph) LoadTIFS

func (p *Periph) LoadTIFS() int

LoadTIFS returns interframe spacing as the number of microseconds from the end of the last bit of the previous packet to the start of the first bit of the subsequent packet.

func (*Periph) LoadTXADDRESS

func (p *Periph) LoadTXADDRESS() int

LoadTXADDRESS returns logical address used when transmitting a packet.

func (*Periph) LoadTXPOWER

func (p *Periph) LoadTXPOWER() int

LoadTXPOWER returns RADIO output power in dBm.

func (*Periph) StoreBASE

func (p *Periph) StoreBASE(n, ba uint32)

StoreBASE stores n-th radio base address 0.

func (*Periph) StoreBCC

func (p *Periph) StoreBCC(bcc int)

StoreBCC stores value of bit counter compare.

func (*Periph) StoreCRCCNF

func (p *Periph) StoreCRCCNF(length int, skipAddr bool)

StoreCRCCNF stores number of bytes in CRC field and whether address will be skipped for CRC calculation.

func (*Periph) StoreCRCINIT

func (p *Periph) StoreCRCINIT(crcinit uint32)

StoreCRCINIT stores initial value for CRC calculation.

func (*Periph) StoreCRCPOLY

func (p *Periph) StoreCRCPOLY(crcpoly uint32)

StoreCRCPOLY stores CRC polynominal coefficients.

func (*Periph) StoreDAB

func (p *Periph) StoreDAB(n int, dab uint32)

StoreDAB stores n-th device address base segment (32 LSBits of device address).

func (*Periph) StoreDACNF

func (p *Periph) StoreDACNF(match, txadd byte)

StoreDACNF stores bitmask that lists device adressess (DAP-DAB pairs) enabled for matching and TxAdd bits

func (*Periph) StoreDAP

func (p *Periph) StoreDAP(n int, dap uint16)

StoreDAP stores n-th device address prefix (16 MSBits of device address).

func (*Periph) StoreDATAWHITEIV

func (p *Periph) StoreDATAWHITEIV(initVal uint32)

StoreDATAWHITEIV stores data whitening initial value.

func (*Periph) StoreFREQUENCY

func (p *Periph) StoreFREQUENCY(f Freq)

StoreFREQUENCY stores radio channel and channel map.

func (*Periph) StoreMODE

func (p *Periph) StoreMODE(mode Mode)

StoreMODE stores MODE. See LoadMODE for more information.

func (*Periph) StoreMODECNF0

func (p *Periph) StoreMODECNF0(c ModeConf0)

StoreMODECNF0 (nRF52 only).

func (*Periph) StoreOVERRIDE

func (p *Periph) StoreOVERRIDE(n int, override uint32)

StoreOVERRIDE stores OVERRIDE[n] parameter. nRF51.

func (*Periph) StorePACKETPTR

func (p *Periph) StorePACKETPTR(addr unsafe.Pointer)

StorePACKETPTR stores PACKETPTR. See LoadPACKETPTR for more information.

func (*Periph) StorePCNF0

func (p *Periph) StorePCNF0(pcnf PktCnf0)

func (*Periph) StorePCNF1

func (p *Periph) StorePCNF1(pcnf PktCnf1)

func (*Periph) StorePOWER

func (p *Periph) StorePOWER(on bool)

StorePOWER sets peripheral power on or off.

func (*Periph) StorePREFIX

func (p *Periph) StorePREFIX(n int, prefix uint32)

StorePREFIX stores prefix bytes in n-th PREFIX register.

func (*Periph) StoreRXADDRESSES

func (p *Periph) StoreRXADDRESSES(lamask uint32)

StoreRXADDRESSES stores bit field where eache of 8 low significant bits enables or disables one logical addresses for receive.

func (*Periph) StoreSHORTS

func (p *Periph) StoreSHORTS(s Shorts)

func (*Periph) StoreTEST

func (p *Periph) StoreTEST(constCarrier, pllLock bool)

func (*Periph) StoreTIFS

func (p *Periph) StoreTIFS(us int)

StoreTIFS stores interframe spacing as the number of microseconds from the end of the last bit of the previous packet to the start of the first bit of the subsequent packet.

func (*Periph) StoreTXADDRESS

func (p *Periph) StoreTXADDRESS(laddr int)

StoreTXADDRESS stores logical address to be used when transmitting a packet.

func (*Periph) StoreTXPOWER

func (p *Periph) StoreTXPOWER(dBm int)

StoreTXPOWER stores TXPOWER. See LoadTXPOWER for more information.

func (*Periph) Task

func (p *Periph) Task(t Task) *te.Task

type PktCnf0

type PktCnf0 uint32
const (
	Pre8b     PktCnf0 = 0
	Pre16b    PktCnf0 = 1 << 24
	S0_0b     PktCnf0 = 0
	S0_8b     PktCnf0 = 1 << 8
	S1AutoRAM PktCnf0 = 0
	S1AlwsRAM PktCnf0 = 1 << 20
)

func LenBitN

func LenBitN(n int) PktCnf0

LenBitN returns PktCnf0 field that sets the length of LENGTH field to n bits.

func S1BitN

func S1BitN(n int) PktCnf0

S1BitN returns PktCnf0 field that sets the length of S1 field to n bits.

func (PktCnf0) LenBitN

func (c PktCnf0) LenBitN() int

LenBitN returns number of bits used for LENGTH field.

func (PktCnf0) S1BitN

func (c PktCnf0) S1BitN() int

S1BitN returns number of bits used for S1 field.

type PktCnf1

type PktCnf1 uint32
const (
	LSBFirst PktCnf1 = 0
	MSBFirst PktCnf1 = 1 << 24
	WhiteDis PktCnf1 = 0
	WhiteEna PktCnf1 = 1 << 25
)

func BALen

func BALen(n int) PktCnf1

BALen returns PktCnf1 field that sets the number of bytes used as base address

func MaxLen

func MaxLen(n int) PktCnf1

MaxLen returns PktCnf1 field that sets the maximum length of packet payload to n bytes.

func StatLen

func StatLen(n int) PktCnf1

StatLen returns PktCnf1 field that sets the static length of payload to n bytes.

func (PktCnf1) BALen

func (c PktCnf1) BALen() int

BALen returns number of bytes used as base address.

func (PktCnf1) MaxLen

func (c PktCnf1) MaxLen() int

MaxLen returns maximum length of packet payload in bytes.

func (PktCnf1) StatLen

func (c PktCnf1) StatLen() int

StatLen returns static length of payload in bytes.

type Shorts

type Shorts uint32
const (
	READY_START       Shorts = 1 << 0
	END_DISABLE       Shorts = 1 << 1
	DISABLED_TXEN     Shorts = 1 << 2
	DISABLED_RXEN     Shorts = 1 << 3
	ADDRESS_RSSISTART Shorts = 1 << 4
	END_START         Shorts = 1 << 5
	ADDRESS_BCSTART   Shorts = 1 << 6
	DISABLED_RSSISTOP Shorts = 1 << 8
)

type State

type State byte
const (
	Disabled  State = 0  // RADIO is in the Disabled state
	RxRU      State = 1  // RADIO is in the RXRU state
	RxIdle    State = 2  // RADIO is in the RXIDLE state
	Rx        State = 3  // RADIO is in the RX state
	RxDisable State = 4  // ADIO is in the RXDISABLED state
	TxRU      State = 9  // RADIO is in the TXRU state
	TxIdle    State = 10 // RADIO is in the TXIDLE state
	Tx        State = 11 // RADIO is in the TX state
	TxDisable State = 12 // RADIO is in the TXDISABLED state
)

func (State) String

func (s State) String() string

type Task

type Task byte
const (
	TXEN      Task = 0 // Enable radio in TX mode.
	RXEN      Task = 1 // Enable radio in RX mode.
	START     Task = 2 // Start radio.
	STOP      Task = 3 // Stop radio.
	DISABLE   Task = 4 // Disable radio.
	RSSISTART Task = 5 // Start measurement and take single sample of the RSSI.
	RSSISTOP  Task = 6 // Stop the RSSI measurement.
	BCSTART   Task = 7 // Start bit counter.
	BCSTOP    Task = 8 // Stop bit counter.
)

Jump to

Keyboard shortcuts

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