static void ds18x20GetAllTemps() { uint8_t i, j; uint8_t crc; static uint8_t arr[DS18X20_SCRATCH_LEN]; for (i = 0; i < devCount; i++) { if (ds18x20IsOnBus()) { ds18x20Select(&devs[i]); ds18x20SendByte(DS18X20_CMD_READ_SCRATCH); // Control scratchpad checksum crc = 0; for (j = 0; j < DS18X20_SCRATCH_LEN; j++) { arr[j] = ds18x20GetByte(); crc = _crc_ibutton_update(crc, arr[j]); } if (crc == 0) { // Save first 2 bytes (temperature) of scratchpad for (j = 0; j < DS18X20_SCRATCH_TEMP_LEN; j++) devs[i].sp[j] = arr[j]; } } } return; }
void ds18x20GetAllTemps() { uint8_t i, j; uint8_t arr[9]; for (i = 0; i < devCount; i++) { if (ds18x20IsOnBus()) { ds18x20Select(&devs[i]); ds18x20SendByte(DS18X20_CMD_READ_SCRATCH); for (j = 0; j < 9; j++) arr[j] = ds18x20GetByte(); if (!calcCRC8(arr, sizeof(arr))) { for (j = 0; j < 9; j++) devs[i].sp[j] = arr[j]; } } } return; }