A cut-down version of https://os.mbed.com/users/Sissors/code/DS1820/ tweaked for use with the STM32F103. It is all generic Mbed operations though, so should be usable anywhere. Non-essential functions have been removed, as this is intended for use within a tutorial.
Dependents: STM32F103C8T6_DS18B20 stm32f103c8t6-ds18b20
Fork of DS1820 by
Revision 12:196e9e54b033, committed 2015-02-26
- Comitter:
- Sissors
- Date:
- Thu Feb 26 22:20:24 2015 +0000
- Parent:
- 11:1a3c3002b50c
- Child:
- 13:51a5011dc0ad
- Commit message:
- Fixed issue with multplie probes
;
; The command byte got garbled after first sent, resulting in other runs no probes responding.
Changed in this revision
DS1820.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DS1820.cpp Mon Feb 16 16:53:11 2015 +0000 +++ b/DS1820.cpp Thu Feb 26 22:20:24 2015 +0000 @@ -117,9 +117,10 @@ } else { ROM_bit_index=1; descrepancy_marker=0; + char command_shift = command; for (int n=0; n<8; n++) { // Search ROM command or Search Alarm command - onewire_bit_out(pin, command & 0x01); - command = command >> 1; // now the next bit is in the least sig bit position. + onewire_bit_out(pin, command_shift & 0x01); + command_shift = command_shift >> 1; // now the next bit is in the least sig bit position. } byte_counter = 0; bit_mask = 0x01;