2010-03-15 13:04:03 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file openpilot.c
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @brief Sets up and runs main OpenPilot tasks.
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* OpenPilot Includes */
|
|
|
|
#include "openpilot.h"
|
|
|
|
|
|
|
|
/* Task Priorities */
|
|
|
|
|
|
|
|
/* Global Variables */
|
|
|
|
|
|
|
|
/* Local Variables */
|
|
|
|
|
|
|
|
/* Function Prototypes */
|
|
|
|
static void TaskTesting(void *pvParameters);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test Main function
|
|
|
|
*/
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// Init
|
|
|
|
PIOS_SYS_Init();
|
|
|
|
PIOS_DELAY_Init();
|
|
|
|
PIOS_COM_Init();
|
|
|
|
PIOS_ADC_Init();
|
|
|
|
PIOS_I2C_Init();
|
|
|
|
xTaskCreate(TaskTesting, (signed portCHAR *)"Test", configMINIMAL_STACK_SIZE , NULL, 1, NULL);
|
|
|
|
|
|
|
|
// Start the FreeRTOS scheduler
|
|
|
|
vTaskStartScheduler();
|
|
|
|
|
|
|
|
// Should not get here
|
|
|
|
PIOS_DEBUG_Assert(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void TaskTesting(void *pvParameters)
|
|
|
|
{
|
|
|
|
portTickType xDelay = 500 / portTICK_RATE_MS;
|
|
|
|
portTickType xTimeout = 10 / portTICK_RATE_MS;
|
|
|
|
|
|
|
|
PIOS_BMP085_Init();
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
2010-03-23 05:01:11 +01:00
|
|
|
PIOS_LED_Toggle(LED2);
|
|
|
|
|
|
|
|
int16_t temp;
|
|
|
|
int32_t pressure;
|
2010-03-15 13:04:03 +01:00
|
|
|
|
|
|
|
PIOS_BMP085_StartADC(TemperatureConv);
|
|
|
|
xSemaphoreTake(PIOS_BMP085_EOC, xTimeout);
|
|
|
|
PIOS_BMP085_ReadADC();
|
|
|
|
|
|
|
|
PIOS_BMP085_StartADC(PressureConv);
|
|
|
|
xSemaphoreTake(PIOS_BMP085_EOC, xTimeout);
|
|
|
|
PIOS_BMP085_ReadADC();
|
2010-03-23 05:01:11 +01:00
|
|
|
|
|
|
|
temp = PIOS_BMP085_GetTemperature();
|
2010-03-15 13:04:03 +01:00
|
|
|
pressure = PIOS_BMP085_GetPressure();
|
|
|
|
|
2010-03-23 05:01:11 +01:00
|
|
|
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART, "%3u,%4u\r", temp, pressure);
|
2010-03-15 13:04:03 +01:00
|
|
|
|
|
|
|
vTaskDelay(xDelay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Idle hook function
|
|
|
|
*/
|
|
|
|
void vApplicationIdleHook(void)
|
|
|
|
{
|
|
|
|
/* Called when the scheduler has no tasks to run */
|
|
|
|
|
|
|
|
|
|
|
|
}
|