main: add rest time parameter

This commit is contained in:
King Kévin 2022-10-12 12:14:03 +02:00
parent 21067f5f4c
commit 0e7914ad9d
1 changed files with 7 additions and 3 deletions

10
main.c
View File

@ -42,6 +42,9 @@ static volatile uint16_t shake_count = 0;
// number of time counts (+1 @ 488 Hz)
static volatile uint32_t time_count = 0;
// time after last shake to go to sleep, in seconds
#define REST_TIME (5 * 60U)
// blocking wait (in 10 us steps, up to UINT32_MAX / 10)
static void wait_10us(uint32_t us10)
{
@ -254,9 +257,10 @@ void main(void)
puts("\r\n");
shake_count = 0; // reset count
}
if (time_count > 488 * 10) {
puts("10s\r\n");
if (time_count > 488UL * REST_TIME) {
puts("rest\r\n");
time_count = 0; // reset counter
LED_UV_PORT->ODR.reg &= ~LED_UV_PIN; // switch UV LED off
led_red(0); // ensure LED is off
led_green(0); // ensure LED is off
led_blue(0); // ensure LED is off
@ -283,7 +287,7 @@ void shake_isr(void) __interrupt(SHAKE_IRQ)
shake_count++; // register vibration
}
// time counter
// system time counter
void time_isr(void) __interrupt(IRQ_TIM4)
{
TIM4->SR.fields.UIF = 0; // clear flag