Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
.DS_Store
*.swp
/Output

# Ignore local overrides of platform.txt and boards.txt,
/boards.local.txt
/platform.local.txt
16 changes: 7 additions & 9 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ feather52832.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
feather52832.menu.debug.l2=Level 2 (Full Debug)
feather52832.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
feather52832.menu.debug.l3=Level 3 (Segger SystemView)
feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
feather52832.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -DCFG_SYSVIEW=0xFFFFFFFF

# ----------------------------------
# Bluefruit Feather nRF52840 Express
Expand Down Expand Up @@ -110,8 +110,7 @@ feather52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
feather52840.menu.debug.l2=Level 2 (Full Debug)
feather52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
feather52840.menu.debug.l3=Level 3 (Segger SystemView)
feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3

feather52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -DCFG_SYSVIEW=0xFFFFFFFF

# ----------------------------------
# Bluefruit ItsyBitsy nRF52840 Express
Expand Down Expand Up @@ -164,7 +163,7 @@ itsybitsy52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
itsybitsy52840.menu.debug.l2=Level 2 (Full Debug)
itsybitsy52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
itsybitsy52840.menu.debug.l3=Level 3 (Segger SystemView)
itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
itsybitsy52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -DCFG_SYSVIEW=0xFFFFFFFF

# ---------------------------------------------
# Bluefruit Circuit Playground nRF52840 Express
Expand Down Expand Up @@ -217,7 +216,7 @@ cplaynrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
cplaynrf52840.menu.debug.l2=Level 2 (Full Debug)
cplaynrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
cplaynrf52840.menu.debug.l3=Level 3 (Segger SystemView)
cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
cplaynrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -DCFG_SYSVIEW=0xFFFFFFFF


# ---------------------------------------------
Expand Down Expand Up @@ -271,7 +270,7 @@ cluenrf52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
cluenrf52840.menu.debug.l2=Level 2 (Full Debug)
cluenrf52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
cluenrf52840.menu.debug.l3=Level 3 (Segger SystemView)
cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
cluenrf52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -DCFG_SYSVIEW=0xFFFFFFFF

# ----------------------------------
# Bluefruit Metro nRF52840 Express
Expand Down Expand Up @@ -324,7 +323,7 @@ metro52840.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
metro52840.menu.debug.l2=Level 2 (Full Debug)
metro52840.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
metro52840.menu.debug.l3=Level 3 (Segger SystemView)
metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3
metro52840.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -DCFG_SYSVIEW=0xFFFFFFFF

# ----------------------------------
# Nordic nRF52840DK (PCA10056)
Expand Down Expand Up @@ -420,5 +419,4 @@ mdbt50qrx.menu.debug.l1.build.debug_flags=-DCFG_DEBUG=1
mdbt50qrx.menu.debug.l2=Level 2 (Full Debug)
mdbt50qrx.menu.debug.l2.build.debug_flags=-DCFG_DEBUG=2
mdbt50qrx.menu.debug.l3=Level 3 (Segger SystemView)
mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3

mdbt50qrx.menu.debug.l3.build.debug_flags=-DCFG_DEBUG=3 -DCFG_SYSVIEW=0xFFFFFFFF
5 changes: 5 additions & 0 deletions cores/nRF5/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void suspendLoop(void);
#include "Tone.h"
#include "WMath.h"
#include "HardwareSerial.h"
#include "SeggerRTTSerial.h"
#include "pulse.h"
#include "HardwarePWM.h"
#include "utility/SoftwareTimer.h"
Expand Down Expand Up @@ -80,6 +81,10 @@ void suspendLoop(void);
#include "wiring_shift.h"
#include "WInterrupts.h"

#ifdef __cplusplus
extern Stream& Adalog_Default_Logger;
#endif

// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
Expand Down
71 changes: 71 additions & 0 deletions cores/nRF5/SeggerRTTSerial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2020 by SimpleHacks, Henry Gabryjelski
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#include <SeggerRTTSerial.h>
#include <SEGGER_Extensions.h>


