blob: ec49b1e6edbb75298416c3fdf7557609a4b811b1 [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FUCHSIA_SDK_EXAMPLES_I2C_TEMPERATURE_DRIVER_I2C_TEMPERATURE_H_
#define FUCHSIA_SDK_EXAMPLES_I2C_TEMPERATURE_DRIVER_I2C_TEMPERATURE_H_
#include <lib/driver/compat/cpp/compat.h>
#include <lib/driver/compat/cpp/context.h>
#include <lib/driver/component/cpp/driver_cpp.h>
#include "i2c_channel.h"
namespace i2c_temperature {
// Sample driver for a virtual temperature sensor device connected to an I2C bus controller.
class I2cTemperatureDriver : public driver::DriverBase {
public:
I2cTemperatureDriver(driver::DriverStartArgs start_args, fdf::UnownedDispatcher driver_dispatcher)
: driver::DriverBase("i2c-temperature", std::move(start_args), std::move(driver_dispatcher)) {
}
virtual ~I2cTemperatureDriver() = default;
zx::result<> Start() override;
private:
zx::result<> SetupI2cChannel();
void InitializeCompatService(zx::result<std::shared_ptr<compat::Context>> result);
std::shared_ptr<compat::Context> compat_context_;
std::shared_ptr<I2cChannel> i2c_channel_;
};
} // namespace i2c_temperature
#endif // FUCHSIA_SDK_EXAMPLES_I2C_TEMPERATURE_DRIVER_I2C_TEMPERATURE_H_