Skip to content

Commit f934a59

Browse files
committed
Merge remote-tracking branch 'origin/debugUpdates' into no_32k_crystal
2 parents 1f96ff2 + d0263d7 commit f934a59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4728
-8922
lines changed

cores/arduino/USB/PluggableUSBSerial.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ class USBSerial: public USBCDC, public ::mbed::Stream, public HardwareSerial {
157157
{
158158
USBCDC::lock();
159159

160-
if ((mptr != NULL) && (tptr != NULL)) {
161-
rx[howManyCallbacks++] = ::mbed::Callback<void()>(mptr, tptr);
160+
if ((mptr != NULL) && (tptr != NULL) && (_howManyCallbacks < sizeof(_rx)/sizeof(_rx[0]))) {
161+
_rx[_howManyCallbacks++] = ::mbed::Callback<void()>(mptr, tptr);
162162
}
163163

164164
USBCDC::unlock();
@@ -173,8 +173,8 @@ class USBSerial: public USBCDC, public ::mbed::Stream, public HardwareSerial {
173173
{
174174
USBCDC::lock();
175175

176-
if (fptr != NULL) {
177-
rx[howManyCallbacks++] = ::mbed::Callback<void()>(fptr);
176+
if ((fptr != NULL) && (_howManyCallbacks < sizeof(_rx)/sizeof(_rx[0]))) {
177+
_rx[_howManyCallbacks++] = ::mbed::Callback<void()>(fptr);
178178
}
179179

180180
USBCDC::unlock();
@@ -189,7 +189,9 @@ class USBSerial: public USBCDC, public ::mbed::Stream, public HardwareSerial {
189189
{
190190
USBCDC::lock();
191191

192-
rx[howManyCallbacks++] = cb;
192+
if (_howManyCallbacks < sizeof(_rx)/sizeof(_rx[0])) {
193+
_rx[_howManyCallbacks++] = cb;
194+
}
193195

194196
USBCDC::unlock();
195197
}
@@ -219,14 +221,17 @@ class USBSerial: public USBCDC, public ::mbed::Stream, public HardwareSerial {
219221
}
220222

221223
int available(void) {
224+
onInterrupt();
222225
return rx_buffer.available();
223226
}
224227

225228
int peek(void) {
229+
onInterrupt();
226230
return rx_buffer.peek();
227231
}
228232

229233
int read(void) {
234+
onInterrupt();
230235
return rx_buffer.read_char();
231236
}
232237

@@ -273,9 +278,9 @@ class USBSerial: public USBCDC, public ::mbed::Stream, public HardwareSerial {
273278
}
274279

275280
private:
276-
::mbed::Callback<void()> rx[MAX_CALLBACKS_ON_IRQ];
277-
int howManyCallbacks = 0;
278281
void (*_settings_changed_callback)(int baud, int bits, int parity, int stop);
282+
::mbed::Callback<void()> _rx[MAX_CALLBACKS_ON_IRQ];
283+
size_t _howManyCallbacks = 0;
279284
};
280285
}
281286

cores/arduino/USB/USBSerial.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,12 @@ void USBSerial::data_rx()
9595
USBCDC::assert_locked();
9696

9797
//call a potential handler
98-
int i = 0;
99-
while (i < howManyCallbacks) {
100-
if (rx[i]) {
101-
rx[i].call();
98+
for (size_t i = 0 ; i < _howManyCallbacks ; i++) {
99+
if (_rx[i]) {
100+
_rx[i].call();
102101
} else {
103102
break;
104103
}
105-
i++;
106104
}
107105
}
108106

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* This example demonstrates how to utilize the KernelDebug library which
2+
allows kernel debugging of the Portenta H7 with GDB over a UART serial
3+
connection.
4+
*/
5+
6+
#include <KernelDebug.h>
7+
8+
KernelDebug kernelDebug(SERIAL1_TX, SERIAL1_RX, USART1_IRQn, 230400, DEBUG_BREAK_IN_SETUP);
9+
10+
void setup() {
11+
12+
}
13+
14+
void loop() {
15+
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=KernelDebug
2+
version=1.0.0
3+
author=Adam Green <adamgreen@users.noreply.github.com>
4+
maintainer=Arduino <info@arduino.cc>
5+
sentence=The GDB compatible kernel debug monitor for Cortex-M devices.
6+
paragraph=KernelDebug is a debug monitor which allows the GNU debugger, GDB, to kernel debug applications running in both handler and thread modes using a full featured source level debugger with no extra hardware other than a UART serial connection.
7+
category=Communication
8+
url=
9+
architectures=mbed

0 commit comments

Comments
 (0)