Documentation
¶
Overview ¶
Package nrf24 provides interface to use nRF24L01 and nRF24L01+ transceivers. This package follows original naming of commands and registers that can be found in documentation.
Index ¶
- type CONFIG
- type DCI
- type FEATURE
- type FIFO_STATUS
- type Pipes
- type RF_SETUP
- type Radio
- func (r *Radio) ACTIVATE(b byte) STATUS
- func (r *Radio) CONFIG() (CONFIG, STATUS)
- func (r *Radio) ClearIRQ(s STATUS) STATUS
- func (r *Radio) DYNPD() (Pipes, STATUS)
- func (r *Radio) EN_AA() (Pipes, STATUS)
- func (r *Radio) EN_RXADDR() (Pipes, STATUS)
- func (r *Radio) Err(clear bool) error
- func (r *Radio) FEATURE() (FEATURE, STATUS)
- func (r *Radio) FIFO_STATUS() (FIFO_STATUS, STATUS)
- func (r *Radio) FLUSH_RX() STATUS
- func (r *Radio) FLUSH_TX() STATUS
- func (r *Radio) NOP() STATUS
- func (r *Radio) OBSERVE_TX() (plos, arc int, s STATUS)
- func (r *Radio) REUSE_TX_PL() STATUS
- func (r *Radio) RF_CH() (int, STATUS)
- func (r *Radio) RF_SETUP() (RF_SETUP, STATUS)
- func (r *Radio) RPD() (bool, STATUS)
- func (r *Radio) RX_PW(pn int) (int, STATUS)
- func (r *Radio) R_REGISTER(addr byte, val []byte) STATUS
- func (r *Radio) R_RX_PAYLOAD(pay []byte) STATUS
- func (d *Radio) R_RX_PL_WID() (int, STATUS)
- func (r *Radio) Read_RX_ADDR(pn int, addr []byte) STATUS
- func (r *Radio) Read_TX_ADDR(addr []byte) STATUS
- func (r *Radio) SETUP_AW() (int, STATUS)
- func (r *Radio) SETUP_RETR() (cnt, dlyus int, s STATUS)
- func (r *Radio) Set_CONFIG(c CONFIG) STATUS
- func (r *Radio) Set_DYNPD(p Pipes) STATUS
- func (r *Radio) Set_EN_AA(p Pipes) STATUS
- func (r *Radio) Set_EN_RXADDR(p Pipes) STATUS
- func (r *Radio) Set_FEATURE(f FEATURE) STATUS
- func (r *Radio) Set_RF_CH(ch int) STATUS
- func (r *Radio) Set_RF_SETUP(rf RF_SETUP) STATUS
- func (r *Radio) Set_RX_PW(pn, pw int) STATUS
- func (r *Radio) Set_SETUP_AW(alen int) STATUS
- func (r *Radio) Set_SETUP_RETR(cnt, dlyus int) STATUS
- func (r *Radio) W_ACK_PAYLOAD(pn int, pay []byte) STATUS
- func (r *Radio) W_REGISTER(addr byte, val ...byte) STATUS
- func (r *Radio) W_TX_PAYLOAD(pay []byte) STATUS
- func (r *Radio) W_TX_PAYLOAD_NOACK(pay []byte) STATUS
- func (r *Radio) Write_RX_ADDR(pn int, addr ...byte) STATUS
- func (r *Radio) Write_TX_ADDR(addr ...byte) STATUS
- type STATUS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CONFIG ¶
type CONFIG byte
const ( PRIM_RX CONFIG = 1 << 0 // 1: Receiver (PRX) / 0: Transmitter (PPTX). PWR_UP CONFIG = 1 << 1 // Power: 1: up / 0: down. CRCO CONFIG = 1 << 2 // CRC encoding scheme: 0: one byte / 1: two bytes. EN_CRC CONFIG = 1 << 3 // Enable CRC. Forced 1 if one of bits in EN_AA is 1. MASK_MAX_RT CONFIG = 1 << 4 // MAX_RT: 1: does not assert / 0: asserts IRQ. MASK_TX_DS CONFIG = 1 << 5 // TX_DS: 1: does not assert, 0: asserts IRQ. MASK_RX_DR CONFIG = 1 << 6 // RX_DR: 1: does not assert, 0: asserts IRQ. )
type DCI ¶
type DCI interface { // WriteRead performs full SPI transation: sets CSN low, writes and reads oi // data and sets CSN high. WriteRead(oi ...[]byte) int // Err returns and clears internal error status. Err(clear bool) error }
DCI represents the simplified nRF24L01(+) Data and Control Interface: only SPI part of the full DCI is need.
type FIFO_STATUS ¶
type FIFO_STATUS byte
const ( RX_EMPTY FIFO_STATUS = 1 << 0 // 1: Rx FIFO empty, 0: Data in Rx FIFO. RX_FULL FIFO_STATUS = 1 << 1 // 1: Rx FIFO full, 0: Available locations in Rx FIFO. TX_EMPTY FIFO_STATUS = 1 << 4 // 1: Tx FIFO empty, 0: Data in Tx FIFO. TX_FULL FIFO_STATUS = 1 << 5 // 1: Tx FIFO full, 0: Available locations in Tx FIFO. TX_REUSE FIFO_STATUS = 1 << 6 // Set by TX_REUSE, cleared by W_TX_PAYLOAD, FLUSH_TX. )
type RF_SETUP ¶
type RF_SETUP byte
const ( LNA_HCURR RF_SETUP = 1 << 0 // LNA gain 0: -1.5 dB, -0.8 mA (nRF24L01 specific). RF_DR_HIGH RF_SETUP = 1 << 3 // High speed data rate 0: 1Mbps, 1: 2Mbps. PLL_LOCK RF_SETUP = 1 << 4 // Force PLL lock signal. Only used in test. RF_DR_LOW RF_SETUP = 1 << 5 // Set RF Data Rate to 250kbps. CONT_WAVE RF_SETUP = 1 << 7 // Enable continuous carrier transmit. )
type Radio ¶
type Radio struct {
DCI DCI
}
Radio provides interface to nRF24L01(+) transceiver. Radio has many methods that are mainly used to send commands that read or write its internal registers. Every such command, as side effect, always reads the value of STATUS regster as it was just before the command was executed. This status value is always returned as the last return value of the command method.
func (*Radio) EN_AA ¶
EN_AA returns the value of the Enable ‘Auto Acknowledgment’ Function register.
func (*Radio) Err ¶
Err returns the error value of the last executed command. You can freely invoke many commands before check an error. If one command have caused an error the subsequent commands will not be executed until Err(true) will be called.
func (*Radio) FIFO_STATUS ¶
func (r *Radio) FIFO_STATUS() (FIFO_STATUS, STATUS)
FIFO_STATUS returns value of FIFO Status Register.
func (*Radio) OBSERVE_TX ¶
OBSERVE_TX returns the values of PLOS_CNT and ARC_CNT counters from the Transmit observe register.
func (*Radio) REUSE_TX_PL ¶
func (*Radio) RPD ¶
RPD returns the value of the Received Power Detector register: true if RP > -64dBm, false otherwise. In case of nRF24L01 it returns the value of the CD (Carrier Detect) register.
func (*Radio) R_RX_PAYLOAD ¶
func (*Radio) R_RX_PL_WID ¶
func (*Radio) Read_RX_ADDR ¶
Read_RX_ADDR reads the receive address of the data pipe pn.
func (*Radio) Read_TX_ADDR ¶
Read_TX_ADDR reads value of Transmit address register into addr.
func (*Radio) SETUP_AW ¶
SETUP_AW returns the value of the Setup of Address Widths register increased by two, that is it returns the address length in bytes.
func (*Radio) SETUP_RETR ¶
SETUP_RETR returns the value of the Setup of Automatic Retransmission register converted to number of retries and delay (µs) between retries.
func (*Radio) Set_CONFIG ¶
Set_CONFIG sets the value of the Configuration Register.
func (*Radio) Set_EN_AA ¶
Set_EN_AA sets the value of the Enable ‘Auto Acknowledgment’ Function register.
func (*Radio) Set_EN_RXADDR ¶
Set_EN_RXADDR sets the value of the Enabled RX Addresses) register.
func (*Radio) Set_FEATURE ¶
Set_FEATURE sets value of FEATURE register.
func (*Radio) Set_RF_SETUP ¶
Set_RF_SETUP sets the value of the RF Setup register.
func (*Radio) Set_SETUP_AW ¶
Set_SETUP_AW sets the value of the Setup of Address Widths register to (aw-2), that is it sets the address length to aw bytes (allowed values: 3, 4, 5).
func (*Radio) Set_SETUP_RETR ¶
Set_SETUP_RETR sets the value of the Setup of Automatic Retransmission register using cnt as number of retries and dlyus as delay between retries.
func (*Radio) W_TX_PAYLOAD ¶
func (*Radio) W_TX_PAYLOAD_NOACK ¶
func (*Radio) Write_RX_ADDR ¶
Write_RX_ADDR sets the receive address of the data pipe pn.
func (*Radio) Write_TX_ADDR ¶
Write_TX_ADDR sets value of Transmit address.