Skip to content

Commit dea22b0

Browse files
committed
Merge remote-tracking branch 'micropython/master'
2 parents 9485634 + 6562076 commit dea22b0

File tree

7 files changed

+47
-13
lines changed

7 files changed

+47
-13
lines changed

extmod/modbtree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ STATIC mp_obj_t btree_seq(size_t n_args, const mp_obj_t *args) {
133133
}
134134

135135
int res = __bt_seq(self->db, &key, &val, flags);
136+
CHECK_ERROR(res);
136137
if (res == RET_SPECIAL) {
137138
return mp_const_none;
138139
}

py/stream.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode
9494
}
9595

9696
const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
97-
mp_obj_base_t *o = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
98-
const mp_stream_p_t *stream_p = o->type->protocol;
97+
mp_obj_type_t *type = mp_obj_get_type(self_in);
98+
const mp_stream_p_t *stream_p = type->protocol;
9999
if (stream_p == NULL
100100
|| ((flags & MP_STREAM_OP_READ) && stream_p->read == NULL)
101101
|| ((flags & MP_STREAM_OP_WRITE) && stream_p->write == NULL)
@@ -167,7 +167,7 @@ STATIC mp_obj_t stream_read_generic(size_t n_args, const mp_obj_t *args, byte fl
167167
// TODO what if we have read only half a non-ASCII char?
168168
vstr_cut_tail_bytes(&vstr, more_bytes - out_sz);
169169
if (out_sz == 0) {
170-
break;
170+
break;
171171
}
172172
}
173173

stmhal/irq.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ MP_DECLARE_CONST_FUN_OBJ(pyb_irq_stats_obj);
126126
#define IRQ_PRI_OTG_HS 6
127127
#define IRQ_SUBPRI_OTG_HS 0
128128

129-
#define IRQ_PRI_TIM3 6
130-
#define IRQ_SUBPRI_TIM3 0
131-
132129
#define IRQ_PRI_TIM5 6
133130
#define IRQ_SUBPRI_TIM5 0
134131

stmhal/stm32_it.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ void TIM1_TRG_COM_TIM17_IRQHandler(void) {
556556
}
557557
#endif
558558

559+
void TIM1_CC_IRQHandler(void) {
560+
IRQ_ENTER(TIM1_CC_IRQn);
561+
timer_irq_handler(1);
562+
IRQ_EXIT(TIM1_CC_IRQn);
563+
}
564+
559565
void TIM2_IRQHandler(void) {
560566
IRQ_ENTER(TIM2_IRQn);
561567
timer_irq_handler(2);
@@ -581,18 +587,23 @@ void TIM5_IRQHandler(void) {
581587
IRQ_EXIT(TIM5_IRQn);
582588
}
583589

590+
#if defined(TIM6) // STM32F401 doesn't have TIM6
584591
void TIM6_DAC_IRQHandler(void) {
585592
IRQ_ENTER(TIM6_DAC_IRQn);
586593
timer_irq_handler(6);
587594
IRQ_EXIT(TIM6_DAC_IRQn);
588595
}
596+
#endif
589597

598+
#if defined(TIM7) // STM32F401 doesn't have TIM7
590599
void TIM7_IRQHandler(void) {
591600
IRQ_ENTER(TIM7_IRQn);
592601
timer_irq_handler(7);
593602
IRQ_EXIT(TIM7_IRQn);
594603
}
604+
#endif
595605

606+
#if defined(TIM8) // STM32F401 doesn't have TIM8
596607
void TIM8_BRK_TIM12_IRQHandler(void) {
597608
IRQ_ENTER(TIM8_BRK_TIM12_IRQn);
598609
timer_irq_handler(12);
@@ -614,11 +625,18 @@ void TIM8_UP_IRQHandler(void) {
614625
}
615626
#endif
616627

628+
void TIM8_CC_IRQHandler(void) {
629+
IRQ_ENTER(TIM8_CC_IRQn);
630+
timer_irq_handler(8);
631+
IRQ_EXIT(TIM8_CC_IRQn);
632+
}
633+
617634
void TIM8_TRG_COM_TIM14_IRQHandler(void) {
618635
IRQ_ENTER(TIM8_TRG_COM_TIM14_IRQn);
619636
timer_irq_handler(14);
620637
IRQ_EXIT(TIM8_TRG_COM_TIM14_IRQn);
621638
}
639+
#endif
622640

623641
// UART/USART IRQ handlers
624642
void USART1_IRQHandler(void) {

stmhal/timer.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,15 @@ STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, mp_uint_t n_args, c
601601
}
602602

603603
// set IRQ priority (if not a special timer)
604-
if (self->tim_id != 3 && self->tim_id != 5) {
604+
if (self->tim_id != 5) {
605605
HAL_NVIC_SetPriority(self->irqn, IRQ_PRI_TIMX, IRQ_SUBPRI_TIMX);
606+
if (self->tim_id == 1) {
607+
HAL_NVIC_SetPriority(TIM1_CC_IRQn, IRQ_PRI_TIMX, IRQ_SUBPRI_TIMX);
608+
#if defined(TIM8)
609+
} else if (self->tim_id == 8) {
610+
HAL_NVIC_SetPriority(TIM8_CC_IRQn, IRQ_PRI_TIMX, IRQ_SUBPRI_TIMX);
611+
#endif
612+
}
606613
}
607614

608615
// init TIM
@@ -932,7 +939,7 @@ STATIC mp_obj_t pyb_timer_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp
932939
if (chan->callback == mp_const_none) {
933940
HAL_TIM_PWM_Start(&self->tim, TIMER_CHANNEL(chan));
934941
} else {
935-
HAL_TIM_PWM_Start_IT(&self->tim, TIMER_CHANNEL(chan));
942+
pyb_timer_channel_callback(chan, chan->callback);
936943
}
937944
// Start the complimentary channel too (if its supported)
938945
if (IS_TIM_CCXN_INSTANCE(self->tim.Instance, TIMER_CHANNEL(chan))) {
@@ -970,7 +977,7 @@ STATIC mp_obj_t pyb_timer_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp
970977
if (chan->callback == mp_const_none) {
971978
HAL_TIM_OC_Start(&self->tim, TIMER_CHANNEL(chan));
972979
} else {
973-
HAL_TIM_OC_Start_IT(&self->tim, TIMER_CHANNEL(chan));
980+
pyb_timer_channel_callback(chan, chan->callback);
974981
}
975982
// Start the complimentary channel too (if its supported)
976983
if (IS_TIM_CCXN_INSTANCE(self->tim.Instance, TIMER_CHANNEL(chan))) {
@@ -997,7 +1004,7 @@ STATIC mp_obj_t pyb_timer_channel(mp_uint_t n_args, const mp_obj_t *pos_args, mp
9971004
if (chan->callback == mp_const_none) {
9981005
HAL_TIM_IC_Start(&self->tim, TIMER_CHANNEL(chan));
9991006
} else {
1000-
HAL_TIM_IC_Start_IT(&self->tim, TIMER_CHANNEL(chan));
1007+
pyb_timer_channel_callback(chan, chan->callback);
10011008
}
10021009
break;
10031010
}
@@ -1294,7 +1301,16 @@ STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback)
12941301
self->callback = mp_const_none;
12951302
} else if (mp_obj_is_callable(callback)) {
12961303
self->callback = callback;
1297-
HAL_NVIC_EnableIRQ(self->timer->irqn);
1304+
uint8_t tim_id = self->timer->tim_id;
1305+
if (tim_id == 1) {
1306+
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
1307+
#if defined(TIM8) // STM32F401 doesn't have a TIM8
1308+
} else if (tim_id == 8) {
1309+
HAL_NVIC_EnableIRQ(TIM8_CC_IRQn);
1310+
#endif
1311+
} else {
1312+
HAL_NVIC_EnableIRQ(self->timer->irqn);
1313+
}
12981314
// start timer, so that it interrupts on overflow
12991315
switch (self->mode) {
13001316
case CHANNEL_MODE_PWM_NORMAL:

teensy/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ int main(void) {
302302
#endif
303303

304304
#if MICROPY_MODULE_FROZEN
305-
pyexec_frozen_module("boot");
305+
pyexec_frozen_module("boot.py");
306306
#else
307307
if (!pyexec_file("/boot.py")) {
308308
flash_error(4);
@@ -314,7 +314,7 @@ int main(void) {
314314

315315
// run main script
316316
#if MICROPY_MODULE_FROZEN
317-
pyexec_frozen_module("main");
317+
pyexec_frozen_module("main.py");
318318
#else
319319
{
320320
vstr_t *vstr = vstr_new();

teensy/memzip_files/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pyb
2+
13
print("Executing main.py")
24

35
led = pyb.LED(1)

0 commit comments

Comments
 (0)