Jump to content
spirilis

[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)

Share this post


Link to post
Share on other sites

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.

Share this post


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.

Share this post


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.

Share this post


Link to post
Share on other sites

G'day,

Seems whenever I do a post I often find the answer.

My problem was solved by a  radio.autoAck(false). This turns auto ack off.  Anyway all is good in the land of Oz.

Share this post


Link to post
Share on other sites

Not sure, just used all the default settings and let the lib set them up.

Now that I have got good comms will start to play around with some of these settings.

Share this post


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

 

Share this post


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

Share this post


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.

Share this post


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

 

 

Share this post


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×