mirror of
https://github.com/xtacocorex/CHIP_IO
synced 2025-07-20 04:43:21 +00:00
Formal initial start at CHIP Pro support. Removed the custom DT Overlays, OverlayManager now pulls dtbo from chip-dt-overlays package from NTC. First commit to CHIP_IO from a CPro DevKit
This commit is contained in:
@ -46,8 +46,10 @@ def toggle_debug():
|
|||||||
global DEBUG
|
global DEBUG
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
print("debug disabled")
|
||||||
else:
|
else:
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
print("debug enabled")
|
||||||
|
|
||||||
def setup(rate=250):
|
def setup(rate=250):
|
||||||
# First we determine if the device exists
|
# First we determine if the device exists
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
import Utilities as UT
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
OVERLAYINSTALLPATH = "/lib/firmware/chip_io"
|
OVERLAYINSTALLPATH = "/lib/firmware/nextthingco/chip"
|
||||||
SPIINSTALLPATH = "/lib/firmware/nextthingco/chip"
|
|
||||||
OVERLAYCONFIGPATH = "/sys/kernel/config/device-tree/overlays"
|
OVERLAYCONFIGPATH = "/sys/kernel/config/device-tree/overlays"
|
||||||
CUSTOMOVERLAYFILEPATH = ""
|
CUSTOMOVERLAYFILEPATH = ""
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ _LOADED = {
|
|||||||
|
|
||||||
_OVERLAYS = {
|
_OVERLAYS = {
|
||||||
"SPI2" : "sample-spi.dtbo",
|
"SPI2" : "sample-spi.dtbo",
|
||||||
"PWM0" : "chip-pwm0.dtbo",
|
"PWM0" : "sample-pwm.dtbo",
|
||||||
"CUST" : ""
|
"CUST" : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +57,10 @@ def toggle_debug():
|
|||||||
global DEBUG
|
global DEBUG
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
print("debug disabled")
|
||||||
else:
|
else:
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
print("debug enabled")
|
||||||
|
|
||||||
def get_spi_loaded():
|
def get_spi_loaded():
|
||||||
"""
|
"""
|
||||||
@ -159,12 +161,14 @@ def load(overlay, path=""):
|
|||||||
print("Custom Overlay path does not exist")
|
print("Custom Overlay path does not exist")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
# DETERMINE IF WE ARE A CHIP PRO AND WE ARE COMMANDED TO LOAD PWM0
|
||||||
|
if UT.is_chip_pro() and overlay.upper() == "PWM0":
|
||||||
|
print("CHIP Pro supports PWM0 in base DTB, exiting")
|
||||||
|
return 1
|
||||||
|
|
||||||
# SET UP THE OVERLAY PATH FOR OUR USE
|
# SET UP THE OVERLAY PATH FOR OUR USE
|
||||||
if overlay.upper() != "CUST":
|
if overlay.upper() != "CUST":
|
||||||
opath = OVERLAYINSTALLPATH
|
opath = OVERLAYINSTALLPATH
|
||||||
# IF THE OVERLAY IS SPI, USE THE NTC PATH
|
|
||||||
if overlay.upper() == "SPI2":
|
|
||||||
opath = SPIINSTALLPATH
|
|
||||||
opath += "/" + _OVERLAYS[overlay.upper()]
|
opath += "/" + _OVERLAYS[overlay.upper()]
|
||||||
else:
|
else:
|
||||||
opath = path
|
opath = path
|
||||||
@ -194,6 +198,12 @@ def unload(overlay):
|
|||||||
global _LOADED
|
global _LOADED
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print("UNLOAD OVERLAY: {0}".format(overlay))
|
print("UNLOAD OVERLAY: {0}".format(overlay))
|
||||||
|
|
||||||
|
# DETERMINE IF WE ARE A CHIP PRO AND WE ARE COMMANDED TO UNLOAD PWM0
|
||||||
|
if UT.is_chip_pro() and overlay.upper() == "PWM0":
|
||||||
|
print("CHIP Pro supports PWM0 in base DTB, exiting")
|
||||||
|
return
|
||||||
|
|
||||||
# SEE IF OUR OVERLAY NAME IS IN THE KEYS
|
# SEE IF OUR OVERLAY NAME IS IN THE KEYS
|
||||||
if overlay.upper() in _OVERLAYS.keys():
|
if overlay.upper() in _OVERLAYS.keys():
|
||||||
# BRUTE FORCE REMOVE AS THE DIRECTORY CONTAINS FILES
|
# BRUTE FORCE REMOVE AS THE DIRECTORY CONTAINS FILES
|
||||||
|
@ -35,8 +35,10 @@ def toggle_debug():
|
|||||||
global DEBUG
|
global DEBUG
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
print("debug disabled")
|
||||||
else:
|
else:
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
print("debug enabled")
|
||||||
|
|
||||||
# Set the 1.8V-pin on the CHIP U13-header to given voltage
|
# Set the 1.8V-pin on the CHIP U13-header to given voltage
|
||||||
# Return False on error
|
# Return False on error
|
||||||
@ -101,3 +103,22 @@ def unexport_all():
|
|||||||
cmd = "echo " + num + " > /sys/class/gpio/unexport"
|
cmd = "echo " + num + " > /sys/class/gpio/unexport"
|
||||||
subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE)
|
subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE)
|
||||||
|
|
||||||
|
# Determine Processor
|
||||||
|
def is_chip_pro():
|
||||||
|
isgr8 = False
|
||||||
|
if DEBUG:
|
||||||
|
print("Determining if computer has R8 or GR8 SOC")
|
||||||
|
|
||||||
|
files = glob.glob("/boot/*.dtb")
|
||||||
|
for f in files:
|
||||||
|
if "gr8" in f.lower():
|
||||||
|
isgr8 = True
|
||||||
|
if DEBUG:
|
||||||
|
print("Found gr8 SOC")
|
||||||
|
break
|
||||||
|
|
||||||
|
if DEBUG and not isgr8:
|
||||||
|
print("Found r8 SOC")
|
||||||
|
|
||||||
|
# Return isgr8
|
||||||
|
return isgr8
|
||||||
|
23
README.rst
23
README.rst
@ -135,21 +135,21 @@ The following "table" is the allowable pin names that are able to be used by the
|
|||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSIVSYNC | SPI-MISO | U14_30 |
|
| CSIVSYNC | SPI-MISO | U14_30 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSID0 | CSID0 | U14_31 |
|
| CSID0 | D0 | U14_31 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSID1 | CSID1 | U14_32 |
|
| CSID1 | D1 | U14_32 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSID2 | CSID2 | U14_33 |
|
| CSID2 | D2 | U14_33 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSID3 | CSID3 | U14_34 |
|
| CSID3 | D3 | U14_34 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSID4 | CSID4 | U14_35 |
|
| CSID4 | D4 | U14_35 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSID5 | CSID5 | U14_36 |
|
| CSID5 | D5 | U14_36 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSID6 | CSID6 | U14_37 |
|
| CSID6 | D6 | U14_37 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
| CSID7 | CSID7 | U14_38 |
|
| CSID7 | D7 | U14_38 |
|
||||||
+------------------+--------------------------+--------+
|
+------------------+--------------------------+--------+
|
||||||
|
|
||||||
**GPIO Setup**
|
**GPIO Setup**
|
||||||
@ -348,9 +348,9 @@ SPI requires a DTB Overlay to access. CHIP_IO does not contain any SPI specific
|
|||||||
**Overlay Manager**::
|
**Overlay Manager**::
|
||||||
|
|
||||||
The Overlay Manager enables you to quickly load simple Device Tree Overlays. The options for loading are:
|
The Overlay Manager enables you to quickly load simple Device Tree Overlays. The options for loading are:
|
||||||
PWM0, SPI2, I2C1, CUST
|
PWM0, SPI2, CUST. The Overlay Manager is smart enough to determine if you are trying to load PWM on a CHIP Pro and will fail due to the base DTB for the CHIP Pro supporting PWM0/1 out of the box.
|
||||||
|
|
||||||
Only one of each type of overlay can be loaded at a time, but all three options can be loaded simultaneously. So you can have SPI2 and I2C1 without PWM0, but you cannot have SPI2 loaded twice.
|
Only one of each type of overlay can be loaded at a time, but all three options can be loaded simultaneously. So you can have SPI2 without PWM0, but you cannot have SPI2 loaded twice.
|
||||||
::
|
::
|
||||||
import CHIP_IO.OverlayManager as OM
|
import CHIP_IO.OverlayManager as OM
|
||||||
# The toggle_debug() function turns on/off debug printing
|
# The toggle_debug() function turns on/off debug printing
|
||||||
@ -399,6 +399,9 @@ To use the utilities, here is sample code::
|
|||||||
UT.get_1v8_pin_voltage()
|
UT.get_1v8_pin_voltage()
|
||||||
# Unexport Everything
|
# Unexport Everything
|
||||||
UT.unexport_all()
|
UT.unexport_all()
|
||||||
|
# Determine if you are running a CHIP/CHIP Pro
|
||||||
|
# This returns True if the computer is a CHIP Pro and False if it is a CHIP
|
||||||
|
UT.is_chip_pro()
|
||||||
|
|
||||||
**Running tests**
|
**Running tests**
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
from subprocess import call
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import glob
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def compile():
|
|
||||||
print("Compiling DTS Files")
|
|
||||||
call(["dtc", "-O", "dtb", "-o", "overlays/chip-pwm0.dtbo", "-b", "o", "-@", "overlays/chip-pwm0.dts"])
|
|
||||||
|
|
||||||
def copy():
|
|
||||||
target_dir = os.environ.get('TARGET_DIR', '')
|
|
||||||
overlay_path = target_dir + "/lib/firmware/chip_io"
|
|
||||||
print("Checking for DTBO Install Path")
|
|
||||||
if not os.path.exists(overlay_path):
|
|
||||||
print("Path not found, creating "+overlay_path)
|
|
||||||
os.makedirs(overlay_path)
|
|
||||||
print("Removing old DTBO files (if applicable)")
|
|
||||||
for fl in glob.glob(overlay_path+"/chip-*-.dtbo"):
|
|
||||||
os.remove(fl)
|
|
||||||
print("Moving DTBO files to "+overlay_path)
|
|
||||||
shutil.move("overlays/chip-pwm0.dtbo", overlay_path+"/chip-pwm0.dtbo")
|
|
@ -1,61 +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";
|
|
||||||
|
|
||||||
/* Enable the PWM */
|
|
||||||
fragment@0 {
|
|
||||||
target = <&pwm>;
|
|
||||||
|
|
||||||
__overlay__ {
|
|
||||||
pinctrl-names = "default";
|
|
||||||
pinctrl-0 = <&pwm0_pins>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
9
setup.py
9
setup.py
@ -1,10 +1,3 @@
|
|||||||
try:
|
|
||||||
from overlays import builder
|
|
||||||
builder.compile()
|
|
||||||
builder.copy()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
import distribute_setup
|
import distribute_setup
|
||||||
distribute_setup.use_setuptools()
|
distribute_setup.use_setuptools()
|
||||||
from setuptools import setup, Extension, find_packages
|
from setuptools import setup, Extension, find_packages
|
||||||
@ -26,7 +19,7 @@ setup(name = 'CHIP_IO',
|
|||||||
description = 'A module to control CHIP IO channels',
|
description = 'A module to control CHIP IO channels',
|
||||||
long_description = open('README.rst').read() + open('CHANGELOG.rst').read(),
|
long_description = open('README.rst').read() + open('CHANGELOG.rst').read(),
|
||||||
license = 'MIT',
|
license = 'MIT',
|
||||||
keywords = 'CHIP NextThingCo IO GPIO PWM ADC',
|
keywords = 'CHIP NextThingCo IO GPIO PWM ADC GR8 R8',
|
||||||
url = 'https://github.com/xtacocorex/CHIP_IO/',
|
url = 'https://github.com/xtacocorex/CHIP_IO/',
|
||||||
classifiers = classifiers,
|
classifiers = classifiers,
|
||||||
packages = find_packages(),
|
packages = find_packages(),
|
||||||
|
115
source/common.c
115
source/common.c
@ -52,6 +52,9 @@ int module_setup = 0;
|
|||||||
// Library Debug
|
// Library Debug
|
||||||
int DEBUG = 0;
|
int DEBUG = 0;
|
||||||
|
|
||||||
|
// Is This a CHIP PRO
|
||||||
|
int ISCHIPPRO = 0;
|
||||||
|
|
||||||
pins_t pins_info[] = {
|
pins_t pins_info[] = {
|
||||||
{ "GND", "GND", "U13_1", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "GND", "GND", "U13_1", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CHG-IN", "CHG-IN", "U13_2", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CHG-IN", "CHG-IN", "U13_2", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
@ -69,35 +72,36 @@ pins_t pins_info[] = {
|
|||||||
{ "X2", "X2", "U13_14", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "X2", "X2", "U13_14", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "Y1", "Y1", "U13_15", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "Y1", "Y1", "U13_15", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "Y2", "Y2", "U13_16", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "Y2", "Y2", "U13_16", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "LCD-D2", "LCD-D2", "U13_17", 98, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D2", "UART2-TX", "U13_17", 98, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "PWM0", "PWM0", "U13_18", 34, BASE_METHOD_AS_IS, 0, -1, BOTH},
|
{ "PWM0", "PWM0", "U13_18", 34, BASE_METHOD_AS_IS, 0, -1, BOTH},
|
||||||
{ "LCD-D4", "LCD-D4", "U13_19", 100, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "PWM1", "PWM1", "EINT13", 205, BASE_METHOD_AS_IS, 0, -1, CHIPPRO},
|
||||||
{ "LCD-D3", "LCD-D3", "U13_20", 99, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D4", "UART2-CTS", "U13_19", 100, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "LCD-D6", "LCD-D6", "U13_21", 102, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D3", "UART2-RX", "U13_20", 99, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "LCD-D5", "LCD-D5", "U13_22", 101, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D6", "LCD-D6", "U13_21", 102, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D10", "LCD-D10", "U13_23", 106, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D5", "UART2-RTS", "U13_22", 101, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "LCD-D7", "LCD-D7", "U13_24", 103, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D10", "LCD-D10", "U13_23", 106, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D12", "LCD-D12", "U13_25", 108, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D7", "LCD-D7", "U13_24", 103, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D11", "LCD-D11", "U13_26", 107, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D12", "LCD-D12", "U13_25", 108, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D14", "LCD-D14", "U13_27", 110, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D11", "LCD-D11", "U13_26", 107, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D13", "LCD-D13", "U13_28", 109, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D14", "LCD-D14", "U13_27", 110, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D18", "LCD-D18", "U13_29", 114, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D13", "LCD-D13", "U13_28", 109, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D15", "LCD-D15", "U13_30", 111, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D18", "LCD-D18", "U13_29", 114, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D20", "LCD-D20", "U13_31", 116, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D15", "LCD-D15", "U13_30", 111, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D19", "LCD-D19", "U13_32", 115, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D20", "LCD-D20", "U13_31", 116, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D22", "LCD-D22", "U13_33", 118, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D19", "LCD-D19", "U13_32", 115, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D21", "LCD-D21", "U13_34", 117, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D22", "LCD-D22", "U13_33", 118, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-CLK", "LCD-CLK", "U13_35", 120, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D21", "LCD-D21", "U13_34", 117, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-D23", "LCD-D23", "U13_36", 119, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-CLK", "LCD-CLK", "U13_35", 120, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-VSYNC", "LCD-VSYNC", "U13_37", 123, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-D23", "LCD-D23", "U13_36", 119, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "LCD-HSYNC", "LCD-HSYNC", "U13_38", 122, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-VSYNC", "LCD-VSYNC", "U13_37", 123, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
|
{ "LCD-HSYNC", "LCD-HSYNC", "U13_38", 122, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "GND", "GND", "U13_39", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "GND", "GND", "U13_39", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "LCD-DE", "LCD-DE", "U13_40", 121, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "LCD-DE", "LCD-DE", "U13_40", 121, BASE_METHOD_AS_IS, -1, -1, CHIP},
|
||||||
{ "GND", "GND", "U14_1", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "GND", "GND", "U14_1", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "VCC-5V", "VCC-5V", "U14_2", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "VCC-5V", "VCC-5V", "U14_2", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "UART1-TX", "UART-TX", "U14_3", 195, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "UART1-TX", "UART-TX", "U14_3", 195, BASE_METHOD_AS_IS, -1, -1, BOTH}, /* THIS IS AP-EINT3 ON CHIP PRO */
|
||||||
{ "HPL", "HPL", "U14_4", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "HPL", "HPL", "U14_4", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "UART1-RX", "UART-RX", "U14_5", 196, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "UART1-RX", "UART-RX", "U14_5", 196, BASE_METHOD_AS_IS, -1, -1, BOTH}, /* THIS IS AP-EINT4 ON CHIP PRO */
|
||||||
{ "HPCOM", "HPCOM", "U14_6", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "HPCOM", "HPCOM", "U14_6", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "FEL", "FEL", "U14_7", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "FEL", "FEL", "U14_7", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "HPR", "HPR", "U14_8", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "HPR", "HPR", "U14_8", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
@ -123,14 +127,14 @@ pins_t pins_info[] = {
|
|||||||
{ "CSICK", "SPI-CLK", "U14_28", 129, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSICK", "SPI-CLK", "U14_28", 129, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CSIHSYNC", "SPI-MOSI", "U14_29", 130, BASE_METHOD_AS_IS, 1, -1, BOTH},
|
{ "CSIHSYNC", "SPI-MOSI", "U14_29", 130, BASE_METHOD_AS_IS, 1, -1, BOTH},
|
||||||
{ "CSIVSYNC", "SPI-MISO", "U14_30", 131, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSIVSYNC", "SPI-MISO", "U14_30", 131, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CSID0", "CSID0", "U14_31", 132, BASE_METHOD_AS_IS, 1, -1, BOTH},
|
{ "CSID0", "D0", "U14_31", 132, BASE_METHOD_AS_IS, 1, -1, BOTH},
|
||||||
{ "CSID1", "CSID1", "U14_32", 133, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSID1", "D1", "U14_32", 133, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CSID2", "CSID2", "U14_33", 134, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSID2", "D2", "U14_33", 134, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CSID3", "CSID3", "U14_34", 135, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSID3", "D3", "U14_34", 135, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CSID4", "CSID4", "U14_35", 136, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSID4", "D4", "U14_35", 136, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CSID5", "CSID5", "U14_36", 137, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSID5", "D5", "U14_36", 137, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CSID6", "CSID6", "U14_37", 138, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSID6", "D6", "U14_37", 138, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "CSID7", "CSID7", "U14_38", 139, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "CSID7", "D7", "U14_38", 139, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "GND", "GND", "U14_39", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "GND", "GND", "U14_39", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ "GND", "GND", "U14_40", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
{ "GND", "GND", "U14_40", -1, BASE_METHOD_AS_IS, -1, -1, BOTH},
|
||||||
{ NULL, NULL, NULL, -1, 0, -1, -1, -1}
|
{ NULL, NULL, NULL, -1, 0, -1, -1, -1}
|
||||||
@ -216,12 +220,59 @@ int get_xio_base(void)
|
|||||||
return xio_base_address;
|
return xio_base_address;
|
||||||
} /* get_xio_base */
|
} /* get_xio_base */
|
||||||
|
|
||||||
|
#define BOOTPATH "/boot"
|
||||||
|
|
||||||
|
int is_this_chippro(void)
|
||||||
|
{
|
||||||
|
int rtnval = -1;
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *ent;
|
||||||
|
|
||||||
|
// Default ISCHIPPRO to 0 for CHIP
|
||||||
|
ISCHIPPRO = 0;
|
||||||
|
|
||||||
|
// Get the boot directory open
|
||||||
|
dir = opendir (BOOTPATH);
|
||||||
|
if (dir == NULL) {
|
||||||
|
char err[256];
|
||||||
|
snprintf(err, sizeof(err), "is_this_chippro: could not open '%s' (%s)", BOOTPATH, strerror(errno));
|
||||||
|
add_error_msg(err);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DEBUG)
|
||||||
|
printf(" ** is_this_chippro: checking boot directory\n");
|
||||||
|
// Loop through the directory files
|
||||||
|
while ((ent = readdir (dir)) != NULL) {
|
||||||
|
//printf ("%s\n", ent->d_name);
|
||||||
|
if(strstr(ent->d_name, "gr8") != NULL) {
|
||||||
|
rtnval = 1;
|
||||||
|
ISCHIPPRO = 1;
|
||||||
|
if (DEBUG)
|
||||||
|
printf(" ** is_this_chippro: this is a chip pro!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir (dir);
|
||||||
|
|
||||||
|
if (ISCHIPPRO == 0)
|
||||||
|
{
|
||||||
|
rtnval = 0;
|
||||||
|
if (DEBUG)
|
||||||
|
printf(" ** is_this_chippro: this is a chip!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return rtnval;
|
||||||
|
}
|
||||||
|
|
||||||
void toggle_debug(void)
|
void toggle_debug(void)
|
||||||
{
|
{
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
DEBUG = 0;
|
DEBUG = 0;
|
||||||
|
printf(" ** debug disabled\n");
|
||||||
} else {
|
} else {
|
||||||
DEBUG = 1;
|
DEBUG = 1;
|
||||||
|
printf(" ** debug enabled\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +89,10 @@ typedef struct dyn_int_array_s dyn_int_array_t;
|
|||||||
int setup_error;
|
int setup_error;
|
||||||
int module_setup;
|
int module_setup;
|
||||||
int DEBUG;
|
int DEBUG;
|
||||||
|
int ISCHIPPRO;
|
||||||
|
|
||||||
int get_xio_base(void);
|
int get_xio_base(void);
|
||||||
|
int is_this_chippro(void);
|
||||||
int gpio_number(pins_t *pin);
|
int gpio_number(pins_t *pin);
|
||||||
int gpio_pud_capable(pins_t *pin);
|
int gpio_pud_capable(pins_t *pin);
|
||||||
int lookup_gpio_by_key(const char *key);
|
int lookup_gpio_by_key(const char *key);
|
||||||
|
@ -85,9 +85,6 @@ void define_constants(PyObject *module)
|
|||||||
bcm = Py_BuildValue("i", BCM);
|
bcm = Py_BuildValue("i", BCM);
|
||||||
PyModule_AddObject(module, "BCM", bcm);
|
PyModule_AddObject(module, "BCM", bcm);
|
||||||
|
|
||||||
module_debug = Py_BuildValue("i", DEBUG ? Py_True: Py_False);
|
|
||||||
PyModule_AddObject(module, "DEBUG", module_debug);
|
|
||||||
|
|
||||||
version = Py_BuildValue("s", "0.4.0");
|
version = Py_BuildValue("s", "0.4.0");
|
||||||
PyModule_AddObject(module, "VERSION", version);
|
PyModule_AddObject(module, "VERSION", version);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,5 @@ PyObject *version;
|
|||||||
PyObject *unknown;
|
PyObject *unknown;
|
||||||
PyObject *board;
|
PyObject *board;
|
||||||
PyObject *bcm;
|
PyObject *bcm;
|
||||||
PyObject *module_debug;
|
|
||||||
|
|
||||||
void define_constants(PyObject *module);
|
void define_constants(PyObject *module);
|
||||||
|
@ -78,6 +78,15 @@ static int init_module(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// figure out if we're a chip pro
|
||||||
|
if (is_this_chippro() < 1) {
|
||||||
|
char err[2000];
|
||||||
|
snprintf(err, sizeof(err), "init_module error (%s)", get_error_msg());
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// After this point, ISCHIPPRO variable should be good to go
|
||||||
|
|
||||||
// If we make it here, we're good to go
|
// If we make it here, we're good to go
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
printf(" ** init_module: setup complete **\n");
|
printf(" ** init_module: setup complete **\n");
|
||||||
@ -86,6 +95,20 @@ static int init_module(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// python function value = is_chip_pro
|
||||||
|
static PyObject *py_is_chip_pro(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *py_value;
|
||||||
|
|
||||||
|
if (!module_setup) {
|
||||||
|
init_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
py_value = Py_BuildValue("i", ISCHIPPRO);
|
||||||
|
|
||||||
|
return py_value;
|
||||||
|
}
|
||||||
|
|
||||||
static void remember_gpio_direction(int gpio, int direction)
|
static void remember_gpio_direction(int gpio, int direction)
|
||||||
{
|
{
|
||||||
dyn_int_array_set(&gpio_direction, gpio, direction, -1);
|
dyn_int_array_set(&gpio_direction, gpio, direction, -1);
|
||||||
@ -947,6 +970,7 @@ PyMethodDef gpio_methods[] = {
|
|||||||
{"direction", (PyCFunction)py_set_direction, METH_VARARGS | METH_KEYWORDS, "Change direction of gpio channel. Either INPUT or OUTPUT\n" },
|
{"direction", (PyCFunction)py_set_direction, METH_VARARGS | METH_KEYWORDS, "Change direction of gpio channel. Either INPUT or OUTPUT\n" },
|
||||||
{"setmode", (PyCFunction)py_setmode, METH_VARARGS, "Dummy function that does nothing but maintain compatibility with RPi.GPIO\n" },
|
{"setmode", (PyCFunction)py_setmode, METH_VARARGS, "Dummy function that does nothing but maintain compatibility with RPi.GPIO\n" },
|
||||||
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
|
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
|
||||||
|
{"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +52,41 @@ static PyObject *py_toggle_debug(PyObject *self, PyObject *args)
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int init_module(void)
|
||||||
|
{
|
||||||
|
clear_error_msg();
|
||||||
|
|
||||||
|
// figure out if we're a chip pro
|
||||||
|
if (is_this_chippro() < 1) {
|
||||||
|
char err[2000];
|
||||||
|
snprintf(err, sizeof(err), "init_module error (%s)", get_error_msg());
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// After this point, ISCHIPPRO variable should be good to go
|
||||||
|
|
||||||
|
// If we make it here, we're good to go
|
||||||
|
if (DEBUG)
|
||||||
|
printf(" ** init_module: setup complete **\n");
|
||||||
|
module_setup = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// python function value = is_chip_pro
|
||||||
|
static PyObject *py_is_chip_pro(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *py_value;
|
||||||
|
|
||||||
|
if (!module_setup) {
|
||||||
|
init_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
py_value = Py_BuildValue("i", ISCHIPPRO);
|
||||||
|
|
||||||
|
return py_value;
|
||||||
|
}
|
||||||
|
|
||||||
// python function start(channel, duty_cycle, freq)
|
// python function start(channel, duty_cycle, freq)
|
||||||
static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwargs)
|
static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
@ -68,6 +103,10 @@ static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwar
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!module_setup) {
|
||||||
|
init_module();
|
||||||
|
}
|
||||||
|
|
||||||
if (!get_pwm_key(channel, key)) {
|
if (!get_pwm_key(channel, key)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Invalid PWM key or name.");
|
PyErr_SetString(PyExc_ValueError, "Invalid PWM key or name.");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -275,6 +314,7 @@ PyMethodDef pwm_methods[] = {
|
|||||||
{"set_pulse_width_ns", (PyCFunction)py_set_pulse_width_ns, METH_VARARGS, "Change the period\npulse_width_ns - pulse width in nanoseconds" },
|
{"set_pulse_width_ns", (PyCFunction)py_set_pulse_width_ns, METH_VARARGS, "Change the period\npulse_width_ns - pulse width in nanoseconds" },
|
||||||
{"cleanup", py_cleanup, METH_VARARGS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"},
|
{"cleanup", py_cleanup, METH_VARARGS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"},
|
||||||
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
|
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
|
||||||
|
{"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,6 +56,41 @@ static PyObject *py_cleanup(PyObject *self, PyObject *args)
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int init_module(void)
|
||||||
|
{
|
||||||
|
clear_error_msg();
|
||||||
|
|
||||||
|
// figure out if we're a chip pro
|
||||||
|
if (is_this_chippro() < 1) {
|
||||||
|
char err[2000];
|
||||||
|
snprintf(err, sizeof(err), "init_module error (%s)", get_error_msg());
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// After this point, ISCHIPPRO variable should be good to go
|
||||||
|
|
||||||
|
// If we make it here, we're good to go
|
||||||
|
if (DEBUG)
|
||||||
|
printf(" ** init_module: setup complete **\n");
|
||||||
|
module_setup = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// python function value = is_chip_pro
|
||||||
|
static PyObject *py_is_chip_pro(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *py_value;
|
||||||
|
|
||||||
|
if (!module_setup) {
|
||||||
|
init_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
py_value = Py_BuildValue("i", ISCHIPPRO);
|
||||||
|
|
||||||
|
return py_value;
|
||||||
|
}
|
||||||
|
|
||||||
// python function start(channel, angle, range)
|
// python function start(channel, angle, range)
|
||||||
static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwargs)
|
static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
@ -73,6 +108,10 @@ static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwar
|
|||||||
}
|
}
|
||||||
ASSRT(channel != NULL);
|
ASSRT(channel != NULL);
|
||||||
|
|
||||||
|
if (!module_setup) {
|
||||||
|
init_module();
|
||||||
|
}
|
||||||
|
|
||||||
if (!get_key(channel, key)) {
|
if (!get_key(channel, key)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Invalid Servo key or name.");
|
PyErr_SetString(PyExc_ValueError, "Invalid Servo key or name.");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -218,6 +257,7 @@ PyMethodDef servo_methods[] = {
|
|||||||
{"set_angle", (PyCFunction)py_set_angle, METH_VARARGS, "Change the servo angle\nangle - angle of the servo between +/-(range/2)" },
|
{"set_angle", (PyCFunction)py_set_angle, METH_VARARGS, "Change the servo angle\nangle - angle of the servo between +/-(range/2)" },
|
||||||
{"cleanup", (PyCFunction)py_cleanup, METH_VARARGS, "Clean up by resetting All or one Servo that have been used by this program."},
|
{"cleanup", (PyCFunction)py_cleanup, METH_VARARGS, "Clean up by resetting All or one Servo that have been used by this program."},
|
||||||
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
|
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
|
||||||
|
{"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +52,41 @@ static PyObject *py_cleanup(PyObject *self, PyObject *args)
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int init_module(void)
|
||||||
|
{
|
||||||
|
clear_error_msg();
|
||||||
|
|
||||||
|
// figure out if we're a chip pro
|
||||||
|
if (is_this_chippro() < 1) {
|
||||||
|
char err[2000];
|
||||||
|
snprintf(err, sizeof(err), "init_module error (%s)", get_error_msg());
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, err);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// After this point, ISCHIPPRO variable should be good to go
|
||||||
|
|
||||||
|
// If we make it here, we're good to go
|
||||||
|
if (DEBUG)
|
||||||
|
printf(" ** init_module: setup complete **\n");
|
||||||
|
module_setup = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// python function value = is_chip_pro
|
||||||
|
static PyObject *py_is_chip_pro(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *py_value;
|
||||||
|
|
||||||
|
if (!module_setup) {
|
||||||
|
init_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
py_value = Py_BuildValue("i", ISCHIPPRO);
|
||||||
|
|
||||||
|
return py_value;
|
||||||
|
}
|
||||||
|
|
||||||
// python function start(channel, duty_cycle, freq)
|
// python function start(channel, duty_cycle, freq)
|
||||||
static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwargs)
|
static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
@ -69,6 +104,10 @@ static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwar
|
|||||||
}
|
}
|
||||||
ASSRT(channel != NULL);
|
ASSRT(channel != NULL);
|
||||||
|
|
||||||
|
if (!module_setup) {
|
||||||
|
init_module();
|
||||||
|
}
|
||||||
|
|
||||||
if (!get_key(channel, key)) {
|
if (!get_key(channel, key)) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Invalid SOFTPWM key or name.");
|
PyErr_SetString(PyExc_ValueError, "Invalid SOFTPWM key or name.");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -192,6 +231,7 @@ PyMethodDef pwm_methods[] = {
|
|||||||
{"set_frequency", (PyCFunction)py_set_frequency, METH_VARARGS, "Change the frequency\nfrequency - frequency in Hz (freq > 0.0)" },
|
{"set_frequency", (PyCFunction)py_set_frequency, METH_VARARGS, "Change the frequency\nfrequency - frequency in Hz (freq > 0.0)" },
|
||||||
{"cleanup", (PyCFunction)py_cleanup, METH_VARARGS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"},
|
{"cleanup", (PyCFunction)py_cleanup, METH_VARARGS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"},
|
||||||
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
|
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
|
||||||
|
{"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user