diff options
-rw-r--r-- | os/hal/include/hal_onewire.h | 4 | ||||
-rw-r--r-- | os/hal/src/hal_onewire.c | 20 | ||||
-rw-r--r-- | testhal/STM32/STM32F0xx/onewire/.project | 8 | ||||
-rw-r--r-- | testhal/STM32/STM32F0xx/onewire/onewire_test.c | 6 | ||||
-rw-r--r-- | testhal/STM32/STM32F0xx/onewire/search_rom_synth.c | 16 | ||||
-rw-r--r-- | testhal/STM32/STM32F1xx/onewire/onewire_test.c | 6 | ||||
-rw-r--r-- | testhal/STM32/STM32F1xx/onewire/search_rom_synth.c | 16 | ||||
-rw-r--r-- | testhal/STM32/STM32F4xx/onewire/onewire_test.c | 6 | ||||
-rw-r--r-- | testhal/STM32/STM32F4xx/onewire/search_rom_synth.c | 16 |
9 files changed, 49 insertions, 49 deletions
diff --git a/os/hal/include/hal_onewire.h b/os/hal/include/hal_onewire.h index 2d27f48..9fb5be2 100644 --- a/os/hal/include/hal_onewire.h +++ b/os/hal/include/hal_onewire.h @@ -342,8 +342,8 @@ extern "C" { uint8_t *result, size_t max_rom_cnt); #endif /* ONEWIRE_USE_SEARCH_ROM */ #if ONEWIRE_SYNTH_SEARCH_TEST - void _synth_ow_write_bit(onewireDriver *owp, uint8_t bit); - uint_fast8_t _synth_ow_read_bit(void); + void _synth_ow_write_bit(onewireDriver *owp, ioline_t bit); + ioline_t _synth_ow_read_bit(void); void synthSearchRomTest(onewireDriver *owp); #endif /* ONEWIRE_SYNTH_SEARCH_TEST */ #ifdef __cplusplus diff --git a/os/hal/src/hal_onewire.c b/os/hal/src/hal_onewire.c index 85f0fdc..a93eec0 100644 --- a/os/hal/src/hal_onewire.c +++ b/os/hal/src/hal_onewire.c @@ -58,6 +58,7 @@ on every timer overflow event. #if (HAL_USE_ONEWIRE == TRUE) || defined(__DOXYGEN__) #include <string.h> +#include <limits.h> /*===========================================================================*/ /* Driver local definitions. */ @@ -172,7 +173,7 @@ static void ow_bus_active(onewireDriver *owp) { * @brief Function performing read of single bit. * @note It must be callable from any context. */ -static uint_fast8_t ow_read_bit(onewireDriver *owp) { +static ioline_t ow_read_bit(onewireDriver *owp) { #if ONEWIRE_SYNTH_SEARCH_TEST (void)owp; return _synth_ow_read_bit(); @@ -221,7 +222,7 @@ static void pwm_search_rom_cb(PWMDriver *pwmp) { * * @notapi */ -static void ow_write_bit_I(onewireDriver *owp, uint_fast8_t bit) { +static void ow_write_bit_I(onewireDriver *owp, ioline_t bit) { #if ONEWIRE_SYNTH_SEARCH_TEST _synth_ow_write_bit(owp, bit); #else @@ -348,12 +349,11 @@ static void ow_write_bit_cb(PWMDriver *pwmp, onewireDriver *owp) { * @param[in] sr pointer to the @p onewire_search_rom_t helper structure * @param[in] bit discovered bit to be stored in helper structure */ -static void store_bit(onewire_search_rom_t *sr, uint_fast8_t bit) { +static void store_bit(onewire_search_rom_t *sr, uint8_t bit) { size_t rb = sr->reg.rombit; - /* / 8 % 8 */ - sr->retbuf[rb >> 3] |= bit << (rb & 7); + sr->retbuf[rb / CHAR_BIT] |= bit << (rb % CHAR_BIT); sr->reg.rombit++; } @@ -365,9 +365,9 @@ static void store_bit(onewire_search_rom_t *sr, uint_fast8_t bit) { * 'search ROM' helper structure * @param[in] bit number of bit [0..63] */ -static uint_fast8_t extract_path_bit(const uint8_t *path, uint_fast8_t bit) { - /* / 8 % 8 */ - return (path[bit >> 3] >> (bit & 7)) & 1; +static uint8_t extract_path_bit(const uint8_t *path, size_t bit) { + + return (path[bit / CHAR_BIT] >> (bit % CHAR_BIT)) & 1; } /** @@ -377,9 +377,9 @@ static uint_fast8_t extract_path_bit(const uint8_t *path, uint_fast8_t bit) { * * @param[in,out] sr pointer to the @p onewire_search_rom_t helper structure */ -static uint_fast8_t collision_handler(onewire_search_rom_t *sr) { +static uint8_t collision_handler(onewire_search_rom_t *sr) { - uint_fast8_t bit; + uint8_t bit; switch(sr->reg.search_iter) { case ONEWIRE_SEARCH_ROM_NEXT: diff --git a/testhal/STM32/STM32F0xx/onewire/.project b/testhal/STM32/STM32F0xx/onewire/.project index 8180131..6599a83 100644 --- a/testhal/STM32/STM32F0xx/onewire/.project +++ b/testhal/STM32/STM32F0xx/onewire/.project @@ -25,14 +25,14 @@ </natures>
<linkedResources>
<link>
- <name>os-contrib</name>
+ <name>os-community</name>
<type>2</type>
- <locationURI>CHIBIOS_CONTRIB</locationURI>
+ <locationURI>PARENT-4-PROJECT_LOC/os</locationURI>
</link>
<link>
- <name>os</name>
+ <name>os-git</name>
<type>2</type>
- <locationURI>CHIBIOS</locationURI>
+ <locationURI>PARENT-5-PROJECT_LOC/ChibiOS-RT/os</locationURI>
</link>
</linkedResources>
</projectDescription>
diff --git a/testhal/STM32/STM32F0xx/onewire/onewire_test.c b/testhal/STM32/STM32F0xx/onewire/onewire_test.c index 719420a..be20dbc 100644 --- a/testhal/STM32/STM32F0xx/onewire/onewire_test.c +++ b/testhal/STM32/STM32F0xx/onewire/onewire_test.c @@ -95,6 +95,7 @@ static void strong_pullup_release(void); static uint8_t testbuf[12]; +/* stores 3 temperature values in millicelsius */ static int32_t temperature[3]; /* @@ -242,9 +243,8 @@ void onewireTest(void) { onewireRead(&OWD1, testbuf, 9); osalDbgCheck(testbuf[8] == onewireCRC(testbuf, 8)); - tmp = 0; - tmp |= (testbuf[1] << 8) | testbuf[0]; - temperature[i] = (tmp * 625) / 10; + memcpy(&tmp, &testbuf, 2); + temperature[i] = ((int32_t)tmp * 625) / 10; } } else { diff --git a/testhal/STM32/STM32F0xx/onewire/search_rom_synth.c b/testhal/STM32/STM32F0xx/onewire/search_rom_synth.c index 98f097d..cd2528f 100644 --- a/testhal/STM32/STM32F0xx/onewire/search_rom_synth.c +++ b/testhal/STM32/STM32F0xx/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_DEVICES_MAX; i++) { - if (((synth_bus.devices[i].id >> 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_DEVICES_MAX; i++) { if (synth_bus.devices[i].active){ - bit = (synth_bus.devices[i].id >> 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; diff --git a/testhal/STM32/STM32F1xx/onewire/onewire_test.c b/testhal/STM32/STM32F1xx/onewire/onewire_test.c index 719420a..be20dbc 100644 --- a/testhal/STM32/STM32F1xx/onewire/onewire_test.c +++ b/testhal/STM32/STM32F1xx/onewire/onewire_test.c @@ -95,6 +95,7 @@ static void strong_pullup_release(void); static uint8_t testbuf[12]; +/* stores 3 temperature values in millicelsius */ static int32_t temperature[3]; /* @@ -242,9 +243,8 @@ void onewireTest(void) { onewireRead(&OWD1, testbuf, 9); osalDbgCheck(testbuf[8] == onewireCRC(testbuf, 8)); - tmp = 0; - tmp |= (testbuf[1] << 8) | testbuf[0]; - temperature[i] = (tmp * 625) / 10; + memcpy(&tmp, &testbuf, 2); + temperature[i] = ((int32_t)tmp * 625) / 10; } } else { diff --git a/testhal/STM32/STM32F1xx/onewire/search_rom_synth.c b/testhal/STM32/STM32F1xx/onewire/search_rom_synth.c index 98f097d..cd2528f 100644 --- a/testhal/STM32/STM32F1xx/onewire/search_rom_synth.c +++ b/testhal/STM32/STM32F1xx/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_DEVICES_MAX; i++) { - if (((synth_bus.devices[i].id >> 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_DEVICES_MAX; i++) { if (synth_bus.devices[i].active){ - bit = (synth_bus.devices[i].id >> 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; diff --git a/testhal/STM32/STM32F4xx/onewire/onewire_test.c b/testhal/STM32/STM32F4xx/onewire/onewire_test.c index 719420a..be20dbc 100644 --- a/testhal/STM32/STM32F4xx/onewire/onewire_test.c +++ b/testhal/STM32/STM32F4xx/onewire/onewire_test.c @@ -95,6 +95,7 @@ static void strong_pullup_release(void); static uint8_t testbuf[12]; +/* stores 3 temperature values in millicelsius */ static int32_t temperature[3]; /* @@ -242,9 +243,8 @@ void onewireTest(void) { onewireRead(&OWD1, testbuf, 9); osalDbgCheck(testbuf[8] == onewireCRC(testbuf, 8)); - tmp = 0; - tmp |= (testbuf[1] << 8) | testbuf[0]; - temperature[i] = (tmp * 625) / 10; + memcpy(&tmp, &testbuf, 2); + temperature[i] = ((int32_t)tmp * 625) / 10; } } else { 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_DEVICES_MAX; i++) { - if (((synth_bus.devices[i].id >> 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_DEVICES_MAX; i++) { if (synth_bus.devices[i].active){ - bit = (synth_bus.devices[i].id >> 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; |