2017-12-08 01:42:20 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
|
2017-12-08 01:42:20 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "hal/HAL.h"
|
|
|
|
|
#include "hal/I2C.h"
|
|
|
|
|
#include "hal/handles/HandlesInternal.h"
|
|
|
|
|
#include "mockdata/I2CData.h"
|
2017-12-08 01:42:20 -05:00
|
|
|
|
|
|
|
|
namespace hal {
|
|
|
|
|
|
|
|
|
|
std::string gTestI2CCallbackName;
|
|
|
|
|
HAL_Value gTestI2CCallbackValue;
|
|
|
|
|
|
|
|
|
|
void TestI2CInitializationCallback(const char* name, void* param,
|
|
|
|
|
const struct HAL_Value* value) {
|
|
|
|
|
gTestI2CCallbackName = name;
|
|
|
|
|
gTestI2CCallbackValue = *value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(I2CSimTests, TestI2CInitialization) {
|
|
|
|
|
const int INDEX_TO_TEST = 1;
|
|
|
|
|
|
|
|
|
|
int32_t status;
|
|
|
|
|
HAL_I2CPort port;
|
|
|
|
|
|
|
|
|
|
int callbackParam = 0;
|
|
|
|
|
int callbackId = HALSIM_RegisterI2CInitializedCallback(
|
|
|
|
|
INDEX_TO_TEST, &TestI2CInitializationCallback, &callbackParam, false);
|
|
|
|
|
ASSERT_TRUE(0 != callbackId);
|
|
|
|
|
|
|
|
|
|
status = 0;
|
|
|
|
|
port = HAL_I2C_kMXP;
|
|
|
|
|
gTestI2CCallbackName = "Unset";
|
|
|
|
|
HAL_InitializeI2C(port, &status);
|
|
|
|
|
EXPECT_STREQ("Initialized", gTestI2CCallbackName.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace hal
|