File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -283,13 +283,9 @@ void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self,
283283 if (trigger_duration > 0 ) {
284284 gpio_set_pin_pull_mode (self -> pin , GPIO_PULL_OFF );
285285 gpio_set_pin_direction (self -> pin , GPIO_DIRECTION_OUT );
286- if (trigger_duration < 1000 ){ // only disable interrupts for < 1 ms
287- common_hal_mcu_disable_interrupts ();
288- }
289286 gpio_set_pin_level (self -> pin , !self -> idle_state );
290287 common_hal_mcu_delay_us ((uint32_t )trigger_duration );
291288 gpio_set_pin_level (self -> pin , self -> idle_state );
292- common_hal_mcu_enable_interrupts ();
293289 }
294290
295291 // Reconfigure the pin and make sure its set to detect the first edge.
Original file line number Diff line number Diff line change @@ -60,26 +60,15 @@ void tick_delay(uint32_t us) {
6060 uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency () / 1000 / 1000 ;
6161 uint32_t us_until_next_tick = SysTick -> VAL / ticks_per_us ;
6262 uint32_t start_tick ;
63- while (us > 1000 ) {
64- // check if interrupts are disabled
65- if (__get_PRIMASK ())
66- return ; // if not just return
63+ while (us > us_until_next_tick ) {
6764 start_tick = SysTick -> VAL ; // wait for SysTick->VAL to RESET
6865 while (SysTick -> VAL < start_tick ) {}
6966 us -= us_until_next_tick ;
7067 us_until_next_tick = 1000 ;
7168 }
72- if (us && ( us < us_until_next_tick ) ){
69+ if (us ){
7370 while (SysTick -> VAL > ((us_until_next_tick - us ) * ticks_per_us )) {}
7471 }
75- else {
76- start_tick = SysTick -> VAL ; // wait for SysTick->VAL to RESET
77- while (SysTick -> VAL < start_tick ) {}
78- us -= us_until_next_tick ;
79- if (us ){
80- while (SysTick -> VAL > ((1000 - us ) * ticks_per_us )) {}
81- }
82- }
8372}
8473
8574// us counts down!
You can’t perform that action at this time.
0 commit comments