8000 Merge pull request #5100 from tannewt/fix_cp_irremote · adafruit/circuitpython@d294692 · GitHub
[go: up one dir, main page]

Skip to content

Commit d294692

Browse files
authored
Merge pull request #5100 from tannewt/fix_cp_irremote
Switch SAMD21 ticks to PER event
2 parents f8b7d5f + fb6b438 commit d294692

File tree

12 files changed

+185
-98
lines changed

12 files changed

+185
-98
lines changed

lib/utils/pyexec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
149149
mp_hal_stdout_tx_strn("\x04", 1);
150150
}
151151
// check for SystemExit
152-
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
152+
if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
153153
// at the moment, the value of SystemExit is unused
154154
ret = pyexec_system_exit;
155155
#if CIRCUITPY_ALARM

ports/atmel-samd/audio_dma.c

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,13 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
273273

274274
#ifdef SAM_D5X_E5X
275275
int irq = dma->event_channel < 4 ? EVSYS_0_IRQn + dma->event_channel : EVSYS_4_IRQn;
276+
// Only disable and clear on SAMD51 because the SAMD21 shares EVSYS with ticks.
277+
NVIC_DisableIRQ(irq);
278+
NVIC_ClearPendingIRQ(irq);
276279
#else
277280
int irq = EVSYS_IRQn;
278281
#endif
279282

280-
NVIC_DisableIRQ(irq);
281-
NVIC_ClearPendingIRQ(irq);
282-
283283
DmacDescriptor *first_descriptor = dma_descriptor(dma_channel);
284284
setup_audio_descriptor(first_descriptor, dma->beat_size, output_spacing, output_register_address);
285285
if (single_buffer) {
@@ -374,7 +374,7 @@ STATIC void dma_callback_fun(void *arg) {
374374
audio_dma_load_next_block(dma);
375375
}
376376

377 10000 -
void evsyshandler_common(void) {
377+
void audio_evsys_handler(void) {
378378
for (uint8_t i = 0; i < AUDIO_DMA_CHANNEL_COUNT; i++) {
379379
audio_dma_t *dma = audio_dma_state[i];
380380
if (dma == NULL) {
@@ -388,26 +388,4 @@ void evsyshandler_common(void) {
388388
}
389389
}
390390

391-
#ifdef SAM_D5X_E5X
392-
void EVSYS_0_Handler(void) {
393-
evsyshandler_common();
394-
}
395-
void EVSYS_1_Handler(void) {
396-
evsyshandler_common();
397-
}
398-
void EVSYS_2_Handler(void) {
399-
evsyshandler_common();
400-
}
401-
void EVSYS_3_Handler(void) {
402-
evsyshandler_common();
403-
}
404-
void EVSYS_4_Handler(void) {
405-
evsyshandler_common();
406-
}
407-
#else
408-
void EVSYS_Handler(void) {
409-
evsyshandler_common();
410-
}
411-
#endif
412-
413391
#endif

ports/atmel-samd/audio_dma.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,6 @@ void audio_dma_background(void);
9999

100100
uint8_t find_sync_event_channel_raise(void);
101101

102+
void audio_evsys_handler(void);
103+
102104
#endif // MICROPY_INCLUDED_ATMEL_SAMD_AUDIO_DMA_H

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define MICROPY_HW_MCU_NAME "samd21e18"
33

44
#define MICROPY_HW_NEOPIXEL (&pin_PA15)
5+
#define MICROPY_HW_NEOPIXEL_COUNT (2)
56

67
#define IGNORE_PIN_PA01 1
78
#define IGNORE_PIN_PA02 1

ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CIRCUITPY_FULL_BUILD = 0
1414
CIRCUITPY_ANALOGIO = 0
1515
CIRCUITPY_AUDIOCORE = 0
1616
CIRCUITPY_BUSIO_SPI = 0
17+
CIRCUITPY_BUSIO_UART = 0
1718
CIRCUITPY_PULSEIO = 0
1819
CIRCUITPY_PWMIO = 0
1920
CIRCUITPY_ROTARYIO = 0

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,16 @@
1616
// USB is always used internally so skip the pin objects for it.
1717
#define IGNORE_PIN_PA24 1
1818
#define IGNORE_PIN_PA25 1
19+
// USD ID
20+
#define IGNORE_PIN_PA18 1
21+
22+
// Hooked to the external crystal
23+
#define IGNORE_PIN_PA00 1
24+
#define IGNORE_PIN_PA01 1
25+
26+
// SWD only
27+
#define IGNORE_PIN_PA30 1
28+
#define IGNORE_PIN_PA31 1
29+
30+
// Not connected
31+
#define IGNORE_PIN_PA28 1

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@
1616
// USB is always used internally so skip the pin objects for it.
1717
#define IGNORE_PIN_PA24 1
1818
#define IGNORE_PIN_PA25 1
19+
20+
// Not connected
21+
#define IGNORE_PIN_PA00 1
22+
#define IGNORE_PIN_PA01 1
23+
24+
// SWD only
25+
#define IGNORE_PIN_PA30 1
26+
#define IGNORE_PIN_PA31 1

ports/atmel-samd/common-hal/pulseio/PulseIn.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t *self) {
272272
void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) {
273273
uint32_t mask = 1 << self->channel;
274274
EIC->INTENCLR.reg = mask << EIC_INTENSET_EXTINT_Pos;
275+
#ifdef SAMD21
276+
rtc_end_pulse();
277+
#endif
275278
}
276279

277280
void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self,
@@ -299,6 +302,9 @@ void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self,
299302
EIC->INTFLAG.reg = mask << EIC_INTFLAG_EXTINT_Pos;
300303
EIC->INTENSET.reg = mask << EIC_INTENSET_EXTINT_Pos;
301304

305+
#ifdef SAMD21
306+
rtc_start_pulse();
307+
#endif
302308
pulsein_set_config(self, true);
303309
}
304310

0 commit comments

Comments
 (0)
0