@@ -61,7 +61,10 @@ void TIM6_IRQHandler(void)
6161static void pulsein_handler (uint8_t num ) {
6262 // Grab the current time first.
6363 uint32_t current_overflow = overflow_count ;
64- uint32_t current_count = TIM6 -> CNT ;
64+ uint32_t current_count = 0 ;
65+ #if HAS_BASIC_TIM
66+ current_count = TIM6 -> CNT ;
67+ #endif
6568
6669 // Interrupt register must be cleared manually
6770 EXTI -> PR = 1 << num ;
@@ -105,12 +108,17 @@ void pulsein_reset(void) {
105108 }
106109 memset (_objs , 0 , sizeof (_objs ));
107110
111+ #if HAS_BASIC_TIM
108112 __HAL_RCC_TIM6_CLK_DISABLE ();
109113 refcount = 0 ;
114+ #endif
110115}
111116
112117void common_hal_pulseio_pulsein_construct (pulseio_pulsein_obj_t * self , const mcu_pin_obj_t * pin ,
113118 uint16_t maxlen , bool idle_state ) {
119+ #if !(HAS_BASIC_TIM )
120+ mp_raise_NotImplementedError (translate ("PulseOut not supported on this chip" ));
121+ #else
114122 // STM32 has one shared EXTI for each pin number, 0-15
115123 uint8_t p_num = pin -> number ;
116124 if (_objs [p_num ]) {
@@ -153,6 +161,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu
153161 }
154162 // Add to active PulseIns
155163 refcount ++ ;
164+ #endif
156165
157166 // EXTI pins can also be read as an input
158167 GPIO_InitTypeDef GPIO_InitStruct = {0 };
0 commit comments