@@ -966,39 +966,25 @@ bool SettingsStruct_tmpl<N_TASKS>::isSPI_valid() const {
966966template <unsigned int N_TASKS>
967967bool SettingsStruct_tmpl<N_TASKS>::isI2C_pin(int8_t pin) const {
968968 if (pin < 0 ) { return false ; }
969- return Pin_i2c_sda == pin || Pin_i2c_scl == pin
970- #if FEATURE_I2C_MULTIPLE
971- || ((getI2CBusCount () >= 2 ) && (Pin_i2c2_sda == pin || Pin_i2c2_scl == pin))
972- #if FEATURE_I2C_INTERFACE_3
973- || ((getI2CBusCount () >= 3 ) && (Pin_i2c3_sda == pin || Pin_i2c3_scl == pin))
974- #endif // if FEATURE_I2C_INTERFACE_3
975- #endif // if FEATURE_I2C_MULTIPLE
976- ;
969+ for (uint8_t i2cBus = 0 ; i2cBus < getI2CBusCount (); ++i2cBus) {
970+ if ((getI2CSdaPin (i2cBus) == pin) || (getI2CSclPin (i2cBus) == pin)) {
971+ return true ;
972+ }
973+ }
974+ return false ;
977975}
978976
979977template <unsigned int N_TASKS>
980978bool SettingsStruct_tmpl<N_TASKS>::isI2CEnabled(uint8_t i2cBus) const {
981- if (0 == i2cBus) {
982- return (Pin_i2c_sda != -1 ) &&
983- (Pin_i2c_scl != -1 ) &&
984- (I2C_clockSpeed > 0 ) &&
985- (I2C_clockSpeed_Slow > 0 );
986- #if FEATURE_I2C_MULTIPLE
987- } else if (1 == i2cBus) {
988- return (Pin_i2c2_sda != -1 ) &&
989- (Pin_i2c2_scl != -1 ) &&
990- (I2C2_clockSpeed > 0 ) &&
991- (I2C2_clockSpeed_Slow > 0 );
992- #if FEATURE_I2C_INTERFACE_3
993- } else {
994- return (Pin_i2c3_sda != -1 ) &&
995- (Pin_i2c3_scl != -1 ) &&
996- (I2C3_clockSpeed > 0 ) &&
997- (I2C3_clockSpeed_Slow > 0 );
998- #endif // if FEATURE_I2C_INTERFACE_3
999- #endif // if FEATURE_I2C_MULTIPLE
1000- }
1001- return false ;
979+ return (getI2CSdaPin (i2cBus) != -1 ) &&
980+ (getI2CSclPin (i2cBus) != -1 ) &&
981+ (getI2CClockSpeed (i2cBus) > 0 ) &&
982+ (getI2CClockSpeedSlow (i2cBus) > 0 );
983+ }
984+
985+ template <unsigned int N_TASKS>
986+ uint8_t SettingsStruct_tmpl<N_TASKS>::getI2CInterface(taskIndex_t TaskIndex) const {
987+ return get3BitFromUL (I2C_Flags[TaskIndex], I2C_FLAGS_BUS_NUMBER);
1002988}
1003989
1004990template <unsigned int N_TASKS>
@@ -1081,6 +1067,23 @@ uint32_t SettingsStruct_tmpl<N_TASKS>::getI2CClockStretch(uint8_t i2cBus) const
10811067 return 0u ;
10821068}
10831069
1070+ #if FEATURE_I2C_MULTIPLE
1071+ template <unsigned int N_TASKS>
1072+ uint8_t SettingsStruct_tmpl<N_TASKS>::getI2CInterfaceRTC () const {
1073+ return get3BitFromUL (I2C_peripheral_bus, I2C_PERIPHERAL_BUS_CLOCK);
1074+ }
1075+
1076+ template <unsigned int N_TASKS>
1077+ uint8_t SettingsStruct_tmpl<N_TASKS>::getI2CInterfaceWDT () const {
1078+ return get3BitFromUL (I2C_peripheral_bus, I2C_PERIPHERAL_BUS_WDT);
1079+ }
1080+
1081+ template <unsigned int N_TASKS>
1082+ uint8_t SettingsStruct_tmpl<N_TASKS>::getI2CInterfacePCFMCP () const {
1083+ return get3BitFromUL (I2C_peripheral_bus, I2C_PERIPHERAL_BUS_PCFMCP);
1084+ }
1085+ #endif // if FEATURE_I2C_MULTIPLE
1086+
10841087#if FEATURE_I2CMULTIPLEXER
10851088template <unsigned int N_TASKS>
10861089int8_t SettingsStruct_tmpl<N_TASKS>::getI2CMultiplexerType (uint8_t i2cBus) const {
0 commit comments