size_t Segger_RTT_Serial_t::write(uint8_t b) {
return SEGGER_RTT_PutChar(0, (char)b);
}
size_t Segger_RTT_Serial_t::write(const uint8_t *buffer, size_t size) {
return SEGGER_RTT_Write(0, buffer, size);
}
int Segger_RTT_Serial_t::availableForWrite() {
return SEGGER_RTT_GetAvailWriteSpace(0);
}
int Segger_RTT_Serial_t::available() { // to read
return SEGGER_RTT_HasData(0);
}
int Segger_RTT_Serial_t::read() {
return SEGGER_RTT_GetKey();
}
int Segger_RTT_Serial_t::peek() {
return SEGGER_RTT_Peek();
}
void Segger_RTT_Serial_t::flush() {
// no-op -- cannot flush as cannot control host
}
// Baud and config are ignored for RTT
void Segger_RTT_Serial_t::begin (uint32_t baud)
{
(void) baud;
}
void Segger_RTT_Serial_t::begin (uint32_t baud, uint8_t config)
{
(void) baud;
(void) config;
}
void Segger_RTT_Serial_t::end(void)
{
// nothing to do
}
Segger_RTT_Serial_t::operator bool()
{
return true;
}



76 changes: 76 additions & 0 deletions cores/nRF5/SeggerRTTSerial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2020 by SimpleHacks, Henry Gabryjelski
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#ifndef SeggerRTTSerial_h
#define SeggerRTTSerial_h

//#include "Arduino.h"
#include <stdint.h>
#include <Stream.h>
#include <SEGGER_RTT.h>
#include <SEGGER_Extensions.h>

class Segger_RTT_Serial_t : public Stream {
public:
virtual size_t write(uint8_t b) override;
virtual size_t write(const uint8_t *buffer, size_t size) override;
virtual int availableForWrite() override;
virtual int available() override;
virtual int read() override;
virtual int peek() override;
virtual void flush() override;
// Additional non-virtual functions to emulate `Serial`
operator bool();
void begin(uint32_t baud);
void begin(uint32_t baud, uint8_t config);
void end(void);
};

// Segger RTT allows for multiple virtual terminals
// via channel 0 ... but note that this will add
// 4 bytes RTT buffer overhead to each call to write().
template <unsigned char TerminalId>
class Segger_RTT_Terminal_t : public Segger_RTT_Serial_t {
private:
static_assert(TerminalId < SEGGER_RTT_NUMBER_OF_TERMINALS, "TerminalID must be less than SEGGER_RTT_NUMBER_OF_TERMINALS" );
public:
virtual size_t write(uint8_t b) override {
return SEGGER_RTT_TerminalOutBuffer(TerminalId, &b, 1);
}
virtual size_t write(const uint8_t *buffer, size_t size) override {
return SEGGER_RTT_TerminalOutBuffer(TerminalId, buffer, size);
}
virtual int availableForWrite() override {
int result = SEGGER_RTT_GetAvailWriteSpace(0);
if (result > SEGGER_RTT_TERMINAL_OUT_OVERHEAD) {
result -= SEGGER_RTT_TERMINAL_OUT_OVERHEAD;
} else if (result > 0) {
result = 0;
}
return result;
}
};

#endif // #ifndef SeggerRTTSerial_h
4 changes: 2 additions & 2 deletions cores/nRF5/WInterrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void detachInterrupt(uint32_t pin)

void GPIOTE_IRQHandler()
{
#if CFG_DEBUG >= 3
#if CFG_SYSVIEW
SEGGER_SYSVIEW_RecordEnterISR();
#endif

Expand All @@ -171,7 +171,7 @@ void GPIOTE_IRQHandler()
event = (uint32_t)((uint32_t)event + 4);
}

#if CFG_DEBUG >= 3
#if CFG_SYSVIEW
SEGGER_SYSVIEW_RecordExitISR();
#endif
}
Loading