Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: ds18b20/DS1Wire.cpp
- Revision:
- 4:5213bee8158e
- Parent:
- 3:0ef2ced1f02d
diff -r 0ef2ced1f02d -r 5213bee8158e ds18b20/DS1Wire.cpp
--- a/ds18b20/DS1Wire.cpp Sat Apr 12 20:07:15 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-#include "DS1Wire.h"
-#include "mbed.h"
-#include <stdint.h>
-
-// Timing delay for 1-wire serial standard option
-enum DELAY { A = 6, B = 64, C = 60, D = 10, E = 9, F = 55, G = 0, H = 480, I = 70, J = 410 };
-
-
-int Reset(DigitalInOut& pin) {
- pin.output();
- pin = 0; // drive bus low
- wait_us(H);
- pin.input(); // release bus
- wait_us(I);
- uint32_t result = pin; // read bus value
- wait_us(J);
- return result;
-}
-
-void WriteBit(DigitalInOut& pin, uint32_t bit) {
- pin.output();
- if (bit) {
- pin = 0; // drive bus low
- wait_us(A); // delay A
- pin.input(); // release bus
- wait_us(B); // delay B
- } else {
- pin = 0; // drive bus low
- wait_us(C); // delay C
- pin.input(); // release bus
- wait_us(D); // delay D
- }
-}
-
-uint32_t ReadBit(DigitalInOut& pin) {
- uint32_t bit_value;
- pin.output();
- pin = 0; // drive bus low
- wait_us(A); // delay A
- pin.input(); // release bus
- wait_us(E); // delay E
- bit_value = pin; // master sample bus
- wait_us(F);
- return bit_value;
-}
-
-void WriteByte(DigitalInOut& pin, uint32_t byte) {
- for (uint32_t bit = 0; bit < 8; ++bit) {
- WriteBit(pin, byte & 0x01); // lsb to msb
- byte >>= 1; // right shift by 1-bit
- }
-}
-
-uint32_t ReadByte(DigitalInOut& pin) {
- uint32_t byte = 0;
- for (uint32_t bit = 0; bit < 8; ++bit) {
- byte |= (ReadBit(pin) << bit); // Reads lsb to msb
- }
- return byte;
-}
\ No newline at end of file