8000 atmel-samd: Use MICROPY_VM_HOOK_LOOP to make sure the mass storage ha… · adafruit/circuitpython@72455e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 72455e4

Browse files
committed
atmel-samd: Use MICROPY_VM_HOOK_LOOP to make sure the mass storage handling code is called even in tight Python loops. Fixes #51
1 parent 16764df commit 72455e4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

atmel-samd/mpconfigport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@ extern const struct _mp_obj_module_t uheap_module;
160160
mp_obj_t mp_kbd_exception; \
161161
FLASH_ROOT_POINTERS \
162162

163+
bool udi_msc_process_trans(void);
164+
#define MICROPY_VM_HOOK_LOOP udi_msc_process_trans();
165+
#define MICROPY_VM_HOOK_RETURN udi_msc_process_trans();
166+
163167
#endif // __INCLUDED_MPCONFIGPORT_H

atmel-samd/mphalport.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,9 @@ int receive_usb(void) {
154154

155155
int mp_hal_stdin_rx_chr(void) {
156156
for (;;) {
157-
// Process any mass storage transfers.
158-
if (mp_msc_enabled) {
159-
udi_msc_process_trans();
160-
}
157+
#ifdef MICROPY_VM_HOOK_LOOP
158+
MICROPY_VM_HOOK_LOOP
159+
#endif
161160
#ifdef USB_REPL
162161
if (reset_next_character) {
163162
return CHAR_CTRL_D;
@@ -211,9 +210,9 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
211210
}
212211
}
213212
start += transmit;
214-
if (mp_msc_enabled) {
215-
udi_msc_process_trans();
216-
}
213+
#ifdef MICROPY_VM_HOOK_LOOP
214+
MICROPY_VM_HOOK_LOOP
215+
#endif
217216
duration = (common_hal_time_monotonic() - start_tick);
218217
}
219218
}
@@ -236,7 +235,9 @@ void mp_hal_delay_ms(mp_uint_t delay) {
236235
uint64_t start_tick = common_hal_time_monotonic();
237236
uint64_t duration = 0;
238237
while (duration < delay) {
239-
udi_msc_process_trans();
238+
#ifdef MICROPY_VM_HOOK_LOOP
239+
MICROPY_VM_HOOK_LOOP
240+
#endif
240241
// Check to see if we've been CTRL-Ced by autoreset or the user.
241242
if(MP_STATE_VM(mp_pending_exception) == MP_STATE_PORT(mp_kbd_exception)) {
242243
break;

0 commit comments

Comments
 (0)
0