@@ -176,7 +176,7 @@ uint8_t INA_Class::begin(const uint8_t maxBusAmps, const uint32_t microOhmR, con
176176 uint16_t originalRegister,tempRegister; // Stores 16-bit register contents //
177177 if (_DeviceCount==0 ) // Enumerate devices in first call //
178178 { // //
179- uint8_t maxDevices = 0 ; // declare variable //
179+ uint16_t maxDevices = 0 ; // declare variable //
180180 #if defined(ESP32) || defined(ESP2866) // //
181181 EEPROM.begin (512 ); // If ESP32 then allocate 512 Bytes //
182182 maxDevices = 512 / sizeof (inaEE); // and compute number of devices //
@@ -185,12 +185,12 @@ uint8_t INA_Class::begin(const uint8_t maxBusAmps, const uint32_t microOhmR, con
185185 #endif // //
186186 #if defined(__STM32F1__) // Emulated EEPROM for STM32F1 //
187187 maxDevices = EEPROM.maxcount () / sizeof (inaEE); // Compute number devices possible //
188- #elif defined(CORE_TEENSY) || defined(MK20DX128) || defined(MK20DX256) || \
189- defined (MKL26Z64) || defined (MK64FX512) || defined (MK66FX1M0) // TEENSY doesn't have EEPROM.length//
188+ #elif defined(CORE_TEENSY) // TEENSY doesn't have EEPROM.length//
190189 maxDevices = 2048 / sizeof (inaEE); // defined, so use 2Kb as value //
191190 #else // EEPROM Library V2.0 for Arduino //
192191 maxDevices = EEPROM.length () / sizeof (inaEE); // Compute number devices possible //
193192 #endif // //
193+ if (maxDevices > 255 ) { maxDevices = 255 ; } // Limit to a 8-bit number //
194194 for (uint8_t deviceAddress = 0x40 ;deviceAddress<0x80 ;deviceAddress++) // Loop for each possible address //
195195 { // //
196196 Wire.beginTransmission (deviceAddress); // See if something is at address //
@@ -201,7 +201,7 @@ uint8_t INA_Class::begin(const uint8_t maxBusAmps, const uint32_t microOhmR, con
201201 tempRegister = readWord (INA_CONFIGURATION_REGISTER,deviceAddress);// Read the newly reset register //
202202 if (tempRegister==INA_RESET_DEVICE ) // If the register isn't reset then //
203203 { // //
204- writeWord (INA_CONFIGURATION_REGISTER,originalRegister,deviceAddress);// Not an an INA, write back value//
204+ writeWord (INA_CONFIGURATION_REGISTER,originalRegister,deviceAddress);// Not an an INA, write back value //
205205 } // //
206206 else // otherwise we know it is an INA //
207207 { // //
0 commit comments