summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-01-29 16:00:38 -0500
committerLucian Copeland <hierophect@gmail.com>2020-01-29 16:00:38 -0500
commit8a9c3097e3f622d965dfd55b121c4cce6a66344c (patch)
tree66adf7b1947f7a8e6c48028dd6d866719bfd2784
parent3c8600554654926fe88d65fc0b5d668c0bea476a (diff)
Add port-specific requested changes
-rw-r--r--ports/stm32f4/boards/meowbit_v121/pins.c2
-rw-r--r--ports/stm32f4/common-hal/pulseio/PWMOut.c13
2 files changed, 6 insertions, 9 deletions
diff --git a/ports/stm32f4/boards/meowbit_v121/pins.c b/ports/stm32f4/boards/meowbit_v121/pins.c
index 1489c23f1..5d077a04c 100644
--- a/ports/stm32f4/boards/meowbit_v121/pins.c
+++ b/ports/stm32f4/boards/meowbit_v121/pins.c
@@ -11,7 +11,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_DISP_CS), MP_ROM_PTR(&pin_PB12) },
{ MP_ROM_QSTR(MP_QSTR_DISP_DC), MP_ROM_PTR(&pin_PA08) },
{ MP_ROM_QSTR(MP_QSTR_DISP_RST), MP_ROM_PTR(&pin_PB10) },
- { MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) }, //what is this, backlight?
+ { MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) },
{ MP_ROM_QSTR(MP_QSTR_BUZZ), MP_ROM_PTR(&pin_PB08) },
{ MP_ROM_QSTR(MP_QSTR_BTNA), MP_ROM_PTR(&pin_PB09) },
diff --git a/ports/stm32f4/common-hal/pulseio/PWMOut.c b/ports/stm32f4/common-hal/pulseio/PWMOut.c
index 29376691b..50bacbb51 100644
--- a/ports/stm32f4/common-hal/pulseio/PWMOut.c
+++ b/ports/stm32f4/common-hal/pulseio/PWMOut.c
@@ -69,7 +69,6 @@ STATIC uint32_t timer_get_source_freq(uint32_t tim_id) {
STATIC uint32_t timer_get_internal_duty(uint16_t duty, uint32_t period) {
//duty cycle is duty/0xFFFF fraction x (number of pulses per period)
- //Note that pulses are inverted, so duty cycle is inverted
return (duty*period) / ((1 << 16) - 1);
}
@@ -114,11 +113,12 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
bool first_time_setup = true;
for (uint i = 0; i < tim_num; i++) {
- uint8_t l_tim_index = mcu_tim_pin_list[i].tim_index - 1;
- uint8_t l_tim_channel = mcu_tim_pin_list[i].channel_index - 1;
+ const mcu_tim_pin_obj_t * l_tim = &mcu_tim_pin_list[i];
+ uint8_t l_tim_index = l_tim->tim_index - 1;
+ uint8_t l_tim_channel = l_tim->channel_index - 1;
//if pin is same
- if (mcu_tim_pin_list[i].pin == pin) {
+ if (l_tim->pin == pin) {
//check if the timer has a channel active
if (reserved_tim[l_tim_index] != 0) {
//is it the same channel? (or all channels reserved by a var-freq)
@@ -139,7 +139,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
first_time_setup = false; //skip setting up the timer
}
//No problems taken, so set it up
- self->tim = &mcu_tim_pin_list[i];
+ self->tim = l_tim;
break;
}
}
@@ -205,9 +205,6 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
self->chan_handle.Pulse = timer_get_internal_duty(duty, period);
self->chan_handle.OCPolarity = TIM_OCPOLARITY_HIGH;
self->chan_handle.OCFastMode = TIM_OCFAST_DISABLE;
- self->chan_handle.OCNPolarity = TIM_OCNPOLARITY_LOW; // needed for TIM1 and TIM8
- self->chan_handle.OCIdleState = TIM_OCIDLESTATE_SET; // needed for TIM1 and TIM8
- self->chan_handle.OCNIdleState = TIM_OCNIDLESTATE_SET; // needed for TIM1 and TIM8
if (HAL_TIM_PWM_ConfigChannel(&self->handle, &self->chan_handle, self->channel) != HAL_OK) {
mp_raise_ValueError(translate("Could not initialize channel"));
}