AP_HAL_AVR_SITL: add Util driver, fix deprecated deps on HAL_AVR.h

This commit is contained in:
Pat Hickey 2012-12-18 17:13:01 -08:00 committed by Andrew Tridgell
parent 771f2a3acf
commit 4c715bfd04
7 changed files with 68 additions and 5 deletions

View File

@ -11,8 +11,9 @@ namespace AVR_SITL {
class SITLAnalogIn;
class SITLRCInput;
class SITLRCOutput;
class ADCSource;
class ADCSource;
class RCInput;
class SITLUtil;
}
#endif // __AP_HAL_AVR_SITL_NAMESPACE_H__

View File

@ -3,7 +3,6 @@
#include <AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
#include "HAL_AVR.h"
#include "AP_HAL_AVR_SITL.h"
#include "AnalogIn.h"
#include <stdint.h>

View File

@ -17,6 +17,7 @@
#include "RCInput.h"
#include "RCOutput.h"
#include "SITL_State.h"
#include "Util.h"
#include <AP_HAL_Empty.h>
#include <AP_HAL_Empty_Private.h>
@ -40,6 +41,8 @@ static SITLUARTDriver sitlUart0Driver(0, &sitlState);
static SITLUARTDriver sitlUart1Driver(1, &sitlState);
static SITLUARTDriver sitlUart2Driver(2, &sitlState);
static SITLUtil utilInstance;
HAL_AVR_SITL::HAL_AVR_SITL() :
AP_HAL::HAL(
&sitlUart0Driver, /* uartA */
@ -53,7 +56,8 @@ HAL_AVR_SITL::HAL_AVR_SITL() :
&emptyGPIO, /* gpio */
&sitlRCInput, /* rcinput */
&sitlRCOutput, /* rcoutput */
&sitlScheduler), /* scheduler */
&sitlScheduler, /* scheduler */
&utilInstance), /* util */
_sitl_state(&sitlState)
{}

View File

@ -3,7 +3,6 @@
#include <AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
#include "HAL_AVR.h"
#include "AP_HAL_AVR_SITL.h"
#include "Scheduler.h"
#include <sys/time.h>

View File

@ -0,0 +1,44 @@
#include <AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
#include <stdio.h>
#include <stdarg.h>
int libc_vsnprintf(char* str, size_t size, const char *format, va_list ap) {
vsnprintf(str, size, format, ap);
}
#include "Util.h"
using namespace AVR_SITL;
int SITLUtil::snprintf(char* str, size_t size, const char *format, ...)
{
va_list ap;
va_start(ap, format);
int res = libc_vsnprintf(str, size, format, ap);
va_end(ap);
return res;
}
int SITLUtil::snprintf_P(char* str, size_t size, const prog_char_t *format, ...)
{
va_list ap;
va_start(ap, format);
int res = libc_vsnprintf(str, size, format, ap);
va_end(ap);
return res;
}
int SITLUtil::vsnprintf(char* str, size_t size, const char *format, va_list ap)
{
return libc_vsnprintf(str, size, format, ap);
}
int SITLUtil::vsnprintf_P(char* str, size_t size, const prog_char_t *format,
va_list ap)
{
return libc_vsnprintf(str, size, format, ap);
}
#endif // CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL

View File

@ -0,0 +1,17 @@
#ifndef __AP_HAL_SITL_UTIL_H__
#define __AP_HAL_SITL_UTIL_H__
#include <AP_HAL.h>
#include "AP_HAL_AVR_SITL_Namespace.h"
class AVR_SITL::SITLUtil : public AP_HAL::Util {
public:
int snprintf(char* str, size_t size, const char *format, ...);
int snprintf_P(char* str, size_t size, const prog_char_t *format, ...);
int vsnprintf(char* str, size_t size, const char *format, va_list ap);
int vsnprintf_P(char* str, size_t size, const prog_char_t *format,
va_list ap);
};
#endif // __AP_HAL_SITL_UTIL_H__

View File

@ -9,7 +9,6 @@
#include <AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
#include "HAL_AVR.h"
#include "AP_HAL_AVR_SITL.h"
using namespace AVR_SITL;