Code from baselined RF22 lib to carry on to RadioHead

78 views
Skip to first unread message

stevech

unread,
Apr 13, 2014, 3:00:25 AM4/13/14
to rf22-a...@googlegroups.com
The Teensy3 specific code below is in RF22.cppI downloaded from the distribution.
I assume it will be in RadioHead. I didn't author it. I did correct an error in the SPI clock pin remapping, which is the last line of code below)

   // Add by Adrien van den Bossche <vand...@univ-tlse2.fr>
    #if defined (__MK20DX128__) || defined (__MK20DX256__)
    pinMode(_interrupt, INPUT);
    #endif

       
    // start the SPI library:
    // Note the RF22 wants mode 0, MSB first and default to 1 Mbps
   
    _spi->begin();
    //Serial.println("begin OK");
    _spi->setDataMode(SPI_MODE0);
    _spi->setBitOrder(MSBFIRST);
    _spi->setClockDivider(SPI_CLOCK_DIV16);  // (16 Mhz / 16) = 1 MHz

    // Add by Adrien van den Bossche <vand...@univ-tlse2.fr>
    #if  defined (__MK20DX128__) || defined (__MK20DX256__)
    // First reassign pin 13 to Alt1 so that it is not SCK but the LED still works
    CORE_PIN13_CONFIG = PORT_PCR_MUX(1); //   Alt1 = PTC5.  chip pin PTC5
    // and then reassign pin 14 to SCK
    CORE_PIN14_CONFIG = PORT_PCR_DSE | PORT_PCR_MUX(2); // Alt2=SPIO_SCK.  chip pin PTD1
    #endif

Mike McCauley

unread,
Apr 13, 2014, 3:07:54 AM4/13/14
to rf22-a...@googlegroups.com
Err,
that Teensy3 code is not in my original distribution.
--
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

Mike McCauley

unread,
Apr 13, 2014, 5:11:03 AM4/13/14
to rf22-a...@googlegroups.com
Looking around some more, that Teensy3 code for RF22 was posted by Adrien
here:

http://forum.pjrc.com/threads/24995-RF22-library-support-on-Teensy-3-0-and-Teensy-3-1

Its not currently in my RF22 distro.

I suppose I could add it, but maybe I need the permission of Adrien?

Also, why is this needed:
pinMode(_interrupt, INPUT);
since the default state of pins should be INPUT?

Also, why is reassigning SCK to pin 14 necessary?

Seems to me the RF22 lib will work out of the box in Teensy3 if you are
willing to lose independent use of the LED?

stevech

unread,
Apr 13, 2014, 7:17:07 PM4/13/14
to rf22-a...@googlegroups.com
Hmm. I can't recall where I downloaded this...

Mike McCauley

unread,
Apr 13, 2014, 7:29:45 PM4/13/14
to rf22-a...@googlegroups.com
Hi,

can you verify if it is really necessary to do this:

pinMode(_interrupt, INPUT);

and this:
CORE_PIN13_CONFIG = PORT_PCR_MUX(1); // Alt1 = PTC5. chip pin PTC5
// and then reassign pin 14 to SCK
CORE_PIN14_CONFIG = PORT_PCR_DSE | PORT_PCR_MUX(2); //

Cheers.

On Sunday, April 13, 2014 04:17:07 PM stevech wrote:
> Hmm. I can't recall where I downloaded this...
>
> On Sunday, April 13, 2014 12:07:54 AM UTC-7, mikem wrote:
> > Err,
> > that Teensy3 code is not in my original distribution.
> >
> > On Sunday, April 13, 2014 12:00:25 AM stevech wrote:
> > > The Teensy3 specific code below is in RF22.cppI downloaded from the
> > > distribution.
> > > I assume it will be in RadioHead. I didn't author it. I did correct an
> > > error in the SPI clock pin remapping, which is the last line of code
> >
> > below)
> >
> > > // Add by Adrien van den Bossche <vand...@univ-tlse2.fr
> > > <javascript:>>
> > >
> > > > #if defined (__MK20DX128__) || defined (__MK20DX256__)
> > > > pinMode(_interrupt, INPUT);
> > > > #endif
> > > >
> > > >
> > > > // start the SPI library:
> > > > // Note the RF22 wants mode 0, MSB first and default to 1 Mbps
> > > >
> > > > _spi->begin();
> > > > //Serial.println("begin OK");
> > > > _spi->setDataMode(SPI_MODE0);
> > > > _spi->setBitOrder(MSBFIRST);
> > > > _spi->setClockDivider(SPI_CLOCK_DIV16); // (16 Mhz / 16) = 1 MHz
> > > >
> > > > // Add by Adrien van den Bossche
> > > > <vand...@univ-tlse2.fr<javascript:>>

stevech

unread,
Apr 13, 2014, 8:03:48 PM4/13/14
to rf22-a...@googlegroups.com
Yes, it is.
Also, the code below remaps the SPI port clock to a different pin so that the on-board LED can still be used.

Mike McCauley

unread,
Apr 13, 2014, 8:06:29 PM4/13/14
to rf22-a...@googlegroups.com
Hi,


On Sunday, April 13, 2014 05:03:48 PM stevech wrote:
> Yes, it is.
> Also, the code below remaps the SPI port clock to a different pin so that
> the on-board LED can still be used.

OK, but it will work with pin 13 if that code is not present?
Reply all
Reply to author
Forward
0 new messages