ISR UC / ISR_Mini-explorer

Energy harvesting mobile robot. Developed at Institute of Systems and Robotics — University of Coimbra.

Dependents:   Mapping VirtualForces_debug OneFileToRuleThemAll VirtualForces_with_class

Embed: (wiki syntax)

« Back to documentation index

nRF24L01P Class Reference

nRF24L01P Class Reference

nRF24L01+ Single Chip 2.4GHz Transceiver from Nordic Semiconductor. More...

#include <nRF24L01P.h>

Public Member Functions

 nRF24L01P (PinName mosi, PinName miso, PinName sck, PinName csn, PinName ce, PinName irq=NC)
 Constructor.
void setRfFrequency (int frequency=DEFAULT_NRF24L01P_RF_FREQUENCY)
 Set the RF frequency.
int getRfFrequency (void)
 Get the RF frequency.
void setRfOutputPower (int power=DEFAULT_NRF24L01P_TX_PWR)
 Set the RF output power.
int getRfOutputPower (void)
 Get the RF output power.
void setAirDataRate (int rate=DEFAULT_NRF24L01P_DATARATE)
 Set the Air data rate.
int getAirDataRate (void)
 Get the Air data rate.
void setCrcWidth (int width=DEFAULT_NRF24L01P_CRC)
 Set the CRC width.
int getCrcWidth (void)
 Get the CRC width.
void setRxAddress (unsigned long long address=DEFAULT_NRF24L01P_ADDRESS, int width=DEFAULT_NRF24L01P_ADDRESS_WIDTH, int pipe=NRF24L01P_PIPE_P0)
 Set the Receive address.
void setTxAddress (unsigned long long address=DEFAULT_NRF24L01P_ADDRESS, int width=DEFAULT_NRF24L01P_ADDRESS_WIDTH)
 Set the Transmit address.
unsigned long long getRxAddress (int pipe=NRF24L01P_PIPE_P0)
 Get the Receive address.
unsigned long long getTxAddress (void)
 Get the Transmit address.
void setTransferSize (int size=DEFAULT_NRF24L01P_TRANSFER_SIZE, int pipe=NRF24L01P_PIPE_P0)
 Set the transfer size.
int getTransferSize (int pipe=NRF24L01P_PIPE_P0)
 Get the transfer size.
bool getRPD (void)
 Get the RPD (Received Power Detector) state.
void setReceiveMode (void)
 Put the nRF24L01+ into Receive mode.
void setTransmitMode (void)
 Put the nRF24L01+ into Transmit mode.
void powerUp (void)
 Power up the nRF24L01+ into Standby mode.
void powerDown (void)
 Power down the nRF24L01+ into Power Down mode.
void enable (void)
 Enable the nRF24L01+ to Receive or Transmit (using the CE pin)
void disable (void)
 Disable the nRF24L01+ to Receive or Transmit (using the CE pin)
int write (int pipe, char *data, int count)
 Transmit data.
int read (int pipe, char *data, int count)
 Receive data.
bool readable (int pipe=NRF24L01P_PIPE_P0)
 Determine if there is data available to read.
void disableAllRxPipes (void)
 Disable all receive pipes.
void disableAutoAcknowledge (void)
 Disable AutoAcknowledge function.
void enableAutoAcknowledge (int pipe=NRF24L01P_PIPE_P0)
 Enable AutoAcknowledge function.
void disableAutoRetransmit (void)
 Disable AutoRetransmit function.
void enableAutoRetransmit (int delay, int count)
 Enable AutoRetransmit function.

Detailed Description

nRF24L01+ Single Chip 2.4GHz Transceiver from Nordic Semiconductor.

Definition at line 84 of file nRF24L01P.h.


Constructor & Destructor Documentation

nRF24L01P ( PinName  mosi,
PinName  miso,
PinName  sck,
PinName  csn,
PinName  ce,
PinName  irq = NC 
)

Constructor.

Methods.

Parameters:
mosimbed pin to use for MOSI line of SPI interface.
misombed pin to use for MISO line of SPI interface.
sckmbed pin to use for SCK line of SPI interface.
csnmbed pin to use for not chip select line of SPI interface.
cembed pin to use for the chip enable line.
irqmbed pin to use for the interrupt request line.

Definition at line 174 of file nRF24L01P.cpp.


Member Function Documentation

void disable ( void   )

Disable the nRF24L01+ to Receive or Transmit (using the CE pin)

Definition at line 285 of file nRF24L01P.cpp.

void disableAllRxPipes ( void   )

Disable all receive pipes.

Note: receive pipes are enabled when their address is set.

Definition at line 520 of file nRF24L01P.cpp.

void disableAutoAcknowledge ( void   )

Disable AutoAcknowledge function.

Definition at line 527 of file nRF24L01P.cpp.

void disableAutoRetransmit ( void   )

Disable AutoRetransmit function.

Definition at line 552 of file nRF24L01P.cpp.

void enable ( void   )

Enable the nRF24L01+ to Receive or Transmit (using the CE pin)

Definition at line 277 of file nRF24L01P.cpp.

void enableAutoAcknowledge ( int  pipe = NRF24L01P_PIPE_P0 )

Enable AutoAcknowledge function.

Parameters:
pipethe receive pipe

Definition at line 534 of file nRF24L01P.cpp.

void enableAutoRetransmit ( int  delay,
int  count 
)

Enable AutoRetransmit function.

Parameters:
delaythe delay between restransmits, in uS (250uS..4000uS)
countnumber of retransmits before generating an error (1..15)
int getAirDataRate ( void   )

