upm  0.1.8
Sensor/Actuator repository for libmraa (v0.4.5)
 All Data Structures Files Functions Variables Macros Pages
Public Member Functions | Data Fields
NRF24l01 Class Reference

C++ API for NRF24l01 transceiver module. More...

Detailed Description

This file defines the NRF24l01 C++ interface for libnrf24l01

void nrf_handler () {
std::cout << "devi1 :: " << *((uint32_t *)&(comm->m_rxBuffer[0])) << std::endl;
}
uint32_t dummyData = 0;
comm = new upm::NRF24l01(7);
comm->nrfSetRXaddr ((uint8_t *) "devi2");
comm->nrfSetTXaddr ((uint8_t *) "devi1");
comm->nrfSetPayload (MAX_BUFFER);
comm->nrfConfigModule ();
comm->dataRecievedHandler = nrf_handler;
signal(SIGINT, sig_handler);
while (!running) {
memcpy (comm->m_txBuffer, &dummyData, sizeof (dummyData));
comm->nrfSend ();
std::cout << "devi2 :: sending data ...." << dummyData << std::endl;
usleep (3000000);
dummyData += 3000;
}
std::cout << "exiting application" << std::endl;
delete comm;

Public Member Functions

 NRF24l01 (uint8_t cs)
 
 ~NRF24l01 ()
 
std::string name ()
 
void nrfInitModule (uint8_t chipSelect, uint8_t chipEnable)
 
void nrfConfigModule ()
 
void nrfSend (uint8_t *value)
 
void nrfSend ()
 
void nrfSetRXaddr (uint8_t *addr)
 
void nrfSetTXaddr (uint8_t *addr)
 
void nrfSetBroadcastAddr (uint8_t *addr)
 
void nrfSetPayload (uint8_t load)
 
bool nrfDataReady ()
 
bool nrfIsSending ()
 
bool nrfRXFifoEmpty ()
 
bool nrfTXFifoEmpty ()
 
void nrfGetData (uint8_t *data)
 
uint8_t nrfGetStatus ()
 
void nrfTransmitSync (uint8_t *dataout, uint8_t len)
 
void nrfTransferSync (uint8_t *dataout, uint8_t *datain, uint8_t len)
 
void nrfConfigRegister (uint8_t reg, uint8_t value)
 
void nrfReadRegister (uint8_t reg, uint8_t *value, uint8_t len)
 
void nrfWriteRegister (uint8_t reg, uint8_t *value, uint8_t len)
 
void nrfPowerUpRX ()
 
void nrfPowerUpTX ()
 
void nrfPowerDown ()
 
mraa_result_t nrfCEHigh ()
 
mraa_result_t nrfCELow ()
 
mraa_result_t nrfCSOn ()
 
mraa_result_t nrfCSOff ()
 
void nrfFlushRX ()
 
void nrfListenForChannel ()
 

Data Fields

uint8_t m_rxBuffer [MAX_BUFFER]
 
uint8_t m_txBuffer [MAX_BUFFER]
 
funcPtrVoidVoid dataRecievedHandler
 

Constructor & Destructor Documentation

NRF24l01 ( uint8_t  cs)

Instanciates a NRF24l01 object

Parameters
cschip select pin

Here is the call graph for this function:

~NRF24l01 ( )

NRF24l01 object destructor

Member Function Documentation

std::string name ( )
inline

Return name of the component

void nrfInitModule ( uint8_t  chipSelect,
uint8_t  chipEnable 
)

Initialize needed Gpio pins and SPI interface

Parameters
chipSelectsetting up the chip select pin
chipEnablesetting up the chip enable pin

Here is the call graph for this function:

Here is the caller graph for this function:

void nrfConfigModule ( )

Configure NRF24l01 chip

Here is the call graph for this function:

void nrfSend ( uint8_t *  value)

Send the buffer data

Parameters
valuepointer to the buffer

Here is the call graph for this function:

void nrfSend ( )

