Skip to content

Commit da19e8e

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-codeformat-subdirs
2 parents dfa7c3d + d93a9a1 commit da19e8e

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

ports/raspberrypi/common-hal/pulseio/PulseIn.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,15 @@ void common_hal_pulseio_pulsein_interrupt() {
142142
// ignore pulses that are too short
143143
if (result <= MAX_PULSE && result > MIN_PULSE) {
144144
self->buffer[buf_index] = (uint16_t)result;
145-
buf_index++;
146-
self->len++;
145+
if (self->len < self->maxlen) {
146+
self->len++;
147+
}
148+
if (buf_index < self->maxlen) {
149+
buf_index++;
150+
} else {
151+
self->start = 0;
152+
buf_index = 0;
153+
}
147154
}
148155
}
149156
}

py/vm.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,21 @@ mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t * code_st
127127
#endif
128128
#if MICROPY_OPT_COMPUTED_GOTO
129129
#include "py/vmentrytable.h"
130+
#if MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
131+
#define ONE_TRUE_DISPATCH() one_true_dispatch : do { \
132+
TRACE(ip); \
133+
MARK_EXC_IP_GLOBAL(); \
134+
goto *(void *)((char *) && entry_MP_BC_LOAD_CONST_FALSE + entry_table[*ip++]); \
135+
} while (0)
136+
#define DISPATCH() do { goto one_true_dispatch; } while (0)
137+
#else
138+
#define ONE_TRUE_DISPATCH() DISPATCH()
130139
#define DISPATCH() do { \
131140
TRACE(ip); \
132141
MARK_EXC_IP_GLOBAL(); \
133142
goto *entry_table[*ip++]; \
134143
} while (0)
144+
#endif
135145
#define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check
136146
#define ENTRY(op) entry_##op
137147
#define ENTRY_DEFAULT entry_default
@@ -197,7 +207,7 @@ mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t * code_st
197207
for (;;) {
198208
dispatch_loop:
199209
#if MICROPY_OPT_COMPUTED_GOTO
200-
DISPATCH();
210+
ONE_TRUE_DISPATCH();
201211
#else
202212
TRACE(ip);
203213
MARK_EXC_IP_GLOBAL();

0 commit comments

Comments
 (0)