Recommended addition to rf22.cpp: time last header was received.

42 views
Skip to first unread message

stevech

unread,
Apr 10, 2014, 7:19:18 PM4/10/14
to rf22-a...@googlegroups.com

Recommended addtion to rf22.cpp. Generally useful to know when the last valid preamble was received. One use is clear channel assessment (no header received for x amount of time).

in the interrupt service function, at the bottom:

    if (_lastInterruptFlags[1] & RF22_IPREAVAL)
    {
       //    Serial.println("IPREAVAL"); 
    _lastRssi = spiRead(RF22_REG_26_RSSI);
    _lastPreambleTime = millis();  // <<< ADDED THIS
    clearRxBuf();
    }

the call to millis() is likely always_inline and low overhead.

and added
  _lastPreambleTime  in the .h as a uint32_t (sizeof millis())

and a "getter" function for this, like

uint32_t get_lastPreambleTime(void); // in .h
and

uint32_t get_lastPreambleTime(void)  {
   return(_lastPreambleTime);
}



Mike McCauley

unread,
Apr 12, 2014, 7:02:29 PM4/12/14
to rf22-a...@googlegroups.com
Hello Steve,

this will also appear in the RF22 driver in RadioHead.

Cheers.

On Thursday, April 10, 2014 04:19:18 PM stevech wrote:
> Recommended addtion to rf22.cpp. Generally useful to know when the last
> valid preamble was received. One use is clear channel assessment (no header
> received for x amount of time).
>
> in the interrupt service function, at the bottom:
>
> if (_lastInterruptFlags[1] & RF22_IPREAVAL)
> {
> // Serial.println("IPREAVAL");
> _lastRssi = spiRead(RF22_REG_26_RSSI);
> *_lastPreambleTime = millis(); // <<< ADDED THIS*
> clearRxBuf();
> }
> the call to millis() is likely* always_inline* and low overhead.
>
> and added
> _lastPreambleTime in the .h as a uint32_t (sizeof millis())
>
> and a "getter" function for this, like
>
> uint32_t get_lastPreambleTime(void); // in .h
> and
>
> uint32_t get_lastPreambleTime(void) {
> return(_lastPreambleTime);
> }

--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com
Phone +61 7 5598-7474 Fax +61 7 5598-7070

stevech

unread,
Apr 12, 2014, 7:08:53 PM4/12/14
to rf22-a...@googlegroups.com
Thanks.

Is RadioHead the name of a library for multiple types of data radios and also not wholly AVR specific?

Mike McCauley

unread,
Apr 12, 2014, 7:15:33 PM4/12/14
to rf22-a...@googlegroups.com
Hello,


On Saturday, April 12, 2014 04:08:53 PM stevech wrote:
> Thanks.
>
> Is RadioHead the name of a library for multiple types of data radios and
> also not wholly AVR specific?

Yes.

It will include the message handlers from RF22:
Datagram, ReliableDatagram, Router and Mesh
and drivers for:
RF22, RF69, Serial port, ASK (using the tech from VirtualWire)
and will build for
Arduino, Maple, Uno32, maybe others.

Cheers.

>
> On Thursday, April 10, 2014 4:19:18 PM UTC-7, stevech wrote:
> > Recommended addtion to rf22.cpp. Generally useful to know when the last
> > valid preamble was received. One use is clear channel assessment (no
> > header
> > received for x amount of time).
> >
> > in the interrupt service function, at the bottom:
> > if (_lastInterruptFlags[1] & RF22_IPREAVAL)
> > {
> >
> > // Serial.println("IPREAVAL");
> >
> > _lastRssi = spiRead(RF22_REG_26_RSSI);
> > *_lastPreambleTime = millis(); // <<< ADDED THIS*
> > clearRxBuf();
> > }
> >
> > the call to millis() is likely* always_inline* and low overhead.
> >
> > and added
> >
> > _lastPreambleTime in the .h as a uint32_t (sizeof millis())
> >
> > and a "getter" function for this, like
> >
> > uint32_t get_lastPreambleTime(void); // in .h
> > and
> >
> > uint32_t get_lastPreambleTime(void) {
> >
> > return(_lastPreambleTime);
> >
> > }

stevech

