main: add rest time parameter
This commit is contained in:
parent
21067f5f4c
commit
0e7914ad9d
10
main.c
10
main.c
|
@ -42,6 +42,9 @@ static volatile uint16_t shake_count = 0;
|
||||||
// number of time counts (+1 @ 488 Hz)
|
// number of time counts (+1 @ 488 Hz)
|
||||||
static volatile uint32_t time_count = 0;
|
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)
|
// blocking wait (in 10 us steps, up to UINT32_MAX / 10)
|
||||||
static void wait_10us(uint32_t us10)
|
static void wait_10us(uint32_t us10)
|
||||||
{
|
{
|
||||||
|
@ -254,9 +257,10 @@ void main(void)
|
||||||
puts("\r\n");
|
puts("\r\n");
|
||||||
shake_count = 0; // reset count
|
shake_count = 0; // reset count
|
||||||
}
|
}
|
||||||
if (time_count > 488 * 10) {
|
if (time_count > 488UL * REST_TIME) {
|
||||||
puts("10s\r\n");
|
puts("rest\r\n");
|
||||||
time_count = 0; // reset counter
|
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_red(0); // ensure LED is off
|
||||||
led_green(0); // ensure LED is off
|
led_green(0); // ensure LED is off
|
||||||
led_blue(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
|
shake_count++; // register vibration
|
||||||
}
|
}
|
||||||
|
|
||||||
// time counter
|
// system time counter
|
||||||
void time_isr(void) __interrupt(IRQ_TIM4)
|
void time_isr(void) __interrupt(IRQ_TIM4)
|
||||||
{
|
{
|
||||||
TIM4->SR.fields.UIF = 0; // clear flag
|
TIM4->SR.fields.UIF = 0; // clear flag
|
||||||
|
|
Loading…
Reference in New Issue