Get the Air data rate.

Returns:
the air data rate in kbps (250, 1M or 2M).

Definition at line 404 of file nRF24L01P.cpp.

int getCrcWidth ( void   )

Get the CRC width.

Returns:
the number of bits for the CRC (0, 8 or 16).

Definition at line 456 of file nRF24L01P.cpp.

int getRfFrequency ( void   )

Get the RF frequency.

Returns:
the frequency of RF transmission in MHz (2400..2525).

Definition at line 307 of file nRF24L01P.cpp.

int getRfOutputPower ( void   )

Get the RF output power.

Returns:
the RF output power in dBm (0, -6, -12 or -18).

Definition at line 349 of file nRF24L01P.cpp.

bool getRPD ( void   )

Get the RPD (Received Power Detector) state.

Returns:
true if the received power exceeded -64dBm
unsigned long long getRxAddress ( int  pipe = NRF24L01P_PIPE_P0 )

Get the Receive address.

Parameters:
pipepipe to get the address from (0..5, default 0)
Returns:
the address associated with the particular pipe

Definition at line 699 of file nRF24L01P.cpp.

int getTransferSize ( int  pipe = NRF24L01P_PIPE_P0 )

Get the transfer size.

Returns:
the size of the transfer, in bytes (1..32).

Definition at line 502 of file nRF24L01P.cpp.

unsigned long long getTxAddress ( void   )

Get the Transmit address.

Returns:
address address for transmission

Definition at line 772 of file nRF24L01P.cpp.

void powerDown ( void   )

Power down the nRF24L01+ into Power Down mode.

Definition at line 231 of file nRF24L01P.cpp.

void powerUp ( void   )

Power up the nRF24L01+ into Standby mode.

Definition at line 215 of file nRF24L01P.cpp.

int read ( int  pipe,
char *  data,
int  count 
)

Receive data.

Parameters:
pipethe receive pipe to get data from
datapointer to an array of bytes to store the received data
countthe number of bytes to receive (1..32)
Returns:
the number of bytes actually received, 0 if none are received, or -1 for an error

Definition at line 896 of file nRF24L01P.cpp.

bool readable ( int  pipe = NRF24L01P_PIPE_P0 )

Determine if there is data available to read.

Parameters:
pipethe receive pipe to check for data
Returns:
true if the is data waiting in the given pipe

Definition at line 821 of file nRF24L01P.cpp.

void setAirDataRate ( int  rate = DEFAULT_NRF24L01P_DATARATE )

Set the Air data rate.

Parameters:
ratethe air data rate in kbps (250, 1M or 2M).

Definition at line 375 of file nRF24L01P.cpp.

void setCrcWidth ( int  width = DEFAULT_NRF24L01P_CRC )

Set the CRC width.

Parameters:
widththe number of bits for the CRC (0, 8 or 16).

Definition at line 427 of file nRF24L01P.cpp.

void setReceiveMode ( void   )

Put the nRF24L01+ into Receive mode.

Definition at line 247 of file nRF24L01P.cpp.

void setRfFrequency ( int  frequency = DEFAULT_NRF24L01P_RF_FREQUENCY )

Set the RF frequency.

Parameters:
frequencythe frequency of RF transmission in MHz (2400..2525).

Definition at line 291 of file nRF24L01P.cpp.

void setRfOutputPower ( int  power = DEFAULT_NRF24L01P_TX_PWR )

Set the RF output power.

Parameters:
powerthe RF output power in dBm (0, -6, -12 or -18).

Definition at line 316 of file nRF24L01P.cpp.

void setRxAddress ( unsigned long long  address = DEFAULT_NRF24L01P_ADDRESS,
int  width = DEFAULT_NRF24L01P_ADDRESS_WIDTH,
int  pipe = NRF24L01P_PIPE_P0 
)

Set the Receive address.

Parameters:
addressaddress associated with the particular pipe
widthwidth of the address in bytes (3..5)
pipepipe to associate the address with (0..5, default 0)

Note that Pipes 0 & 1 have 3, 4 or 5 byte addresses, while Pipes 2..5 only use the lowest byte (bits 7..0) of the address provided here, and use 2, 3 or 4 bytes from Pipe 1's address. The width parameter is ignored for Pipes 2..5.

Definition at line 558 of file nRF24L01P.cpp.

void setTransferSize ( int  size = DEFAULT_NRF24L01P_TRANSFER_SIZE,
int  pipe = NRF24L01P_PIPE_P0 
)

Set the transfer size.

Parameters:
sizethe size of the transfer, in bytes (1..32)
pipepipe for the transfer (0..5, default 0)

Definition at line 479 of file nRF24L01P.cpp.

void setTransmitMode ( void   )

Put the nRF24L01+ into Transmit mode.

Definition at line 262 of file nRF24L01P.cpp.

void setTxAddress ( unsigned long long  address = DEFAULT_NRF24L01P_ADDRESS,
int  width = DEFAULT_NRF24L01P_ADDRESS_WIDTH 
)

Set the Transmit address.

Parameters:
addressaddress for transmission
widthwidth of the address in bytes (3..5)

Note that the address width is shared with the Receive pipes, so a change to that address width affect transmissions.

Definition at line 652 of file nRF24L01P.cpp.

int write ( int  pipe,
char *  data,
int  count 
)

Transmit data.

Parameters:
pipeis ignored (included for consistency with file write routine)
datapointer to an array of bytes to write
countthe number of bytes to send (1..32)
Returns:
the number of bytes actually written, or -1 for an error

Definition at line 837 of file nRF24L01P.cpp.