shell: alarm: add command to enable/disable the alarm

master
S.J.R. van Schaik 7 years ago
parent 0542810d22
commit 6394c5f006
  1. 3
      include/shell/alarm.h
  2. 1
      source/shell/Makefile
  3. 28
      source/shell/alarm.c

@ -0,0 +1,3 @@
#pragma once
int shell_alarm(struct console *con, size_t argc, const char **argv);

@ -1,3 +1,4 @@
obj-y += source/shell/alarm.o
obj-y += source/shell/args.o
obj-y += source/shell/boot.o
obj-y += source/shell/buzzer.o

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libopencm3/stm32/gpio.h>
#include <console.h>
#include <rtc.h>
int shell_alarm(struct console *con, size_t argc, const char **argv)
{
int state = 0;
uint32_t timeout = 10;
if (argc >= 2)
timeout = strtoul(argv[0], NULL, 0);
if (argc >= 1)
state = (strcmp(argv[1], "on") == 0);
if (state) {
alarm_enable(timeout);
} else {
alarm_disable();
}
return 0;
}
Loading…
Cancel
Save