Skip to content

Commit 4b063ae

Browse files
committed
Hack up STM32 PulseIn so it builds
1 parent a4a4589 commit 4b063ae

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

ports/stm/common-hal/pulseio/PulseIn.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ void TIM6_IRQHandler(void)
6161
static 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

112117
void 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

Comments
 (0)