OP-1900 added deceleration check to autotakeoff failsafe
[librepilot.git] / flight / modules / Osd / WavPlayer / wavplayer.c
blob0a96e54b7ef33b1b944412fd0e3544b65bc1fc1c
1 /**
2 ******************************************************************************
3 * @addtogroup OpenPilotModules OpenPilot Modules
4 * @{
5 * @addtogroup WavPlayerModule WavPlayer Module
6 * @brief Process WavPlayer information
7 * @{
9 * @file wavplayer.c
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
11 * @brief WavPlayer module
12 * @see The GNU Public License (GPL) Version 3
14 *****************************************************************************/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 // ****************
32 #include "openpilot.h"
34 // ****************
35 // Private functions
37 static void WavPlayerTask(void *parameters);
39 // ****************
40 // Private constants
42 #define STACK_SIZE_BYTES 1600
44 #define TASK_PRIORITY (tskIDLE_PRIORITY + 4)
46 // ****************
47 // Private variables
49 static xTaskHandle WavPlayerTaskHandle;
51 static uint32_t timeOfLastCommandMs;
52 static uint32_t timeOfLastUpdateMs;
54 // ****************
55 int32_t WavPlayerStart(void)
57 // Start WavPlayer task
58 xTaskCreate(WavPlayerTask, "WavPlayer", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY, &WavPlayerTaskHandle);
60 return 0;
62 /**
63 * Initialise the WavPlayer module
64 * \return -1 if initialisation failed
65 * \return 0 on success
67 int32_t WavPlayerInitialize(void)
69 return 0;
71 MODULE_INITCALL(WavPlayerInitialize, WavPlayerStart);
73 // ****************
74 /**
75 * Main WavPlayer task. It does not return.
78 static void WavPlayerTask(__attribute__((unused)) void *parameters)
80 portTickType lastSysTime;
82 // Loop forever
83 lastSysTime = xTaskGetTickCount();
84 uint32_t timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS;
86 timeOfLastUpdateMs = timeNowMs;
87 timeOfLastCommandMs = timeNowMs;
88 #if defined(PIOS_INCLUDE_WAVE)
89 WavePlayer_Start();
90 #endif
91 // Loop forever
92 while (1) {
93 vTaskDelayUntil(&lastSysTime, 50 / portTICK_RATE_MS);
94 timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS;
98 // ****************
101 * @}
102 * @}