uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
/*
|
|
|
|
|
* Author: Jon Trulson <jtrulson@ics.com>
|
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
|
* the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2017-11-17 17:22:34 +05:30
|
|
|
*
|
|
|
|
|
* Example usage: Search and print the found OW device ID recursively.
|
|
|
|
|
*
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
*/
|
|
|
|
|
|
2017-11-17 17:22:34 +05:30
|
|
|
/* standard headers */
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
#include "stdio.h"
|
2017-11-17 17:22:34 +05:30
|
|
|
|
|
|
|
|
/* mraa header */
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
#include "mraa.h"
|
|
|
|
|
|
|
|
|
|
int
|
2017-11-17 17:22:34 +05:30
|
|
|
main(void)
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
{
|
2017-11-17 17:22:34 +05:30
|
|
|
mraa_uart_ow_context uart_ow;
|
|
|
|
|
mraa_result_t status;
|
|
|
|
|
uint8_t id[MRAA_UART_OW_ROMCODE_SIZE];
|
|
|
|
|
uint8_t count = 0;
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
|
2017-11-17 17:22:34 +05:30
|
|
|
//! [Interesting]
|
|
|
|
|
uart_ow = mraa_uart_ow_init(0);
|
|
|
|
|
if (uart_ow == NULL) {
|
|
|
|
|
fprintf(stderr, "Failed to initialize UART OW\n");
|
|
|
|
|
mraa_deinit();
|
|
|
|
|
return EXIT_FAILURE;
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reset the ow bus and see if anything is present
|
2017-11-17 17:22:34 +05:30
|
|
|
status = mraa_uart_ow_reset(uart_ow);
|
|
|
|
|
if (status == MRAA_SUCCESS) {
|
|
|
|
|
fprintf(stdout, "Reset succeeded, device(s) detected!\n");
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
} else {
|
2017-11-17 17:22:34 +05:30
|
|
|
goto err_exit;
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-17 17:22:34 +05:30
|
|
|
fprintf(stdout, "Looking for devices...\n");
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
|
2017-11-17 17:22:34 +05:30
|
|
|
/*
|
|
|
|
|
* we are essentially doing a binary tree search through the 64
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
* bit address space. id is modified during this search, and will
|
|
|
|
|
* be set to the valid rom code for each device found.
|
2017-11-17 17:22:34 +05:30
|
|
|
*
|
|
|
|
|
* start the search from scratch
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
*/
|
2017-11-17 17:22:34 +05:30
|
|
|
status = mraa_uart_ow_rom_search(uart_ow, 1, id);
|
|
|
|
|
if (status != MRAA_SUCCESS) {
|
|
|
|
|
goto err_exit;
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-17 17:22:34 +05:30
|
|
|
while (status == MRAA_SUCCESS) {
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
/* The first byte (id[0]]) is the device type (family) code.
|
|
|
|
|
* The last byte (id[7]) is the rom code CRC value. The
|
|
|
|
|
* intervening bytes (id[1]-id[6]) are the unique 48 bit
|
|
|
|
|
* device ID.
|
|
|
|
|
*/
|
2017-11-17 17:22:34 +05:30
|
|
|
fprintf(stdout, "Device %02d Type 0x%02x ID %02x%02x%02x%02x%02x%02x CRC 0x%02x\n", count,
|
|
|
|
|
id[0], id[6], id[5], id[4], id[3], id[2], id[1], id[7]);
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
count++;
|
|
|
|
|
|
|
|
|
|
// continue the search with start argument set to 0
|
2017-11-17 17:22:34 +05:30
|
|
|
status = mraa_uart_ow_rom_search(uart_ow, 0, id);
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-17 17:22:34 +05:30
|
|
|
/* stop uart_ow */
|
|
|
|
|
mraa_uart_ow_stop(uart_ow);
|
|
|
|
|
|
|
|
|
|
//! [Interesting]
|
|
|
|
|
/* deinitialize mraa for the platform (not needed most of the time) */
|
|
|
|
|
mraa_deinit();
|
|
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
|
|
|
|
|
err_exit:
|
|
|
|
|
mraa_result_print(status);
|
|
|
|
|
|
|
|
|
|
/* stop uart_ow */
|
|
|
|
|
mraa_uart_ow_stop(uart_ow);
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
|
2017-11-17 17:22:34 +05:30
|
|
|
/* deinitialize mraa for the platform (not needed most of the times) */
|
|
|
|
|
mraa_deinit();
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
|
2017-11-17 17:22:34 +05:30
|
|
|
return EXIT_FAILURE;
|
uart_ow: Initial support for Dallas 1-wire over UART support for MRAA
This commit introduces support for Dallas Semiconductor (DS) 1-wire
compliant device support using an available UART device.
The principle of operation is described in the following Application
note by Maxim Electronics:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/214
with help (1-wire search) from:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/187
It has been tested on Galileo 2 and Edison, with 2 DS 1-wire devices,
the DS18B20 and DS2413 connected to the bus. A UPM driver for the
DS2413 is already complete and a PR will be submitted after this one.
It is important that you use a UART with CMOS/TTL level voltages
(3.3v/5v) RX and TX lines. DO NOT use standard RS232 level voltages
or you are going to have a bad day.
In order for this to work, a simple interface circuit, using a single
diode must be constructed:
(forgive my "Asciihematic" :)
-|
U|
A| TX---|<--+
R| |
T| RX-------o--------o 1-wire data bus
-|
The diode on TX is a 1N4148 (cheap and common), with the cathode
connected to TX, and the anode connected to RX and the 1-wire data
line.
The 1-wire data line requires a pull-up resistor, as the DS 1-wire
spec requires. 4.7-5K is typical for DS 1-wire buses.
NOTE: DHT-type (temp/humidity sensor) 1-wire devices ARE NOT DS 1-wire
compliant, and will not work with this code/circuit unfortunately.
Also note, this will use up one of your UARTs, which cannot be used
for any other purpose (ie: to access true UART-type serial devices).
You can however, connect as many DS 1-wire devices as feasible to this
UART, as it will function as a DS 1-wire bus master.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-12-15 17:11:14 -07:00
|
|
|
}
|