From 310ff3839cec11d966649897debbd1d52ffa11e6 Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Thu, 22 Oct 2020 13:04:55 +0200 Subject: [PATCH] Add platform.h interface definition --- openrtx/include/interfaces/platform.h | 106 ++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 openrtx/include/interfaces/platform.h diff --git a/openrtx/include/interfaces/platform.h b/openrtx/include/interfaces/platform.h new file mode 100644 index 00000000..33170c04 --- /dev/null +++ b/openrtx/include/interfaces/platform.h @@ -0,0 +1,106 @@ +/*************************************************************************** + * Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Silvano Seva IU2KWO * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see * + ***************************************************************************/ + +#ifndef PLATFORM_H +#define PLATFORM_H + +#include +#include + +/** + * Standard interface for device-specific hardware. + * This interface handles: + * - LEDs + * - Battery voltage read + * - Microphone level + * - Volume and channel selectors + * - Screen backlight control + */ + +typedef enum +{ + GREEN = 0, + RED, + YELLOW, + WHITE, +} led_t; + +/** + * This function handles device hardware initialization. + * Usually called at power-on + */ +void platform_init(); + +/** + * This function handles device hardware de-initialization. + * Usually called at power-down + */ +void platform_terminate(); + +/** + * This function reads and returns the current battery voltage. + */ +float platform_getVbat(); + +/** + * This function reads and returns the current microphone input level. + */ +float platform_getMicLevel(); + +/** + * This function reads and returns the current volume selector level. + */ +float platform_getVolumeLevel(); + +/** + * This function reads and returns the current channel selector level. + */ +uint8_t platform_getChSelector(); + +/** + * This function turns on the selected led. + * @param led: which led to control + */ +void platform_ledOn(led_t led); + +/** + * This function turns off the selected led. + * @param led: which led to control + */ +void platform_ledOff(led_t led); + +/** + * This function emits a tone of the specified frequency from the speaker. + * @param freq: desired frequency + */ +void platform_beepStart(uint16_t freq); + +/** + * This function stops emitting a tone. + */ +void platform_beepStop(); + +/** + * This function sets the screen backlight to the specified level. + * @param level: backlight level, from 0 (backlight off) to 255 (backlight at + * full brightness). + */ +void platform_setBacklightLevel(uint8_t level); + +#endif /* PLATFORM_H */