This is the nRF24L01+ transceiver used in several Nordic Semiconductor devices. The transceiver is set up and controlled via an internal SPI interface on the chip. The HAL for the radio transceiver hides this SPI interface from the programmer.
The nRF24LE1 uses the same 2.4GHz GFSK RF transceiver with embedded protocol engine (Enhanced ShockBurst™) that is found in the nRF24L01+ single chip RF Transceiver.
The RF Transceiver module is configured and operated through the RF transceiver map. This register map is accessed by the MCU through a dedicated on-chip Serial Peripheral interface (SPI) and is available in all power modes of the RF Transceiver module. The register map contains all configuration registers in the RF Transceiver and is accessible in all operation modes of the transceiver. The radio transceiver HAL hides this register map and the usage of the internal SPI.
This HAL module contains setup functions for configurating the radio; operation functions for controlling the radio when active and for sending and receiving data; and test functions for setting the radio in test modes.
void hal_nrf_set_irq_mode | ( | hal_nrf_irq_source_t | int_source, |
_Bool | irq_state | ||
) |
Enable or disable interrupt for radio. Use this function to enable or disable one of the interrupt sources for the radio. This function only changes state for selected int_type, the rest of the interrupt sources are left unchanged.
int_source | Radio interrupt Source. |
irq_state | Enable or Disable. |
< nRF24L01 config register
< nRF24L01 config register
Definition at line 248 of file hal_nrf.c.
{ config_t config; config.value = hal_nrf_read_reg (CONFIG); switch (int_source) { case HAL_NRF_MAX_RT: config.bits.mask_max_rt = irq_state ? 0U : 1U; break; case HAL_NRF_TX_DS: config.bits.mask_tx_ds = irq_state ? 0U : 1U; break; case HAL_NRF_RX_DR: config.bits.mask_rx_dr = irq_state ? 0U : 1U; break; } hal_nrf_write_reg (CONFIG, config.value); }
void hal_nrf_enable_dynamic_payload | ( | _Bool | enable ) |
Enables the dynamic packet length
enable | Whether enable or disable dynamic packet length |
< nRF24L01 Exclusive feature setup
< nRF24L01 Exclusive feature setup
Definition at line 631 of file hal_nrf.c.
{ feature_t feature; feature.value = hal_nrf_read_reg (FEATURE); feature.bits.en_dpl = (enable) ? 1U : 0U; hal_nrf_write_reg (FEATURE, feature.value); }
void hal_nrf_enable_ack_payload | ( | _Bool | enable ) |
Enables the ACK payload feature
enable | Whether to enable or disable ACK payload |
< nRF24L01 Exclusive feature setup
< nRF24L01 Exclusive feature setup
Definition at line 640 of file hal_nrf.c.
{ feature_t feature; feature.value = hal_nrf_read_reg (FEATURE); feature.bits.en_ack_pay = (enable) ? 1U : 0U; hal_nrf_write_reg (FEATURE, feature.value); }
void hal_nrf_enable_dynamic_ack | ( | _Bool | enable ) |
Enables the dynamic ack feature
enable | Whether to enable or disable Dynamic ACK |
< nRF24L01 Exclusive feature setup
< nRF24L01 Exclusive feature setup
Definition at line 649 of file hal_nrf.c.
{ feature_t feature; feature.value = hal_nrf_read_reg (FEATURE); feature.bits.en_dyn_ack = (enable) ? 1U : 0U; hal_nrf_write_reg (FEATURE, feature.value); }
void hal_nrf_setup_dynamic_payload | ( | uint8_t | setup ) |
Function for enabling dynmic payload size. The input parameter contains is a byte where the bit values tells weather the pipe should use dynamic payload size. For example if bit 0 is set then pipe 0 will accept dynamic payload size.
setup | Byte value telling for which pips(s) to enable dynamic payload size |
< nRF24L01 Dynamic payload setup
Definition at line 623 of file hal_nrf.c.
{ en_pipes_t dynpd; dynpd.value = setup & (uint8_t)~0xC0U; hal_nrf_write_reg (DYNPD, dynpd.value); }
uint8_t hal_nrf_read_rx_payload_width | ( | void | ) |
Reads the payload width of the received ack payload
< Read RX payload command
Definition at line 673 of file hal_nrf.c.
{ return hal_nrf_read_reg(R_RX_PL_WID); }
void hal_nrf_write_ack_payload | ( | uint8_t | pipe, |
const uint8_t * | tx_pload, | ||
uint8_t | length | ||
) |
Write ack payload Writes the payload that will be transmitted with the ack on the given pipe.
pipe | Pipe that transmits the payload |
tx_pload | Pointer to the payload data |
length | Size of the data to transmit |
< Write ACK payload command
Definition at line 668 of file hal_nrf.c.
{ hal_nrf_write_multibyte_reg(W_ACK_PAYLOAD | pipe, tx_pload, length); }
uint8_t hal_nrf_get_clear_irq_flags | ( | void | ) |
Read then clears all interrupt flags. Use this function to get the interrupt flags and clear them in the same operation. Reduced radio interface activity and speed optimized.
0x10 | Max Retransmit interrupt |
0x20 | TX Data sent interrupt |
0x40 | RX Data received interrupt |
< nRF24L01 status register
< The value of bit 6
< The value of bit 5
< The value of bit 4
< The value of bit 6
< The value of bit 5
< The value of bit 4
uint8_t hal_nrf_clear_irq_flags_get_status | ( | void | ) |
< nRF24L01 status register
< The value of bit 6
< The value of bit 5
< The value of bit 4
< The value of bit 6
< The value of bit 5
< The value of bit 4
< nRF24L01 status register
< The value of bit 3
< The value of bit 2
< The value of bit 1
< The value of bit 0
void hal_nrf_clear_irq_flag | ( | hal_nrf_irq_source_t | int_source ) |
Clear one selected interrupt flag. Use this function to clear one spesific interrupt flag. Other interrupt flags are left unchanged.
int_source | Interrupt source of which flag to clear |
< nRF24L01 status register
Definition at line 290 of file hal_nrf.c.
{ hal_nrf_write_reg (STATUS, SET_BIT(int_source)); }
void hal_nrf_set_crc_mode | ( | hal_nrf_crc_mode_t | crc_mode ) |
Set the CRC mode used by the radio. Use this function to set the CRC mode; CRC disabled, 1 or 2 bytes.
crc_mode | CRC mode to use |
< nRF24L01 config register
< nRF24L01 config register
Definition at line 223 of file hal_nrf.c.
{ config_t config; config.value = hal_nrf_read_reg (CONFIG); switch (crc_mode) { case HAL_NRF_CRC_OFF: config.bits.en_crc = 0U; break; case HAL_NRF_CRC_8BIT: config.bits.en_crc = 1U; config.bits.crc0 = 0U; break; case HAL_NRF_CRC_16BIT: config.bits.en_crc = 1U; config.bits.crc0 = 1U; break; default: break; } hal_nrf_write_reg (CONFIG, config.value); }
void hal_nrf_open_pipe | ( | hal_nrf_address_t | pipe_num, |
_Bool | auto_ack | ||
) |
Open radio pipe(s) and enable/ disable auto acknowledge. Use this function to open one or all pipes, with or without auto acknowledge.
pipe_num | Radio pipe to open |
auto_ack | Auto_Ack ON/OFF |
< nRF24L01 enable RX addresses register
< nRF24L01 enable Auto-Acknowledge register
< The value of bit 6
< The value of bit 7
< The value of bit 6
< The value of bit 7
< nRF24L01 enable RX addresses register
< nRF24L01 enable Auto-Acknowledge register
Definition at line 300 of file hal_nrf.c.
{ en_pipes_t en_rxaddr; en_pipes_t en_aa; en_rxaddr.value = hal_nrf_read_reg (EN_RXADDR); en_aa.value = hal_nrf_read_reg (EN_AA); switch(pipe_num) { case HAL_NRF_PIPE0: case HAL_NRF_PIPE1: case HAL_NRF_PIPE2: case HAL_NRF_PIPE3: case HAL_NRF_PIPE4: case HAL_NRF_PIPE5: en_rxaddr.value = en_rxaddr.value | SET_BIT(pipe_num); if(auto_ack) { en_aa.value = en_aa.value | SET_BIT(pipe_num); } else { en_aa.value = en_aa.value & (uint8_t)~SET_BIT(pipe_num); } break; case HAL_NRF_ALL: en_rxaddr.value = (uint8_t)(~(BIT_6|BIT_7)); if(auto_ack) { en_aa.value = (uint8_t)(~(BIT_6|BIT_7)); } else { en_aa.value = 0U; } break; case HAL_NRF_TX: default: break; } hal_nrf_write_reg (EN_RXADDR, en_rxaddr.value); hal_nrf_write_reg (EN_AA, en_aa.value); }
void hal_nrf_close_pipe | ( | hal_nrf_address_t | pipe_num ) |
Close radio pipe(s). Use this function to close one pipe or all pipes.
pipe_num | Pipe# number to close |
< nRF24L01 enable RX addresses register
< nRF24L01 enable Auto-Acknowledge register
< nRF24L01 enable RX addresses register
< nRF24L01 enable Auto-Acknowledge register
Definition at line 349 of file hal_nrf.c.
{ en_pipes_t en_rxaddr; en_pipes_t en_aa; en_rxaddr.value = hal_nrf_read_reg (EN_RXADDR); en_aa.value = hal_nrf_read_reg (EN_AA); switch(pipe_num) { case HAL_NRF_PIPE0: case HAL_NRF_PIPE1: case HAL_NRF_PIPE2: case HAL_NRF_PIPE3: case HAL_NRF_PIPE4: case HAL_NRF_PIPE5: en_rxaddr.value = en_rxaddr.value & (uint8_t)~SET_BIT(pipe_num); en_aa.value = en_aa.value & (uint8_t)~SET_BIT(pipe_num); break; case HAL_NRF_ALL: en_rxaddr.value = 0U; en_aa.value = 0U; break; case HAL_NRF_TX: default: break; } hal_nrf_write_reg (EN_RXADDR, en_rxaddr.value); hal_nrf_write_reg (EN_AA, en_aa.value); }
void hal_nrf_set_address | ( | const hal_nrf_address_t | address, |
const uint8_t * | addr | ||
) |
Set radio's RX address and TX address. Use this function to set a RX address, or to set the TX address. Beware of the difference for single and multibyte address registers.
address | Which address to set |
*addr | Buffer from which the address is stored in |
< Register write command
< nRF24L01 receive address data pipe0
< nRF24L01 receive address data pipe0
Definition at line 382 of file hal_nrf.c.
{ switch(address) { case HAL_NRF_TX: case HAL_NRF_PIPE0: case HAL_NRF_PIPE1: hal_nrf_write_multibyte_reg(W_REGISTER + RX_ADDR_P0 + (uint8_t) address, addr, hal_nrf_get_address_width()); break; case HAL_NRF_PIPE2: case HAL_NRF_PIPE3: case HAL_NRF_PIPE4: case HAL_NRF_PIPE5: hal_nrf_write_reg (RX_ADDR_P0 + (uint8_t) address, *addr); break; case HAL_NRF_ALL: default: break; } }
uint8_t hal_nrf_get_address | ( | uint8_t | address, |
uint8_t * | addr | ||
) |
Get address for selected pipe. Use this function to get address for selected pipe.
address | Which address to get, Pipe- or TX-address |
*addr | buffer in which address bytes are written. For pipes containing only LSB byte of address, this byte is returned in the *addr buffer. |
< nRF24L01 receive address data pipe0
Definition at line 404 of file hal_nrf.c.
{ switch (address) { case HAL_NRF_PIPE0: case HAL_NRF_PIPE1: case HAL_NRF_TX: return (uint8_t)hal_nrf_read_multibyte_reg (address, addr); default: *addr = hal_nrf_read_reg(RX_ADDR_P0 + address); return 1U; } }
void hal_nrf_set_auto_retr | ( | uint8_t | retr, |
uint16_t | delay | ||
) |
Set auto acknowledge parameters. Use this function to set retransmit and retransmit delay parameters.
retr | Number of retransmit, 0 equ retransmit OFF |
delay | Retransmit delay in µs. Must be a |
< nRF24L01 setup of automatic retransmission register
Definition at line 418 of file hal_nrf.c.
{ setup_retr_t setup_retr; setup_retr.bits.ard = (uint8_t)(delay >> 8); setup_retr.bits.arc = retr; hal_nrf_write_reg (SETUP_RETR, setup_retr.value); }
void hal_nrf_set_address_width | ( | hal_nrf_address_width_t | address_width ) |
Set radio's address width. Use this function to define the radio's address width, referes to both RX and TX.
address_width | Address with in bytes |
< nRF24L01 setup of address width register
Definition at line 427 of file hal_nrf.c.
{ setup_aw_t setup_aw; setup_aw.value = 0U; setup_aw.bits.aw = (uint8_t)address_width - 2U; hal_nrf_write_reg (SETUP_AW, setup_aw.value); }
uint8_t hal_nrf_get_address_width | ( | void | ) |
Gets the radio's address width.
< nRF24L01 setup of address width register
Definition at line 436 of file hal_nrf.c.
{ return hal_nrf_read_reg (SETUP_AW) + 2U; }
void hal_nrf_set_rx_payload_width | ( | uint8_t | pipe_num, |
uint8_t | pload_width | ||
) |
Set payload width for selected pipe. Use this function to set the number of bytes expected on a selected pipe.
pipe_num | Pipe number to set payload width for |
pload_width | number of bytes expected |
< nRF24L01 # of bytes in rx payload for pipe0
Definition at line 441 of file hal_nrf.c.
{ hal_nrf_write_reg (RX_PW_P0 + pipe_num, pload_width); }
_Bool hal_nrf_get_irq_mode | ( | uint8_t | int_source ) |
Read current interrupt mode for selected interrupt source. Use this function to get the interrupt source's mode, either enabled or disabled.
int_source | Interrupt source to get mode from |
FALSE | Interrupt disabled |
TRUE | Interrupt enabled |
uint8_t hal_nrf_get_irq_flags | ( | void | ) |
Read all interrupt flags. Use this function to get the interrupt flags. This function is similar to hal_nrf_get_clear_irq_flags with the exception that it does NOT clear the irq_flags.
0x10 | Max Retransmit interrupt |
0x20 | TX Data sent interrupt |
0x40 | RX Data received interrupt |
< The value of bit 6
< The value of bit 5
< The value of bit 4
Definition at line 295 of file hal_nrf.c.
{ return hal_nrf_nop() & (BIT_6|BIT_5|BIT_4); }
uint8_t hal_nrf_get_pipe_status | ( | uint8_t | pipe_num ) |
Get pipe status. Use this function to check status for a selected pipe.
pipe_num | Pipe number to check status for |
0x00 | Pipe is closed, autoack disabled |
0x01 | Pipe is open, autoack disabled |
0x03 | Pipe is open, autoack enabled |
< nRF24L01 enable RX addresses register
< nRF24L01 enable Auto-Acknowledge register
Definition at line 446 of file hal_nrf.c.
{ en_pipes_t en_rxaddr; en_pipes_t en_aa; uint8_t en_rx_r, en_aa_r; en_rxaddr.value = hal_nrf_read_reg (EN_RXADDR); en_aa.value = hal_nrf_read_reg (EN_AA); switch (pipe_num) { case 0: en_rx_r = en_rxaddr.bits.pipe_0; en_aa_r = en_aa.bits.pipe_0; break; case 1: en_rx_r = en_rxaddr.bits.pipe_1; en_aa_r = en_aa.bits.pipe_1; break; case 2: en_rx_r = en_rxaddr.bits.pipe_2; en_aa_r = en_aa.bits.pipe_2; break; case 3: en_rx_r = en_rxaddr.bits.pipe_3; en_aa_r = en_aa.bits.pipe_3; break; case 4: en_rx_r = en_rxaddr.bits.pipe_4; en_aa_r = en_aa.bits.pipe_4; break; case 5: en_rx_r = en_rxaddr.bits.pipe_5; en_aa_r = en_aa.bits.pipe_5; break; default: en_rx_r = 0U; en_aa_r = 0U; break; } return (uint8_t)(en_aa_r << 1) + en_rx_r; }
uint8_t hal_nrf_get_auto_retr_status | ( | void | ) |
Get auto retransmit parameters. Use this function to get the auto retransmit parameters, retrans count and retrans delay.
UpperNibble | Retransmit Delay |
LowerNibble | Retransmit Count |
< nRF24L01 transmit observe register
Definition at line 490 of file hal_nrf.c.
{ return hal_nrf_read_reg(OBSERVE_TX); }
uint8_t hal_nrf_get_packet_lost_ctr | ( | void | ) |
Get packet lost counter Use this function to get the packet(s) counter.
< nRF24L01 transmit observe register
< The value of bit 7
< The value of bit 6
< The value of bit 5
< The value of bit 4
Definition at line 495 of file hal_nrf.c.
{ return ((hal_nrf_read_reg(OBSERVE_TX) & (BIT_7|BIT_6|BIT_5|BIT_4)) >> 4); }
uint8_t hal_nrf_get_rx_payload_width | ( | uint8_t | pipe_num ) |
Get RX payload width for selected pipe. Use this function to get the expected payload width for selected ppe number.
pipe_num | Pipe number to get payload width for |
< nRF24L01 # of bytes in rx payload for pipe0
< nRF24L01 # of bytes in rx payload for pipe1
< nRF24L01 # of bytes in rx payload for pipe2
< nRF24L01 # of bytes in rx payload for pipe3
< nRF24L01 # of bytes in rx payload for pipe4
< nRF24L01 # of bytes in rx payload for pipe5
Definition at line 500 of file hal_nrf.c.
{ uint8_t pw; switch (pipe_num) { case 0: pw = hal_nrf_read_reg (RX_PW_P0); break; case 1: pw = hal_nrf_read_reg (RX_PW_P1); break; case 2: pw = hal_nrf_read_reg (RX_PW_P2); break; case 3: pw = hal_nrf_read_reg (RX_PW_P3); break; case 4: pw = hal_nrf_read_reg (RX_PW_P4); break; case 5: pw = hal_nrf_read_reg (RX_PW_P5); break; default: pw = 0U; break; } return pw; }
void hal_nrf_set_operation_mode | ( | hal_nrf_operation_mode_t | op_mode ) |
Set radio's operation mode. Use this function to enter PTX (primary TX) or PRX (primary RX).
op_mode | Operation mode |
< nRF24L01 config register
< nRF24L01 config register
Definition at line 189 of file hal_nrf.c.
{ config_t config; config.value = hal_nrf_read_reg (CONFIG); if(op_mode == HAL_NRF_PRX) { config.bits.prim_rx = 1U; } else { config.bits.prim_rx = 0U; } hal_nrf_write_reg (CONFIG, config.value); }
void hal_nrf_set_power_mode | ( | hal_nrf_pwr_mode_t | pwr_mode ) |
Set radio's power mode. Use this function to power_up or power_down radio.
pwr_mode | POWER_UP or POWER_DOWN |
< nRF24L01 config register
< nRF24L01 config register
Definition at line 206 of file hal_nrf.c.
{ config_t config; config.value = hal_nrf_read_reg (CONFIG); if(pwr_mode == HAL_NRF_PWR_UP) { config.bits.pwr_up = 1U; } else { config.bits.pwr_up = 0U; } hal_nrf_write_reg (CONFIG, config.value); }
void hal_nrf_set_rf_channel | ( | uint8_t | channel ) |
Set radio's RF channel. Use this function to select which RF channel to use.
channel | RF channel |
< nRF24L01 RF channel register
Definition at line 532 of file hal_nrf.c.
{ rf_ch_t rf_ch; rf_ch.value = 0U; rf_ch.bits.rf_ch = channel; hal_nrf_write_reg (RF_CH, rf_ch.value); }
void hal_nrf_set_output_power | ( | hal_nrf_output_power_t | power ) |
Set radio's TX output power. Use this function set the radio's TX output power.
power | Radio's TX output power |
< nRF24L01 RF setup register
< nRF24L01 RF setup register
Definition at line 540 of file hal_nrf.c.
{ rf_setup_t rf_setup; rf_setup.value = hal_nrf_read_reg (RF_SETUP); rf_setup.bits.rf_pwr = (uint8_t)power; hal_nrf_write_reg (RF_SETUP, rf_setup.value); }
void hal_nrf_set_datarate | ( | hal_nrf_datarate_t | datarate ) |
Set radio's on-air datarate. Use this function to select radio's on-air datarate.
datarate | On-air datarate |
< nRF24L01 RF setup register
< nRF24L01 RF setup register
Definition at line 550 of file hal_nrf.c.
{ rf_setup_t rf_setup; rf_setup.value = hal_nrf_read_reg (RF_SETUP); switch (datarate) { case HAL_NRF_250KBPS: rf_setup.bits.rf_dr_low = 1U; rf_setup.bits.rf_dr_high = 0U; break; case HAL_NRF_1MBPS: rf_setup.bits.rf_dr_low = 0U; rf_setup.bits.rf_dr_high = 0U; break; case HAL_NRF_2MBPS: default: rf_setup.bits.rf_dr_low = 0U; rf_setup.bits.rf_dr_high = 1U; break; } hal_nrf_write_reg (RF_SETUP, rf_setup.value); }
uint8_t hal_nrf_get_tx_fifo_status | ( | void | ) |
Get radio's TX FIFO status. Use this function to get the radio's TX FIFO status.
0x00 | TX FIFO NOT empty, but NOT full |
0x01 | FIFO empty |
0x02 | FIFO full |
< nRF24L01 FIFO status register
< FIFO_STATUS register bit 5
< FIFO_STATUS register bit 4
Definition at line 595 of file hal_nrf.c.
{ return ((hal_nrf_read_reg(FIFO_STATUS) & ((1U<<TX_FIFO_FULL)|(1U<<TX_EMPTY))) >> 4); }
_Bool hal_nrf_tx_fifo_empty | ( | void | ) |
Check for TX FIFO empty. Use this function to check if TX FIFO is empty.
FALSE | TX FIFO NOT empty |
TRUE | TX FIFO empty |
< nRF24L01 FIFO status register
< FIFO_STATUS register bit 4
Definition at line 585 of file hal_nrf.c.
{ return (bool)((hal_nrf_read_reg(FIFO_STATUS) >> TX_EMPTY) & 0x01U); }
_Bool hal_nrf_tx_fifo_full | ( | void | ) |
Check for TX FIFO full. Use this function to check if TX FIFO is full.
FALSE | TX FIFO NOT full |
TRUE | TX FIFO full |
< nRF24L01 FIFO status register
< FIFO_STATUS register bit 5
Definition at line 590 of file hal_nrf.c.
{ return (bool)((hal_nrf_read_reg(FIFO_STATUS) >> TX_FIFO_FULL) & 0x01U); }
uint8_t hal_nrf_get_rx_fifo_status | ( | void | ) |
Get radio's RX FIFO status. Use this function to get the radio's TX FIFO status.
0x00 | RX FIFO NOT empty, but NOT full |
0x01 | RX FIFO empty |
0x02 | RX FIFO full |
< nRF24L01 FIFO status register
< FIFO_STATUS register bit 1
< FIFO_STATUS register bit 0
Definition at line 600 of file hal_nrf.c.
{ return (hal_nrf_read_reg(FIFO_STATUS) & ((1U<<RX_FULL)|(1U<<RX_EMPTY))); }
uint8_t hal_nrf_get_fifo_status | ( | void | ) |
< nRF24L01 FIFO status register
Definition at line 605 of file hal_nrf.c.
{ return hal_nrf_read_reg(FIFO_STATUS); }
_Bool hal_nrf_rx_fifo_empty | ( | void | ) |
Check for RX FIFO empty. Use this function to check if RX FIFO is empty.
Reads STATUS register to check this, not FIFO_STATUS
FALSE | RX FIFO NOT empty |
TRUE | RX FIFO empty |
< nRF24L01 FIFO status register
< FIFO_STATUS register bit 0
Definition at line 575 of file hal_nrf.c.
{ return (bool)((hal_nrf_read_reg(FIFO_STATUS) >> RX_EMPTY) & 0x01U); }
_Bool hal_nrf_rx_fifo_full | ( | void | ) |
Check for RX FIFO full. Use this function to check if RX FIFO is full.
FALSE | RX FIFO NOT full |
TRUE | RX FIFO full |
< nRF24L01 FIFO status register
< FIFO_STATUS register bit 1
Definition at line 580 of file hal_nrf.c.
{ return (bool)((hal_nrf_read_reg(FIFO_STATUS) >> RX_FULL) & 0x01U); }
uint8_t hal_nrf_get_transmit_attempts | ( | void | ) |
Get radio's transmit attempts status. Use this function to get number of retransmit attempts and number of packet lost.
< nRF24L01 transmit observe register
< The value of bit 3
< The value of bit 2
< The value of bit 1
< The value of bit 0
Definition at line 610 of file hal_nrf.c.
{ return (hal_nrf_read_reg(OBSERVE_TX) & (BIT_3|BIT_2|BIT_1|BIT_0)); }
_Bool hal_nrf_get_carrier_detect | ( | void | ) |
Get the carrier detect flag. Use this function to get the carrier detect flag, used to detect stationary disturbance on selected RF channel.
FALSE | Carrier NOT Detected |
TRUE | Carrier Detected |
< nRF24L01 carrier detect register
Definition at line 615 of file hal_nrf.c.
{ return (bool)(hal_nrf_read_reg(CD) & 0x01U); }
uint8_t hal_nrf_get_rx_data_source | ( | void | ) |
Get RX data source. Use this function to read which RX pipe data was received on for current top level FIFO data packet.
< The value of bit 3
< The value of bit 2
< The value of bit 1
Definition at line 683 of file hal_nrf.c.
{ return ((hal_nrf_nop() & (BIT_3|BIT_2|BIT_1)) >> 1); }
uint16_t hal_nrf_read_rx_payload | ( | uint8_t * | rx_pload ) |
Read RX payload. Use this function to read top level payload available in the RX FIFO.
*rx_pload | pointer to buffer in which RX payload are stored |
Definition at line 678 of file hal_nrf.c.
{ return hal_nrf_read_multibyte_reg(UINT8(HAL_NRF_RX_PLOAD), rx_pload); }
void hal_nrf_write_tx_payload | ( | const uint8_t * | tx_pload, |
uint8_t | length | ||
) |
Write TX payload to radio. Use this function to write a packet of TX payload into the radio. length number of bytes, which are stored in *tx_pload.
*tx_pload | pointer to buffer in which TX payload are present |
length | number of bytes to write |
< Write TX payload command
Definition at line 658 of file hal_nrf.c.
{ hal_nrf_write_multibyte_reg(W_TX_PAYLOAD, tx_pload, length); }
void hal_nrf_write_tx_payload_noack | ( | const uint8_t * | tx_pload, |
uint8_t | length | ||
) |
Write TX payload which do not require ACK. When transmitting a ACK is not required nor sent from the receiver. The payload will always be assumed as "sent".
Use this function to write a packet of TX payload into the radio. length number of bytes, which are stored in *tx_pload.
*tx_pload | pointer to buffer in which TX payload are present |
length | number of bytes to write |
< Write ACK payload command
Definition at line 663 of file hal_nrf.c.
{ hal_nrf_write_multibyte_reg(W_TX_PAYLOAD_NOACK, tx_pload, length); }
void hal_nrf_reuse_tx | ( | void | ) |
Reuse TX payload. Use this function to set that the radio is using the last transmitted payload for the next packet as well.
< Reuse TX payload command
Definition at line 688 of file hal_nrf.c.
{ CSN_LOW(); hal_nrf_rw(REUSE_TX_PL); CSN_HIGH(); }
_Bool hal_nrf_get_reuse_tx_status | ( | void | ) |
Get status of reuse TX function. Use this function to check if reuse TX payload is activated
FALSE | Not activated |
TRUE | Activated |
< FIFO_STATUS register bit 6
< FIFO_STATUS register bit 6
Definition at line 695 of file hal_nrf.c.
{ return (bool)((hal_nrf_get_fifo_status() & (1U<<TX_REUSE)) >> TX_REUSE); }
void hal_nrf_flush_rx | ( | void | ) |
void hal_nrf_flush_tx | ( | void | ) |
uint8_t hal_nrf_nop | ( | void | ) |
void hal_nrf_set_pll_mode | ( | _Bool | pll_lock ) |
Set radio's PLL mode. Use this function to either LOCK or UNLOCK the radio's PLL.
pll_lock | PLL locked, TRUE or FALSE |
< nRF24L01 RF setup register
< nRF24L01 RF setup register
Definition at line 725 of file hal_nrf.c.
{ rf_setup_t rf_setup; rf_setup.value = hal_nrf_read_reg (RF_SETUP); rf_setup.bits.pll_lock = (pll_lock) ? 1U : 0U; hal_nrf_write_reg(RF_SETUP, rf_setup.value); }
void hal_nrf_set_lna_gain | ( | _Bool | lna_gain ) |
Set radio's LNA gain mode. Use this function to either use HI current or LOW current mode for the radio.
lna_gain | LNA gain mode |
void hal_nrf_enable_continious_wave | ( | _Bool | enable ) |
Enables continuous carrier transmit. Use this function to enable or disable continuous carrier transmission.
enable | Enable continuous carrier |
< nRF24L01 RF setup register
< nRF24L01 RF setup register
Definition at line 734 of file hal_nrf.c.
{ rf_setup_t rf_setup; rf_setup.value = hal_nrf_read_reg (RF_SETUP); rf_setup.bits.cont_wave = (enable ? 1U : 0U); hal_nrf_write_reg(RF_SETUP, rf_setup.value); }
uint8_t hal_nrf_rw | ( | uint8_t | value ) |
Basis function, nrf_rw This function is used by the basis functions to exchange data with the data.
value | Databyte to write |
Definition at line 25 of file hal_nrf_hw.c.