// Copyright 2018 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. #pragma once #include #include namespace imx_i2c { class SlaveAddressReg : public hwreg::RegisterBase { public: DEF_FIELD(7, 1, address); static auto Get() { return hwreg::RegisterAddr(0x0); } }; class FreqReg : public hwreg::RegisterBase { public: DEF_FIELD(5, 0, freq); static auto Get() { return hwreg::RegisterAddr(0x4); } }; class ControlReg : public hwreg::RegisterBase { public: DEF_BIT(7, enable); DEF_BIT(6, interrupt_enable); DEF_BIT(5, master); DEF_BIT(4, transmit); DEF_BIT(3, tx_ack_disable); DEF_BIT(2, repeat_start); static auto Get() { return hwreg::RegisterAddr(0x8); } }; class StatusReg : public hwreg::RegisterBase { public: DEF_BIT(7, transfer_complete); DEF_BIT(6, addressed_as_slave); DEF_BIT(5, bus_busy); DEF_BIT(4, arbitration_lost); DEF_BIT(2, slave_read_write); DEF_BIT(1, interrupt_pending); DEF_BIT(0, ack); static auto Get() { return hwreg::RegisterAddr(0xC); } }; // The register is 16 bits but since we only use 8 bits define as uint8_t to avoid casting class DataReg : public hwreg::RegisterBase { public: DEF_FIELD(7, 0, data); static auto Get() { return hwreg::RegisterAddr(0x10); } }; } // namespace imx_i2c