mirror of
https://github.com/xtacocorex/CHIP_IO
synced 2025-07-20 04:43:21 +00:00
Removing i2c-1 custom support in OverlayManager as it's back in 4.4.13, this is to close #31. Update to version 0.2.5
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
0.2.5
|
||||||
|
----
|
||||||
|
* Updates to the pytest code for HWPWM and SoftPWM
|
||||||
|
* Removed the i2c-1 load/unload support in OverlayManager as CHIP Kernel 4.4.13 has that bus brought back by default
|
||||||
|
|
||||||
0.2.4
|
0.2.4
|
||||||
----
|
----
|
||||||
* HW PWM Fixed
|
* HW PWM Fixed
|
||||||
|
@ -28,7 +28,6 @@ OVERLAYCONFIGPATH = "/sys/kernel/config/device-tree/overlays"
|
|||||||
CUSTOMOVERLAYFILEPATH = ""
|
CUSTOMOVERLAYFILEPATH = ""
|
||||||
|
|
||||||
PWMSYSFSPATH = "/sys/class/pwm/pwmchip0"
|
PWMSYSFSPATH = "/sys/class/pwm/pwmchip0"
|
||||||
I2C1SYSFSPATH = "/sys/class/i2c-dev/i2c-1"
|
|
||||||
# USING THE BASE DIRECTORY FOR SPI AS THE DEVICE NUMBER CHANGES ON LOAD/UNLOAD
|
# USING THE BASE DIRECTORY FOR SPI AS THE DEVICE NUMBER CHANGES ON LOAD/UNLOAD
|
||||||
SPI2SYSFSPATH = "/sys/class/spi_master/"
|
SPI2SYSFSPATH = "/sys/class/spi_master/"
|
||||||
|
|
||||||
@ -36,21 +35,18 @@ SPI2SYSFSPATH = "/sys/class/spi_master/"
|
|||||||
# DO NOT MODIFY BY HAND WHEN USING
|
# DO NOT MODIFY BY HAND WHEN USING
|
||||||
# AS IT COULD BREAK FUNCTIONALITY
|
# AS IT COULD BREAK FUNCTIONALITY
|
||||||
_LOADED = {
|
_LOADED = {
|
||||||
"I2C1" : False,
|
|
||||||
"SPI2" : False,
|
"SPI2" : False,
|
||||||
"PWM0" : False,
|
"PWM0" : False,
|
||||||
"CUST" : False
|
"CUST" : False
|
||||||
}
|
}
|
||||||
|
|
||||||
_OVERLAYS = {
|
_OVERLAYS = {
|
||||||
"I2C1" : "chip-i2c1.dtbo",
|
|
||||||
"SPI2" : "chip-spi2.dtbo",
|
"SPI2" : "chip-spi2.dtbo",
|
||||||
"PWM0" : "chip-pwm0.dtbo",
|
"PWM0" : "chip-pwm0.dtbo",
|
||||||
"CUST" : ""
|
"CUST" : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
_FOLDERS = {
|
_FOLDERS = {
|
||||||
"I2C1" : "chip-i2c",
|
|
||||||
"SPI2" : "chip-spi",
|
"SPI2" : "chip-spi",
|
||||||
"PWM0" : "chip-pwm",
|
"PWM0" : "chip-pwm",
|
||||||
"CUST" : "chip-cust"
|
"CUST" : "chip-cust"
|
||||||
@ -60,13 +56,6 @@ def enable_debug():
|
|||||||
global DEBUG
|
global DEBUG
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
def get_i2c_loaded():
|
|
||||||
"""
|
|
||||||
get_i2c_loaded - Returns True/False based upon if the i2c-1 Overlay is loaded
|
|
||||||
"""
|
|
||||||
global _LOADED
|
|
||||||
return _LOADED["I2C1"]
|
|
||||||
|
|
||||||
def get_spi_loaded():
|
def get_spi_loaded():
|
||||||
"""
|
"""
|
||||||
get_spi_loaded - Returns True/False based upon if the spi2 Overlay is loaded
|
get_spi_loaded - Returns True/False based upon if the spi2 Overlay is loaded
|
||||||
@ -123,15 +112,6 @@ def _set_overlay_verify(name, overlay_path, config_path):
|
|||||||
if DEBUG:
|
if DEBUG:
|
||||||
print("ERROR LOAIDNG PWM0")
|
print("ERROR LOAIDNG PWM0")
|
||||||
return 1
|
return 1
|
||||||
elif name == "I2C1":
|
|
||||||
if os.path.exists(I2C1SYSFSPATH):
|
|
||||||
if DEBUG:
|
|
||||||
print("I2C-1 IS LOADED!")
|
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
if DEBUG:
|
|
||||||
print("ERROR LOADING I2C-1")
|
|
||||||
return 1
|
|
||||||
elif name == "SPI2":
|
elif name == "SPI2":
|
||||||
if os.listdir(SPI2SYSFSPATH) != "":
|
if os.listdir(SPI2SYSFSPATH) != "":
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
@ -147,7 +127,7 @@ def load(overlay, path=""):
|
|||||||
load - Load a DTB Overlay
|
load - Load a DTB Overlay
|
||||||
|
|
||||||
Inputs:
|
Inputs:
|
||||||
overlay - Overlay Key: I2C1, SPI2, PWM0, CUST
|
overlay - Overlay Key: SPI2, PWM0, CUST
|
||||||
path - Full Path to where the custom overlay is stored
|
path - Full Path to where the custom overlay is stored
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -187,10 +167,6 @@ def load(overlay, path=""):
|
|||||||
print("PWM0 Overlay already loaded")
|
print("PWM0 Overlay already loaded")
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
if overlay.upper() == "I2C1" and _LOADED[overlay.upper()]:
|
|
||||||
print("I2C1 Overlay already loaded")
|
|
||||||
return 2
|
|
||||||
|
|
||||||
if overlay.upper() == "SPI2" and _LOADED[overlay.upper()]:
|
if overlay.upper() == "SPI2" and _LOADED[overlay.upper()]:
|
||||||
print("SPI2 Overlay already loaded")
|
print("SPI2 Overlay already loaded")
|
||||||
return 2
|
return 2
|
||||||
@ -203,7 +179,7 @@ def load(overlay, path=""):
|
|||||||
_LOADED[overlay.upper()] = True
|
_LOADED[overlay.upper()] = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid Overlay name specified! Choose between: I2C1, SPI2, PWM0, CUST")
|
raise ValueError("Invalid Overlay name specified! Choose between: SPI2, PWM0, CUST")
|
||||||
|
|
||||||
def unload(overlay):
|
def unload(overlay):
|
||||||
global DEBUG
|
global DEBUG
|
||||||
@ -216,6 +192,6 @@ def unload(overlay):
|
|||||||
os.system('rmdir \"{}\"'.format(OVERLAYCONFIGPATH + "/" + _FOLDERS[overlay.upper()]))
|
os.system('rmdir \"{}\"'.format(OVERLAYCONFIGPATH + "/" + _FOLDERS[overlay.upper()]))
|
||||||
_LOADED[overlay.upper()] = False
|
_LOADED[overlay.upper()] = False
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid Overlay name specified! Choose between: I2C1, SPI2, PWM0, CUST")
|
raise ValueError("Invalid Overlay name specified! Choose between: SPI2, PWM0, CUST")
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ If using SOFTPWM and PWM at the same time, import CHIP_IO.SOFTPWM as SPWM or som
|
|||||||
**LRADC**::
|
**LRADC**::
|
||||||
|
|
||||||
The LRADC was enabled in the 4.4.13-ntc-mlc. This is a 6 bit ADC that is 2 Volt tolerant.
|
The LRADC was enabled in the 4.4.13-ntc-mlc. This is a 6 bit ADC that is 2 Volt tolerant.
|
||||||
Sample code below details how to talk to the LRADC.
|
Sample code below details how to talk to the LRADC.::
|
||||||
|
|
||||||
import CHIP_IO.LRADC as ADC
|
import CHIP_IO.LRADC as ADC
|
||||||
# Enable Debug
|
# Enable Debug
|
||||||
@ -294,7 +294,6 @@ Only one of each type of overlay can be loaded at a time, but all three options
|
|||||||
OM.load("PWM0")
|
OM.load("PWM0")
|
||||||
# To verify the overlay was properly loaded, the get_ functions return booleans
|
# To verify the overlay was properly loaded, the get_ functions return booleans
|
||||||
OM.get_pwm_loaded()
|
OM.get_pwm_loaded()
|
||||||
OM.get_i2c_loaded()
|
|
||||||
OM.get_spi_loaded()
|
OM.get_spi_loaded()
|
||||||
# To unload an overlay, feed in the name to unload()
|
# To unload an overlay, feed in the name to unload()
|
||||||
OM.unload("PWM0")
|
OM.unload("PWM0")
|
||||||
@ -331,6 +330,8 @@ To use the utilities, here is sample code::
|
|||||||
UT.disable_1v8_pin()
|
UT.disable_1v8_pin()
|
||||||
# Get currently-configured voltage (returns False if the pin is not enabled as output)
|
# Get currently-configured voltage (returns False if the pin is not enabled as output)
|
||||||
UT.get_1v8_pin_voltage()
|
UT.get_1v8_pin_voltage()
|
||||||
|
# Unexport Everything
|
||||||
|
UT.unexport_all()
|
||||||
|
|
||||||
**Running tests**
|
**Running tests**
|
||||||
|
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Free Electrons
|
|
||||||
* Copyright 2016 NextThing Co
|
|
||||||
*
|
|
||||||
* Maxime Ripard <maxime.ripard@free-electrons.com>
|
|
||||||
*
|
|
||||||
* This file is dual-licensed: you can use it either under the terms
|
|
||||||
* of the GPL or the X11 license, at your option. Note that this dual
|
|
||||||
* licensing only applies to this file, and not this project as a
|
|
||||||
* whole.
|
|
||||||
*
|
|
||||||
* a) This file is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This file is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* Or, alternatively,
|
|
||||||
*
|
|
||||||
* b) 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/dts-v1/;
|
|
||||||
/plugin/;
|
|
||||||
|
|
||||||
/ {
|
|
||||||
compatible = "nextthing,chip", "allwinner,sun5i-r8";
|
|
||||||
|
|
||||||
fragment@0 {
|
|
||||||
target-path = "/aliases";
|
|
||||||
__overlay__ {
|
|
||||||
i2c1 = "/soc@01c00000/i2c@01c2b000";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Enable the I2C1 bus and the keyboard */
|
|
||||||
fragment@1 {
|
|
||||||
target = <&i2c1>;
|
|
||||||
|
|
||||||
__overlay__ {
|
|
||||||
#address-cells = <1>;
|
|
||||||
#size-cells = <0>;
|
|
||||||
pinctrl-names = "default";
|
|
||||||
pinctrl-0 = <&i2c1_pins_a>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
2
setup.py
2
setup.py
@ -20,7 +20,7 @@ classifiers = ['Development Status :: 3 - Alpha',
|
|||||||
'Topic :: System :: Hardware']
|
'Topic :: System :: Hardware']
|
||||||
|
|
||||||
setup(name = 'CHIP_IO',
|
setup(name = 'CHIP_IO',
|
||||||
version = '0.2.4',
|
version = '0.2.5',
|
||||||
author = 'Robert Wolterman',
|
author = 'Robert Wolterman',
|
||||||
author_email = 'robert.wolterman@gmail.com',
|
author_email = 'robert.wolterman@gmail.com',
|
||||||
description = 'A module to control CHIP IO channels',
|
description = 'A module to control CHIP IO channels',
|
||||||
|
@ -76,6 +76,6 @@ void define_constants(PyObject *module)
|
|||||||
both_edge = Py_BuildValue("i", BOTH_EDGE);
|
both_edge = Py_BuildValue("i", BOTH_EDGE);
|
||||||
PyModule_AddObject(module, "BOTH", both_edge);
|
PyModule_AddObject(module, "BOTH", both_edge);
|
||||||
|
|
||||||
version = Py_BuildValue("s", "0.2.4");
|
version = Py_BuildValue("s", "0.2.5");
|
||||||
PyModule_AddObject(module, "VERSION", version);
|
PyModule_AddObject(module, "VERSION", version);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user