diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2020-03-31 15:12:11 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2020-03-31 15:12:11 -0700 |
| commit | 4b063aeb29c889809af0758351e68eda48e37f3a (patch) | |
| tree | 2e57815a135394ec46b3d6b6bf1c61ce5f95ceea | |
| parent | a4a458943d1129c691b6585b1f71439db233d4df (diff) | |
Hack up STM32 PulseIn so it builds
| -rw-r--r-- | ports/stm/common-hal/pulseio/PulseIn.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ports/stm/common-hal/pulseio/PulseIn.c b/ports/stm/common-hal/pulseio/PulseIn.c index 5e94653fc..c44d03cf0 100644 --- a/ports/stm/common-hal/pulseio/PulseIn.c +++ b/ports/stm/common-hal/pulseio/PulseIn.c @@ -61,7 +61,10 @@ void TIM6_IRQHandler(void) static void pulsein_handler(uint8_t num) { // Grab the current time first. uint32_t current_overflow = overflow_count; - uint32_t current_count = TIM6->CNT; + uint32_t current_count = 0; + #if HAS_BASIC_TIM + current_count = TIM6->CNT; + #endif // Interrupt register must be cleared manually EXTI->PR = 1 << num; @@ -105,12 +108,17 @@ void pulsein_reset(void) { } memset(_objs, 0, sizeof(_objs)); + #if HAS_BASIC_TIM __HAL_RCC_TIM6_CLK_DISABLE(); refcount = 0; + #endif } void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu_pin_obj_t* pin, uint16_t maxlen, bool idle_state) { +#if !(HAS_BASIC_TIM) + mp_raise_NotImplementedError(translate("PulseOut not supported on this chip")); +#else // STM32 has one shared EXTI for each pin number, 0-15 uint8_t p_num = pin->number; if(_objs[p_num]) { @@ -153,6 +161,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu } // Add to active PulseIns refcount++; +#endif // EXTI pins can also be read as an input GPIO_InitTypeDef GPIO_InitStruct = {0}; |
