Skip to content

Commit 8a9c309

Browse files
committed
Add port-specific requested changes
1 parent 3c86005 commit 8a9c309

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

ports/stm32f4/boards/meowbit_v121/pins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
1111
{ MP_ROM_QSTR(MP_QSTR_DISP_CS), MP_ROM_PTR(&pin_PB12) },
1212
{ MP_ROM_QSTR(MP_QSTR_DISP_DC), MP_ROM_PTR(&pin_PA08) },
1313
{ MP_ROM_QSTR(MP_QSTR_DISP_RST), MP_ROM_PTR(&pin_PB10) },
14-
{ MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) }, //what is this, backlight?
14+
{ MP_ROM_QSTR(MP_QSTR_DISP_BL), MP_ROM_PTR(&pin_PB03) },
1515

1616
{ MP_ROM_QSTR(MP_QSTR_BUZZ), MP_ROM_PTR(&pin_PB08) },
1717
{ MP_ROM_QSTR(MP_QSTR_BTNA), MP_ROM_PTR(&pin_PB09) },

ports/stm32f4/common-hal/pulseio/PWMOut.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ STATIC uint32_t timer_get_source_freq(uint32_t tim_id) {
6969

7070
STATIC uint32_t timer_get_internal_duty(uint16_t duty, uint32_t period) {
7171
//duty cycle is duty/0xFFFF fraction x (number of pulses per period)
72-
//Note that pulses are inverted, so duty cycle is inverted
7372
return (duty*period) / ((1 << 16) - 1);
7473
}
7574

@@ -114,11 +113,12 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
114113
bool first_time_setup = true;
115114

116115
for (uint i = 0; i < tim_num; i++) {
117-
uint8_t l_tim_index = mcu_tim_pin_list[i].tim_index - 1;
118-
uint8_t l_tim_channel = mcu_tim_pin_list[i].channel_index - 1;
116+
const mcu_tim_pin_obj_t * l_tim = &mcu_tim_pin_list[i];
117+
uint8_t l_tim_index = l_tim->tim_index - 1;
118+
uint8_t l_tim_channel = l_tim->channel_index - 1;
119119

120120
//if pin is same
121-
if (mcu_tim_pin_list[i].pin == pin) {
121+
if (l_tim->pin == pin) {
122122
//check if the timer has a channel active
123123
if (reserved_tim[l_tim_index] != 0) {
124124
//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,
139139
first_time_setup = false; //skip setting up the timer
140140
}
141141
//No problems taken, so set it up
142-
self->tim = &mcu_tim_pin_list[i];
142+
self->tim = l_tim;
143143
break;
144144
}
145145
}
@@ -205,9 +205,6 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
205205
self->chan_handle.Pulse = timer_get_internal_duty(duty, period);
206206
self->chan_handle.OCPolarity = TIM_OCPOLARITY_HIGH;
207207
self->chan_handle.OCFastMode = TIM_OCFAST_DISABLE;
208-
self->chan_handle.OCNPolarity = TIM_OCNPOLARITY_LOW; // needed for TIM1 and TIM8
209-
self->chan_handle.OCIdleState = TIM_OCIDLESTATE_SET; // needed for TIM1 and TIM8
210-
self->chan_handle.OCNIdleState = TIM_OCNIDLESTATE_SET; // needed for TIM1 and TIM8
211208
if (HAL_TIM_PWM_ConfigChannel(&self->handle, &self->chan_handle, self->channel) != HAL_OK) {
212209
mp_raise_ValueError(translate("Could not initialize channel"));
213210
}

0 commit comments

Comments
 (0)