2014-04-13 22:10:01 -07:00
|
|
|
/*
|
|
|
|
Copyright 2012-2014 Benjamin Vedder benjamin@vedder.se
|
|
|
|
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
2014-09-19 18:22:38 -07:00
|
|
|
*/
|
2014-04-13 22:10:01 -07:00
|
|
|
|
|
|
|
/*
|
2014-04-18 15:09:46 -07:00
|
|
|
* app.c
|
2014-04-13 22:10:01 -07:00
|
|
|
*
|
2014-04-18 15:09:46 -07:00
|
|
|
* Created on: 18 apr 2014
|
2014-04-13 22:10:01 -07:00
|
|
|
* Author: benjamin
|
|
|
|
*/
|
|
|
|
|
2014-04-18 15:09:46 -07:00
|
|
|
#include "app.h"
|
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
2014-04-13 22:10:01 -07:00
|
|
|
|
2014-09-17 12:05:57 -07:00
|
|
|
// Private variables
|
2014-09-19 18:22:38 -07:00
|
|
|
static app_configuration appconf;
|
2014-09-17 12:05:57 -07:00
|
|
|
|
|
|
|
void app_init(app_configuration *conf) {
|
2014-09-19 18:22:38 -07:00
|
|
|
appconf = *conf;
|
2014-09-17 12:05:57 -07:00
|
|
|
|
2014-09-19 18:22:38 -07:00
|
|
|
switch (appconf.app_to_use) {
|
2014-09-17 12:05:57 -07:00
|
|
|
case APP_PPM:
|
2014-09-19 18:22:38 -07:00
|
|
|
app_ppm_configure(appconf.app_ppm_ctrl_type, appconf.app_ppm_pid_max_erpm, appconf.app_ppm_hyst,
|
|
|
|
appconf.app_ppm_timeout, appconf.app_ppm_pulse_start, appconf.app_ppm_pulse_width);
|
2014-09-17 12:05:57 -07:00
|
|
|
app_ppm_start();
|
|
|
|
break;
|
|
|
|
|
2014-09-19 18:22:38 -07:00
|
|
|
case APP_UART:
|
|
|
|
app_uartcomm_configure(appconf.app_uart_baudrate, appconf.app_uart_timeout);
|
|
|
|
app_uartcomm_start();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case APP_PPM_UART:
|
|
|
|
app_ppm_configure(appconf.app_ppm_ctrl_type, appconf.app_ppm_pid_max_erpm, appconf.app_ppm_hyst,
|
|
|
|
appconf.app_ppm_timeout, appconf.app_ppm_pulse_start, appconf.app_ppm_pulse_width);
|
|
|
|
app_ppm_start();
|
|
|
|
app_uartcomm_configure(appconf.app_uart_baudrate, appconf.app_uart_timeout);
|
2014-09-18 14:00:14 -07:00
|
|
|
app_uartcomm_start();
|
2014-09-17 12:05:57 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case APP_CUSTOM:
|
2014-04-18 15:09:46 -07:00
|
|
|
#ifdef USE_APP_STEN
|
2014-09-17 12:05:57 -07:00
|
|
|
app_sten_init();
|
2014-04-18 15:09:46 -07:00
|
|
|
#endif
|
|
|
|
#ifdef USE_APP_GURGALOF
|
2014-09-17 12:05:57 -07:00
|
|
|
app_gurgalof_init();
|
2014-07-19 02:41:16 -07:00
|
|
|
#endif
|
2014-09-17 12:05:57 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const app_configuration* app_get_configuration(void) {
|
2014-09-19 18:22:38 -07:00
|
|
|
return &appconf;
|
2014-09-17 12:05:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reconfigure all apps. Note that this will not start apps that are not already running, that
|
|
|
|
* should be done at boot. Some apps don't have any configuration options.
|
|
|
|
*
|
|
|
|
* @param conf
|
|
|
|
* The new configuration to use.
|
|
|
|
*/
|
|
|
|
void app_set_configuration(app_configuration *conf) {
|
2014-09-19 18:22:38 -07:00
|
|
|
appconf = *conf;
|
|
|
|
app_ppm_configure(appconf.app_ppm_ctrl_type, appconf.app_ppm_pid_max_erpm, appconf.app_ppm_hyst,
|
|
|
|
appconf.app_ppm_timeout, appconf.app_ppm_pulse_start, appconf.app_ppm_pulse_width);
|
|
|
|
app_uartcomm_configure(appconf.app_uart_baudrate, appconf.app_uart_timeout);
|
2014-04-18 15:09:46 -07:00
|
|
|
}
|