unread,
Apr 12, 2014, 10:55:39 PM4/12/14
to rf22-a...@googlegroups.com
There is some Teensy3 (ARM Cortex M4) changes in the libs... hope they prevail. THis ARM board is < $20 and has a big Arduino compatability library.
And I'd be happy to help continue that into the RadioHead.



On Thursday, April 10, 2014 4:19:18 PM UTC-7, stevech wrote:

Mike McCauley

unread,
Apr 13, 2014, 2:34:45 AM4/13/14
to rf22-a...@googlegroups.com, stevech
Hi Steve,

On Saturday, April 12, 2014 07:55:39 PM stevech wrote:
> There is some Teensy3 (ARM Cortex M4) changes in the libs... hope they
> prevail. THis ARM board is < $20 and has a big Arduino compatability
> library.
> And I'd be happy to help continue that into the RadioHead.

I hope to continue the support of the other platforms into RadioHead, but alas
I have no way to test them at the moment, and its possible I will break some.
So, your testing will be invaluable.

Cheers.


>
> On Thursday, April 10, 2014 4:19:18 PM UTC-7, stevech wrote:
> > Recommended addtion to rf22.cpp. Generally useful to know when the last
> > valid preamble was received. One use is clear channel assessment (no
> > header
> > received for x amount of time).
> >
> > in the interrupt service function, at the bottom:
> > if (_lastInterruptFlags[1] & RF22_IPREAVAL)
> > {
> >
> > // Serial.println("IPREAVAL");
> >
> > _lastRssi = spiRead(RF22_REG_26_RSSI);
> > *_lastPreambleTime = millis(); // <<< ADDED THIS*
> > clearRxBuf();
> > }
> >
> > the call to millis() is likely* always_inline* and low overhead.
> >
> > and added
> >
> > _lastPreambleTime in the .h as a uint32_t (sizeof millis())
> >
> > and a "getter" function for this, like
> >
> > uint32_t get_lastPreambleTime(void); // in .h
> > and
> >
> > uint32_t get_lastPreambleTime(void) {
> >
> > return(_lastPreambleTime);
> >
> > }

stevech

unread,
Apr 13, 2014, 2:52:54 AM4/13/14
to rf22-a...@googlegroups.com
I'll be glad to help. If you wish, I can probably get Teensy's proprietor to send you some feebies. So much easier to do things with Arduino libraries, 256K flash and 64KB ARM, 96MHz CPU, for $19.80.
I've kind of moved on from AVRs now.



On Thursday, April 10, 2014 4:19:18 PM UTC-7, stevech wrote:

Mike McCauley

unread,
Apr 13, 2014, 3:05:16 AM4/13/14
to rf22-a...@googlegroups.com, stevech
On Saturday, April 12, 2014 11:52:54 PM stevech wrote:
> I'll be glad to help. If you wish, I can probably get Teensy's proprietor
> to send you some feebies.

That would be cool. Ta!


> So much easier to do things with Arduino
> libraries, 256K flash and 64KB ARM, 96MHz CPU, for $19.80.


Yes, sounds good.

> I've kind of moved on from AVRs now.
>
> On Thursday, April 10, 2014 4:19:18 PM UTC-7, stevech wrote:
> > Recommended addtion to rf22.cpp. Generally useful to know when the last
> > valid preamble was received. One use is clear channel assessment (no
> > header
> > received for x amount of time).
> >
> > in the interrupt service function, at the bottom:
> > if (_lastInterruptFlags[1] & RF22_IPREAVAL)
> > {
> >
> > // Serial.println("IPREAVAL");
> >
> > _lastRssi = spiRead(RF22_REG_26_RSSI);
> > *_lastPreambleTime = millis(); // <<< ADDED THIS*
> > clearRxBuf();
> > }
> >
> > the call to millis() is likely* always_inline* and low overhead.
> >
> > and added
> >
> > _lastPreambleTime in the .h as a uint32_t (sizeof millis())
> >
> > and a "getter" function for this, like
> >
> > uint32_t get_lastPreambleTime(void); // in .h
> > and
> >
> > uint32_t get_lastPreambleTime(void) {
> >
> > return(_lastPreambleTime);
> >
> > }

Reply all
Reply to author
Forward
0 new messages