From 7aaa1dc85d932ec667ac14d49912f2da6f5bbffe Mon Sep 17 00:00:00 2001
From: Federico Terraneo <fede.tft@miosix.org>
Date: Sun, 14 May 2017 12:18:09 +0200
Subject: [PATCH] Cleanup: removed using namespace from header files

---
 src/entrypoints/dma-lowlevel-test.cpp |  3 +++
 src/shared/canbus/CanBus.cpp          |  3 +++
 src/shared/canbus/CanBus.h            |  9 +++------
 src/shared/canbus/CanInterrupt.cpp    |  2 ++
 src/shared/canbus/CanManager.cpp      |  3 +++
 src/shared/canbus/CanManager.h        | 17 ++++++-----------
 src/shared/sensors/ADC.h              |  8 ++++----
 7 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/entrypoints/dma-lowlevel-test.cpp b/src/entrypoints/dma-lowlevel-test.cpp
index aab6ff58f..9b6befc63 100644
--- a/src/entrypoints/dma-lowlevel-test.cpp
+++ b/src/entrypoints/dma-lowlevel-test.cpp
@@ -1,4 +1,5 @@
 
+
 #include <sensors/iNemo.h>
 #include <sensors/FXAS21002.h>
 #include <sensors/MPU9250.h>
@@ -21,6 +22,8 @@ typedef ProtocolSPI<busSPI1, Gpio<GPIOG_BASE,  9>> spiINEMOG;
 typedef MPU9250<spiMPU9250> mpu_t;
 typedef iNEMOLSM9DS0<spiINEMOG,spiINEMOA> inemo_t;
 
