-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from mthoren-adi/cn0575_dev
Add support for CN0575, 10BASE-T1L Raspberry Pi Hat with Button, LED,…
- Loading branch information
Showing
10 changed files
with
216 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright (C) 2023 Analog Devices, Inc. | ||
# | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# - Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# - Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in | ||
# the documentation and/or other materials provided with the | ||
# distribution. | ||
# - Neither the name of Analog Devices, Inc. nor the names of its | ||
# contributors may be used to endorse or promote products derived | ||
# from this software without specific prior written permission. | ||
# - The use of this software may or may not infringe the patent rights | ||
# of one or more patent holders. This license does not release you | ||
# from the requirement that you obtain separate licenses from these | ||
# patent holders to use this software. | ||
# - Use of the software either in source or binary form, must be run | ||
# on or directly connected to an Analog Devices Inc. component. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A | ||
# PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# | ||
# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY | ||
# RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import adi | ||
|
||
|
||
class cn0575: | ||
""" CN0575 class, exposing onboard temperature sensor, pushbutton, | ||
and LED. Also reads the platform CPU's temperature, which under | ||
most operating conditions should be higher than the onboard sensor. | ||
""" | ||
|
||
def __init__(self, uri=""): | ||
|
||
self.gpios = adi.one_bit_adc_dac(uri) | ||
self.adt75 = adi.lm75(uri) # ADI version of LM75 | ||
self.gpios.gpio_ext_led = 0 # turn off LED | ||
|
||
@property | ||
def button(self): | ||
"""Read button state.""" | ||
return self.gpios.gpio_ext_btn | ||
|
||
@property | ||
def led(self): | ||
"""Read LED state.""" | ||
return self.gpios.gpio_ext_led | ||
|
||
@led.setter | ||
def led(self, value): | ||
"""Set LED state""" | ||
self.gpios.gpio_ext_led = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cn0575 | ||
================= | ||
|
||
.. automodule:: adi.cn0575 | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ Supported Devices | |
adi.cn0532 | ||
adi.cn0540 | ||
adi.cn0554 | ||
adi.cn0575 | ||
adi.daq2 | ||
adi.daq3 | ||
adi.fmc_vna | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (C) 2023 Analog Devices, Inc. | ||
# | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# - Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# - Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in | ||
# the documentation and/or other materials provided with the | ||
# distribution. | ||
# - Neither the name of Analog Devices, Inc. nor the names of its | ||
# contributors may be used to endorse or promote products derived | ||
# from this software without specific prior written permission. | ||
# - The use of this software may or may not infringe the patent rights | ||
# of one or more patent holders. This license does not release you | ||
# from the requirement that you obtain separate licenses from these | ||
# patent holders to use this software. | ||
# - Use of the software either in source or binary form, must be run | ||
# on or directly connected to an Analog Devices Inc. component. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
# INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A | ||
# PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# | ||
# IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY | ||
# RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | ||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import sys | ||
from time import sleep | ||
|
||
import adi | ||
|
||
# Optionally pass URI as command line argument, | ||
# else use default context manager search | ||
my_uri = sys.argv[1] if len(sys.argv) >= 2 else None | ||
print("uri: " + str(my_uri)) | ||
|
||
# Connect to CN0575 | ||
my_cn0575 = adi.cn0575(uri=my_uri) | ||
|
||
print("\nReading onboard ADT75 ...") | ||
print("Temperature: ", my_cn0575.adt75(), " deg. C") | ||
|
||
print("Blinking LED and reading button:") | ||
for i in range(1, 10): | ||
my_cn0575.led = 1 | ||
sleep(0.5) | ||
my_cn0575.led = 0 | ||
sleep(0.5) | ||
if my_cn0575.button == 1: | ||
print("Button Pressed") | ||
else: | ||
print("Button NOT Pressed") | ||
|
||
# del my_cn0575 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,7 @@ | |
- CN0540 | ||
- CN0554 | ||
- CN0549 | ||
- CN0575 | ||
- DAQ2 | ||
- DAQ3 | ||
- FMCADC3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
|
||
hardware = "cn0575" | ||
classname = "adi.cn0575" | ||
|
||
######################################### | ||
@pytest.mark.iio_hardware(hardware) | ||
@pytest.mark.parametrize("classname", [(classname)]) | ||
@pytest.mark.parametrize( | ||
"attr, start, stop, step, tol, repeats, sub_channel", | ||
[ | ||
("max", -55000, 125000, 30000, 1, 10, "adt75"), | ||
("max_hyst", -55000, 125000, 30000, 1, 10, "adt75"), | ||
], | ||
) | ||
def test_adt75_attr( | ||
test_attribute_single_value, | ||
iio_uri, | ||
classname, | ||
attr, | ||
start, | ||
stop, | ||
step, | ||
tol, | ||
repeats, | ||
sub_channel, | ||
): | ||
test_attribute_single_value( | ||
iio_uri, classname, attr, start, stop, step, tol, repeats, sub_channel | ||
) | ||
|
||
|
||
######################################### | ||
@pytest.mark.iio_hardware(hardware) | ||
@pytest.mark.parametrize("classname", [(classname)]) | ||
@pytest.mark.parametrize( | ||
"attr, val", [("led", [1, 0],),], | ||
) | ||
def test_led_attr(test_attribute_multipe_values, iio_uri, classname, attr, val): | ||
test_attribute_multipe_values(iio_uri, classname, attr, val, 0, repeats=10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters