aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@chickadee.tech>2016-08-23 16:51:47 -0700
committerScott Shawcroft <scott@chickadee.tech>2016-08-23 16:51:47 -0700
commitdea22b0b5db46702777e8baa41dc8bf985b34672 (patch)
tree661dc55c4c4efddc4f3c4f8974c9bde176dd8c48
parent9485634d41369e896a0ef0f7504f2195b68679e7 (diff)
parent656207645485295477411224fdf41cfd4d598a88 (diff)
Merge remote-tracking branch 'micropython/master'
-rw-r--r--extmod/modbtree.c1
-rw-r--r--py/stream.c6
-rw-r--r--stmhal/irq.h3
-rw-r--r--stmhal/stm32_it.c18
-rw-r--r--stmhal/timer.c26
-rw-r--r--teensy/main.c4
-rw-r--r--teensy/memzip_files/main.py2
7 files changed, 47 insertions, 13 deletions
diff --git a/extmod/modbtree.c b/extmod/modbtree.c
index f21e7e442..ea2ea582c 100644
--- a/extmod/modbtree.c
+++ b/extmod/modbtree.c
@@ -133,6 +133,7 @@ STATIC mp_obj_t btree_seq(size_t n_args, const mp_obj_t *args) {
}
int res = __bt_seq(self->db, &key, &val, flags);
+ CHECK_ERROR(res);
if (res == RET_SPECIAL) {
return mp_const_none;
}
diff --git a/py/stream.c b/py/stream.c
index 473eb9690..eef9080b7 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -94,8 +94,8 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode
}
const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
- mp_obj_base_t *o = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
- const mp_stream_p_t *stream_p = o->type->protocol;
+ mp_obj_type_t *type = mp_obj_get_type(self_in);
+ const mp_stream_p_t *stream_p = type->protocol;
if (stream_p == NULL
|| ((flags & MP_STREAM_OP_READ) && stream_p->read == NULL)
|| ((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
// TODO what if we have read only half a non-ASCII char?
vstr_cut_tail_bytes(&vstr, more_bytes - out_sz);
if (out_sz == 0) {
- break;
+ break;
}
}
diff --git a/stmhal/irq.h b/stmhal/irq.h
index f3a8a2cc9..5a08a7d50 100644
--- a/stmhal/irq.h
+++ b/stmhal/irq.h
@@ -126,9 +126,6 @@ MP_DECLARE_CONST_FUN_OBJ(pyb_irq_stats_obj);
#define IRQ_PRI_OTG_HS 6
#define IRQ_SUBPRI_OTG_HS 0
-#define IRQ_PRI_TIM3 6
-#define IRQ_SUBPRI_TIM3 0
-
#define IRQ_PRI_TIM5 6
#define IRQ_SUBPRI_TIM5 0
diff --git a/stmhal/stm32_it.c b/stmhal/stm32_it.c
index c9af20ce5..d2f8c271c 100644
--- a/stmhal/stm32_it.c
+++ b/stmhal/stm32_it.c
@@ -556,6 +556,12 @@ void TIM1_TRG_COM_TIM17_IRQHandler(void) {
}
#endif
+void TIM1_CC_IRQHandler(void) {
+ IRQ_ENTER(TIM1_CC_IRQn);
+ timer_irq_handler(1);
+ IRQ_EXIT(TIM1_CC_IRQn);
+}
+
void TIM2_IRQHandler(void) {
IRQ_ENTER(TIM2_IRQn);
timer_irq_handler(2);
@@ -581,18 +587,23 @@ void TIM5_IRQHandler(void) {
IRQ_EXIT(TIM5_IRQn);
}
+#if defined(TIM6) // STM32F401 doesn't have TIM6
void TIM6_DAC_IRQHandler(void) {
IRQ_ENTER(TIM6_DAC_IRQn);
timer_irq_handler(6);
IRQ_EXIT(TIM6_DAC_IRQn);
}
+#endif
+#if defined(TIM7) // STM32F401 doesn't have TIM7
void TIM7_IRQHandler(void) {
IRQ_ENTER(TIM7_IRQn);
timer_irq_handler(7);
IRQ_EXIT(TIM7_IRQn);
}
+#endif
+#if defined(TIM8) // STM32F401 doesn't have TIM8
void TIM8_BRK_TIM12_IRQHandler(void) {
IRQ_ENTER(TIM8_BRK_TIM12_IRQn);
timer_irq_handler(12);
@@ -614,11 +625,18 @@ void TIM8_UP_IRQHandler(void) {
}
#endif
+void TIM8_CC_IRQHandler(void) {
+ IRQ_ENTER(TIM8_CC_IRQn);
+ timer_irq_handler(8);
+ IRQ_EXIT(TIM8_CC_IRQn);
+}
+
void TIM8_TRG_COM_TIM14_IRQHandler(void) {
IRQ_ENTER(TIM8_TRG_COM_TIM14_IRQn);
timer_irq_handler(14);
IRQ_EXIT(TIM8_TRG_COM_TIM14_IRQn);
}
+#endif
// UART/USART IRQ handlers
void USART1_IRQHandler(void) {
diff --git a/stmhal/timer.c b/stmhal/timer.c
index f1f14f331..5727a95b7 100644
--- a/stmhal/timer.c
+++ b/stmhal/timer.c
@@ -601,8 +601,15 @@ STATIC mp_obj_t pyb_timer_init_helper(pyb_timer_obj_t *self, mp_uint_t n_args, c
}
// set IRQ priority (if not a special timer)
- if (self->tim_id != 3 && self->tim_id != 5) {
+ if (self->tim_id != 5) {
HAL_NVIC_SetPriority(self->irqn, IRQ_PRI_TIMX, IRQ_SUBPRI_TIMX);
+ if (self->tim_id == 1) {
+ HAL_NVIC_SetPriority(TIM1_CC_IRQn, IRQ_PRI_TIMX, IRQ_SUBPRI_TIMX);
+ #if defined(TIM8)
+ } else if (self->tim_id == 8) {
+ HAL_NVIC_SetPriority(TIM8_CC_IRQn, IRQ_PRI_TIMX, IRQ_SUBPRI_TIMX);
+ #endif
+ }
}
// 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
if (chan->callback == mp_const_none) {
HAL_TIM_PWM_Start(&self->tim, TIMER_CHANNEL(chan));
} else {
- HAL_TIM_PWM_Start_IT(&self->tim, TIMER_CHANNEL(chan));
+ pyb_timer_channel_callback(chan, chan->callback);
}
// Start the complimentary channel too (if its supported)
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
if (chan->callback == mp_const_none) {
HAL_TIM_OC_Start(&self->tim, TIMER_CHANNEL(chan));
} else {
- HAL_TIM_OC_Start_IT(&self->tim, TIMER_CHANNEL(chan));
+ pyb_timer_channel_callback(chan, chan->callback);
}
// Start the complimentary channel too (if its supported)
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
if (chan->callback == mp_const_none) {
HAL_TIM_IC_Start(&self->tim, TIMER_CHANNEL(chan));
} else {
- HAL_TIM_IC_Start_IT(&self->tim, TIMER_CHANNEL(chan));
+ pyb_timer_channel_callback(chan, chan->callback);
}
break;
}
@@ -1294,7 +1301,16 @@ STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback)
self->callback = mp_const_none;
} else if (mp_obj_is_callable(callback)) {
self->callback = callback;
- HAL_NVIC_EnableIRQ(self->timer->irqn);
+ uint8_t tim_id = self->timer->tim_id;
+ if (tim_id == 1) {
+ HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
+ #if defined(TIM8) // STM32F401 doesn't have a TIM8
+ } else if (tim_id == 8) {
+ HAL_NVIC_EnableIRQ(TIM8_CC_IRQn);
+ #endif
+ } else {
+ HAL_NVIC_EnableIRQ(self->timer->irqn);
+ }
// start timer, so that it interrupts on overflow
switch (self->mode) {
case CHANNEL_MODE_PWM_NORMAL:
diff --git a/teensy/main.c b/teensy/main.c
index 41e445cb5..890ee8149 100644
--- a/teensy/main.c
+++ b/teensy/main.c
@@ -302,7 +302,7 @@ soft_reset:
#endif
#if MICROPY_MODULE_FROZEN
- pyexec_frozen_module("boot");
+ pyexec_frozen_module("boot.py");
#else
if (!pyexec_file("/boot.py")) {
flash_error(4);
@@ -314,7 +314,7 @@ soft_reset:
// run main script
#if MICROPY_MODULE_FROZEN
- pyexec_frozen_module("main");
+ pyexec_frozen_module("main.py");
#else
{
vstr_t *vstr = vstr_new();
diff --git a/teensy/memzip_files/main.py b/teensy/memzip_files/main.py
index 4f30f2fc5..b652377f9 100644
--- a/teensy/memzip_files/main.py
+++ b/teensy/memzip_files/main.py
@@ -1,3 +1,5 @@
+import pyb
+
print("Executing main.py")
led = pyb.LED(1)