AP_HAL_Empty: add Util driver

This commit is contained in:
Pat Hickey 2012-12-18 17:12:41 -08:00 committed by Andrew Tridgell
parent f9eff068f9
commit 771f2a3acf
5 changed files with 57 additions and 1 deletions

View File

@ -22,6 +22,7 @@ namespace Empty {
class EmptyRCOutput;
class EmptySemaphore;
class EmptyScheduler;
class EmptyUtil;
class EmptyPrivateMember;
}

View File

@ -17,6 +17,7 @@
#include "RCOutput.h"
#include "Semaphore.h"
#include "Scheduler.h"
#include "Util.h"
#include "PrivateMember.h"
#endif // __AP_HAL_EMPTY_PRIVATE_H__

View File

@ -18,6 +18,7 @@ static EmptyGPIO gpioDriver;
static EmptyRCInput rcinDriver;
static EmptyRCOutput rcoutDriver;
static EmptyScheduler schedulerInstance;
static EmptyUtil utilInstance;
HAL_Empty::HAL_Empty() :
AP_HAL::HAL(
@ -32,7 +33,8 @@ HAL_Empty::HAL_Empty() :
&gpioDriver,
&rcinDriver,
&rcoutDriver,
&schedulerInstance),
&schedulerInstance,
&utilInstance),
_member(new EmptyPrivateMember(123))
{}

View File

@ -0,0 +1,35 @@
#include "Util.h"
using namespace Empty;
int EmptyUtil::snprintf(char* str, size_t size, const char *format, ...)
{
va_list ap;
va_start(ap, format);
int res = this->vsnprintf(str, size, format, ap);
va_end(ap);
return res;
}
int EmptyUtil::snprintf_P(char* str, size_t size, const prog_char_t *format, ...)
{
va_list ap;
va_start(ap, format);
int res = this->vsnprintf_P(str, size, format, ap);
va_end(ap);
return res;
}
int EmptyUtil::vsnprintf(char* str, size_t size, const char *format, va_list ap)
{
return 0;
}
int EmptyUtil::vsnprintf_P(char* str, size_t size, const prog_char_t *format,
va_list ap)
{
return 0;
}

View File

@ -0,0 +1,17 @@
#ifndef __AP_HAL_EMPTY_UTIL_H__
#define __AP_HAL_EMPTY_UTIL_H__
#include <AP_HAL.h>
#include "AP_HAL_Empty_Namespace.h"
class Empty::EmptyUtil : 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_EMPTY_UTIL_H__