From b10e42340675dfb915be881b45053aeccf1dcbe4 Mon Sep 17 00:00:00 2001 From: barthess Date: Tue, 31 May 2016 00:04:19 +0300 Subject: 1-wire improvements. 1) Functions reading bit from PAL now return ioline_t type. 2) Functions that handle acquired buffer with acquired bits now use uint8_t type because it corresponds to buffer type. 3) Cryptic bit shifting in bit storage functions replaced by dividion operations because all modern compilers perfectly optimise such operations. --- testhal/STM32/STM32F4xx/onewire/search_rom_synth.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'testhal/STM32/STM32F4xx/onewire/search_rom_synth.c') diff --git a/testhal/STM32/STM32F4xx/onewire/search_rom_synth.c b/testhal/STM32/STM32F4xx/onewire/search_rom_synth.c index 98f097d..cd2528f 100644 --- a/testhal/STM32/STM32F4xx/onewire/search_rom_synth.c +++ b/testhal/STM32/STM32F4xx/onewire/search_rom_synth.c @@ -41,7 +41,7 @@ typedef struct { OWSynthDevice devices[SYNTH_DEVICES_MAX]; size_t dev_present; bool complement_bit; - uint_fast8_t rom_bit; + ioline_t rom_bit; } OWSynthBus; /* @@ -86,12 +86,12 @@ static uint64_t detected_devices[SYNTH_DEVICES_MAX]; /** * */ -void _synth_ow_write_bit(onewireDriver *owp, uint8_t bit) { +void _synth_ow_write_bit(onewireDriver *owp, ioline_t bit) { (void)owp; size_t i; for (i=0; i> synth_bus.rom_bit) & 1) != bit) { + if (((synth_bus.devices[i].id >> synth_bus.rom_bit) & 1U) != bit) { synth_bus.devices[i].active = false; } } @@ -101,16 +101,16 @@ void _synth_ow_write_bit(onewireDriver *owp, uint8_t bit) { /** * */ -uint_fast8_t _synth_ow_read_bit(void) { - uint_fast8_t ret = 0xFF; +ioline_t _synth_ow_read_bit(void) { + ioline_t ret = 0xFF; size_t i; - uint_fast8_t bit; + ioline_t bit; for (i=0; i> synth_bus.rom_bit) & 1; + bit = (synth_bus.devices[i].id >> synth_bus.rom_bit) & 1U; if (synth_bus.complement_bit){ - bit ^= 1; + bit ^= 1U; } if (0xFF == ret) ret = bit; -- cgit v1.2.3