Skip to content

Commit d7e60e4

Browse files
author
Hasnain Virk
authored
Merge pull request #1 from ARMmbed/ns_pollution
Removing namespace pollution & rf ctrls refactor
2 parents 0d53676 + 622d50b commit d7e60e4

File tree

2 files changed

+58
-59
lines changed

2 files changed

+58
-59
lines changed

SX1272/SX1272_LoRaRadio.h

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,24 @@ SPDX-License-Identifier: BSD-3-Clause
2626
#ifndef SX1272_LORARADIO_H_
2727
#define SX1272_LORARADIO_H_
2828

29+
#include "PinNames.h"
30+
#include "InterruptIn.h"
31+
#include "DigitalOut.h"
32+
#include "DigitalInOut.h"
33+
#include "SPI.h"
34+
#include "Timeout.h"
35+
#ifdef MBED_CONF_RTOS_PRESENT
36+
#include "rtos/Thread.h"
37+
#endif
2938
#include "netsocket/LoRaRadio.h"
3039

40+
3141
#ifdef MBED_SX1272_LORARADIO_BUFFER_SIZE
3242
#define MAX_DATA_BUFFER_SIZE MBED_SX1272_LORARADIO_BUFFER_SIZE
3343
#else
3444
#define MAX_DATA_BUFFER_SIZE 256
3545
#endif
3646