Send the data located in inner bufer, user must fill the m_txBuffer buffer

void nrfSetRXaddr ( uint8_t *  addr)

Set recieving address of the device

Parameters
addr5 bytes addres

Here is the call graph for this function:

void nrfSetTXaddr ( uint8_t *  addr)

Set recipient address. nrfSend method will send the data buffer to this address

Parameters
addr5 bytes addres

Here is the call graph for this function:

void nrfSetBroadcastAddr ( uint8_t *  addr)

Set broadcasting address.

Parameters
addr5 bytes addres

Here is the call graph for this function:

void nrfSetPayload ( uint8_t  load)

Set payload size.

Parameters
loadsize of the payload (MAX 32)
bool nrfDataReady ( )

Check if data arrived

Here is the call graph for this function:

Here is the caller graph for this function:

bool nrfIsSending ( )

Check if chip in sending mode

Here is the call graph for this function:

Here is the caller graph for this function:

bool nrfRXFifoEmpty ( )

Check if recieving stack is empty

Here is the call graph for this function:

Here is the caller graph for this function:

bool nrfTXFifoEmpty ( )

Check if transmitting stack is empty

void nrfGetData ( uint8_t *  data)

Sink all arrived data into the provided buffer

Parameters
datapointer to buffer of data

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t nrfGetStatus ( )

Check the chip state

Here is the call graph for this function:

Here is the caller graph for this function:

void nrfTransmitSync ( uint8_t *  dataout,
uint8_t  len 
)

Transmit provided data to the chip

Parameters
dataoutpointer to the buffer with data
lenlength of the buffer

Here is the caller graph for this function:

void nrfTransferSync ( uint8_t *  dataout,
uint8_t *  datain,
uint8_t  len 
)

Recieve data from the chip

Parameters
dataoutpointer to the buffer with data
datainpointer to the buffer where the arrived data will be sinked
lenlength of the buffer

Here is the caller graph for this function:

void nrfConfigRegister ( uint8_t  reg,
uint8_t  value 
)

Write byte value into a register

Parameters
regregister address
valuethe value to write

Here is the call graph for this function:

Here is the caller graph for this function:

void nrfReadRegister ( uint8_t  reg,
uint8_t *  value,
uint8_t  len 
)

Read continues data from register

Parameters
regregister address
valuepointer to the buffer
lenlength of the buffer

Here is the call graph for this function:

Here is the caller graph for this function:

void nrfWriteRegister ( uint8_t  reg,
uint8_t *  value,
uint8_t  len 
)

Write continues data to register

Parameters
regregister address
valuepointer to the buffer
lenlength of the buffer

Here is the call graph for this function:

Here is the caller graph for this function:

void nrfPowerUpRX ( )

Power up reciever

Here is the call graph for this function:

Here is the caller graph for this function:

void nrfPowerUpTX ( )

Power up transmitter

Here is the call graph for this function:

Here is the caller graph for this function:

void nrfPowerDown ( )

Power down all

Here is the call graph for this function:

mraa_result_t nrfCEHigh ( )

Set chip enable pin HIGH

Here is the caller graph for this function:

mraa_result_t nrfCELow ( )

Set chip enable LOW

Here is the caller graph for this function:

mraa_result_t nrfCSOn ( )

Set chip select pin LOW

Here is the caller graph for this function:

mraa_result_t nrfCSOff ( )

Set chip select pin HIGH

Here is the caller graph for this function:

void nrfFlushRX ( )

Flush reciver stack

Here is the call graph for this function:

Here is the caller graph for this function:

void nrfListenForChannel ( )

Pulling method which listenning for arrived data, if data arrived dataRecievedHandler will be triggered

Here is the call graph for this function:

Field Documentation

uint8_t m_rxBuffer[MAX_BUFFER]

Reciver buffer

uint8_t m_txBuffer[MAX_BUFFER]

Transmit buffer

funcPtrVoidVoid dataRecievedHandler

Data arrived handler


The documentation for this class was generated from the following files: