diff --git a/src/main.c b/src/main.c index e2d515bf714f6a9b0aed76ccc42cacc115a8b697..cb69edfb2fa8b135ef191e4a361c96f96db81a9e 100644 --- a/src/main.c +++ b/src/main.c @@ -117,10 +117,22 @@ void set_progress(double percentage) } } -void callback() +void callback(uint gpio, uint32_t events) + { int b = 4; int c = 9; + volatile uint another_slice_num = pwm_gpio_to_slice_num(27); + + if (events & GPIO_IRQ_EDGE_RISE) // reset pwm counter + { + pwm_set_counter(another_slice_num, 0); + } + else if (events & GPIO_IRQ_EDGE_FALL) + { + volatile uint16_t test = pwm_get_counter(another_slice_num); + set_progress(100); + } } int a = 0; @@ -164,8 +176,11 @@ int main() pwm_set_clkdiv(another_slice_num, 1); pwm_set_wrap(another_slice_num, 0xFFFF); pwm_set_clkdiv_mode(another_slice_num, PWM_DIV_FREE_RUNNING); - pwm_set_enabled(slice_num, true); + pwm_set_enabled(another_slice_num, true); + set_progress(0); + gpio_set_irq_enabled_with_callback(27, GPIO_IRQ_LEVEL_LOW | GPIO_IRQ_LEVEL_HIGH | GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE, true, &callback); + /* timer_hw->dbgpause = 0; gpio_init(27); gpio_init(28); @@ -197,7 +212,7 @@ int main() set_progress(percentage); asm("BKPT #0"); } - + */ a = 3; return 0; } \ No newline at end of file