Adapting other libraries with ChibiOS

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

Moderator: tfAteba

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

Adapting other libraries with ChibiOS

Post by gmj »

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: 359
Joined: Sat Jan 07, 2012 6:22 pm
Has thanked: 1 time
Been thanked: 20 times

Re: Adapting other libraries with ChibiOS

Post by utzig »

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

Post by gmj »

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: 359
Joined: Sat Jan 07, 2012 6:22 pm
Has thanked: 1 time
Been thanked: 20 times

Re: Adapting other libraries with ChibiOS

Post by utzig »

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

Post by gmj »

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: 359
Joined: Sat Jan 07, 2012 6:22 pm
Has thanked: 1 time
Been thanked: 20 times

Re: Adapting other libraries with ChibiOS

Post by utzig »

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