Dallas' 1-Wire bus protocol library
Dependents: DS1825 DISCO-F746-Dessiccateur-V1 watersenor_and_temp_code DS1820 ... more
Revision 17:bbe8bf32e8bc, committed 2020-12-29
- Comitter:
- hudakz
- Date:
- Tue Dec 29 16:06:46 2020 +0000
- Parent:
- 16:4c3edd30ad6e
- Commit message:
- 1-wre bus: Modified.
Changed in this revision
OneWire.cpp | Show annotated file Show diff for this revision Revisions of this file |
OneWire.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4c3edd30ad6e -r bbe8bf32e8bc OneWire.cpp --- a/OneWire.cpp Mon Dec 28 21:13:05 2020 +0000 +++ b/OneWire.cpp Tue Dec 29 16:06:46 2020 +0000 @@ -118,9 +118,27 @@ /** * @brief Constructs a OneWire object. * @note GPIO is configured as output and an internal pull up resistor is connected. - * But because for STM chips it takes very long time to change from output - * to input an open drain mode is used rather and the GPIO remains output forever. - * @param + * An addition 4.7k Ohm resistor can connected between the 1-wire data bus/line + * and the +3.3V pin, + * + * ---------------- + * | | -----------------------> +3.3V + * | MBED BOARD | | + * | | | ------ + * | +3.3V |--o--| 4.7k |------- + * | | ------ | + * | | | + * | | | + * | | | + * | | | + * | GPIO |--------------------o-----> 1-wire bus/line + * | | + * | | + * | GND |--------------------------> GND + * | | + * ---------------- + * + * @param gpioPin GPIO pin to be used as 1-wire bus/line * @retval */ OneWire::OneWire(PinName gpioPin, int samplePoint_us /*= 13*/) : @@ -155,30 +173,33 @@ /** * @brief Constructs a OneWire object. - * @note UART is used to implement a 1-Wire Bus Master according to Maxim Integrated tutorial + * @note UART is used to implement a 1-Wire Bus Master according to Maxim Integrated application note + * * https://www.maximintegrated.com/en/design/technical-documents/tutorials/2/214.html - * In addition to the 4.7k Ohm resitor between the 1-wire data bus/line and the +3.3V pin, - * a 470 Ohm resitor shall be tied to the UART's tx and rx pin. UART's rx pin is then used + * + * In addition to the 4.7k Ohm resistor between the 1-wire data bus/line and the +3.3V pin, + * a 470 Ohm resistor shall be tied to the UART's tx and rx pin. UART's rx pin is then used * as 1-wire data bus/line. - * + * * ---------------- * | | -----------------------> +3.3V * | MBED BOARD | | * | | | ------ - * | 3.3V |--o--| 4.7k |------- + * | +3.3V |--o--| 4.7k |------- * | | ------ | * | | ------ | - * | UART TX |-----| 470 |--- | + * | UART TX |-----| 470 |--- | * | | ------ | | * | | | | - * | UART RX |----------------o---o-----> 1-wire bus/line + * | UART RX |----------------o---o-----> 1-wire bus/line * | | * | | * | GND |--------------------------> GND * | | * ---------------- - * - * @param + * + * @param txPin UART's Tx pin name + * @param rxPin UART's Rx pin name * @retval */ OneWire::OneWire(PinName txPin, PinName rxPin, int baud /*=115200*/) :
diff -r 4c3edd30ad6e -r bbe8bf32e8bc OneWire.h --- a/OneWire.h Mon Dec 28 21:13:05 2020 +0000 +++ b/OneWire.h Tue Dec 29 16:06:46 2020 +0000 @@ -5,18 +5,11 @@ #include <mbed.h> #include "SerialBase.h" -#if defined(TARGET_STM) - #define MODE() _gpio->output(); \ - _gpio->mode(OpenDrain) - #define OUTPUT() // configured as output in the constructor and stays like that forever -#else - #define MODE() _gpio->mode(PullUp) - #define OUTPUT() _gpio->output() -#endif - -#define INPUT() _gpio->input() -#define READ() _gpio->read() -#define WRITE(x) _gpio->write(x) +#define MODE() _gpio->mode(PullUp) +#define INPUT() _gpio->input() +#define OUTPUT() _gpio->output() +#define READ() _gpio->read() +#define WRITE(x) _gpio->write(x) #ifdef TARGET_NORDIC //NORDIC targets (NRF) use software delays since their ticker uses a 32kHz clock @@ -197,4 +190,6 @@ #endif }; -#endif \ No newline at end of file +#endif + +