Skip to content

Commit b2d98ed

Browse files
authored
Merge pull request adafruit#901 from tannewt/pulseio_too_fast
Prevent freezing USB during high frequency PulseIn.
2 parents 4e4d795 + 8fb34a5 commit b2d98ed

File tree

31 files changed

+608
-25
lines changed

31 files changed

+608
-25
lines changed

ports/atmel-samd/background.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@
2626
#include "background.h"
2727

2828
#include "audio_dma.h"
29+
#include "tick.h"
2930
#include "usb.h"
3031
#include "usb_mass_storage.h"
3132

33+
volatile uint64_t last_finished_tick = 0;
34+
3235
void run_background_tasks(void) {
3336
audio_dma_background();
3437
usb_msc_background();
3538
usb_cdc_background();
39+
last_finished_tick = ticks_ms;
40+
}
41+
42+
bool background_tasks_ok(void) {
43+
return ticks_ms - last_finished_tick < 1000;
3644
}

ports/atmel-samd/background.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_BACKGROUND_H
2828
#define MICROPY_INCLUDED_ATMEL_SAMD_BACKGROUND_H
2929

30+
#include <stdbool.h>
31+
3032
void run_background_tasks(void);
33+
bool background_tasks_ok(void);
3134

3235
#endif // MICROPY_INCLUDED_ATMEL_SAMD_BACKGROUND_H

ports/atmel-samd/bindings/samd/Clock.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,7 @@
4747
STATIC void samd_clock_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
4848
samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in);
4949

50-
mp_printf(print, "%q.%q.%s(", MP_QSTR_samd, MP_QSTR_clock, self->name);
51-
if (clock_get_enabled(self->type, self->index)) {
52-
mp_printf(print, "frequency=%u", clock_get_frequency(self->type, self->index));
53-
uint32_t calibration = clock_get_calibration(self->type, self->index);
54-
if (calibration) {
55-
mp_printf(print, ", calibration=%u", calibration);
56-
}
57-
}
58-
mp_printf(print, ")");
50+
mp_printf(print, "%q.%q.%q", MP_QSTR_samd, MP_QSTR_clock, self->name);
5951
}
6052

6153
//| .. attribute:: enabled

ports/atmel-samd/bindings/samd/Clock.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,39 @@
3131

3232
typedef struct {
3333
mp_obj_base_t base;
34-
const char *name;
34+
qstr name;
3535
uint8_t type;
3636
uint8_t index;
3737
} samd_clock_obj_t;
3838

3939
#define CLOCK(_name, _type, _index) \
4040
const samd_clock_obj_t clock_ ## _name = { \
4141
{ &samd_clock_type }, \
42-
.name = #_name, \
42+
.name = MP_QSTR_ ## _name, \
4343
.type = _type, \
4444
.index = _index, \
4545
}
4646

4747
#define CLOCK_SOURCE(_name) \
4848
const samd_clock_obj_t clock_ ## _name = { \
4949
{ &samd_clock_type }, \
50-
.name = #_name, \
50+
.name = MP_QSTR_ ## _name, \
5151
.type = 0, \
5252
.index = GCLK_SOURCE_ ## _name, \
5353
}
5454

5555
#define CLOCK_GCLK(_name) \
5656
const samd_clock_obj_t clock_ ## _name = { \
5757
{ &samd_clock_type }, \
58-
.name = #_name, \
58+
.name = MP_QSTR_ ## _name, \
5959
.type = 1, \
6060
.index = _name ## _GCLK_ID, \
6161
}
6262

6363
#define CLOCK_GCLK_(_name, _extra) \
6464
const samd_clock_obj_t clock_ ## _name ## _ ## _extra = { \
6565
{ &samd_clock_type }, \
66-
.name = #_name "_" #_extra, \
66+
.name = MP_QSTR_ ## _name ## _ ## _extra, \
6767
.type = 1, \
6868
.index = _name ## _GCLK_ID_ ## _extra, \
6969
}

ports/atmel-samd/boards/arduino_zero/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424

2525
#define DEFAULT_UART_BUS_RX (&pin_PA11)
2626
#define DEFAULT_UART_BUS_TX (&pin_PA10)
27+
28+
// USB is always used internally so skip the pin objects for it.
29+
#define IGNORE_PIN_PA24 1
30+
#define IGNORE_PIN_PA25 1

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@
6868

6969
#define DEFAULT_UART_BUS_RX (&pin_PB09)
7070
#define DEFAULT_UART_BUS_TX (&pin_PB08)
71+
72+
// USB is always used internally so skip the pin objects for it.
73+
#define IGNORE_PIN_PA24 1
74+
#define IGNORE_PIN_PA25 1

ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@
7171

7272
#define DEFAULT_UART_BUS_RX (&pin_PB09)
7373
#define DEFAULT_UART_BUS_TX (&pin_PB08)
74+
75+
// USB is always used internally so skip the pin objects for it.
76+
#define IGNORE_PIN_PA24 1
77+
#define IGNORE_PIN_PA25 1

ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@
2222

2323
#define DEFAULT_UART_BUS_RX (&pin_PA11)
2424
#define DEFAULT_UART_BUS_TX (&pin_PA10)
25+
26+
// USB is always used internally so skip the pin objects for it.
27+
#define IGNORE_PIN_PA24 1
28+
#define IGNORE_PIN_PA25 1

ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@
2323

2424
#define DEFAULT_UART_BUS_RX (&pin_PA11)
2525
#define DEFAULT_UART_BUS_TX (&pin_PA10)
26+
27+
// USB is always used internally so skip the pin objects for it.
28+
#define IGNORE_PIN_PA24 1
29+
#define IGNORE_PIN_PA25 1

ports/atmel-samd/boards/feather_m0_express/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@
5858

5959
#define DEFAULT_UART_BUS_RX (&pin_PA11)
6060
#define DEFAULT_UART_BUS_TX (&pin_PA10)
61+
62+
// USB is always used internally so skip the pin objects for it.
63+
#define IGNORE_PIN_PA24 1
64+
#define IGNORE_PIN_PA25 1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy