Adapting other libraries with ChibiOS

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderators: utzig, tfAteba

gmj
Posts: 3
Joined: Sat Feb 27, 2016 10:17 pm

Adapting other libraries with ChibiOS

Postby gmj » Sat Feb 27, 2016 10:53 pm

Hi, I am using Arduino and nRF24l01+ radio for some tests of WSN projects. To use this radio, the best driver/library I have seen so far is tmrh20's ( https://github.com/TMRh20/RF24 ). Until now, I implemented my projects without any OS, but recently some mechanisms demanded preemption, mutual exclusion and threads would also be welcome :P, so I thought that using ChibiOS/RT or NIL would be useful.

Is there a way to use these OS with tmrh20's library without modifying it to use HAL?
Would it work if I executed the radio methods (which use SPI) as atomic operations, in order to keep using this library?

Thanks :)

utzig
Posts: 355
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: Adapting other libraries with ChibiOS

Postby utzig » Wed Mar 02, 2016 1:13 am

Your best bet would be to use:

https://github.com/greiman/ChibiOS-Arduino

The libraries would than work "as is". If you want to run natively you'll probably have to change your compiler from gcc to g++ and create some small adapter to glue the Arduino SPI calls to the HAL SPI.

Cheers,
Fabio Utzig

gmj
Posts: 3
Joined: Sat Feb 27, 2016 10:17 pm

Re: Adapting other libraries with ChibiOS

Postby gmj » Sun Mar 06, 2016 3:30 pm

Thanks for your reply utzig :)
Browsing through projects of Arduino RTOS I also found NilRTOS ( https://github.com/greiman/NilRTOS-Arduino ) from this same author, which I think would work the same way of ChibiOS Arduino but with less overhead, right?

As I have no experience with these OS yet, does anybody think this approach of doing radio calls "atomic" would work?

utzig
Posts: 355
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: Adapting other libraries with ChibiOS

Postby utzig » Mon Mar 07, 2016 5:49 pm

Yes, Nil is more lightweight than ChibiOS/RT. What do you mean by "atomic" radio operations?

gmj
Posts: 3
Joined: Sat Feb 27, 2016 10:17 pm

Re: Adapting other libraries with ChibiOS

Postby gmj » Wed Mar 09, 2016 4:51 pm

I mean to disable interrupts and preemption during radio operations like radio.write(), radio.read(), etc, so SPI operations are not interrupted and no further modification on the driver is necessary...

utzig
Posts: 355
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: Adapting other libraries with ChibiOS

Postby utzig » Thu Mar 10, 2016 1:50 am

You would probably not need to do that, but it should also not stop anything from working just cause extra latency.


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 1 guest