37-
typedef struct {
38-
PinName rf_switch_ctl1;
39-
PinName rf_switch_ctl2;
40-
PinName txctl;
41-
PinName rxctl;
42-
PinName ant_switch;
43-
PinName pwr_amp_ctl;
44-
} rf_ctrls;
45-
4647
/**
4748
* Radio driver implementation for Semtech SX1272 plus variants.
4849
* Supports only SPI at the moment. Implements pure virtual LoRaRadio class.
@@ -301,27 +302,27 @@ class SX1272_LoRaRadio: public LoRaRadio {
301302
private:
302303

303304
// SPI and chip select control
304-
SPI _spi;
305-
DigitalOut _chip_select;
305+
mbed::SPI _spi;
306+
mbed::DigitalOut _chip_select;
306307

307308
// module rest control
308-
DigitalInOut _reset_ctl;
309+
mbed::DigitalInOut _reset_ctl;
309310

310311
// Interrupt controls
311-
InterruptIn _dio0_ctl;
312-
InterruptIn _dio1_ctl;
313-
InterruptIn _dio2_ctl;
314-
InterruptIn _dio3_ctl;
315-
InterruptIn _dio4_ctl;
316-
InterruptIn _dio5_ctl;
312+
mbed::InterruptIn _dio0_ctl;
313+
mbed::InterruptIn _dio1_ctl;
314+
mbed::InterruptIn _dio2_ctl;
315+
mbed::InterruptIn _dio3_ctl;
316+
mbed::InterruptIn _dio4_ctl;
317+
mbed::InterruptIn _dio5_ctl;
317318

318319
// Radio specific controls
319-
DigitalOut _rf_switch_ctl1;
320-
DigitalOut _rf_switch_ctl2;
321-
DigitalOut _txctl;
322-
DigitalOut _rxctl;
323-
DigitalInOut _ant_switch;
324-
DigitalOut _pwr_amp_ctl;
320+
mbed::DigitalOut _rf_switch_ctl1;
321+
mbed::DigitalOut _rf_switch_ctl2;
322+
mbed::DigitalOut _txctl;
323+
mbed::DigitalOut _rxctl;
324+
mbed::DigitalInOut _ant_switch;
325+
mbed::DigitalOut _pwr_amp_ctl;
325326

326327
// Contains all RF control pin names
327328
// This storage is needed even after assigning the
@@ -343,13 +344,13 @@ class SX1272_LoRaRadio: public LoRaRadio {
343344
uint8_t _data_buffer[MAX_DATA_BUFFER_SIZE];
344345

345346
// TX/RX Timers - all use milisecond units
346-
Timeout tx_timeout_timer;
347-
Timeout rx_timeout_timer;
348-
Timeout rx_timeout_sync_word;
347+
mbed::Timeout tx_timeout_timer;
348+
mbed::Timeout rx_timeout_timer;
349+
mbed::Timeout rx_timeout_sync_word;
349350

350351
#ifdef MBED_CONF_RTOS_PRESENT
351352
// Thread to handle interrupts
352-
Thread irq_thread;
353+
rtos::Thread irq_thread;
353354
#endif
354355

355356
// Access protection

SX1276/SX1276_LoRaRadio.h

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ SPDX-License-Identifier: BSD-3-Clause
2626
#ifndef SX1276_LORARADIO_H_
2727
#define SX1276_LORARADIO_H_
2828

29+
#include "PinNames.h"
30+
#include "InterruptIn.h"
31+
#include "DigitalOut.h"
32+
#include "DigitalInOut.h"
33+
#include "SPI.h"
34+
#include "Timeout.h"
35+
#ifdef MBED_CONF_RTOS_PRESENT
36+
#include "rtos/Thread.h"
37+
#endif
2938
#include "netsocket/LoRaRadio.h"
3039

3140
#ifdef MBED_SX1276_LORARADIO_BUFFER_SIZE
@@ -34,16 +43,6 @@ SPDX-License-Identifier: BSD-3-Clause
3443
#define MAX_DATA_BUFFER_SIZE 256
3544
#endif
3645

37-
typedef struct {
38-
PinName rf_switch_ctl1;
39-
PinName rf_switch_ctl2;
40-
PinName txctl;
41-
PinName rxctl;
42-
PinName ant_switch;
43-
PinName pwr_amp_ctl;
44-
PinName tcxo;
45-
} rf_ctrls;
46-
4746
/**
4847
* Radio driver implementation for Semtech SX1272 plus variants.
4948
* Supports only SPI at the moment. Implements pure virtual LoRaRadio class.
@@ -318,28 +317,28 @@ class SX1276_LoRaRadio: public LoRaRadio {
318317
private:
319318

320319
// SPI and chip select control
321-
SPI _spi;
322-
DigitalOut _chip_select;
320+
mbed::SPI _spi;
321+
mbed::DigitalOut _chip_select;
323322

324323
// module rest control
325-
DigitalInOut _reset_ctl;
324+
mbed::DigitalInOut _reset_ctl;
326325

327326
// Interrupt controls
328-
InterruptIn _dio0_ctl;
329-
InterruptIn _dio1_ctl;
330-
InterruptIn _dio2_ctl;
331-
InterruptIn _dio3_ctl;
332-
InterruptIn _dio4_ctl;
333-
InterruptIn _dio5_ctl;
327+
mbed::InterruptIn _dio0_ctl;
328+
mbed::InterruptIn _dio1_ctl;
329+
mbed::InterruptIn _dio2_ctl;
330+
mbed::InterruptIn _dio3_ctl;
331+
mbed::InterruptIn _dio4_ctl;
332+
mbed::InterruptIn _dio5_ctl;
334333

335334
// Radio specific controls
336-
DigitalOut _rf_switch_ctl1;
337-
DigitalOut _rf_switch_ctl2;
338-
DigitalOut _txctl;
339-
DigitalOut _rxctl;
340-
DigitalInOut _ant_switch;
341-
DigitalOut _pwr_amp_ctl;
342-
DigitalOut _tcxo;
335+
mbed::DigitalOut _rf_switch_ctl1;
336+
mbed::DigitalOut _rf_switch_ctl2;
337+
mbed::DigitalOut _txctl;
338+
mbed::DigitalOut _rxctl;
339+
mbed::DigitalInOut _ant_switch;
340+
mbed::DigitalOut _pwr_amp_ctl;
341+
mbed::DigitalOut _tcxo;
343342

344343
// Contains all RF control pin names
345344
// This storage is needed even after assigning the
@@ -361,13 +360,13 @@ class SX1276_LoRaRadio: public LoRaRadio {
361360
uint8_t _data_buffer[MAX_DATA_BUFFER_SIZE];
362361

363362
// TX/RX Timers - all use milisecond units
364-
Timeout tx_timeout_timer;
365-
Timeout rx_timeout_timer;
366-
Timeout rx_timeout_sync_word;
363+
mbed::Timeout tx_timeout_timer;
364+
mbed::Timeout rx_timeout_timer;
365+
mbed::Timeout rx_timeout_sync_word;
367366

368367
#ifdef MBED_CONF_RTOS_PRESENT
369368
// Thread to handle interrupts
370-
Thread irq_thread;
369+
rtos::Thread irq_thread;
371370
#endif
372371

373372
// Access protection
@@ -419,6 +418,5 @@ class SX1276_LoRaRadio: public LoRaRadio {
419418
void handle_dio4_irq();
420419
void handle_dio5_irq();
421420
void handle_timeout_irq();
422-
};
423421

424422
#endif // SX1276_LORARADIO_H_

0 commit comments

Comments
 (0)