From 622d50b56df04bea93234b005f1825dd26386c1d Mon Sep 17 00:00:00 2001 From: Hasnain Virk Date: Fri, 15 Dec 2017 10:50:24 +0200 Subject: [PATCH] Removing namespace pollution & rf ctrls refactor rf_ctrls is a data structure that holds all control pins for a certain LoRa Radio. Same data structure was being used in both SX1272 and SX1276 drivers. As we are heading towards putting both drivers in the same repo and as the plan is to use them togather, i.e., both header files could be included we need to move this data structure to a common location so that the name does not collide. In addition to that we have tried to reduce namespace pollution caused by the driver header files. --- SX1272/SX1272_LoRaRadio.h | 57 +++++++++++++++++++------------------ SX1276/SX1276_LoRaRadio.h | 60 +++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/SX1272/SX1272_LoRaRadio.h b/SX1272/SX1272_LoRaRadio.h index c99d2372071..05a2ad89f70 100644 --- a/SX1272/SX1272_LoRaRadio.h +++ b/SX1272/SX1272_LoRaRadio.h @@ -26,23 +26,24 @@ SPDX-License-Identifier: BSD-3-Clause #ifndef SX1272_LORARADIO_H_ #define SX1272_LORARADIO_H_ +#include "PinNames.h" +#include "InterruptIn.h" +#include "DigitalOut.h" +#include "DigitalInOut.h" +#include "SPI.h" +#include "Timeout.h" +#ifdef MBED_CONF_RTOS_PRESENT + #include "rtos/Thread.h" +#endif #include "netsocket/LoRaRadio.h" + #ifdef MBED_SX1272_LORARADIO_BUFFER_SIZE #define MAX_DATA_BUFFER_SIZE MBED_SX1272_LORARADIO_BUFFER_SIZE #else #define MAX_DATA_BUFFER_SIZE 256 #endif -typedef struct { - PinName rf_switch_ctl1; - PinName rf_switch_ctl2; - PinName txctl; - PinName rxctl; - PinName ant_switch; - PinName pwr_amp_ctl; -} rf_ctrls; - /** * Radio driver implementation for Semtech SX1272 plus variants. * Supports only SPI at the moment. Implements pure virtual LoRaRadio class. @@ -301,27 +302,27 @@ class SX1272_LoRaRadio: public LoRaRadio { private: // SPI and chip select control - SPI _spi; - DigitalOut _chip_select; + mbed::SPI _spi; + mbed::DigitalOut _chip_select; // module rest control - DigitalInOut _reset_ctl; + mbed::DigitalInOut _reset_ctl; // Interrupt controls - InterruptIn _dio0_ctl; - InterruptIn _dio1_ctl; - InterruptIn _dio2_ctl; - InterruptIn _dio3_ctl; - InterruptIn _dio4_ctl; - InterruptIn _dio5_ctl; + mbed::InterruptIn _dio0_ctl; + mbed::InterruptIn _dio1_ctl; + mbed::InterruptIn _dio2_ctl; + mbed::InterruptIn _dio3_ctl; + mbed::InterruptIn _dio4_ctl; + mbed::InterruptIn _dio5_ctl; // Radio specific controls - DigitalOut _rf_switch_ctl1; - DigitalOut _rf_switch_ctl2; - DigitalOut _txctl; - DigitalOut _rxctl; - DigitalInOut _ant_switch; - DigitalOut _pwr_amp_ctl; + mbed::DigitalOut _rf_switch_ctl1; + mbed::DigitalOut _rf_switch_ctl2; + mbed::DigitalOut _txctl; + mbed::DigitalOut _rxctl; + mbed::DigitalInOut _ant_switch; + mbed::DigitalOut _pwr_amp_ctl; // Contains all RF control pin names // This storage is needed even after assigning the @@ -343,13 +344,13 @@ class SX1272_LoRaRadio: public LoRaRadio { uint8_t _data_buffer[MAX_DATA_BUFFER_SIZE]; // TX/RX Timers - all use milisecond units - Timeout tx_timeout_timer; - Timeout rx_timeout_timer; - Timeout rx_timeout_sync_word; + mbed::Timeout tx_timeout_timer; + mbed::Timeout rx_timeout_timer; + mbed::Timeout rx_timeout_sync_word; #ifdef MBED_CONF_RTOS_PRESENT // Thread to handle interrupts - Thread irq_thread; + rtos::Thread irq_thread; #endif // Access protection diff --git a/SX1276/SX1276_LoRaRadio.h b/SX1276/SX1276_LoRaRadio.h index 79fd476c28b..6c3489d54a7 100644 --- a/SX1276/SX1276_LoRaRadio.h +++ b/SX1276/SX1276_LoRaRadio.h @@ -26,6 +26,15 @@ SPDX-License-Identifier: BSD-3-Clause #ifndef SX1276_LORARADIO_H_ #define SX1276_LORARADIO_H_ +#include "PinNames.h" +#include "InterruptIn.h" +#include "DigitalOut.h" +#include "DigitalInOut.h" +#include "SPI.h" +#include "Timeout.h" +#ifdef MBED_CONF_RTOS_PRESENT + #include "rtos/Thread.h" +#endif #include "netsocket/LoRaRadio.h" #ifdef MBED_SX1276_LORARADIO_BUFFER_SIZE @@ -34,16 +43,6 @@ SPDX-License-Identifier: BSD-3-Clause #define MAX_DATA_BUFFER_SIZE 256 #endif -typedef struct { - PinName rf_switch_ctl1; - PinName rf_switch_ctl2; - PinName txctl; - PinName rxctl; - PinName ant_switch; - PinName pwr_amp_ctl; - PinName tcxo; -} rf_ctrls; - /** * Radio driver implementation for Semtech SX1272 plus variants. * Supports only SPI at the moment. Implements pure virtual LoRaRadio class. @@ -318,28 +317,28 @@ class SX1276_LoRaRadio: public LoRaRadio { private: // SPI and chip select control - SPI _spi; - DigitalOut _chip_select; + mbed::SPI _spi; + mbed::DigitalOut _chip_select; // module rest control - DigitalInOut _reset_ctl; + mbed::DigitalInOut _reset_ctl; // Interrupt controls - InterruptIn _dio0_ctl; - InterruptIn _dio1_ctl; - InterruptIn _dio2_ctl; - InterruptIn _dio3_ctl; - InterruptIn _dio4_ctl; - InterruptIn _dio5_ctl; + mbed::InterruptIn _dio0_ctl; + mbed::InterruptIn _dio1_ctl; + mbed::InterruptIn _dio2_ctl; + mbed::InterruptIn _dio3_ctl; + mbed::InterruptIn _dio4_ctl; + mbed::InterruptIn _dio5_ctl; // Radio specific controls - DigitalOut _rf_switch_ctl1; - DigitalOut _rf_switch_ctl2; - DigitalOut _txctl; - DigitalOut _rxctl; - DigitalInOut _ant_switch; - DigitalOut _pwr_amp_ctl; - DigitalOut _tcxo; + mbed::DigitalOut _rf_switch_ctl1; + mbed::DigitalOut _rf_switch_ctl2; + mbed::DigitalOut _txctl; + mbed::DigitalOut _rxctl; + mbed::DigitalInOut _ant_switch; + mbed::DigitalOut _pwr_amp_ctl; + mbed::DigitalOut _tcxo; // Contains all RF control pin names // This storage is needed even after assigning the @@ -361,13 +360,13 @@ class SX1276_LoRaRadio: public LoRaRadio { uint8_t _data_buffer[MAX_DATA_BUFFER_SIZE]; // TX/RX Timers - all use milisecond units - Timeout tx_timeout_timer; - Timeout rx_timeout_timer; - Timeout rx_timeout_sync_word; + mbed::Timeout tx_timeout_timer; + mbed::Timeout rx_timeout_timer; + mbed::Timeout rx_timeout_sync_word; #ifdef MBED_CONF_RTOS_PRESENT // Thread to handle interrupts - Thread irq_thread; + rtos::Thread irq_thread; #endif // Access protection @@ -419,6 +418,5 @@ class SX1276_LoRaRadio: public LoRaRadio { void handle_dio4_irq(); void handle_dio5_irq(); void handle_timeout_irq(); -}; #endif // SX1276_LORARADIO_H_