Skip to content

Commit

Permalink
Replace using namespace in headers with explicit namespaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosperate committed Jan 1, 2023
1 parent 92341a8 commit 16dda9b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions inc/NRF52ADC.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ DEALINGS IN THE SOFTWARE.
//
#define NRF52_ADC_DATA_READY 1


using namespace codal;

//
// NRF52ADCChannel status codes
//
#define NRF52_ADC_CHANNEL_STATUS_ENABLED 0x10
#define NRF52_ADC_CHANNEL_STATUS_CONNECTED 0x20

namespace codal
{
class NRF52ADC;

class NRF52ADCChannel : public DataSource
Expand Down Expand Up @@ -329,5 +328,6 @@ class NRF52ADC : public CodalComponent
*/
void configureSampling();
};
} // namespace codal

#endif
4 changes: 3 additions & 1 deletion inc/NRF52PDM.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ DEALINGS IN THE SOFTWARE.
//
#define NRF52_PDM_BUFFER_SIZE 512

using namespace codal;
namespace codal
{

class NRF52PDM : public CodalComponent, public DataSource
{
Expand Down Expand Up @@ -103,5 +104,6 @@ class NRF52PDM : public CodalComponent, public DataSource

void startDMA();
};
} // namespace codal

#endif
7 changes: 6 additions & 1 deletion inc/NRF52PWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
#define NRF52PWM_PWM_PERIPHERALS 3
#define NRF52PWM_PWM_CHANNELS 4


// TODO: Currently other CODAL libraries depend on this global namespace to
// compile, once those are fixed `using namespace codal;` line can be removed
// https://github.com/lancaster-university/codal-nrf52/pull/43
using namespace codal;

namespace codal
{
class NRF52PWM : public CodalComponent, public DataSink
{

Expand Down Expand Up @@ -147,5 +151,6 @@ class NRF52PWM : public CodalComponent, public DataSink
int tryPull(uint8_t b);

};
} // namespace codal

#endif
3 changes: 3 additions & 0 deletions inc/neopixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
#include "NRF52PWM.h"
#include "WS2812B.h"

namespace codal
{
void neopixel_send_buffer(Pin &pin, const uint8_t *ptr, int numBytes);
void neopixel_send_buffer(Pin &pin, ManagedBuffer buffer);
}

#endif // CODAL_NEOPIXEL_H
2 changes: 2 additions & 0 deletions source/NRF52ADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ DEALINGS IN THE SOFTWARE.
#include "nrf.h"
#include "cmsis.h"

using namespace codal;

// Calculation to determine the optimal usable space for a DMA buffer for the given number of channels
#define NRF52ADC_DMA_ALIGNED_SIZED(c) ((bufferSize - (bufferSize % (c * 2 * softwareOversample)))/2);

Expand Down
2 changes: 2 additions & 0 deletions source/NRF52PDM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ DEALINGS IN THE SOFTWARE.
#include "NRF52PDM.h"
#include "nrf.h"

using namespace codal;

// Handle on the last (and probably only) instance of this class (NRF52 has only one PDM module)
static NRF52PDM *nrf52_pdm_driver = NULL;

Expand Down
2 changes: 2 additions & 0 deletions source/NRF52PWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "nrf.h"
#include "cmsis.h"

using namespace codal;

#define NRF52PWM_EMPTY_BUFFERSIZE 8
static uint16_t emptyBuffer[NRF52PWM_EMPTY_BUFFERSIZE];

Expand Down
4 changes: 3 additions & 1 deletion source/neopixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "neopixel.h"

using namespace codal;

#if CONFIG_ENABLED(HARDWARE_NEOPIXEL)

void neopixel_send_buffer(Pin &pin, const uint8_t *ptr, int numBytes)
Expand Down Expand Up @@ -88,5 +90,5 @@ __attribute__((noinline)) void neopixel_send_buffer(Pin &pin, const uint8_t *ptr

void neopixel_send_buffer(Pin &pin, ManagedBuffer buffer)
{
neopixel_send_buffer(pin, &buffer[0], buffer.length());
codal::neopixel_send_buffer(pin, &buffer[0], buffer.length());
}

0 comments on commit 16dda9b

Please sign in to comment.