Tests for PWM issues, style changes
This commit is contained in:
parent
5b9209aa02
commit
28b1d718a3
@ -36,7 +36,7 @@
|
||||
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
|
||||
|
||||
#define BOARD_OSC_DIV 12
|
||||
#define BOARD_NO_VBUS
|
||||
#define BOARD_NO_VBUS_SENSE
|
||||
|
||||
// On-board flash
|
||||
// #define SPI_FLASH_MOSI_PIN (&pin_PB15)
|
||||
|
@ -52,7 +52,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_P9), MP_ROM_PTR(&pin_PC06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_P8), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_PA01) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA10) }, //in use by USB
|
||||
{ MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_PC07) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PB05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PC01) },
|
||||
|
@ -124,6 +124,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
uint16_t duty,
|
||||
uint32_t frequency,
|
||||
bool variable_frequency) {
|
||||
mp_printf(&mp_plat_print, "Construct PWM\n");
|
||||
TIM_TypeDef * TIMx;
|
||||
uint8_t tim_num = sizeof(mcu_tim_pin_list)/sizeof(*mcu_tim_pin_list);
|
||||
bool tim_chan_taken = false;
|
||||
@ -194,6 +195,8 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
GPIO_InitStruct.Alternate = self->tim->altfn_index;
|
||||
HAL_GPIO_Init(pin_port(pin->port), &GPIO_InitStruct);
|
||||
|
||||
mp_printf(&mp_plat_print, "PWM Pin:%d Port:%d\n", pin->number, pin->port);
|
||||
|
||||
tim_clock_enable(1<<(self->tim->tim_index - 1));
|
||||
|
||||
//translate channel into handle value
|
||||
@ -203,6 +206,8 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
uint32_t period = 0; //period is 16 bit
|
||||
timer_get_optimal_divisors(&period, &prescaler,frequency,timer_get_source_freq(self->tim->tim_index));
|
||||
|
||||
mp_printf(&mp_plat_print, "Per:%d presc:%d\n", period, prescaler);
|
||||
|
||||
//Timer init
|
||||
self->handle.Instance = TIMx;
|
||||
self->handle.Init.Period = period - 1;
|
||||
|
@ -125,6 +125,7 @@ const mcu_uart_rx_obj_t mcu_uart_rx_list[6] = {
|
||||
TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, NULL, TIM9, TIM10,
|
||||
TIM11, NULL, NULL, NULL};
|
||||
|
||||
//#define TIM(index, alt, channel, tim_pin)
|
||||
const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = {
|
||||
TIM(2,1,1,&pin_PA00),
|
||||
TIM(5,2,1,&pin_PA00),
|
||||
|
Loading…
Reference in New Issue
Block a user