pico hid: slow blinking

This commit is contained in:
Maxim Devaev 2023-08-04 04:19:50 +03:00
parent 8c6e9eb4c1
commit b44c8516d7
3 changed files with 7 additions and 2 deletions

View File

@ -115,7 +115,7 @@ int main(void) {
ph_usb_task(); ph_usb_task();
if (!_reset_required) { if (!_reset_required) {
ph_spi_task(); ph_spi_task();
ph_debug_act_pulse(50); ph_debug_act_pulse(100);
} }
} }
return 0; return 0;

View File

@ -41,12 +41,16 @@ void ph_debug_init(bool enable_uart) {
gpio_set_dir(_ACT_PIN, GPIO_OUT); gpio_set_dir(_ACT_PIN, GPIO_OUT);
} }
void ph_debug_act(bool flag) {
gpio_put(_ACT_PIN, flag);
}
void ph_debug_act_pulse(u64 delay_ms) { void ph_debug_act_pulse(u64 delay_ms) {
static bool flag = false; static bool flag = false;
static u64 next_ts = 0; static u64 next_ts = 0;
const u64 now_ts = time_us_64(); const u64 now_ts = time_us_64();
if (now_ts >= next_ts) { if (now_ts >= next_ts) {
gpio_put(_ACT_PIN, flag); ph_debug_act(flag);
flag = !flag; flag = !flag;
next_ts = now_ts + (delay_ms * 1000); next_ts = now_ts + (delay_ms * 1000);
} }

View File

@ -24,4 +24,5 @@
void ph_debug_init(bool enable_uart); void ph_debug_init(bool enable_uart);
void ph_debug_act(bool flag);
void ph_debug_act_pulse(u64 delay_ms); void ph_debug_act_pulse(u64 delay_ms);