#include "i_hal.h" #include #include static RETURN_CODE_C hal_init(IHal *object) { return CreateReturnCode(C_RETURN_CODE_VIRTUAL_FUNCTION); } static void hal_free(IHal *object) { } static RETURN_CODE_C hal_un_init(IHal *object) { return CreateReturnCode(C_RETURN_CODE_VIRTUAL_FUNCTION); } static IHal default_hal = { .init = hal_init, .free = hal_free, .un_init = hal_un_init, }; static IHal *hal_instance = &default_hal; IHal *get_hal_instance(void) { return hal_instance; } RETURN_CODE_C new_i_hal(IHal **object) { if (!object || !(*object)) { return CreateReturnCode(C_RETURN_CODE_NOT_OK); } memcpy(*object, &default_hal, sizeof(IHal)); return CreateReturnCode(C_RETURN_CODE_OK); } void reset_hal_impl(IHal *impl) { hal_instance = impl; }