Page 1 of 1

Adapting other libraries with ChibiOS

Posted: Sat Feb 27, 2016 10:53 pm
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 :)

Re: Adapting other libraries with ChibiOS

Posted: Wed Mar 02, 2016 1:13 am
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

Re: Adapting other libraries with ChibiOS

Posted: Sun Mar 06, 2016 3:30 pm
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?

Re: Adapting other libraries with ChibiOS

Posted: Mon Mar 07, 2016 5:49 pm
by utzig
Yes, Nil is more lightweight than ChibiOS/RT. What do you mean by "atomic" radio operations?

Re: Adapting other libraries with ChibiOS

Posted: Wed Mar 09, 2016 4:51 pm
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...

Re: Adapting other libraries with ChibiOS

Posted: Thu Mar 10, 2016 1:50 am
by utzig
You would probably not need to do that, but it should also not stop anything from working just cause extra latency.