2012-12-12 18:04:27 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2012-12-11 21:30:12 -04:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2012-12-11 21:30:12 -04:00
|
|
|
|
2015-05-04 03:15:12 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
2012-12-11 21:30:12 -04:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include "AP_HAL_SITL.h"
|
2015-05-04 03:15:12 -03:00
|
|
|
#include "AP_HAL_SITL_Namespace.h"
|
|
|
|
#include "HAL_SITL_Class.h"
|
2012-12-12 18:04:27 -04:00
|
|
|
#include "Scheduler.h"
|
2012-12-13 18:57:01 -04:00
|
|
|
#include "AnalogIn.h"
|
2012-12-12 18:04:27 -04:00
|
|
|
#include "UARTDriver.h"
|
|
|
|
#include "Storage.h"
|
2012-12-17 22:33:46 -04:00
|
|
|
#include "RCInput.h"
|
2012-12-17 23:56:21 -04:00
|
|
|
#include "RCOutput.h"
|
2012-12-13 18:57:01 -04:00
|
|
|
#include "SITL_State.h"
|
2012-12-18 21:13:01 -04:00
|
|
|
#include "Util.h"
|
2012-12-13 18:57:01 -04:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include <AP_HAL_Empty/AP_HAL_Empty.h>
|
|
|
|
#include <AP_HAL_Empty/AP_HAL_Empty_Private.h>
|
2012-12-17 22:33:46 -04:00
|
|
|
|
2015-05-04 03:15:12 -03:00
|
|
|
using namespace HALSITL;
|
2012-12-11 21:30:12 -04:00
|
|
|
|
2012-12-12 18:04:27 -04:00
|
|
|
static SITLEEPROMStorage sitlEEPROMStorage;
|
2012-12-13 18:57:01 -04:00
|
|
|
static SITL_State sitlState;
|
2014-11-15 20:04:55 -04:00
|
|
|
static SITLScheduler sitlScheduler(&sitlState);
|
2012-12-17 23:56:21 -04:00
|
|
|
static SITLRCInput sitlRCInput(&sitlState);
|
|
|
|
static SITLRCOutput sitlRCOutput(&sitlState);
|
2012-12-18 03:42:48 -04:00
|
|
|
static SITLAnalogIn sitlAnalogIn(&sitlState);
|
2012-12-11 21:30:12 -04:00
|
|
|
|
2012-12-18 06:14:32 -04:00
|
|
|
// use the Empty HAL for hardware we don't emulate
|
2012-12-17 22:33:46 -04:00
|
|
|
static Empty::EmptyGPIO emptyGPIO;
|
2013-01-04 20:20:22 -04:00
|
|
|
static Empty::EmptySemaphore emptyI2Csemaphore;
|
|
|
|
static Empty::EmptyI2CDriver emptyI2C(&emptyI2Csemaphore);
|
2012-12-18 06:14:32 -04:00
|
|
|
static Empty::EmptySPIDeviceManager emptySPI;
|
2012-12-17 22:33:46 -04:00
|
|
|
|
|
|
|
static SITLUARTDriver sitlUart0Driver(0, &sitlState);
|
|
|
|
static SITLUARTDriver sitlUart1Driver(1, &sitlState);
|
|
|
|
static SITLUARTDriver sitlUart2Driver(2, &sitlState);
|
2013-11-22 04:16:05 -04:00
|
|
|
static SITLUARTDriver sitlUart3Driver(3, &sitlState);
|
2013-12-21 07:26:30 -04:00
|
|
|
static SITLUARTDriver sitlUart4Driver(4, &sitlState);
|
2012-12-11 21:30:12 -04:00
|
|
|
|
2012-12-18 21:13:01 -04:00
|
|
|
static SITLUtil utilInstance;
|
|
|
|
|
2015-05-04 03:15:12 -03:00
|
|
|
HAL_SITL::HAL_SITL() :
|
2012-12-11 21:30:12 -04:00
|
|
|
AP_HAL::HAL(
|
2015-05-04 21:59:07 -03:00
|
|
|
&sitlUart0Driver, /* uartA */
|
2013-11-22 04:16:05 -04:00
|
|
|
&sitlUart1Driver, /* uartB */
|
2012-12-12 18:04:27 -04:00
|
|
|
&sitlUart2Driver, /* uartC */
|
2013-11-22 04:16:05 -04:00
|
|
|
&sitlUart3Driver, /* uartD */
|
2013-12-21 07:26:30 -04:00
|
|
|
&sitlUart4Driver, /* uartE */
|
2012-12-18 06:14:32 -04:00
|
|
|
&emptyI2C, /* i2c */
|
2015-06-15 14:46:31 -03:00
|
|
|
&emptyI2C, /* i2c */
|
|
|
|
&emptyI2C, /* i2c */
|
2012-12-18 06:14:32 -04:00
|
|
|
&emptySPI, /* spi */
|
2012-12-18 03:32:20 -04:00
|
|
|
&sitlAnalogIn, /* analogin */
|
2012-12-12 18:04:27 -04:00
|
|
|
&sitlEEPROMStorage, /* storage */
|
2013-10-05 05:32:23 -03:00
|
|
|
&sitlUart0Driver, /* console */
|
2012-12-17 22:33:46 -04:00
|
|
|
&emptyGPIO, /* gpio */
|
2012-12-17 23:56:21 -04:00
|
|
|
&sitlRCInput, /* rcinput */
|
|
|
|
&sitlRCOutput, /* rcoutput */
|
2012-12-18 21:13:01 -04:00
|
|
|
&sitlScheduler, /* scheduler */
|
|
|
|
&utilInstance), /* util */
|
2012-12-13 18:57:01 -04:00
|
|
|
_sitl_state(&sitlState)
|
2012-12-11 21:30:12 -04:00
|
|
|
{}
|
|
|
|
|
2015-05-04 21:59:07 -03:00
|
|
|
void HAL_SITL::init(int argc, char * const argv[]) const
|
2012-12-13 18:57:01 -04:00
|
|
|
{
|
|
|
|
_sitl_state->init(argc, argv);
|
2012-12-12 18:04:27 -04:00
|
|
|
scheduler->init(NULL);
|
2012-12-11 21:30:12 -04:00
|
|
|
uartA->begin(115200);
|
|
|
|
|
2012-12-17 22:33:46 -04:00
|
|
|
rcin->init(NULL);
|
|
|
|
rcout->init(NULL);
|
|
|
|
|
2012-12-13 18:57:01 -04:00
|
|
|
//spi->init(NULL);
|
|
|
|
//i2c->begin();
|
|
|
|
//i2c->setTimeout(100);
|
2012-12-11 21:30:12 -04:00
|
|
|
analogin->init(NULL);
|
|
|
|
}
|
|
|
|
|
2015-05-04 03:15:12 -03:00
|
|
|
const HAL_SITL AP_HAL_SITL;
|
2012-12-11 21:30:12 -04:00
|
|
|
|
2015-05-04 03:15:12 -03:00
|
|
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_SITL
|