i2c: add auto-generated bus/device map
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
|
||||
#else
|
||||
|
||||
#error "Unknown board for ams::gpio::driver::"
|
||||
#error "Unknown board for ams::i2c::driver::"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,6 +19,46 @@
|
||||
|
||||
namespace ams::i2c {
|
||||
|
||||
enum I2cBus {
|
||||
I2cBus_I2c1 = 0,
|
||||
I2cBus_I2c2 = 1,
|
||||
I2cBus_I2c3 = 2,
|
||||
I2cBus_I2c4 = 3,
|
||||
I2cBus_I2c5 = 4,
|
||||
I2cBus_I2c6 = 5,
|
||||
};
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_I2c1 = 0x02000001;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c2 = 0x02000002;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c3 = 0x02000003;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c4 = 0x02000004;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c5 = 0x02000005;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c6 = 0x02000006;
|
||||
|
||||
constexpr inline DeviceCode ConvertToDeviceCode(I2cBus bus) {
|
||||
switch (bus) {
|
||||
case I2cBus_I2c1: return DeviceCode_I2c1;
|
||||
case I2cBus_I2c2: return DeviceCode_I2c2;
|
||||
case I2cBus_I2c3: return DeviceCode_I2c3;
|
||||
case I2cBus_I2c4: return DeviceCode_I2c4;
|
||||
case I2cBus_I2c5: return DeviceCode_I2c5;
|
||||
case I2cBus_I2c6: return DeviceCode_I2c6;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
constexpr inline DeviceCode ConvertToI2cBus(DeviceCode dc) {
|
||||
switch (dc.GetInternalValue()) {
|
||||
case DeviceCode_I2c1.GetInternalValue(): return I2cBus_I2c1;
|
||||
case DeviceCode_I2c2.GetInternalValue(): return I2cBus_I2c2;
|
||||
case DeviceCode_I2c3.GetInternalValue(): return I2cBus_I2c3;
|
||||
case DeviceCode_I2c4.GetInternalValue(): return I2cBus_I2c4;
|
||||
case DeviceCode_I2c5.GetInternalValue(): return I2cBus_I2c5;
|
||||
case DeviceCode_I2c6.GetInternalValue(): return I2cBus_I2c6;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
enum I2cDevice : u32 {
|
||||
I2cDevice_ClassicController = 0,
|
||||
I2cDevice_Ftm3bd56 = 1,
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace ams::i2c {
|
||||
|
||||
enum TransactionOption : u32 {
|
||||
TransactionOption_StartCondition = (1u << 0),
|
||||
TransactionOption_TopCondition = (1u << 1),
|
||||
TransactionOption_StopCondition = (1u << 1),
|
||||
TransactionOption_MaxBits = (1u << 30),
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace ams::i2c {
|
||||
};
|
||||
|
||||
enum SpeedMode : u32 {
|
||||
SpeedMode_Normal = 100000,
|
||||
SpeedMode_Standard = 100000,
|
||||
SpeedMode_Fast = 400000,
|
||||
SpeedMode_FastPlus = 1000000,
|
||||
SpeedMode_HighSpeed = 3400000,
|
||||
|
||||
Reference in New Issue
Block a user