Jump to content
43oh

[Energia Library] Nordic nRF24L01+ library


Recommended Posts

I collapsed LM4Bits.h into Enrf24.h and included the new #include's for the platform.

 

Can you guys verify this works--it builds just fine for me with board set to Stellaris LaunchPad:

Enrf24_v1_5.zip

 

 

Changes:

Version promoted to v1.5

#include's for Stellaris LaunchPad

BITx defines for Stellaris LaunchPad

Enrf24_ChannelScan example modified to use while(1); to halt CPU instead of LPM4 since that isn't available on Stellaris LaunchPad.

AStelTXdemo example included.

 

The original Enrf24_* examples only need the pin names changed in the constructor up above to work.  (Haven't actually tested these myself on the Stellaris LP though)

 

Past changes not included in the prior zip file in this thread:

Subsequent hits to .available(1) will return TRUE until data is actually read.  Normally .available(1) (only reports data available if RX IRQ present) will report false after the first hit b/c the IRQ is cleared behind the scenes.

.write() auto-sends only when you try to send a 33rd byte into the buffer

A .lastTXfailed variable exposed to the user so they can test if the last write() or flush() performed failed (only available with AutoACK, and only at 1Mbps & 2Mbps)

Link to post
Share on other sites
  • Replies 352
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hi folks... So I'm a little new to Energia, but since I wrote a library for the nRF24L01+ digital transceivers for native C-based apps I figured it'd be a great idea to port this to Energia.   I'm r

Ok, so I ported the Enrf library over so that it works with both MSP430 and Stellaris.  Seems to work great.  I am watching the tx rx demo between msp430g2553 (on the RX side), and the StellarPad doin

Okie doke - https://github.com/spirilis/Enrf24   The examples are the same as the ones I posted... I'll write up the API in a wiki page soon.  Alternately, I put documentation in the Enrf24.h file f

Posted Images

Can someone guide me on pin mapping...

Not sure what you mean ... Pin mapping for what?  If you mean the transceiver, track where you put the CE, CSN and IRQ pins from the transceiver module and see which port they correspond to on the LaunchPad, then specify those in the Enrf24 constructor parameters.

 

E.g. in the new AStelTXdemo he specified:

 

Enrf24 radio(PE_1, PE_2, PE_3);  // P2.0=CE, P2.1=CSN, P2.2=IRQ
 

Comment wasn't updated, think I'll go edit that now :smile:  but he's using PE_1 for the CE pin on the nRF24, PE_2 for CSN, PE_3 for IRQ.  That's on the Stellaris LaunchPad.

Link to post
Share on other sites

Not sure what you mean ... Pin mapping for what?  If you mean the transceiver, track where you put the CE, CSN and IRQ pins from the transceiver module and see which port they correspond to on the LaunchPad, then specify those in the Enrf24 constructor parameters.

 

E.g. in the new AStelTXdemo he specified:

 

Enrf24 radio(PE_1, PE_2, PE_3);  // P2.0=CE, P2.1=CSN, P2.2=IRQ
 

Comment wasn't updated, think I'll go edit that now :smile:  but he's using PE_1 for the CE pin on the nRF24, PE_2 for CSN, PE_3 for IRQ.  That's on the Stellaris LaunchPad.

 

I got it spirilis. It's using SPI module 3 for SPI. And other pins as you mentioned here :)

Now I'm trying to convert this to 'C' so that I can use it in Code Composer Studio. I hope i'll get help on this too. Thank you very much.

Link to post
Share on other sites

G'day.

Have got the Stellaris sending to the 430 OK, led flashing and all that. I'm now trying to get data back from the 430.

The 430 is normally in RX mode, so when I want to send data back to Stellaris  I do a radio.flush() then have a radio.enableRX() as the next instruction (also put a delay in but made no difference) . But the data not sent, and the 430 can no longer Rx Stellaris commands

What noob thing am I doing.

Grant.

Link to post
Share on other sites

Hello,

I have a small problem with the library. I need to understand how radio.setRXaddress(); works. I mean, I don't understand, why the address in examples is { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 }

 

What I need is loop going through some number of addresses and send message to each of them.

 

For example:

I have 100 of devices waiting for "start" message. I want the main unit to call each of the devices separately and send the "start" command. I need to know how to incrementaly set the address and call the devices. And of course those devices would have set the RX address permanently on exact address. But my point is, I don't know how to work with the addresses.

 

could someone show me example code of loop going through some number (256) or all possible addresses?

 

what is the address structure, are all five bytes arbitrary or are some of them fixed?

 

Thank you

 

Link to post
Share on other sites

G'day

Am sure there are smarter guys than me (heck there always is) but do have a few  RF remotes talking to me.  I put a hex switch in each slave that sets the last byte in the address array..

The other address bytes  don't matter, as long as radio.setTxaddress in master (in my case have a stellaris polling the slaves) is the same as radio.setRXaddress in the 430.

 

A simple for loop incrementing the LSB address then polls each slave.

 

There is also an option to reduce the total number of byte in the address, but have not bothered with that at this stage.

Grant

Link to post
Share on other sites

Ok, so you are saying what I thought, that this approach would work? Ok, I'll use it. Thank you

const uint8_t rxaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
.
.
.
for(uint8_t i=0x01; i<0xff; i++)
{
  txaddr[4]=i
  radio.setTXaddress(txaddr);
}
.
.
.

Still would be nice if someone would describe how the addressing works.

Link to post
Share on other sites

Addressing is quite simple, it's 5 bytes. Incoming packets are continually filtered to find packets whose address matches the 5 byte RX address configured on the transceiver.

 

There is more to it under the hood but this library is intentionally designed for you to ignore them.

 

Btw since the .setRXaddress() and .setTXaddress() methods just take a pointer, you could pass a string to it and that would work. Just be sure it is 5-chars long.

 

Sent from my Galaxy Note II with Tapatalk

 

 

Link to post
Share on other sites

Great!

So, let's say I plan to have maximum 20 devices (in fact about five, but just to be sure). That makes an alphabet enough big to use it as ID's like this to go through ids from dev-a to dev-z to make the addresses easy to remember.

const uint8_t txaddr[] = "dev-a";
.
.
.
for(uint8_t i='a'; i<='z'; i++)
{
  txaddr[4]=i
  radio.setTXaddress(txaddr);
}
.
.
.

and of course on the RX side (for example)

const uint8_t rxaddr[] = "dev-a";

So you say it's valid?

 

Thank you

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...