40 lines
887 B
C++
40 lines
887 B
C++
#include "IHal.h"
|
|
#include "IHalCpp.h"
|
|
#include "StatusCode.h"
|
|
// #include <stddef.h>
|
|
#include <string.h>
|
|
static StatusCode IHalInit(IHal *object)
|
|
{
|
|
return IHalCpp::GetInstance()->Init();
|
|
}
|
|
static void IHalFree(IHal *object)
|
|
{
|
|
}
|
|
static StatusCode IHalUnInit(IHal *object)
|
|
{
|
|
return IHalCpp::GetInstance()->UnInit();
|
|
}
|
|
static IHal default_hal = {
|
|
.init = IHalInit,
|
|
.free = IHalFree,
|
|
.un_init = IHalUnInit,
|
|
};
|
|
static IHal *hal_instance = &default_hal;
|
|
IHal *GetHalIntance(void)
|
|
{
|
|
return hal_instance;
|
|
}
|
|
StatusCode NewIHal(IHal **object)
|
|
{
|
|
if (!object || !(*object))
|
|
{
|
|
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
|
}
|
|
memcpy(*object, &default_hal, sizeof(IHal));
|
|
return CreateStatusCode(STATUS_CODE_OK);
|
|
}
|
|
void ResetHalImpl(IHal *impl)
|
|
{
|
|
hal_instance->free(hal_instance);
|
|
hal_instance = impl;
|
|
} |