SX1272Lib updated in order to be RTOS aware
Fork of SX1272Lib by
Since Semtech original SX1272 library used InterruptIn and Timout mbed-os classes, whose ISRs are not allowed to lock RTOS mutexes, any SPI-related operation was doomed to fail. Indeed, SPI transactions functions are always nested inside a spi-level mutex lock/unlock pair in order to provide for thread access safety. A typical case occurs for example when radio is set to sleep state after a RX timeout.
This fork solves such problems by mean of a EventQueue/Thread pair, where any InterruptIn and Timeout ISRs actually enqueue callback calls.
Take a look at usage example at https://github.com/maiorfi/mbedos_lablet_lora_1
Revision 11:866b939cf709, committed 2018-03-03
- Comitter:
- Lorenzo Maiorfi
- Date:
- Sat Mar 03 18:07:30 2018 +0100
- Parent:
- 10:bd29cdff8f3e
- Commit message:
- Fix debug
Changed in this revision
diff -r bd29cdff8f3e -r 866b939cf709 debug/sx1272-debug.h --- a/debug/sx1272-debug.h Sat Feb 24 08:47:30 2018 +0100 +++ b/debug/sx1272-debug.h Sat Mar 03 18:07:30 2018 +0100 @@ -21,7 +21,7 @@ /** @file debug.h */ -#ifndef NDEBUG +#ifdef SX127x_DEBUG_ENABLED #include <stdarg.h> #include <stdio.h>
diff -r bd29cdff8f3e -r 866b939cf709 sx1272/sx1272-hal.cpp --- a/sx1272/sx1272-hal.cpp Sat Feb 24 08:47:30 2018 +0100 +++ b/sx1272/sx1272-hal.cpp Sat Mar 03 18:07:30 2018 +0100 @@ -179,7 +179,7 @@ nss = 1; spi.format( 8,0 ); uint32_t frequencyToSet = 8000000; - #if( defined ( TARGET_NUCLEO_L152RE ) || defined ( TARGET_MOTE_L152RC ) || defined ( TARGET_NUCLEO_L476RG ) || defined ( TARGET_LPC11U6X ) || defined ( TARGET_MTS_MDOT_F411RE ) ) + #if( defined ( TARGET_NUCLEO_L152RE ) || defined ( TARGET_MOTE_L152RC ) || defined ( TARGET_NUCLEO_L476RG ) || defined ( TARGET_LPC11U6X ) || defined ( TARGET_MTS_MDOT_F411RE ) || defined ( TARGET_NUCLEO_L073RZ )) spi.frequency( frequencyToSet ); #elif( defined ( TARGET_KL25Z ) ) //busclock frequency is halved -> double the spi frequency to compensate spi.frequency( frequencyToSet * 2 );
diff -r bd29cdff8f3e -r 866b939cf709 sx1272/sx1272.h --- a/sx1272/sx1272.h Sat Feb 24 08:47:30 2018 +0100 +++ b/sx1272/sx1272.h Sat Mar 03 18:07:30 2018 +0100 @@ -99,7 +99,7 @@ static const FskBandwidth_t FskBandwidths[]; // <RTOS> - Thread* _thread_events_queue; + //Thread* _thread_events_queue; EventQueue* _eq_events; // </RTOS> @@ -120,7 +120,7 @@ virtual ~SX1272( ); // <RTOS> - void assign_events_queue_thread(Thread* thread) {_thread_events_queue=thread;} + //void assign_events_queue_thread(Thread* thread) {_thread_events_queue=thread;} void assign_events_queue(EventQueue* event_queue) {_eq_events=event_queue;} // </RTOS>