+typedef SensorADC<0,0,Gpio<GPIOA_BASE,0>> adc1;
+
 int main()
 {
     puts("\n\n---");
diff --git a/src/shared/canbus/CanBus.cpp b/src/shared/canbus/CanBus.cpp
index 452d3ca63..9799d202b 100644
--- a/src/shared/canbus/CanBus.cpp
+++ b/src/shared/canbus/CanBus.cpp
@@ -36,6 +36,9 @@ TODO:
 #include "CanSocket.h"
 #include "CanUtils.h"
 
+using namespace miosix;
+using std::set;
+
 // Transmit mailbox request
 #define TMIDxR_TXRQ       ((uint32_t)0x00000001) 
 
diff --git a/src/shared/canbus/CanBus.h b/src/shared/canbus/CanBus.h
index 93b093a77..618eaf049 100644
--- a/src/shared/canbus/CanBus.h
+++ b/src/shared/canbus/CanBus.h
@@ -28,15 +28,12 @@
 #include <Common.h>
 #include "CanUtils.h"
 
-using namespace miosix;
-using std::set;
-
 class CanSocket;
 class CanManager;
 
 class CanBus {
     public:
-        Queue<CanMsg,6> messageQueue;
+        miosix::Queue<CanMsg,6> messageQueue;
 
         bool registerSocket(CanSocket *socket);
         bool unregisterSocket(CanSocket *socket);
@@ -59,8 +56,8 @@ class CanBus {
         CanManager* manager;
         const int id;
 
-        FastMutex mutex;
-        set<CanSocket *> socket_map[1 << 11];
+        miosix::FastMutex mutex;
+        std::set<CanSocket *> socket_map[1 << 11];
 
         volatile bool terminate;
         pthread_t t;
diff --git a/src/shared/canbus/CanInterrupt.cpp b/src/shared/canbus/CanInterrupt.cpp
index 261acc1c9..724cb5f6b 100644
--- a/src/shared/canbus/CanInterrupt.cpp
+++ b/src/shared/canbus/CanInterrupt.cpp
@@ -24,6 +24,8 @@
 
 #include "CanBus.h"
 
+using namespace miosix;
+
 CanBus * global_bus_ptr[2] = {NULL, NULL};
 uint32_t global_bus_ctr = 0;
 
diff --git a/src/shared/canbus/CanManager.cpp b/src/shared/canbus/CanManager.cpp
index f13e76623..aa77ee72f 100644
--- a/src/shared/canbus/CanManager.cpp
+++ b/src/shared/canbus/CanManager.cpp
@@ -24,6 +24,9 @@
 
 #include "CanManager.h"
 
+using namespace miosix;
+using namespace std;
+
 CanBus *CanManager::getBus(uint32_t id) {
     if(id >= bus.size())
         return NULL;
diff --git a/src/shared/canbus/CanManager.h b/src/shared/canbus/CanManager.h
index 91920cc5a..237eda2b0 100644
--- a/src/shared/canbus/CanManager.h
+++ b/src/shared/canbus/CanManager.h
@@ -30,11 +30,6 @@
 #include "CanUtils.h"
 #include "CanBus.h"
 
-using namespace miosix;
-using namespace std;
-
-using std::vector;
-using std::array;
 class CanBus;
 
 static const int8_t AF_NONE = -1;
@@ -54,7 +49,7 @@ struct canbus_init_t {
     const int8_t af;
 
     /** Array of interrupts */
-    const vector<IRQn_Type> interrupts;
+    const std::vector<IRQn_Type> interrupts;
 };  
 
 class CanManager {
@@ -67,8 +62,8 @@ class CanManager {
         
         template<uint32_t gpio, uint8_t rx, uint8_t tx>
         void addBus(const canbus_init_t& i) {
-            typedef Gpio<gpio, rx> rport;
-            typedef Gpio<gpio, tx> tport;
+            typedef miosix::Gpio<gpio, rx> rport;
+            typedef miosix::Gpio<gpio, tx> tport;
             
             rport::mode(i.mode);
             tport::mode(i.mode);
@@ -80,7 +75,7 @@ class CanManager {
 
             // TODO de-hardcode this part 
             {
-                FastInterruptDisableLock dLock;
+                miosix::FastInterruptDisableLock dLock;
                 RCC->APB1ENR |= RCC_APB1ENR_CAN1EN | RCC_APB1ENR_CAN2EN; 
                 RCC_SYNC();
             }
@@ -144,8 +139,8 @@ class CanManager {
         static constexpr int max_glob_filters = 2 * max_chan_filters;
 
     private:
-        map<uint16_t, uint8_t> filters[2];
-        vector<CanBus *> bus;
+        std::map<uint16_t, uint8_t> filters[2];
+        std::vector<CanBus *> bus;
 
         // TODO change "2" with number of available CAN buses
         uint16_t enabled_filters[2];
diff --git a/src/shared/sensors/ADC.h b/src/shared/sensors/ADC.h
index fd8157a89..5c49f24f3 100644
--- a/src/shared/sensors/ADC.h
+++ b/src/shared/sensors/ADC.h
@@ -23,7 +23,7 @@
 #include "Sensor.h"
 #include "Common.h"
 
-using namespace miosix;
+// using namespace miosix;
 
 template<unsigned N,unsigned CHANNEL, class GpioADC>
 class SensorADC  {
@@ -34,7 +34,7 @@ public:
     }
 
     bool init() {
-        GpioADC::mode(Mode::INPUT_ANALOG);
+        GpioADC::mode(miosix::Mode::INPUT_ANALOG);
         enableADC(ADCx);
 
         ADCx->SQR1 = 0x0; //One conversion
@@ -60,7 +60,7 @@ public:
     }
 
     static inline void enableADC(ADC_TypeDef* adc) {
-        FastInterruptDisableLock dLock;
+        miosix::FastInterruptDisableLock dLock;
 
         if(adc == ADC1){
             RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
@@ -88,7 +88,7 @@ public:
                     | ADC_CR2_CONT
                     | ADC_CR2_ADON;
 
-        Thread::sleep(10);
+        miosix::Thread::sleep(10);
         ADCx->CR2|=ADC_CR2_ADON; //Setting ADC ON twice starts a conversion
         while((ADCx->SR & ADC_SR_EOC)==0);
             last_value = ADCx->DR;
-- 
GitLab