MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / owb_read_rom

Function owb_read_rom

modules/drivers/onewire/esp/owb.c:273–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273owb_status owb_read_rom(const OneWireBus * bus, OneWireBus_ROMCode *rom_code)
274{
275 owb_status status;
276
277 memset(rom_code, 0, sizeof(OneWireBus_ROMCode));
278
279 if(!bus || !rom_code)
280 {
281 status = OWB_STATUS_PARAMETER_NULL;
282 } else if (!_is_init(bus))
283 {
284 status = OWB_STATUS_NOT_INITIALIZED;
285 } else
286 {
287 bool is_present;
288 bus->driver->reset(bus, &is_present);
289 if (is_present)
290 {
291 uint8_t value = OWB_ROM_READ;
292 bus->driver->write_bits(bus, value, 8);
293 owb_read_bytes(bus, rom_code->bytes, sizeof(OneWireBus_ROMCode));
294
295 if (bus->use_crc)
296 {
297 if (owb_crc8_bytes(0, rom_code->bytes, sizeof(OneWireBus_ROMCode)) != 0)
298 {
299 memset(rom_code->bytes, 0, sizeof(OneWireBus_ROMCode));
300 status = OWB_STATUS_CRC_FAILED;
301 } else
302 {
303 status = OWB_STATUS_OK;
304 }
305 } else
306 {
307 status = OWB_STATUS_OK;
308 }
309 }
310 else
311 {
312 status = OWB_STATUS_DEVICE_NOT_RESPONDING;
313 }
314 }
315
316 return status;
317}
318
319owb_status owb_verify_rom(const OneWireBus * bus, OneWireBus_ROMCode rom_code, bool* is_present)
320{

Callers

nothing calls this directly

Calls 4

_is_initFunction · 0.85
owb_read_bytesFunction · 0.85
owb_crc8_bytesFunction · 0.85
resetMethod · 0.45

Tested by

no test coverage detected