summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Michael Green <plugwash@debian.org>2021-01-28 19:07:37 +0000
committerPeter Michael Green <plugwash@debian.org>2021-01-28 19:07:37 +0000
commitb13be442cbed5e73aac1158e488a87aefb38d03f (patch)
treed57d605144790b1e1a93231b9826d403da31726c
parentedb6ffdb45648a882874a0dbad38f591b1c1f9ea (diff)
parentcc17196c7586c3625ac8adf8f34838d320ffeda6 (diff)
Merge tag 'v78' of https://github.com/joan2937/pigpio into debian
-rw-r--r--.gitignore10
-rw-r--r--CMakeLists.txt159
-rw-r--r--CONTRIBUTING.md58
-rw-r--r--DOC/HTML/images/LDR-fritz.pngbin0 -> 42505 bytes
-rw-r--r--DOC/HTML/images/LDR-gnup-1.pngbin0 -> 47487 bytes
-rw-r--r--DOC/HTML/images/LDR-gnup-2.pngbin0 -> 31410 bytes
-rw-r--r--DOC/HTML/images/LDR-photo.jpgbin0 -> 109499 bytes
-rw-r--r--DOC/HTML/images/LDR-wave-1.pngbin0 -> 4557 bytes
-rw-r--r--DOC/HTML/images/LDR-wave-2.pngbin0 -> 4438 bytes
-rw-r--r--DOC/HTML/images/LDR-wave-3.pngbin0 -> 4872 bytes
-rw-r--r--DOC/HTML/images/breadboard.jpgbin0 -> 46953 bytes
-rw-r--r--DOC/HTML/images/caps.jpgbin0 -> 35397 bytes
-rw-r--r--DOC/HTML/images/driver.jpgbin0 -> 41058 bytes
-rw-r--r--DOC/HTML/images/faq-i2c-ss.pngbin0 -> 9006 bytes
-rw-r--r--DOC/HTML/images/faq-i2c.jpgbin0 -> 42782 bytes
-rw-r--r--DOC/HTML/images/faq-serial.jpgbin0 -> 40297 bytes
-rw-r--r--DOC/HTML/images/faq-spi.jpgbin0 -> 43222 bytes
-rw-r--r--DOC/HTML/images/faq1.jpgbin0 -> 14196 bytes
-rw-r--r--DOC/HTML/images/faq2.jpgbin0 -> 37418 bytes
-rw-r--r--DOC/HTML/images/faq3.jpgbin0 -> 6686 bytes
-rw-r--r--DOC/HTML/images/imu-1.jpgbin0 -> 44650 bytes
-rw-r--r--DOC/HTML/images/imu-2.jpgbin0 -> 42737 bytes
-rw-r--r--DOC/HTML/images/imu-3.jpgbin0 -> 42800 bytes
-rw-r--r--DOC/HTML/images/ir-fritz.pngbin0 -> 40477 bytes
-rw-r--r--DOC/HTML/images/ir-motion.jpgbin0 -> 22139 bytes
-rw-r--r--DOC/HTML/images/ir-photo.jpgbin0 -> 90482 bytes
-rw-r--r--DOC/HTML/images/ir-rx.jpgbin0 -> 32358 bytes
-rw-r--r--DOC/HTML/images/ir-wave-1.pngbin0 -> 4827 bytes
-rw-r--r--DOC/HTML/images/ir-wave-2.pngbin0 -> 4237 bytes
-rw-r--r--DOC/HTML/images/ir-wave-3.pngbin0 -> 5038 bytes
-rw-r--r--DOC/HTML/images/keypad.jpgbin0 -> 30294 bytes
-rw-r--r--DOC/HTML/images/lcd.jpgbin0 -> 29926 bytes
-rw-r--r--DOC/HTML/images/ldr-cap.jpgbin0 -> 34448 bytes
-rw-r--r--DOC/HTML/images/ldr.jpgbin0 -> 28458 bytes
-rw-r--r--DOC/HTML/images/leds.jpgbin0 -> 36146 bytes
-rw-r--r--DOC/HTML/images/meter.jpgbin0 -> 29610 bytes
-rw-r--r--DOC/HTML/images/motor.jpgbin0 -> 17593 bytes
-rw-r--r--DOC/HTML/images/msp430.jpgbin0 -> 43686 bytes
-rw-r--r--DOC/HTML/images/nano.jpgbin0 -> 40463 bytes
-rw-r--r--DOC/HTML/images/oled-2.jpgbin0 -> 40888 bytes
-rw-r--r--DOC/HTML/images/oled.jpgbin0 -> 31872 bytes
-rw-r--r--DOC/HTML/images/pigpio-logo.gifbin0 -> 375 bytes
-rw-r--r--DOC/HTML/images/pins.jpgbin0 -> 42788 bytes
-rw-r--r--DOC/HTML/images/pisc-1.jpgbin0 -> 20520 bytes
-rw-r--r--DOC/HTML/images/pisc-2.jpgbin0 -> 17527 bytes
-rw-r--r--DOC/HTML/images/pisc-3.jpgbin0 -> 15915 bytes
-rw-r--r--DOC/HTML/images/pot.jpgbin0 -> 26518 bytes
-rw-r--r--DOC/HTML/images/pro-mini.jpgbin0 -> 36398 bytes
-rw-r--r--DOC/HTML/images/psu.jpgbin0 -> 33988 bytes
-rw-r--r--DOC/HTML/images/re-fritz.pngbin0 -> 39702 bytes
-rw-r--r--DOC/HTML/images/re-photo.jpgbin0 -> 50100 bytes
-rw-r--r--DOC/HTML/images/re-wave-1.pngbin0 -> 5570 bytes
-rw-r--r--DOC/HTML/images/re-wave-2.pngbin0 -> 5404 bytes
-rw-r--r--DOC/HTML/images/remote-1.jpgbin0 -> 27199 bytes
-rw-r--r--DOC/HTML/images/remote-2.jpgbin0 -> 28482 bytes
-rw-r--r--DOC/HTML/images/reverse.jpgbin0 -> 35860 bytes
-rw-r--r--DOC/HTML/images/rf-rx-2.jpgbin0 -> 34515 bytes
-rw-r--r--DOC/HTML/images/rf-rx.jpgbin0 -> 31082 bytes
-rw-r--r--DOC/HTML/images/rf-tx.jpgbin0 -> 40421 bytes
-rw-r--r--DOC/HTML/images/rotary.jpgbin0 -> 22765 bytes
-rw-r--r--DOC/HTML/images/rpi.jpgbin0 -> 37698 bytes
-rw-r--r--DOC/HTML/images/serial.jpgbin0 -> 29831 bytes
-rw-r--r--DOC/HTML/images/servo.jpgbin0 -> 28811 bytes
-rw-r--r--DOC/HTML/images/sidebar.gifbin0 -> 52 bytes
-rw-r--r--DOC/HTML/images/son-fritz.pngbin0 -> 69915 bytes
-rw-r--r--DOC/HTML/images/son-gnup-1.pngbin0 -> 15447 bytes
-rw-r--r--DOC/HTML/images/son-gnup-2.pngbin0 -> 12101 bytes
-rw-r--r--DOC/HTML/images/son-photo.jpgbin0 -> 69827 bytes
-rw-r--r--DOC/HTML/images/son-wave-1.pngbin0 -> 4410 bytes
-rw-r--r--DOC/HTML/images/son-wave-2.pngbin0 -> 4293 bytes
-rw-r--r--DOC/HTML/images/son-wave-3.pngbin0 -> 4757 bytes
-rw-r--r--DOC/HTML/images/son-wave-4.pngbin0 -> 5270 bytes
-rw-r--r--DOC/HTML/images/speaker.jpgbin0 -> 34456 bytes
-rw-r--r--DOC/HTML/images/spi-lnx-pi3b.pngbin0 -> 9134 bytes
-rw-r--r--DOC/HTML/images/spi-lnx-pibr1.pngbin0 -> 7174 bytes
-rw-r--r--DOC/HTML/images/spi-pig-pi3b.pngbin0 -> 8896 bytes
-rw-r--r--DOC/HTML/images/spi-pig-pibr1.pngbin0 -> 8502 bytes
-rw-r--r--DOC/HTML/images/srf02.jpgbin0 -> 26595 bytes
-rw-r--r--DOC/HTML/images/srf04.jpgbin0 -> 33664 bytes
-rw-r--r--DOC/HTML/images/stepper.jpgbin0 -> 30634 bytes
-rw-r--r--DOC/HTML/images/switches.jpgbin0 -> 43275 bytes
-rw-r--r--DOC/HTML/images/topbar.gifbin0 -> 1015 bytes
-rw-r--r--DOC/HTML/images/transistors.jpgbin0 -> 43174 bytes
-rw-r--r--DOC/HTML/images/ubec-2.jpgbin0 -> 18920 bytes
-rw-r--r--DOC/HTML/images/uln2003a.jpgbin0 -> 26817 bytes
-rw-r--r--DOC/HTML/images/wheel.jpgbin0 -> 23241 bytes
-rw-r--r--DOC/HTML/images/wires.jpgbin0 -> 36804 bytes
-rw-r--r--DOC/HTML/images/yl-40.jpgbin0 -> 43771 bytes
-rw-r--r--DOC/HTML/scripts/index.css52
-rw-r--r--DOC/HTML/scripts/standard.css3
-rw-r--r--DOC/MAN/README1
-rw-r--r--DOC/README16
-rwxr-xr-xDOC/bin/backup.sh5
-rwxr-xr-xDOC/bin/body.py14
-rwxr-xr-xDOC/bin/build_site.py21
-rwxr-xr-xDOC/bin/cmakdoc.py563
-rwxr-xr-xDOC/bin/examples.py123
-rwxr-xr-xDOC/bin/html.py137
-rwxr-xr-xDOC/bin/purge.sh14
-rwxr-xr-xDOC/bin/pymakdoc.py270
-rwxr-xr-xDOC/bin/smakdoc.py376
-rwxr-xr-xDOC/bin/tidy.py28
-rwxr-xr-xDOC/bin/updatesql.py21
-rw-r--r--DOC/dbase/pigpio.sqlitebin0 -> 1433600 bytes
-rwxr-xr-xDOC/makedoc47
-rw-r--r--DOC/src/defs/examples.def521
-rw-r--r--DOC/src/defs/pig2vcd.def110
-rw-r--r--DOC/src/defs/pigpiod.def101
-rw-r--r--DOC/src/defs/pigs.def3482
-rw-r--r--DOC/src/html/download.html68
-rw-r--r--DOC/src/html/ex_LDR.html150
-rw-r--r--DOC/src/html/ex_ir_remote.html253
-rw-r--r--DOC/src/html/ex_motor_shield.html254
-rw-r--r--DOC/src/html/ex_rotary_encoder.html185
-rw-r--r--DOC/src/html/ex_sonar_ranger.html164
-rw-r--r--DOC/src/html/faq.html462
-rw-r--r--DOC/src/html/index.html659
-rw-r--r--DOC/src/html/misc.html33
-rw-r--r--DOC/src/html/pif.html30
-rw-r--r--DOC/src/html/piscope.html216
-rw-r--r--DOC/src/html/sif.html2004
-rw-r--r--README.md6
-rw-r--r--SUPPORT.md8
-rw-r--r--cmake/FindRT.cmake39
-rw-r--r--cmake/pigpioConfig.cmake1
-rw-r--r--cmake/setup.py.in24
-rw-r--r--command.c399
-rw-r--r--command.h4
-rw-r--r--pig2vcd.12
-rw-r--r--pigpio.3826
-rw-r--r--pigpio.c869
-rw-r--r--pigpio.h442
-rw-r--r--pigpio.py352
-rw-r--r--pigpiod.12
-rw-r--r--pigpiod.c6
-rw-r--r--pigpiod_if.3338
-rw-r--r--pigpiod_if.c2
-rw-r--r--pigpiod_if2.3691
-rw-r--r--pigpiod_if2.c57
-rw-r--r--pigpiod_if2.h340
-rw-r--r--pigs.1558
-rw-r--r--pigs.c5
-rw-r--r--setup.py2
-rwxr-xr-xutil/pigpiod31
-rw-r--r--util/pigpiod.service3
-rw-r--r--x_pigpio.c47
-rwxr-xr-xx_pigpio.py41
-rw-r--r--x_pigpiod_if2.c44
-rwxr-xr-xx_pigs20
149 files changed, 14675 insertions, 1094 deletions
diff --git a/.gitignore b/.gitignore
index f67291c..fcdcc13 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
*.o
*.so
+*.so.*
*.pyc
pig2vcd
pigpiod
@@ -11,3 +12,12 @@ __pycache__
build
dist
*.egg-info
+
+tmp/
+
+# DOC files
+DOC/dbase/pigpio.sqlite.*
+DOC/tmp
+DOC/MAN/*
+!DOC/MAN/README*
+DOC/HTML/*.html
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aac33fa..383c445 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,83 +1,95 @@
cmake_minimum_required(VERSION 3.0)
-project(pigpio)
+project(pigpio LANGUAGES C VERSION 0.71)
-set(CMAKE_C_FLAGS "-O3 -Wall -pthread")
-set(PIGPIO_FLAGS "-L. -lrt")
-#set(DESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/build/dest)
+list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
-# libpigpio.so
-add_library(pigpio SHARED pigpio.c command.c custom.cext)
-set_property(TARGET pigpio
- PROPERTY POSITION_INDEPENDENT_CODE ON
-)
+find_package(Threads REQUIRED)
+find_package(RT REQUIRED)
-# libpigpiod_if.so
-add_library(pigpiod_if SHARED pigpiod_if.c command.c)
-set_property(TARGET pigpiod_if
- PROPERTY POSITION_INDEPENDENT_CODE ON
-)
+option(BUILD_SHARED_LIBS "Create shared libraries" ON)
-# libpigpiod_if2.so
-add_library(pigpiod_if2 SHARED pigpiod_if2.c command.c)
-set_property(TARGET pigpiod_if2
- PROPERTY POSITION_INDEPENDENT_CODE ON
-)
+add_compile_options(-Wall)
+
+# libpigpio.(so|a)
+add_library(pigpio pigpio.c command.c custom.cext)
+
+# libpigpiod_if.(so|a)
+add_library(pigpiod_if pigpiod_if.c command.c)
+
+# libpigpiod_if2.(so|a)
+add_library(pigpiod_if2 pigpiod_if2.c command.c)
# x_pigpio
add_executable(x_pigpio x_pigpio.c)
-add_dependencies(x_pigpio pigpio)
-target_link_libraries(x_pigpio
- ${PIGPIO_FLAGS}
- -lpigpio
-)
+target_link_libraries(x_pigpio pigpio RT::RT Threads::Threads)
# x_pigpiod_if
add_executable(x_pigpiod_if x_pigpiod_if.c)
-add_dependencies(x_pigpiod_if pigpiod_if)
-target_link_libraries(x_pigpiod_if
- ${PIGPIO_FLAGS}
- -lpigpiod_if
-)
+target_link_libraries(x_pigpiod_if pigpiod_if RT::RT Threads::Threads)
# x_pigpiod_if2
add_executable(x_pigpiod_if2 x_pigpiod_if2.c)
-add_dependencies(x_pigpiod_if2 pigpiod_if2)
-target_link_libraries(x_pigpiod_if2
- ${PIGPIO_FLAGS}
- -lpigpiod_if2
-)
+target_link_libraries(x_pigpiod_if2 pigpiod_if2 RT::RT Threads::Threads)
# pigpiod
add_executable(pigpiod pigpiod.c)
-add_dependencies(pigpiod pigpio)
-target_link_libraries(pigpiod
- ${PIGPIO_FLAGS}
- -lpigpio
-)
+target_link_libraries(pigpiod pigpio RT::RT Threads::Threads)
# pigs
add_executable(pigs pigs.c command.c)
+target_link_libraries(pigs Threads::Threads)
# pig2vcd
add_executable(pig2vcd pig2vcd.c command.c)
+target_link_libraries(pig2vcd Threads::Threads)
-# install
-install(DIRECTORY
- DESTINATION ${DESTDIR}/opt/pigpio/cgi
- PATTERN ""
- PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
- GROUP_READ GROUP_EXECUTE
- WORLD_READ WORLD_EXECUTE
-)
+# Configure and install project
+
+include (GenerateExportHeader)
+include (CMakePackageConfigHelpers)
+
+generate_export_header(${PROJECT_NAME})
install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs
- LIBRARY DESTINATION ${DESTDIR}/usr/local/lib
- RUNTIME DESTINATION ${DESTDIR}/usr/local/bin
+ EXPORT ${PROJECT_NAME}Targets
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin
+ INCLUDES DESTINATION include
+)
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ VERSION ${${PROJECT_NAME}_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+export(EXPORT ${PROJECT_NAME}Targets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
+ NAMESPACE pigpio::
+)
+
+set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
+install(EXPORT ${PROJECT_NAME}Targets
+ FILE
+ ${PROJECT_NAME}Targets.cmake
+ NAMESPACE
+ pigpio::
+ DESTINATION
+ ${ConfigPackageLocation}
+)
+
+install(
+ FILES
+ ${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ DESTINATION
+ ${ConfigPackageLocation}
)
install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h
- DESTINATION ${DESTDIR}/usr/local/include
+ DESTINATION include
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
@@ -85,7 +97,7 @@ install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h
file(GLOB man_1_SRC "*.1")
install(FILES ${man_1_SRC}
- DESTINATION ${DESTDIR}/usr/local/man/man1
+ DESTINATION man/man1
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
@@ -93,48 +105,23 @@ install(FILES ${man_1_SRC}
file(GLOB man_3_SRC "*.3")
install(FILES ${man_3_SRC}
- DESTINATION ${DESTDIR}/usr/local/man/man3
+ DESTINATION man/man3
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
)
-file(GLOB setup_SRC "setup.py")
-find_program(PYTHON2_FOUND python2)
-if(PYTHON2_FOUND)
- install(CODE "execute_process(COMMAND cd ${CMAKE_SOURCE_DIR} && python2 ${setup_SRC} install)")
-endif()
-find_program(PYTHON3_FOUND python3)
-if(PYTHON3_FOUND)
- install(CODE "execute_process(COMMAND cd ${CMAKE_SOURCE_DIR} && python3 ${setup_SRC} install)")
-endif()
+# Install python modules.
+find_package(Python COMPONENTS Interpreter QUIET)
-install(CODE "execute_process(COMMAND ldconfig)")
+if(Python_FOUND)
+ configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/setup.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/setup.py
+ )
-# uninstall
-if(PYTHON2_FOUND)
- set(PY2_CMD python2 ${setup_SRC} install --record /tmp/pigpio > /dev/null)
- set(PY2_CMD ${PY2_CMD} && xargs rm -f < /tmp/pigpio > /dev/null)
+ install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)")
endif()
-if(PYTHON3_FOUND)
- set(PY3_CMD python3 ${setup_SRC} install --record /tmp/pigpio > /dev/null)
- set(PY3_CMD ${PY3_CMD} && xargs rm -f < /tmp/pigpio > /dev/null)
-endif()
+# package project
-add_custom_target(uninstall
- COMMAND rm -f ${DESTDIR}/usr/local/include/pigpio.h
- COMMAND rm -f ${DESTDIR}/usr/local/include/pigpiod_if.h
- COMMAND rm -f ${DESTDIR}/usr/local/include/pigpiod_if2.h
- COMMAND rm -f ${DESTDIR}/usr/local/lib/libpigpio.so
- COMMAND rm -f ${DESTDIR}/usr/local/lib/libpigpiod_if.so
- COMMAND rm -f ${DESTDIR}/usr/local/lib/libpigpiod_if2.so
- COMMAND rm -f ${DESTDIR}/usr/local/bin/pig2vcd
- COMMAND rm -f ${DESTDIR}/usr/local/bin/pigpiod
- COMMAND rm -f ${DESTDIR}/usr/local/bin/pigs
- COMMAND cd ${CMAKE_SOURCE_DIR} && ${PY2_CMD}
- COMMAND cd ${CMAKE_SOURCE_DIR} && ${PY3_CMD}
- COMMAND rm -f ${DESTDIR}/usr/local/man/man1/pig*.1
- COMMAND rm -f ${DESTDIR}/usr/local/man/man3/pig*.3
- COMMAND ldconfig
-)
+include (CPack) \ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..a698a89
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,58 @@
+## Submitting a New Issue
+If you are reporting a **bug** or defect, please provide the steps to reproduce the problem you are describing.
+Ideally, provide a simple script that will reproduce the issue. Also provide a description of the hardware and
+software types and versions used in your application/test environment.
+
+Requests for a feature or **enhancement** to the library software will be treated at a lower priority due to the lack
+of resources (contributors with skillset, knowledge of the library or time). Unless your request has wide support
+from the community it will be treated at a low priority. If the repo's maintainer judges your request to be of value
+then it will be labeled `enhancement`. If additional resources are required, it will be tagged with `help wanted`.
+
+If you simply have a **question**, consult the SUPPORT.md document.
+
+## Creating a Pull Request
+Contributions are welcome. To save time it is best to have an open issue relating to what it is you want to contribute
+and to discuss the prospects of getting your contribution accepted.
+
+Your changes *must* pass the set of test files `x_*`. Please indicate that you have run the test scripts successfuly or attach
+a screen shot of the output from the test scripts.
+
+In addition, you *should* provide updated or additional scripts that at least test the 'happy' paths of your code changes. For
+larger changes the additional test cases will be considered mandatory.
+
+Beginning 2020, this repo will follow a dual branch model: `master` is the stable branch that people use in production. A second branch, `develop`, is the first branch to receive merges from bug fixes and new features. Only after we consider `develop` stable we merge it into the `master` branch and release the changes with a tagged version.
+
+Adhering to the following process is the best way to get your work included in the project:
+
+- Fork the project, clone your fork, and configure the remotes:
+```
+# Clone your fork of the repo into the current directory
+git clone https://github.com/<your-username>/pigio.git
+
+# Navigate to the newly cloned directory
+cd pigpio
+
+# Assign the original repo to a remote called "upstream"
+git remote add upstream https://github.com/joan2937/pigpio.git
+```
+- If you cloned a while ago, get the latest changes from upstream:
+```
+git checkout develop
+git pull upstream develop
+```
+- Create a new topic branch (off the develop branch) to contain your feature, change, or fix:
+```
+git checkout -b <topic-branch-name>
+```
+- Commit your changes.
+
+- Locally merge (or rebase) the upstream dev branch into your topic branch:
+```
+git pull [--rebase] upstream develop
+```
+- Push your topic branch up to your fork:
+```
+git push origin <topic-branch-name>
+```
+- Open a Pull Request with a clear title and description. See [creating a pull request from a fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork).
+Make sure the base branch drop down menu is selecting 'develop'.
diff --git a/DOC/HTML/images/LDR-fritz.png b/DOC/HTML/images/LDR-fritz.png
new file mode 100644
index 0000000..6265585
--- /dev/null
+++ b/DOC/HTML/images/LDR-fritz.png
Binary files differ
diff --git a/DOC/HTML/images/LDR-gnup-1.png b/DOC/HTML/images/LDR-gnup-1.png
new file mode 100644
index 0000000..6ec6194
--- /dev/null
+++ b/DOC/HTML/images/LDR-gnup-1.png
Binary files differ
diff --git a/DOC/HTML/images/LDR-gnup-2.png b/DOC/HTML/images/LDR-gnup-2.png
new file mode 100644
index 0000000..4453096
--- /dev/null
+++ b/DOC/HTML/images/LDR-gnup-2.png
Binary files differ
diff --git a/DOC/HTML/images/LDR-photo.jpg b/DOC/HTML/images/LDR-photo.jpg
new file mode 100644
index 0000000..95a63a3
--- /dev/null
+++ b/DOC/HTML/images/LDR-photo.jpg
Binary files differ
diff --git a/DOC/HTML/images/LDR-wave-1.png b/DOC/HTML/images/LDR-wave-1.png
new file mode 100644
index 0000000..69bb43b
--- /dev/null
+++ b/DOC/HTML/images/LDR-wave-1.png
Binary files differ
diff --git a/DOC/HTML/images/LDR-wave-2.png b/DOC/HTML/images/LDR-wave-2.png
new file mode 100644
index 0000000..ea68076
--- /dev/null
+++ b/DOC/HTML/images/LDR-wave-2.png
Binary files differ
diff --git a/DOC/HTML/images/LDR-wave-3.png b/DOC/HTML/images/LDR-wave-3.png
new file mode 100644
index 0000000..a2ca42a
--- /dev/null
+++ b/DOC/HTML/images/LDR-wave-3.png
Binary files differ
diff --git a/DOC/HTML/images/breadboard.jpg b/DOC/HTML/images/breadboard.jpg
new file mode 100644
index 0000000..5d916f7
--- /dev/null
+++ b/DOC/HTML/images/breadboard.jpg
Binary files differ
diff --git a/DOC/HTML/images/caps.jpg b/DOC/HTML/images/caps.jpg
new file mode 100644
index 0000000..f82e73b
--- /dev/null
+++ b/DOC/HTML/images/caps.jpg
Binary files differ
diff --git a/DOC/HTML/images/driver.jpg b/DOC/HTML/images/driver.jpg
new file mode 100644
index 0000000..48266fe
--- /dev/null
+++ b/DOC/HTML/images/driver.jpg
Binary files differ
diff --git a/DOC/HTML/images/faq-i2c-ss.png b/DOC/HTML/images/faq-i2c-ss.png
new file mode 100644
index 0000000..0e4c58a
--- /dev/null
+++ b/DOC/HTML/images/faq-i2c-ss.png
Binary files differ
diff --git a/DOC/HTML/images/faq-i2c.jpg b/DOC/HTML/images/faq-i2c.jpg
new file mode 100644
index 0000000..02b4a01
--- /dev/null
+++ b/DOC/HTML/images/faq-i2c.jpg
Binary files differ
diff --git a/DOC/HTML/images/faq-serial.jpg b/DOC/HTML/images/faq-serial.jpg
new file mode 100644
index 0000000..9963589
--- /dev/null
+++ b/DOC/HTML/images/faq-serial.jpg
Binary files differ
diff --git a/DOC/HTML/images/faq-spi.jpg b/DOC/HTML/images/faq-spi.jpg
new file mode 100644
index 0000000..65ed087
--- /dev/null
+++ b/DOC/HTML/images/faq-spi.jpg
Binary files differ
diff --git a/DOC/HTML/images/faq1.jpg b/DOC/HTML/images/faq1.jpg
new file mode 100644
index 0000000..72c6eb6
--- /dev/null
+++ b/DOC/HTML/images/faq1.jpg
Binary files differ
diff --git a/DOC/HTML/images/faq2.jpg b/DOC/HTML/images/faq2.jpg
new file mode 100644
index 0000000..a22800e
--- /dev/null
+++ b/DOC/HTML/images/faq2.jpg
Binary files differ
diff --git a/DOC/HTML/images/faq3.jpg b/DOC/HTML/images/faq3.jpg
new file mode 100644
index 0000000..9785a49
--- /dev/null
+++ b/DOC/HTML/images/faq3.jpg
Binary files differ
diff --git a/DOC/HTML/images/imu-1.jpg b/DOC/HTML/images/imu-1.jpg
new file mode 100644
index 0000000..f9de3a3
--- /dev/null
+++ b/DOC/HTML/images/imu-1.jpg
Binary files differ
diff --git a/DOC/HTML/images/imu-2.jpg b/DOC/HTML/images/imu-2.jpg
new file mode 100644
index 0000000..cd56dfd
--- /dev/null
+++ b/DOC/HTML/images/imu-2.jpg
Binary files differ
diff --git a/DOC/HTML/images/imu-3.jpg b/DOC/HTML/images/imu-3.jpg
new file mode 100644
index 0000000..193fe48
--- /dev/null
+++ b/DOC/HTML/images/imu-3.jpg
Binary files differ
diff --git a/DOC/HTML/images/ir-fritz.png b/DOC/HTML/images/ir-fritz.png
new file mode 100644
index 0000000..595d8d5
--- /dev/null
+++ b/DOC/HTML/images/ir-fritz.png
Binary files differ
diff --git a/DOC/HTML/images/ir-motion.jpg b/DOC/HTML/images/ir-motion.jpg
new file mode 100644
index 0000000..7fe557e
--- /dev/null
+++ b/DOC/HTML/images/ir-motion.jpg
Binary files differ
diff --git a/DOC/HTML/images/ir-photo.jpg b/DOC/HTML/images/ir-photo.jpg
new file mode 100644
index 0000000..f42ffa2
--- /dev/null
+++ b/DOC/HTML/images/ir-photo.jpg
Binary files differ
diff --git a/DOC/HTML/images/ir-rx.jpg b/DOC/HTML/images/ir-rx.jpg
new file mode 100644
index 0000000..130b365
--- /dev/null
+++ b/DOC/HTML/images/ir-rx.jpg
Binary files differ
diff --git a/DOC/HTML/images/ir-wave-1.png b/DOC/HTML/images/ir-wave-1.png
new file mode 100644
index 0000000..29edad3
--- /dev/null
+++ b/DOC/HTML/images/ir-wave-1.png
Binary files differ
diff --git a/DOC/HTML/images/ir-wave-2.png b/DOC/HTML/images/ir-wave-2.png
new file mode 100644
index 0000000..f820503
--- /dev/null
+++ b/DOC/HTML/images/ir-wave-2.png
Binary files differ
diff --git a/DOC/HTML/images/ir-wave-3.png b/DOC/HTML/images/ir-wave-3.png
new file mode 100644
index 0000000..b5292b8
--- /dev/null
+++ b/DOC/HTML/images/ir-wave-3.png
Binary files differ
diff --git a/DOC/HTML/images/keypad.jpg b/DOC/HTML/images/keypad.jpg
new file mode 100644
index 0000000..d6e1f3b
--- /dev/null
+++ b/DOC/HTML/images/keypad.jpg
Binary files differ
diff --git a/DOC/HTML/images/lcd.jpg b/DOC/HTML/images/lcd.jpg
new file mode 100644
index 0000000..b38a174
--- /dev/null
+++ b/DOC/HTML/images/lcd.jpg
Binary files differ
diff --git a/DOC/HTML/images/ldr-cap.jpg b/DOC/HTML/images/ldr-cap.jpg
new file mode 100644
index 0000000..cd34bb8
--- /dev/null
+++ b/DOC/HTML/images/ldr-cap.jpg
Binary files differ
diff --git a/DOC/HTML/images/ldr.jpg b/DOC/HTML/images/ldr.jpg
new file mode 100644
index 0000000..d49be11
--- /dev/null
+++ b/DOC/HTML/images/ldr.jpg
Binary files differ
diff --git a/DOC/HTML/images/leds.jpg b/DOC/HTML/images/leds.jpg
new file mode 100644
index 0000000..7b79f72
--- /dev/null
+++ b/DOC/HTML/images/leds.jpg
Binary files differ
diff --git a/DOC/HTML/images/meter.jpg b/DOC/HTML/images/meter.jpg
new file mode 100644
index 0000000..65ce37d
--- /dev/null
+++ b/DOC/HTML/images/meter.jpg
Binary files differ
diff --git a/DOC/HTML/images/motor.jpg b/DOC/HTML/images/motor.jpg
new file mode 100644
index 0000000..1ddcb82
--- /dev/null
+++ b/DOC/HTML/images/motor.jpg
Binary files differ
diff --git a/DOC/HTML/images/msp430.jpg b/DOC/HTML/images/msp430.jpg
new file mode 100644
index 0000000..04633f3
--- /dev/null
+++ b/DOC/HTML/images/msp430.jpg
Binary files differ
diff --git a/DOC/HTML/images/nano.jpg b/DOC/HTML/images/nano.jpg
new file mode 100644
index 0000000..03c3fb1
--- /dev/null
+++ b/DOC/HTML/images/nano.jpg
Binary files differ
diff --git a/DOC/HTML/images/oled-2.jpg b/DOC/HTML/images/oled-2.jpg
new file mode 100644
index 0000000..622713f
--- /dev/null
+++ b/DOC/HTML/images/oled-2.jpg
Binary files differ
diff --git a/DOC/HTML/images/oled.jpg b/DOC/HTML/images/oled.jpg
new file mode 100644
index 0000000..02f093d
--- /dev/null
+++ b/DOC/HTML/images/oled.jpg
Binary files differ
diff --git a/DOC/HTML/images/pigpio-logo.gif b/DOC/HTML/images/pigpio-logo.gif
new file mode 100644
index 0000000..f0980e1
--- /dev/null
+++ b/DOC/HTML/images/pigpio-logo.gif
Binary files differ
diff --git a/DOC/HTML/images/pins.jpg b/DOC/HTML/images/pins.jpg
new file mode 100644
index 0000000..60e2f4e
--- /dev/null
+++ b/DOC/HTML/images/pins.jpg
Binary files differ
diff --git a/DOC/HTML/images/pisc-1.jpg b/DOC/HTML/images/pisc-1.jpg
new file mode 100644
index 0000000..a83d4c9
--- /dev/null
+++ b/DOC/HTML/images/pisc-1.jpg
Binary files differ
diff --git a/DOC/HTML/images/pisc-2.jpg b/DOC/HTML/images/pisc-2.jpg
new file mode 100644
index 0000000..1506017
--- /dev/null
+++ b/DOC/HTML/images/pisc-2.jpg
Binary files differ
diff --git a/DOC/HTML/images/pisc-3.jpg b/DOC/HTML/images/pisc-3.jpg
new file mode 100644
index 0000000..6b473ff
--- /dev/null
+++ b/DOC/HTML/images/pisc-3.jpg
Binary files differ
diff --git a/DOC/HTML/images/pot.jpg b/DOC/HTML/images/pot.jpg
new file mode 100644
index 0000000..ea386e9
--- /dev/null
+++ b/DOC/HTML/images/pot.jpg
Binary files differ
diff --git a/DOC/HTML/images/pro-mini.jpg b/DOC/HTML/images/pro-mini.jpg
new file mode 100644
index 0000000..af8f0b9
--- /dev/null
+++ b/DOC/HTML/images/pro-mini.jpg
Binary files differ
diff --git a/DOC/HTML/images/psu.jpg b/DOC/HTML/images/psu.jpg
new file mode 100644
index 0000000..f848d14
--- /dev/null
+++ b/DOC/HTML/images/psu.jpg
Binary files differ
diff --git a/DOC/HTML/images/re-fritz.png b/DOC/HTML/images/re-fritz.png
new file mode 100644
index 0000000..2f545b5
--- /dev/null
+++ b/DOC/HTML/images/re-fritz.png
Binary files differ
diff --git a/DOC/HTML/images/re-photo.jpg b/DOC/HTML/images/re-photo.jpg
new file mode 100644
index 0000000..22c4bfe
--- /dev/null
+++ b/DOC/HTML/images/re-photo.jpg
Binary files differ
diff --git a/DOC/HTML/images/re-wave-1.png b/DOC/HTML/images/re-wave-1.png
new file mode 100644
index 0000000..f8a194d
--- /dev/null
+++ b/DOC/HTML/images/re-wave-1.png
Binary files differ
diff --git a/DOC/HTML/images/re-wave-2.png b/DOC/HTML/images/re-wave-2.png
new file mode 100644
index 0000000..399d7a4
--- /dev/null
+++ b/DOC/HTML/images/re-wave-2.png
Binary files differ
diff --git a/DOC/HTML/images/remote-1.jpg b/DOC/HTML/images/remote-1.jpg
new file mode 100644
index 0000000..2d28bef
--- /dev/null
+++ b/DOC/HTML/images/remote-1.jpg
Binary files differ
diff --git a/DOC/HTML/images/remote-2.jpg b/DOC/HTML/images/remote-2.jpg
new file mode 100644
index 0000000..d11685a
--- /dev/null
+++ b/DOC/HTML/images/remote-2.jpg
Binary files differ
diff --git a/DOC/HTML/images/reverse.jpg b/DOC/HTML/images/reverse.jpg
new file mode 100644
index 0000000..2eb3804
--- /dev/null
+++ b/DOC/HTML/images/reverse.jpg
Binary files differ
diff --git a/DOC/HTML/images/rf-rx-2.jpg b/DOC/HTML/images/rf-rx-2.jpg
new file mode 100644
index 0000000..1f1e93c
--- /dev/null
+++ b/DOC/HTML/images/rf-rx-2.jpg
Binary files differ
diff --git a/DOC/HTML/images/rf-rx.jpg b/DOC/HTML/images/rf-rx.jpg
new file mode 100644
index 0000000..c246a4f
--- /dev/null
+++ b/DOC/HTML/images/rf-rx.jpg
Binary files differ
diff --git a/DOC/HTML/images/rf-tx.jpg b/DOC/HTML/images/rf-tx.jpg
new file mode 100644
index 0000000..324d257
--- /dev/null
+++ b/DOC/HTML/images/rf-tx.jpg
Binary files differ
diff --git a/DOC/HTML/images/rotary.jpg b/DOC/HTML/images/rotary.jpg
new file mode 100644
index 0000000..0f7d224
--- /dev/null
+++ b/DOC/HTML/images/rotary.jpg
Binary files differ
diff --git a/DOC/HTML/images/rpi.jpg b/DOC/HTML/images/rpi.jpg
new file mode 100644
index 0000000..85ce158
--- /dev/null
+++ b/DOC/HTML/images/rpi.jpg
Binary files differ
diff --git a/DOC/HTML/images/serial.jpg b/DOC/HTML/images/serial.jpg
new file mode 100644
index 0000000..c2bb917
--- /dev/null
+++ b/DOC/HTML/images/serial.jpg
Binary files differ
diff --git a/DOC/HTML/images/servo.jpg b/DOC/HTML/images/servo.jpg
new file mode 100644
index 0000000..bbd895c
--- /dev/null
+++ b/DOC/HTML/images/servo.jpg
Binary files differ
diff --git a/DOC/HTML/images/sidebar.gif b/DOC/HTML/images/sidebar.gif
new file mode 100644
index 0000000..89a0620
--- /dev/null
+++ b/DOC/HTML/images/sidebar.gif
Binary files differ
diff --git a/DOC/HTML/images/son-fritz.png b/DOC/HTML/images/son-fritz.png
new file mode 100644
index 0000000..c864641
--- /dev/null
+++ b/DOC/HTML/images/son-fritz.png
Binary files differ
diff --git a/DOC/HTML/images/son-gnup-1.png b/DOC/HTML/images/son-gnup-1.png
new file mode 100644
index 0000000..be53824
--- /dev/null
+++ b/DOC/HTML/images/son-gnup-1.png
Binary files differ
diff --git a/DOC/HTML/images/son-gnup-2.png b/DOC/HTML/images/son-gnup-2.png
new file mode 100644
index 0000000..c552306
--- /dev/null
+++ b/DOC/HTML/images/son-gnup-2.png
Binary files differ
diff --git a/DOC/HTML/images/son-photo.jpg b/DOC/HTML/images/son-photo.jpg
new file mode 100644
index 0000000..6954f40
--- /dev/null
+++ b/DOC/HTML/images/son-photo.jpg
Binary files differ
diff --git a/DOC/HTML/images/son-wave-1.png b/DOC/HTML/images/son-wave-1.png
new file mode 100644
index 0000000..96261bc
--- /dev/null
+++ b/DOC/HTML/images/son-wave-1.png
Binary files differ
diff --git a/DOC/HTML/images/son-wave-2.png b/DOC/HTML/images/son-wave-2.png
new file mode 100644
index 0000000..73c8b6d
--- /dev/null
+++ b/DOC/HTML/images/son-wave-2.png
Binary files differ
diff --git a/DOC/HTML/images/son-wave-3.png b/DOC/HTML/images/son-wave-3.png
new file mode 100644
index 0000000..346f5ae
--- /dev/null
+++ b/DOC/HTML/images/son-wave-3.png
Binary files differ
diff --git a/DOC/HTML/images/son-wave-4.png b/DOC/HTML/images/son-wave-4.png
new file mode 100644
index 0000000..ad454ef
--- /dev/null
+++ b/DOC/HTML/images/son-wave-4.png
Binary files differ
diff --git a/DOC/HTML/images/speaker.jpg b/DOC/HTML/images/speaker.jpg
new file mode 100644
index 0000000..2be827b
--- /dev/null
+++ b/DOC/HTML/images/speaker.jpg
Binary files differ
diff --git a/DOC/HTML/images/spi-lnx-pi3b.png b/DOC/HTML/images/spi-lnx-pi3b.png
new file mode 100644
index 0000000..09ee665
--- /dev/null
+++ b/DOC/HTML/images/spi-lnx-pi3b.png
Binary files differ
diff --git a/DOC/HTML/images/spi-lnx-pibr1.png b/DOC/HTML/images/spi-lnx-pibr1.png
new file mode 100644
index 0000000..3c708e4
--- /dev/null
+++ b/DOC/HTML/images/spi-lnx-pibr1.png
Binary files differ
diff --git a/DOC/HTML/images/spi-pig-pi3b.png b/DOC/HTML/images/spi-pig-pi3b.png
new file mode 100644
index 0000000..602922c
--- /dev/null
+++ b/DOC/HTML/images/spi-pig-pi3b.png
Binary files differ
diff --git a/DOC/HTML/images/spi-pig-pibr1.png b/DOC/HTML/images/spi-pig-pibr1.png
new file mode 100644
index 0000000..308f25d
--- /dev/null
+++ b/DOC/HTML/images/spi-pig-pibr1.png
Binary files differ
diff --git a/DOC/HTML/images/srf02.jpg b/DOC/HTML/images/srf02.jpg
new file mode 100644
index 0000000..22486f8
--- /dev/null
+++ b/DOC/HTML/images/srf02.jpg
Binary files differ
diff --git a/DOC/HTML/images/srf04.jpg b/DOC/HTML/images/srf04.jpg
new file mode 100644
index 0000000..632d194
--- /dev/null
+++ b/DOC/HTML/images/srf04.jpg
Binary files differ
diff --git a/DOC/HTML/images/stepper.jpg b/DOC/HTML/images/stepper.jpg
new file mode 100644
index 0000000..11a1473
--- /dev/null
+++ b/DOC/HTML/images/stepper.jpg
Binary files differ
diff --git a/DOC/HTML/images/switches.jpg b/DOC/HTML/images/switches.jpg
new file mode 100644
index 0000000..6cd1df5
--- /dev/null
+++ b/DOC/HTML/images/switches.jpg
Binary files differ
diff --git a/DOC/HTML/images/topbar.gif b/DOC/HTML/images/topbar.gif
new file mode 100644
index 0000000..27ae71f
--- /dev/null
+++ b/DOC/HTML/images/topbar.gif
Binary files differ
diff --git a/DOC/HTML/images/transistors.jpg b/DOC/HTML/images/transistors.jpg
new file mode 100644
index 0000000..6f6a14f
--- /dev/null
+++ b/DOC/HTML/images/transistors.jpg
Binary files differ
diff --git a/DOC/HTML/images/ubec-2.jpg b/DOC/HTML/images/ubec-2.jpg
new file mode 100644
index 0000000..8fe87ce
--- /dev/null
+++ b/DOC/HTML/images/ubec-2.jpg
Binary files differ
diff --git a/DOC/HTML/images/uln2003a.jpg b/DOC/HTML/images/uln2003a.jpg
new file mode 100644
index 0000000..aeebee4
--- /dev/null
+++ b/DOC/HTML/images/uln2003a.jpg
Binary files differ
diff --git a/DOC/HTML/images/wheel.jpg b/DOC/HTML/images/wheel.jpg
new file mode 100644
index 0000000..f274a2d
--- /dev/null
+++ b/DOC/HTML/images/wheel.jpg
Binary files differ
diff --git a/DOC/HTML/images/wires.jpg b/DOC/HTML/images/wires.jpg
new file mode 100644
index 0000000..9574f90
--- /dev/null
+++ b/DOC/HTML/images/wires.jpg
Binary files differ
diff --git a/DOC/HTML/images/yl-40.jpg b/DOC/HTML/images/yl-40.jpg
new file mode 100644
index 0000000..1320405
--- /dev/null
+++ b/DOC/HTML/images/yl-40.jpg
Binary files differ
diff --git a/DOC/HTML/scripts/index.css b/DOC/HTML/scripts/index.css
new file mode 100644
index 0000000..64cfd33
--- /dev/null
+++ b/DOC/HTML/scripts/index.css
@@ -0,0 +1,52 @@
+body
+{
+font-size: 100%;
+font-family: Arial, Helvetica, sans-serif;
+color: #101010;
+margin-left: 1%; margin-right: 10%;
+}
+
+h1 {font-size: 2.4em; color: #5d9dce; font-weight: bold;}
+h2 {font-size: 1.8em; color: #5d9dce; font-weight: bold;}
+h3 {font-size: 1.4em; color: #5d9dce; font-weight: bold;}
+h4 {font-size: 1.2em; color: #5d9dce;}
+h5 {font-size: 1.0em; color: #5d9dce;}
+h6 {font-size: 0.8em; color: #5d9dce;}
+
+code {display:block;font-size:80%; font-family: "Courier New", Courier, monospace; background-color:#D0D0D0;}
+pre {font-size:80%; font-family: Courier; background-color:#D0D020;}
+
+table.ev
+{
+border: 3px solid green;
+}
+
+td.ev1
+{
+width: 200px;
+border: 1px solid green;
+}
+
+td.ev2
+{
+border: 1px solid green;
+}
+
+a.l1:link,a.l1:visited
+{
+display:block;
+font-weight:bold;
+color:#FFFFFF;
+background-color:#98bf21;
+width:120px;
+text-align:center;
+padding:4px;
+text-decoration:none;
+}
+
+a.l1:hover,a.l1:active
+{
+background-color:#7A991A;
+}
+
+
diff --git a/DOC/HTML/scripts/standard.css b/DOC/HTML/scripts/standard.css
new file mode 100644
index 0000000..ad0415b
--- /dev/null
+++ b/DOC/HTML/scripts/standard.css
@@ -0,0 +1,3 @@
+html { height: 100% }
+body { height: 100%; margin: 0px; padding: 0px }
+#map_canvas { height: 100% }
diff --git a/DOC/MAN/README b/DOC/MAN/README
new file mode 100644
index 0000000..cde5d85
--- /dev/null
+++ b/DOC/MAN/README
@@ -0,0 +1 @@
+Placeholder directory for man pages.
diff --git a/DOC/README b/DOC/README
new file mode 100644
index 0000000..19a1516
--- /dev/null
+++ b/DOC/README
@@ -0,0 +1,16 @@
+bin various scripts to generate man pages and HTML
+
+dbase defines the structure of the web documentation
+
+HTML auto generated html web site
+
+makedoc run to regenerate documentation
+
+MAN auto generated man pages
+
+src/defs edit to change pigs, pigpiod, pig2vcd, and examples docs
+
+src/html edit to change the fairly invariant web pages
+ DO NOT ADD auto generated HTML to this directory
+
+tmp stores temporary files, may be deleted
diff --git a/DOC/bin/backup.sh b/DOC/bin/backup.sh
new file mode 100755
index 0000000..6a45c48
--- /dev/null
+++ b/DOC/bin/backup.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# backup database
+cp dbase/pigpio.sqlite dbase/pigpio.sqlite.bak
+
diff --git a/DOC/bin/body.py b/DOC/bin/body.py
new file mode 100755
index 0000000..9e4c437
--- /dev/null
+++ b/DOC/bin/body.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import glob
+
+for fn in glob.glob("src/html/*.html"):
+ f = open(fn)
+ h = f.read()
+ f.close()
+ s1,d1,e1=h.partition("<body>")
+ s2,d2,e2=e1.partition("</body>")
+ f = open("tmp/body/" + fn[9:-5] + ".body", "w")
+ f.write(s2)
+ f.close()
+
diff --git a/DOC/bin/build_site.py b/DOC/bin/build_site.py
new file mode 100755
index 0000000..c153150
--- /dev/null
+++ b/DOC/bin/build_site.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+import os
+import sqlite3
+
+db=sqlite3.connect("dbase/pigpio.sqlite")
+
+c=db.cursor()
+
+c.execute("select file_name from pigpio")
+
+names = c.fetchall()
+
+for n in names:
+ os.system("bin/html.py {0} >HTML/{0}.html".format(n[0]))
+ print(n[0])
+
+c.close()
+
+db.close()
+
diff --git a/DOC/bin/cmakdoc.py b/DOC/bin/cmakdoc.py
new file mode 100755
index 0000000..dd1bd52
--- /dev/null
+++ b/DOC/bin/cmakdoc.py
@@ -0,0 +1,563 @@
+#!/usr/bin/env python3
+
+import sys
+
+pigpio_m1="""
+.\" Process this file with
+.\" groff -man -Tascii pigpio.3
+.\"
+.TH pigpio 3 2012-2020 Linux "pigpio archive"
+.SH NAME
+pigpio - A C library to manipulate the Pi's GPIO.\n
+.SH SYNOPSIS\n
+#include <pigpio.h>\n
+
+gcc -Wall -pthread -o prog prog.c -lpigpio -lrt\n
+sudo ./prog
+.SH DESCRIPTION\n
+"""
+
+pigpiod_if_m1="""
+.\" Process this file with
+.\" groff -man -Tascii pigpiod_if.3
+.\"
+.TH pigpiod_if 3 2012-2020 Linux "pigpio archive"
+.SH NAME
+pigpiod_if - A C library to interface to the pigpio daemon.\n
+.SH SYNOPSIS\n
+#include <pigpiod_if.h>\n
+
+gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt\n
+ ./prog
+.SH DESCRIPTION\n
+"""
+
+pigpiod_if2_m1="""
+.\" Process this file with
+.\" groff -man -Tascii pigpiod_if2.3
+.\"
+.TH pigpiod_if2 3 2012-2020 Linux "pigpio archive"
+.SH NAME
+pigpiod_if2 - A C library to interface to the pigpio daemon.\n
+.SH SYNOPSIS\n
+#include <pigpiod_if2.h>\n
+
+gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt\n
+ ./prog
+.SH DESCRIPTION\n
+"""
+
+pigpiod_m1="""
+.\" Process this file with
+.\" groff -man -Tascii pigpiod.1
+.\"
+.TH pigpiod 1 2012-2020 Linux "pigpio archive"
+.SH NAME
+pigpiod - A utility to start the pigpio library as a daemon.\n
+.SH SYNOPSIS\n
+sudo pigpiod [OPTION]...
+.SH DESCRIPTION\n
+"""
+
+pig2vcd_m1="""
+.\" Process this file with
+.\" groff -man -Tascii pig2vcd.1
+.\"
+.TH pig2vcd 1 2012-2020 Linux "pigpio archive"
+.SH NAME
+pig2vd - A utility to convert pigpio notifications to VCD.\n
+.SH SYNOPSIS\n
+pig2vcd </dev/pigpioXX >file.VCD
+.SH DESCRIPTION\n
+"""
+
+pigpio_m2="""
+.SH SEE ALSO\n
+pigpiod(1), pig2vcd(1), pigs(1), pigpiod_if(3), pigpiod_if2(3)
+.SH AUTHOR\n
+joan@abyz.me.uk
+"""
+
+pigpiod_if_m2="""
+.SH SEE ALSO\n
+pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if2(3)
+.SH AUTHOR\n
+joan@abyz.me.uk
+"""
+
+pigpiod_if2_m2="""
+.SH SEE ALSO\n
+pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3)
+.SH AUTHOR\n
+joan@abyz.me.uk
+"""
+
+pigpiod_m2="""
+.SH SEE ALSO\n
+pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
+.SH AUTHOR\n
+joan@abyz.me.uk
+"""
+
+pig2vcd_m2="""
+.SH SEE ALSO\n
+pigpiod(1), pigs(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
+.SH AUTHOR\n
+joan@abyz.me.uk
+"""
+
+
+def emit(s):
+ sys.stdout.write(s)
+
+def get_line(f):
+ line = f.readline()
+ if man:
+ line = line.replace(" \n", "\n.br\n")
+ else:
+ line = line.replace("<", "&lt;")
+ line = line.replace(">", "&gt;")
+ line = line.replace(" \n", "<br>\n")
+ return line
+
+def nostar(k):
+ if k[0] == "*":
+ return k[1:]
+ else:
+ return k
+
+NONE =0
+MAN =1
+TEXT =2
+OVERVIEW=4
+FUNC =5
+DESC =6
+OPT =7
+PARAMS =8
+DEFS =9
+
+param_used = []
+param_defd = []
+param_refd = []
+
+at = NONE
+
+in_code = False
+in_pard = False
+in_table = False
+
+if len(sys.argv) > 2:
+ obj = sys.argv[1]
+ fn = sys.argv[2]
+ if len(sys.argv) > 3:
+ man = True
+ else:
+ man = False
+else:
+ exit("bad args, need page file [man]")
+try:
+ f = open(fn, "r")
+except:
+ exit("aborting, can't open {}".format(fn))
+
+if man:
+ if obj == "pigpio":
+ emit(pigpio_m1)
+ elif obj == "pigpiod_if":
+ emit(pigpiod_if_m1)
+ elif obj == "pigpiod_if2":
+ emit(pigpiod_if2_m1)
+ elif obj == "pigpiod":
+ emit(pigpiod_m1)
+ elif obj == "pig2vcd":
+ emit(pig2vcd_m1)
+
+ emit("\n.ad l\n")
+ emit("\n.nh\n")
+
+while True:
+
+ line = get_line(f)
+
+ if line == "":
+ for p in param_used:
+ if p not in param_defd:
+ sys.stderr.write("{} used but not defined.\n".format(p))
+ for p in param_defd:
+ if p not in param_used and p not in param_refd:
+ sys.stderr.write("{} defined but not used.\n".format(p))
+ break
+
+ if line == "/*MAN\n":
+ at = MAN
+ continue
+
+ elif line == "MAN*/\n":
+ at = NONE
+ continue
+
+ if line == "/*TEXT\n":
+ at = TEXT
+ continue
+
+ elif line == "TEXT*/\n":
+ at = NONE
+ continue
+
+ elif line == "/*OVERVIEW\n":
+
+ if man:
+ emit("\n.SH OVERVIEW\n")
+ else:
+ emit("<h2>OVERVIEW</h2>")
+ emit(
+ "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
+
+ at = OVERVIEW
+ continue
+
+ elif line == "OVERVIEW*/\n":
+
+ if man:
+ emit(".SH FUNCTIONS\n")
+ else:
+ emit("</tbody></table>")
+ emit("<h2>FUNCTIONS</h2>")
+
+ at = NONE
+
+ elif line == "/*F*/\n":
+ in_code = False
+ fdef=""
+ line = get_line(f)
+ at = FUNC
+
+ elif line == "/*D\n":
+ # Function definition should be complete.
+ fdef = fdef.replace("\n", " ")
+
+ while fdef.find(" ") != -1:
+ fdef = fdef.replace(" ", " ")
+
+ fdef = fdef.replace("( ", "(")
+
+ (rf, sep1, end1) = fdef.partition("(")
+ (parl, sep2, end2) = end1.partition(")")
+ tps = parl.split(",")
+ rf = rf.split(" ")
+ ret = rf[0]
+ func = rf[1]
+
+ if ret not in param_used:
+ param_used.append(ret)
+
+ if man:
+ t = "\\fB" + ret + " " + func + "(" + parl + ")\\fP"
+ emit("\n.IP \"{}\"\n.IP \"\" 4\n".format(t))
+ else:
+ emit("<h3><a name=\"{}\"></a><a href=\"#{}\"><small>{}</small></a> {}".
+ format(nostar(func), ret, ret,func))
+ emit("<small>(")
+
+ x = 0
+ for tp in tps:
+ tp = tp.strip()
+ (t, sep3, p) = tp.partition(" ")
+ t = t.strip()
+ p = p.strip()
+ if (p != ""):
+ if p not in param_used:
+ param_used.append(p)
+ if t not in param_used:
+ param_used.append(t)
+ if x > 0:
+
+ if man:
+ pass
+ else:
+ emit(", ")
+
+ x += 1
+
+ if man:
+ pass
+ else:
+
+ emit("<a href=\"#{}\">{}</a> <a href=\"#{}\">{}</a>".
+ format(t, t, p, p))
+
+ else:
+
+ if man:
+ pass
+ else:
+ emit("{}".format(t))
+
+ if man:
+ pass
+ else:
+ emit(")</small></h3>\n")
+
+ line = get_line(f)
+ at = DESC
+
+ elif line == "D*/\n":
+ at = NONE
+
+ elif line == "/*O\n":
+ if man:
+ emit(".SH OPTIONS\n")
+ else:
+ emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
+ at = OPT
+ continue
+
+ elif line == "O*/\n":
+ if man:
+ pass
+ else:
+ emit("</tbody></table>")
+ at = NONE
+ continue
+
+ elif line == "/*PARAMS\n":
+ last_par = "*"
+
+ if man:
+ emit(".SH PARAMETERS\n")
+ else:
+ emit("<h2>PARAMETERS</h2>")
+
+ at = PARAMS
+ continue
+
+ elif line == "PARAMS*/\n":
+ at = NONE
+
+ elif line.startswith("/*DEF_S "):
+ title = line[8:-3]
+ in_code = True
+ if man:
+ emit(".SH {}\n".format(title))
+ emit("\n.EX\n")
+ else:
+ emit("<h2>{}</h2>".format(title))
+ emit("<code>")
+ at = DEFS
+ continue
+
+ elif line == "/*DEF_E*/\n":
+ in_code = False
+ if man:
+ emit("\n.EE\n")
+ else:
+ emit("</code>")
+ at = NONE
+ continue
+
+
+ if at != NONE and at != OVERVIEW:
+ if line.find("@") != -1:
+ if not in_table:
+ in_table = True
+
+ if man:
+ pass
+ else:
+ emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
+
+ if man:
+ line = line.replace("@", " ")
+ emit(line)
+ # emit("\n.br\n")
+ emit(".br\n")
+ else:
+ emit("<tr>")
+ cols = line.split("@")
+ for col in cols:
+ emit("<td>{}</td>".format(col.strip()))
+ emit("</tr>")
+
+ continue
+
+ else:
+ if in_table:
+ in_table = False
+
+ if man:
+ pass
+ else:
+ emit("</tbody></table>")
+
+ if line == "...\n" or line == ". .\n":
+ if in_code:
+ in_code = False
+
+ if man:
+ emit("\n.EE\n")
+ else:
+ emit("</code>")
+
+ else:
+ in_code = True
+ if line == "...\n":
+
+ if man:
+ emit("\\fBExample\\fP\n.br\n")
+ else:
+ emit("<b><small>Example</small></b><br><br>")
+
+ if man:
+ emit("\n.EX\n")
+ else:
+ emit("<code>")
+
+ continue
+
+ if line == "\n":
+
+ if man:
+ emit("\n.br\n")
+ else:
+ emit("<br>")
+
+ if not in_code:
+ if man:
+ emit("\n.br\n")
+ else:
+ emit("<br>")
+
+ continue
+
+ if in_code:
+
+ if man:
+ line = line.replace("\n", "\n.br\n")
+ else:
+ line = line.replace(" ", "&nbsp;")
+ line = line.replace("\n", "<br>")
+
+ while line.find("[*") != -1 and line.find("*]") != -1:
+ (b, s, e) = line.partition("[*")
+ (l, s, e) = e.partition("*]")
+
+ if man:
+ line = "{}\\fB{}\\fP{}".format(b, l, e)
+ else:
+ line = "{}<a href=\"#{}\">{}</a>{}".format(b, l, l, e)
+
+ if l not in param_refd:
+ param_refd.append(l)
+
+ while line.find("[[") != -1 and line.find("]]") != -1:
+ (b, s, e) = line.partition("[[")
+ (l, s, e) = e.partition("]]")
+
+ if man:
+ line = "{}\\fB{}\\fP{}".format(b, l, e)
+ else:
+ line = "{}<a href=\"{}\">{}</a>{}".format(b, l, l, e)
+
+ if at == TEXT:
+ if line[0] == '*' and line[-2] == '*':
+ if man:
+ emit(".SS {}".format(line[1:-2]))
+ else:
+ emit("<h3>{}</h3>".format(line[1:-2]))
+ elif line[0] == '^' and line[-2] == '^':
+ if man:
+ emit(".SS {}".format(line[1:-2]))
+ else:
+ emit("<br><b>{}</b><br>".format(line[1:-2]))
+ else:
+ emit(line)
+
+ elif at == OVERVIEW:
+ if line == "\n":
+
+ if man:
+ emit("\n.br\n")
+ else:
+ emit("<tr><td></td><td></td></tr>")
+
+ else:
+ (func, sep, desc) = line.partition(" ")
+ if desc != "":
+
+ if man:
+ emit("\n.br\n{}".format(line.strip()))
+ else:
+ emit("<tr><td><a href=\"#{}\">{}</a></td><td>{}</td></tr>".
+ format(func, func, desc))
+
+ else:
+
+ if man:
+ emit(".SS {}".format(line.replace("_", " ").strip()))
+ else:
+ emit("<tr><td><b>{}</b></td><td></td></tr>".
+ format(func.replace("_", " ")))
+
+ elif at == FUNC:
+ fdef += line
+
+ elif at == DESC:
+ emit(line)
+
+ elif at == PARAMS:
+ if line.find("::") != -1:
+ (par, sep, end) = line.partition("::")
+ par = par.strip()
+ end = end.strip()
+
+ if nostar(par.lower()) < nostar(last_par.lower()):
+ sys.stderr.write("Out of order {} after {}.\n".
+ format(par, last_par))
+ last_par = par
+
+ if par in param_defd:
+ sys.stderr.write("Duplicate definition of {}.\n".format(par))
+ else:
+ param_defd.append(par)
+
+ if end != "":
+ end = ": " + end
+ if man:
+ emit("\n.IP \"\\fB{}\\fP{}\" 0\n".format(par, end))
+ else:
+ emit("<h3><a name=\"{}\">{}</a>{}</h3>\n".format(par, par, end))
+
+ else:
+ emit(line)
+
+ elif at == MAN:
+ if man:
+ emit(line)
+
+ elif at == OPT:
+ line = line.split("|")
+ if man:
+ emit("\n.IP \"\\fB{}\\fP\"\n{}.\n{}.\n{}.".format(
+ line[0], line[1], line[2], line[3]))
+ else:
+ emit("<tr><td><b>{}</b></td><td>{}</td><td>{}</td><td>{}</td></tr>".
+ format(line[0], line[1], line[2], line[3]))
+
+ elif at == DEFS:
+ emit(line)
+
+if man:
+ if obj == "pigpio":
+ emit(pigpio_m2)
+ elif obj == "pigpiod_if":
+ emit(pigpiod_if_m2)
+ elif obj == "pigpiod_if2":
+ emit(pigpiod_if2_m2)
+ elif obj == "pigpiod":
+ emit(pigpiod_m2)
+ elif obj == "pig2vcd":
+ emit(pig2vcd_m2)
+
+
+f.close()
+
diff --git a/DOC/bin/examples.py b/DOC/bin/examples.py
new file mode 100755
index 0000000..e389341
--- /dev/null
+++ b/DOC/bin/examples.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python3
+
+import sys
+from collections import OrderedDict
+
+def emit(s):
+ sys.stdout.write(s)
+
+def get_line(f):
+ line = f.readline()
+ return line
+
+def get_file():
+ try:
+ fn = sys.argv[1]
+ f = open(fn, "r")
+ except:
+ exit("aborting, can't open {}".format(fn))
+ return f
+
+def cancel_row():
+ global in_row
+ if in_row:
+ in_row = False
+ emit('</td></tr>')
+
+def start_row():
+ global in_row
+ if not in_row:
+ in_row = True
+ emit('<tr><td style="width: 150px; vertical-align: top; font-size: 0.8em; font-weight: bold;">')
+
+def cancel_table():
+ global in_table
+ if in_table:
+ in_table = False
+ cancel_row()
+ emit('</tbody></table>')
+
+def start_table():
+ global in_table
+ if not in_table:
+ in_table = True
+ emit('<table style="text-align: left; width: 90%;" border="0" cellpadding="4" cellspacing="4"><tbody>')
+ else:
+ cancel_row()
+ start_row()
+
+index = {}
+
+in_code = False
+in_samp = False
+in_table = False
+in_row = False
+
+f = get_file()
+
+while True:
+
+ line = get_line(f)
+
+ if line == "":
+ cancel_table()
+
+ emit('<table style="text-align: left; width: 90%;" border="0" cellpadding="4" cellspacing="4"><tbody>\n')
+ last = None
+ ordered = OrderedDict(sorted(index.items(), key=lambda t: t[1].lower()))
+ for k,v in ordered.items():
+ tag=k.split('_')[0]
+ if last != v.lower():
+ if last is not None:
+ emit('</td></tr>')
+ last = v.lower()
+ anchor="index_"+last.replace(" ", "_")
+ emit('<tr><td><span id="'+anchor+'"></span>'+v+'</td><td>')
+ emit(' <a href="#'+k+'">'+tag+'</a>\n')
+ emit('</td></tr></tbody></table>')
+ break
+
+ if line.startswith("?0|"):
+ s = line.split("|")
+ anchor=s[1].strip()
+ emit('<a href="#'+anchor+'">'+anchor+'</a><br>')
+ continue
+
+ if line.startswith("?1|"):
+ cancel_table()
+ s = line.split("|")
+ tag = s[1].strip()+"_"
+ anchor=s[2].strip()
+ emit('<h3><span id="'+anchor+'">'+anchor+'</span></h3>')
+ continue
+
+ elif line.startswith("?2|") or line.startswith("?3|") or line.startswith("?4|"):
+ start_table()
+
+ s = line.split("|")
+
+ anchor=tag+s[1].strip()
+
+ if line.startswith("?2|"):
+ link=s[1].strip()+".html"
+ elif line.startswith("?3|"):
+ link="code/"+s[1].strip()+".zip"
+ elif line.startswith("?4|"):
+ link=s[1].strip()
+ else:
+ link="code/"+s[1].strip()
+
+ date=s[2].strip()
+
+ title=s[3].strip()
+ emit('<span id="'+anchor+'"><a href="'+link+'">'+title+'</a><br>'+date+'</span></td><td>')
+
+ index.update({anchor:title})
+
+ continue
+
+ else:
+ emit(line.replace("\n", "<br>\n"))
+
+f.close()
+
diff --git a/DOC/bin/html.py b/DOC/bin/html.py
new file mode 100755
index 0000000..1259430
--- /dev/null
+++ b/DOC/bin/html.py
@@ -0,0 +1,137 @@
+#!/usr/bin/env python3
+
+import sys
+import sqlite3
+import time
+
+i_file_name = 0
+i_menu_title = 1
+i_menu_pos = 2
+i_menu_level = 3
+i_page_title = 4
+i_pic1 = 5
+i_pic2 = 6
+i_pic3 = 7
+i_body = 8
+
+print("""
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta name="description" content="Raspberry Pi Reg. C GPIO library and Python GPIO module and shell command utilities to control the GPIO, including SPI, I2C, and serial links." />
+ <meta name="keywords" content="raspberry, pi, C, Python, GPIO, library, shell, command, utilities, module, SPI, I2C, serial" />
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+ <title>pigpio library</title>
+ <link rel="stylesheet" type="text/css" href="scripts/index.css">
+ <link rel="icon" href="favicon.ico" type="image/x-icon">
+ <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
+</head>
+<body>
+""")
+
+page = sys.argv[1]
+
+menuH = ""
+menuV = ""
+sitemap = ""
+
+header = '<a href="index.html"><img src="images/pigpio-logo.gif" border="0" /></a>pigpio library'
+
+footer1 = "<small>&copy; 2012-2020</small>";
+footer2 = "e-mail: pigpio @ abyz.me.uk";
+footer3 = "<small>Updated: " + time.strftime("%d/%m/%Y") + "</small>";
+
+db=sqlite3.connect("dbase/pigpio.sqlite")
+
+c=db.cursor()
+
+def menu_titles():
+
+ global menuV, menuH
+
+ c.execute(
+ "SELECT file_name, menu_title, menu_level FROM pigpio ORDER by menu_pos")
+
+ recs = c.fetchall()
+
+ menuV = ""
+ menuH = ""
+
+ for r in recs:
+ if r[2] == 1:
+ menuV += '<a class="l1" href="' + r[0] + '.html">' + r[1] + '</a>\n'
+ menuH += '<a class="l2" href="' + r[0] + '.html">[' + r[1] + ']</a>\n'
+
+def sitemap():
+
+ c.execute(
+ "SELECT file_name, menu_title, menu_level FROM pigpio ORDER by menu_pos")
+
+ recs = c.fetchall()
+
+ stemap = ""
+
+ for r in recs:
+ if r[2] > 0:
+ s = "----" * (r[2]-1)
+ stemap += s + '<a href="' + r[0] + '.html">' + r[1] + '</a><br>\n'
+
+ return stemap
+
+def check_image(d):
+
+ img = "images/" + d
+
+ try:
+ with open("HTML/" + img) as f:
+ print('<td><img src="' + img + '" width="250"></td>')
+ except:
+ pass
+
+titles = menu_titles()
+
+s_sidebar = 'style="background:#EAF2E6 url(\'images/sidebar.gif\') repeat-y; width:35px; height:100%"'
+
+s_header = 'style="background:url(\'images/topbar.gif\') repeat-x; height: 70px; font-size:1.5em; vertical-align: top;"'
+
+s_menuV = 'style="vertical-align: top; background-color: #98bf21;"'
+
+c.execute("SELECT * FROM pigpio WHERE file_name=?", (page,))
+
+rec = c.fetchone()
+
+if page == "sitemap":
+ body = sitemap()
+else:
+ body = rec[i_body]
+
+c.close()
+db.close()
+
+print('<table style="padding:0px; border:0px; margin:0px; width:780px; background-color:#e0e0e0;">')
+print('<td ' + s_sidebar + '></td>')
+print('<td>')
+print('<table>')
+print('<div ' + s_header + '>' + header + '</div>')
+print('</table>')
+print('<table><div>')
+check_image(rec[i_pic1])
+check_image(rec[i_pic2])
+check_image(rec[i_pic3])
+print('</div></table>')
+print("<table>")
+print('<td ' + s_menuV + '>' + menuV + '</td>')
+print('<td><center><h2>' + rec[i_page_title] + '</h2></center>' + body + '</td>')
+print('</table>')
+print('<div style="vertical-align: center; text-align: center; background-color:#98bf21; font-size:0.8em; height:30px">' + menuH + '</div>')
+print('<table><tr>')
+print('<td style="width: 200px"><div style="text-align: left;">' + footer1 + '</div></td>')
+print('<td style="width: 350px"><div style="text-align: center;">' + footer2 + '</div></td>')
+print('<td style="width: 200px"><div style="text-align: right;">' + footer3 + '</div></td>')
+print('</tr></table>')
+print('</td>')
+print('</table>')
+
+print('</body>\n</html>')
+
diff --git a/DOC/bin/purge.sh b/DOC/bin/purge.sh
new file mode 100755
index 0000000..54553bb
--- /dev/null
+++ b/DOC/bin/purge.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# if backup same as new delete it
+if cmp -s dbase/pigpio.sqlite dbase/pigpio.sqlite.bak
+then
+ rm dbase/pigpio.sqlite.bak
+else
+ d=$(date "+%F-%H-%M-%S")
+ mv -f dbase/pigpio.sqlite.bak dbase/pigpio.sqlite.$d
+fi
+
+# delete backups older than a week
+find dbase/pigpio.sqlite.2* -mtime +7 -delete &>/dev/null
+
diff --git a/DOC/bin/pymakdoc.py b/DOC/bin/pymakdoc.py
new file mode 100755
index 0000000..c2a6e87
--- /dev/null
+++ b/DOC/bin/pymakdoc.py
@@ -0,0 +1,270 @@
+#!/usr/bin/env python3
+
+import sys
+
+def emit(s):
+ sys.stdout.write(s)
+
+def str2hex(s):
+ return ":".join("{:02x}".format(ord(c)) for c in s)
+
+def funchdr(line):
+ if len(line) > 1 and (not line.startswith(" ")) and line.find("(") != -1:
+ return True
+ else:
+ return False
+
+def get_line(f):
+ line = f.readline()
+ line = line.replace("<", "&lt;")
+ line = line.replace(">", "&gt;")
+ return line
+
+def get_file():
+ try:
+ fn = sys.argv[1]
+ f = open(fn, "r")
+ except:
+ exit("aborting, can't open {}".format(fn))
+ return f
+
+
+NONE = 0
+DESCRIPTION = 1
+OVERVIEW = 2
+CLASSES = 3
+CLASS = 4
+FUNC = 5
+XREF = 6
+DATA = 7
+
+f = get_file()
+
+param_used = []
+param_defd = []
+param_refd = []
+
+at = NONE
+
+in_code = False
+in_samp = False
+in_table = False
+left = 0
+
+while True:
+
+ line = get_line(f)
+
+ if line == "":
+ for p in param_used:
+ if p not in param_defd:
+ sys.stderr.write("{} is used but not defined.\n".format(p))
+ for p in param_defd:
+ if p not in param_used and p not in param_refd:
+ sys.stderr.write("{} is defined but not used.\n".format(p))
+ break
+
+ if line.startswith("DESCRIPTION"):
+ left = 4
+ at = DESCRIPTION
+ continue
+
+ elif line.startswith(" OVERVIEW"):
+ left = 4
+ emit("<h2>OVERVIEW</h2>")
+ emit(
+ "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
+ at = OVERVIEW
+ continue
+
+ elif line.startswith("CLASSES"):
+ left = 4
+ emit("</tbody></table>")
+ at = NONE
+ continue
+
+ elif line.startswith(" class "):
+ in_func = False
+ if line.startswith(" class error"):
+ at = NONE
+ else:
+ left = 8
+ emit("<h2>{}</h2>".format(line))
+ _class = line[10:-1]
+ at = CLASS
+ continue
+
+ elif line.startswith("FUNCTIONS"):
+ left = 4
+ emit("<h2>FUNCTIONS</h2>")
+ in_func = False
+ at = FUNC
+ continue
+
+ elif line.startswith(" xref()"):
+ left = 8
+ emit("<h2>PARAMETERS</h2>")
+ in_func = False
+ last_par = ""
+ at = XREF
+ continue
+
+ elif line.startswith("DATA"):
+ at = DATA
+ continue
+
+ line = line[left:]
+
+ at_funchdr = funchdr(line)
+
+ if at != NONE and at != OVERVIEW:
+
+ if at == CLASS or at == FUNC:
+
+ if not at_funchdr:
+ line = line[4:]
+
+ line = line.replace(' \n', '<br>')
+
+ if line.find('@') != -1:
+ if not in_table:
+ in_table = True
+ emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
+ emit("<tr>")
+ cols = line.split('@')
+ for col in cols:
+ emit("<td>{}</td>".format(col.strip()))
+ emit("</tr>")
+ continue
+ else:
+ if in_table:
+ in_table = False
+ emit("</tbody></table>")
+
+ if line.find(":=") != -1:
+ if not in_samp:
+ emit("<br><b><small>Parameters</small></b><br><br><samp>")
+ in_samp = True
+
+ if line == '...\n' or line == '. .\n':
+ if in_code:
+ in_code = False
+ emit("</code>")
+ else:
+ in_code = True
+ if line == '...\n':
+ emit("<b><small>Example</small></b><br><br>")
+ emit("<code>")
+ continue
+
+ if line == '\n' or line == '':
+ if in_samp:
+ emit("</samp>")
+ in_samp = False
+ emit('<br>')
+ if not in_code:
+ emit('<br>')
+ continue
+
+ if in_code or in_samp:
+ line = line.replace(" ", "&nbsp;")
+ line = line.replace("\n", "<br>")
+
+ while line.find('[*') != -1 and line.find('*]') != -1:
+ (b, s, e) = line.partition('[*')
+ (l, s, e) = e.partition('*]')
+ line = '{}<a href="#{}">{}</a>{}'.format(b, l, l, e)
+ if l not in param_refd:
+ param_refd.append(l)
+
+ while line.find('[[') != -1 and line.find(']]') != -1:
+ (b, s, e) = line.partition('[[')
+ (l, s, e) = e.partition(']]')
+ line = '{}<a href="{}">{}</a>{}'.format(b, l, l, e)
+
+ if at == DESCRIPTION:
+ if line[0] == '*' and line[-2] == '*':
+ emit("<h3>{}</h3>".format(line[1:-2]))
+ elif line[0] == '[' and line[-2] == ']':
+ pass
+ else:
+ emit(line)
+
+ elif at == OVERVIEW:
+ if line == "\n":
+ emit("<tr><td></td><td></td></tr>")
+ else:
+ (func, sep, desc) = line.partition(' ')
+ if desc != '':
+ emit("<tr><td><a href=\"#{}\">{}</a></td><td>{}</td></tr>".
+ format(func, func, desc))
+ else:
+ emit("<tr><td><b>{}</b></td><td></td></tr>".
+ format(func).replace("_", " "))
+
+ elif at == CLASS or at == FUNC:
+ if at_funchdr:
+ in_func = True
+
+ if in_code:
+ emit("<br>***C***</code>")
+ in_code = False
+
+ if in_samp:
+ emit("<br>***S***</samp>")
+ in_samp = False
+
+ (func, sep1, end1) = line.partition("(")
+ (parl, sep2, end2) = end1.partition(")")
+ pars = parl.split(",")
+
+ func = func.strip()
+
+ if at == FUNC:
+ func = "pigpio." + func
+ else:
+ if func == "__init__":
+ func = "pigpio." + _class
+
+ emit("<h3><a name=\"{}\">{}".format(func,func))
+
+ emit('<small>(')
+
+ x = 0
+ for p in pars:
+ (p, sep3, end3) = p.partition('=')
+ p = p.strip()
+ if (p != 'self') and (p != '...') and (p != ''):
+ if p not in param_used:
+ param_used.append(p)
+ if x > 0:
+ emit(", ")
+ x += 1
+ emit("<a href=\"#{}\">{}</a>".format(p, p))
+ emit(')</small></h3>\n')
+
+ else:
+ if in_func:
+ emit(line)
+
+ elif at == XREF:
+ if line.find(':') != -1:
+ (par, sep, end) = line.partition(':')
+ par = par.strip()
+ end = end.strip()
+ emit("<h3><a name=\"{}\"></a>{}: {}</h3>".format(par, par, end))
+
+ if par.lower() < last_par.lower():
+ sys.stderr.write("Out of order {} after {}.\n".
+ format(par, last_par))
+ last_par = par
+
+ if par in param_defd:
+ sys.stderr.write("Duplicate definition of {}.\n".format(par))
+ else:
+ param_defd.append(par)
+ else:
+ emit(line)
+
+f.close()
+
diff --git a/DOC/bin/smakdoc.py b/DOC/bin/smakdoc.py
new file mode 100755
index 0000000..a36975f
--- /dev/null
+++ b/DOC/bin/smakdoc.py
@@ -0,0 +1,376 @@
+#!/usr/bin/env python3
+
+import sys
+
+def get_file():
+ try:
+ fn = sys.argv[1]
+ f = open(fn, "r")
+ except:
+ exit("aborting, can't open {}".format(fn))
+ return f
+
+def emit(s):
+ sys.stdout.write(s)
+
+def str2hex(s):
+ return ":".join("{:02x}".format(ord(c)) for c in s)
+
+def get_line(f):
+ line = f.readline()
+ if man:
+ line = line.replace(" \n", "\n.br\n")
+ else:
+ line = line.replace("<", "&lt;")
+ line = line.replace(">", "&gt;")
+ line = line.replace(" \n", "<br>\n")
+ return line
+
+if len(sys.argv) > 2: # Are we creating a man page?
+ man = True
+else:
+ man = False
+
+NONE=0
+INTRO=1
+OVERVIEW=2
+COMMANDS=3
+PARAMETERS=4
+SCRIPTS=5
+
+param_used = []
+param_defd = []
+
+f = get_file()
+
+at = NONE
+
+in_table = False
+in_code = False
+
+funcdef ={}
+
+if man:
+ emit("""
+.\" Process this file with
+.\" groff -man -Tascii foo.1
+.\"
+.TH pigs 1 2012-2020 Linux "pigpio archive"
+.SH NAME
+pigs - command line socket access to the pigpio daemon.\n
+/dev/pigpio - command line pipe access to the pigpio daemon.\n
+.SH SYNOPSIS\n
+.B sudo pigpiod\n
+then\n
+.B pigs {command}+\n
+or\n
+.B \"echo {command}+ >/dev/pigpio\"\n
+.SH DESCRIPTION\n
+.ad l\n
+.nh\n
+""")
+
+while True:
+
+ line = get_line(f)
+
+ if line == "":
+ for p in param_used:
+ if p not in param_defd:
+ sys.stderr.write("{} used but not defined.\n".format(p))
+ for p in param_defd:
+ if p not in param_used:
+ sys.stderr.write("{} defined but not used.\n".format(p))
+ break
+
+ if line.startswith("INTRO"):
+ line = get_line(f)
+
+ if man:
+ pass
+ else:
+ emit("<h2><a name=\"Introduction\">Introduction</a></h2>\n")
+
+ at = INTRO
+
+ elif line.startswith("OVERVIEW"):
+ line = get_line(f)
+
+ if man:
+ emit("\n.SH OVERVIEW\n")
+ else:
+ emit("<h2><a name=\"Overview\">Overview</a></h2>\n")
+ emit(
+ "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
+ at = OVERVIEW
+
+ elif line.startswith("COMMANDS"):
+ line = get_line(f)
+
+ if man:
+ emit("\n.SH COMMANDS\n")
+ else:
+ emit("</tbody></table>")
+ emit("<h2><a name=\"Commands\">Commands</a></h2>\n")
+
+ funcs = sorted(funcdef)
+ at = COMMANDS
+
+ elif line.startswith("PARAMETERS"):
+ line = get_line(f)
+ last_par = ""
+
+ if man:
+ emit("\n.SH PARAMETERS\n")
+ else:
+ emit("<h2><a name=\"Parameters\">Parameters</a></h2>\n")
+
+ at = PARAMETERS
+
+ elif line.startswith("SCRIPTS"):
+ line = get_line(f)
+
+ if man:
+ emit("\n.SH SCRIPTS\n")
+ else:
+ emit("<h2><a name=\"Scripts\">Scripts</a></h2>\n")
+
+ at = SCRIPTS
+
+ if at != NONE:
+ if line.find("@") != -1:
+ if not in_table:
+ in_table = True
+
+ if man:
+ emit("\n.EX\n")
+ else:
+ emit("<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\"><tbody>")
+ if man:
+ pass
+ else:
+ emit("<tr>")
+
+ if man:
+ line = line.replace("@", " ")
+ emit(line)
+ else:
+ cols = line.split("@")
+ for col in cols:
+ emit("<td>{}</td>".format(col.strip()))
+
+ if man:
+ pass
+ else:
+ emit("</tr>")
+ continue
+ else:
+ if in_table:
+ in_table = False
+
+ if man:
+ emit("\n.EE\n")
+ else:
+ emit("</tbody></table>")
+
+ if line == "...\n" or line == ". .\n":
+ if in_code:
+ in_code = False
+
+ if man:
+ emit("\n.EE\n")
+ else:
+ emit("</code>")
+
+ else:
+ in_code = True
+
+ if at == COMMANDS:
+
+ if line == "...\n":
+ if man:
+ emit("\n\\fBExample\\fP\n.br\n")
+ else:
+ emit("<b><small>Example</small></b><br><br>")
+
+ if man:
+ emit("\n.EX\n")
+ else:
+ emit("<code>")
+
+ continue
+
+ if line == "\n" and at != OVERVIEW:
+ if man:
+ # emit("\n.br\n.br\n")
+ emit("\n.br\n")
+ else:
+ emit("<br><br>")
+ continue
+
+ if in_code:
+ if man:
+ line = line.replace("\n", "\n.br\n")
+ else:
+ line = line.replace(" ", "&nbsp;")
+ line = line.replace("\n", "<br>")
+
+ while line.find("[*") != -1 and line.find("*]") != -1:
+ (b, s, e) = line.partition("[*")
+ (l, s, e) = e.partition("*]")
+ if man:
+ line = "{}\\fB{}\\fP{}".format(b, l, e)
+ else:
+ line = "{}<a href=\"#{}\">{}</a>{}".format(b, l, l, e)
+
+ while line.find("[{") != -1 and line.find("}]") != -1:
+ (b, s, e) = line.partition("[[")
+ (l, s, e) = e.partition("]]")
+
+ if man:
+ line = "{}\\fB{}\\fP{}".format(b, l, e)
+ else:
+ line = "{}<a href=\"{}\">{}</a>{}".format(b, l, l, e)
+
+ if at == INTRO or at == SCRIPTS:
+ if line[0] == "*" and line[-2] == "*":
+ if man:
+ emit(".SS {}".format(line[1:-2]))
+ else:
+ emit("<h3>{}</h3>".format(line[1:-2]))
+ else:
+ emit(line)
+
+ elif at == OVERVIEW:
+ if line == "\n":
+
+ if man:
+ pass
+ else:
+ emit("<tr><td></td><td></td><td></td></tr>")
+
+ elif line.find("::") == -1:
+
+ if man:
+ emit(".SS {}".format(line))
+ else:
+ emit("<tr><td>{}</td><td></td><td></td></tr>".format(line))
+ else:
+ (funcpar, sep, desc) = line.partition("::")
+ funcpar = funcpar.strip()
+ desc = desc.strip()
+ if desc != "":
+ (func, sep, parl) = funcpar.partition(" ")
+ func = func.strip()
+ parl = parl.strip()
+ if func in funcdef:
+ sys.stderr.write("{} has been redefined.\n".format(func))
+ funcdef[func]=parl+"::"+desc
+
+ if man:
+ emit(".B {}\n".format(func+" "+parl+" "))
+ pass
+ else:
+ emit("<tr><td><a href=\"#{}\">{}</a>".format(func, func))
+
+ pars = parl.split()
+
+ for p in pars:
+
+ if p not in param_used:
+ param_used.append(p)
+
+ if man:
+ pass
+ else:
+ emit(" <a href=\"#{}\">{}</a>".format(p, p))
+
+ (des, sep, c) = desc.partition("::")
+ c = c.strip()
+
+ if man:
+ emit("{}\n.P\n".format(des))
+ pass
+ else:
+ emit("</td><td>{}</td><td><small><a href=\"cif.html#{}\">{}</a></small></td></tr>".format(des, c, c))
+
+ else:
+ if man:
+ pass
+ else:
+ emit("<tr><td><b>{}</b></td><td></td></tr>".format(funcpar))
+
+ if man:
+ # emit(".IP {} 9\n".format(func))
+ pass
+ else:
+ emit("<tr><td><a href=\"#{}\">{}</a>".format(func, func))
+
+
+ elif at == COMMANDS:
+ if line.find("::") != -1:
+ (func, sep, desc) = line.partition("::")
+ func = func.strip()
+
+ if func not in funcdef:
+ parl="unknown"
+ desc="unknown"
+ else:
+ (parl,sep,desc) = funcdef[func].partition("::")
+
+ (des, sep, c) = desc.partition("::")
+
+ if man:
+ t = "\\fB" + func + " " + parl + "\\fP" + " - " + des.strip()
+ emit("\n.IP \"{}\"\n.IP \"\" 4\n".format(t))
+ else:
+ emit("<h3><a name=\"{}\">{}</a>\n".format(func,func))
+
+ pars = parl.split()
+ for p in pars:
+
+ if man:
+ pass
+ else:
+ emit(" <a href=\"#{}\">{}</a>".format(p, p))
+
+ if man:
+ pass
+ else:
+ emit(" - {}</h3>".format(des.strip()))
+
+ else:
+ emit(line)
+
+ elif at == PARAMETERS:
+ if line.find("::") != -1:
+ (par, sep, desc) = line.partition("::")
+ par = par.strip()
+ desc = desc.strip()
+
+ if par.lower() < last_par.lower():
+ sys.stderr.write("Out of order {} after {}.\n".format(par, last_par))
+ last_par = par
+
+ if par in param_defd:
+ sys.stderr.write("Duplicate definition of {}.\n".format(par))
+ else:
+ param_defd.append(par)
+
+ if man:
+ emit("\n.IP \"\\fB{}\\fP - {}\" 0\n".format(par, desc))
+ else:
+ emit("<h3><a name=\"{}\">{}</a> - {}</h3>\n".format(par,par,desc))
+ else:
+ emit(line)
+
+if man:
+ emit("""
+.SH SEE ALSO\n
+pigpiod(1), pig2vcd(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3)
+.SH AUTHOR\n
+joan@abyz.me.uk
+""")
+
+f.close()
+
diff --git a/DOC/bin/tidy.py b/DOC/bin/tidy.py
new file mode 100755
index 0000000..4a789f4
--- /dev/null
+++ b/DOC/bin/tidy.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+import glob
+
+def snafu(t, s, r):
+ l = t
+ while l.find(s) != -1:
+ l = l.replace(s, r)
+ return l
+
+for n in glob.glob("tmp/body/*.body"):
+
+ f = open(n, "r");
+ t = f.read()
+ f.close()
+
+ t = snafu(t, "<br><h2>", "<h2>")
+ t = snafu(t, "<br><h3>", "<h3>")
+ t = snafu(t, "</h2><br>", "</h2>")
+ t = snafu(t, "</h2>\n<br>", "</h2>\n")
+ t = snafu(t, "</h3><br>", "</h3>")
+ t = snafu(t, "</h3>\n<br>", "</h3>\n")
+ t = snafu(t, "<br><br><br>", "<br><br>")
+
+ f = open(n, "w");
+ f.write(t)
+ f.close()
+
diff --git a/DOC/bin/updatesql.py b/DOC/bin/updatesql.py
new file mode 100755
index 0000000..56a916c
--- /dev/null
+++ b/DOC/bin/updatesql.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+import sqlite3
+import glob
+
+db=sqlite3.connect("dbase/pigpio.sqlite")
+
+c=db.cursor()
+
+for fn in glob.glob("tmp/body/*.body"):
+ f = open(fn, encoding='utf-8')
+ body = f.read()
+ f.close()
+ c.execute("UPDATE pigpio SET body=? WHERE file_name=?", (body, fn[9:-5]))
+
+c.close()
+
+db.commit()
+
+db.close()
+
diff --git a/DOC/dbase/pigpio.sqlite b/DOC/dbase/pigpio.sqlite
new file mode 100644
index 0000000..f24fd30
--- /dev/null
+++ b/DOC/dbase/pigpio.sqlite
Binary files differ
diff --git a/DOC/makedoc b/DOC/makedoc
new file mode 100755
index 0000000..4494252
--- /dev/null
+++ b/DOC/makedoc
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+mkdir -p tmp/pydoc
+mkdir -p tmp/body
+
+echo "*** making man pages ***"
+
+echo "pigs"
+bin/smakdoc.py src/defs/pigs.def man >MAN/pigs.1
+
+echo "pigpiod"
+bin/cmakdoc.py pigpiod src/defs/pigpiod.def man >MAN/pigpiod.1
+
+echo "pig2vcd"
+bin/cmakdoc.py pig2vcd src/defs/pig2vcd.def man >MAN/pig2vcd.1
+
+echo "pigpio.h"
+bin/cmakdoc.py pigpio ../pigpio.h man >MAN/pigpio.3
+
+echo "pigpiod_if.h"
+bin/cmakdoc.py pigpiod_if ../pigpiod_if.h man >MAN/pigpiod_if.3
+
+echo "pigpiod_if2.h"
+bin/cmakdoc.py pigpiod_if2 ../pigpiod_if2.h man >MAN/pigpiod_if2.3
+
+# *** preparing HTML bodies ***
+
+bin/smakdoc.py src/defs/pigs.def >tmp/body/pigs.body
+bin/cmakdoc.py pigpiod src/defs/pigpiod.def >tmp/body/pigpiod.body
+bin/cmakdoc.py pig2vcd src/defs/pig2vcd.def >tmp/body/pig2vcd.body
+bin/cmakdoc.py pigpio ../pigpio.h >tmp/body/cif.body
+bin/cmakdoc.py pigpiod_if ../pigpiod_if.h >tmp/body/pdif.body
+bin/cmakdoc.py pigpiod_if2 ../pigpiod_if2.h >tmp/body/pdif2.body
+pydoc ../pigpio.py >tmp/pydoc/pigpio.pydoc
+bin/pymakdoc.py tmp/pydoc/pigpio.pydoc >tmp/body/python.body
+bin/examples.py src/defs/examples.def >tmp/body/examples.body
+
+bin/body.py # get bodies of manually generated pages
+bin/tidy.py # tidy the bodies
+bin/backup.sh # backup database
+bin/updatesql.py # update the database with the new bodies
+bin/purge.sh # remove redundant datatbase copies
+
+echo "*** making web pages ***"
+
+bin/build_site.py # construct the web site
+
diff --git a/DOC/src/defs/examples.def b/DOC/src/defs/examples.def
new file mode 100644
index 0000000..637a82b
--- /dev/null
+++ b/DOC/src/defs/examples.def
@@ -0,0 +1,521 @@
+The following examples show various ways pigpio may be used to communicate with sensors via the GPIO.
+
+Although many are complete programs they are intended to be a starting point in producing your own code, not an end point.
+
+?0|Index
+
+?0|Hardware
+
+?0|Shell code
+
+?0|C code
+
+?0|C++ code
+
+?0|pigpiod_if2 code
+
+?0|Python code
+
+?0|Miscellaneous related code
+
+?0|External links
+
+?1|Hardware|Hardware
+
+A few practical examples of using pigpio with hardware.
+
+?2|ex_ir_remote|2013-06-09|IR Receiver
+Reading an infrared remote receiver.
+
+?2|ex_LDR|2013-06-09|Light Dependent Resistor
+Measuring brightness with a light dependent resistor (LDR). Improved methods of timing the start of the capacitor recharge are given for <a href="#C_pot_cap_charge_c">C</a> and <a href="#Python_pot_cap_py">Python</a>.
+
+?2|ex_motor_shield|2013-12-15|Motor Shield
+Using an Arduino motor shield.
+
+?2|ex_rotary_encoder|2013-06-09|Rotary Encoder
+Reading a rotary encoder.
+
+?2|ex_sonar_ranger|2013-06-10|Sonar Ranger
+Measuring range with a sonar ranger.
+
+?1|Shell|Shell code
+
+Examples of using pigpio with shell code.
+
+?3|gpiotest|2014-08-11|GPIO test
+This bash script tests the user GPIO. <a href="http://youtu.be/sCJFLKWaxHo">Video</a>
+
+?1|C|C code
+
+Examples of C pigpio programs.
+
+If your program is called foobar.c then build with
+
+gcc -Wall -o foobar foobar.c -lpigpio
+
+?3|freq_count_1|2014-08-20|Frequency Counter 1
+A program showing how to use the <a href="cif.html#gpioSetAlertFunc">gpioSetAlertFunc</a> function to set a callback for GPIO state changes. A frequency count is generated for each monitored GPIO (frequencies up to 500kHz with a sample rate of 1&mu;s).
+
+?3|freq_count_2|2014-08-20|Frequency Counter 2
+A program showing how to use the <a href="cif.html#gpioSetGetSamplesFunc">gpioSetGetSamplesFunc</a> function to set a callback for accumulated GPIO state changes over the last millisecond. A frequency count is generated for each monitored GPIO (frequencies up to 500kHz with a sample rate of 1&mu;s). Generally the method used is more complicated but more efficient than frequency counter 1.
+
+?3|hall|2014-06-13|Hall Effect Sensor
+Program to show status changes for a Hall effect sensor.
+
+?3|I2C_sniffer|2014-06-15|I2C Sniffer
+A program to passively sniff I2C transactions (100kHz bus maximum) and display the results. This C program uses pigpio notifications.
+
+?3|ir_hasher_c|2015-02-25|IR Receiver
+Function to hash a code from an IR receiver (reading an IR remote control).
+
+?3|PCF8591|2014-08-26|PCF8591 YL-40
+A program to display readings from the (I2C) PCF8591.
+
+?3|pot_cap_charge_c|2014-03-14|Pot + Capacitor Recharge Timing
+Function to time capacitor charging (through a resistance). The time can be used to estimate the resistance.
+
+?3|pps_c|2020-07-28|Pulse Per Second generator
+A program to generate a pulse on a GPIO every x seconds (1<=x<=60). The pulse is synced with the wall time second boundary.
+
+?3|rotary_encoder_c|2015-10-03|Rotary Encoder
+Function to decode a mechanical rotary encoder.
+
+?3|rawMCP3008_c|2016-03-20|SPI bit bang MCP3008
+This program shows how to read multiple MCP3008 ADC simultaneously with accurately timed intervals. One 10-bit channel of each ADC may be sampled at up to 25k samples per second.
+
+?3|rawMCP3202_c|2016-03-20|SPI bit bang MCP3202
+This program shows how to read multiple MCP3202 ADC simultaneously with accurately timed intervals. One 12-bit channel of each ADC may be sampled at up to 25k samples per second.
+
+?3|rawMCP3XXX_c|2016-03-20|SPI bit bang MCP3008 and MCP3202
+This program shows how to read multiple MCP3008 and MCP3202 ADC simultaneously with accurately timed intervals. One channel of each ADC may be sampled at up to 25k samples per second. The 10-bit MCP3008 readings are multiplied by 4 so they have the same range (0-4095) as the 12-bit MCP3202.
+
+?3|servo_demo|2016-10-08|Servo Pulse Generator
+This program generates servo pulses on one or more GPIO. Each connected servo is swept between 1000µs and 2000µs at a different speed.
+
+sudo ./servo_demo # Generate pulses on GPIO 4.
+
+sudo ./servo_demo 5 9 20 # Generate pulses on GPIO 5, 9, and 20.
+
+?4|code/spi-pigpio-speed.c|2016-11-06|SPI pigpio driver speed test
+This C code is used to benchmark the pigpio SPI driver on the Pi. The code executes a given number of loops at a given baud rate and bytes per transfer.
+
+?3|wiegand_c|2013-12-30|Wiegand Reader
+Function to read a Wiegand Reader.
+
+?1|C++|C++ code
+
+Examples of C++ pigpio programs.
+
+If your program is called foobar.cpp then build with
+
+g++ -Wall -pthread -o foobar foobar.cpp -lpigpio -lrt
+
+?3|ir_hasher_cpp|2015-02-22|IR Receiver
+Class to hash a code from an IR receiver (reading an IR remote control).
+
+?3|rotary_encoder_cpp|2013-12-30|Rotary Encoder
+Class to decode a mechanical rotary encoder.
+
+?3|wiegand_cpp|2013-12-30|Wiegand Reader
+Class to read a Wiegand Reader.
+
+?1|pdif2|pigpiod_if2 code
+The pigpiod_if2 code examples are linked with libpigpiod_if2 and are written in C.
+
+The pigpiod_if2 library may be compiled and run on any Linux machine and allows control of the GPIO on one or more networked Pis.
+
+It should be possible to adapt the library to run on Macs and PCs.
+
+Each Pi needs the pigpio daemon to be running. The pigpio daemon may be started with the command sudo pigpiod.
+
+?3|_433D|2015-11-17|433MHz Keyfob RX/TX
+Code to read and transmit 313 and 434 MHz key fob codes. The codes to be read must use Manchester encoding. The transmitted codes use Manchester encoding.
+
+./_433D -r10 # Print fob keycodes received on GPIO 10.
+
+./_433D -t5 8246184 # Transmit code on GPIO 5.
+
+./_433D -r10 -t5 8246184 # Transmit code on GPIO 5 then listen for codes
+
+./_433D -? for options.
+
+?3|DHTXXD|2016-02-16|DHT11/21/22/33/44 Sensor
+Code to read the DHT temperature and humidity sensors. The sensor may be auto detected. A DHT11 sensor may be read once per second. The other sensors should not be read more often than once every three seconds.
+
+The code auto detects the DHT model and generally only the GPIO needs to be specified.
+
+./DHTXXD -g17 # Read a DHT connected to GPIO 17.
+
+./DHTXXD -g5 -i3 # Read a DHT connected to GPIO 5 every three seconds.
+
+./DHTXXD -? # for options.
+
+?3|RED|2015-11-18|Rotary Encoder
+Code to monitor a rotary encoder and show the position changes. By default the detent changes are shown. There is an option to show the four steps per detent instead.
+
+./RED -a7 -b8 -s30 # Show encoder on 7/8 detent changes for 30 seconds.
+
+./RED -a5 -b6 -m1 # Show encoder on 5/6 step changes forever.
+
+./RED -? # for options.
+
+?3|servo_demo_D|2016-10-08|Servo Pulse Generator
+This program generates servo pulses on one or more GPIO. Each connected servo is swept between 1000µs and 2000µs at a different speed.
+
+./servo_demo_D # Generate pulses on GPIO 4.
+
+./servo_demo_D 5 9 20 # Generate pulses on GPIO 5, 9, and 20.
+
+?3|SRTED|2015-11-16|Sonar Ranger
+Code to read the SRF-04 and SRF-05 type of sonar rangers which use the trigger echo method of operation. A 10 &mu;s trigger pulse initiates a series of high frequency sonar chirps. The echo line then goes high and stays high until an echo from an object is received. The echo high time is used to calculate the distance of the object.
+
+For a one-off reading only the trigger and echo GPIO need to be specified.
+
+./SRTED -t5 -e6 # Read a sonar ranger connected to GPIO 5/6.
+
+./SRTED -t11 -e5 -i0.1 # Read a sonar ranger connected to GPIO 11/5 every 0.1 seconds.
+
+./SRTED -? # for options.
+
+?3|tx_RED|2015-11-25|Transmit Rotary Encoder Test Signals
+Code to transmit quadrature signals to test rotary encoder software.
+
+tx_RED -aGPIO -bGPIO [options]
+
+tx_RED -? for options
+
+E.g.
+
+tx_RED -a5 -b6 -s20 -r-100
+
+?3|tx_WD|2015-11-25|Transmit Wiegand Test Signals
+Code to transmit Wiegand codes to test Wiegand decoder software.
+
+tx_WD -gGPIO -wGPIO [options] {code}+
+
+tx_WD -? for options
+
+E.g.
+
+tx_WD -g5 -w6 -s37 12345 67890 123 899999
+
+?3|WD|2015-11-25|Wiegand Reader
+Code to read a Wiegand Reader.
+
+./WD -g7 -w8 -s30 # Read Wiegand codes from GPIO 7/8 for 30 seconds.
+
+./WD -g5 -w6 # Read Wiegand codes from GPIO 5/6 forever.
+
+./WD -? # for options.
+
+?1|Python|Python code
+The Python code may be run on any Python machine and allows control of the GPIO on one or more networked Pis.
+
+The Python machine need not be a Pi, it may run Windows, Mac, Linux, anything as long as it supports Python.
+
+Each Pi needs the pigpio daemon to be running. The pigpio daemon may be started with the command sudo pigpiod.
+
+?3|_433_py|2015-10-30|433MHz Keyfob RX/TX
+Classes to send and receive 433MHz wireless keyfob codes. These keyfobs are widely used for remote control of devices.
+
+?3|_7_segment|2016-12-12|7-Segment LED Display Multiplexing
+Script to multiplex several 7-segment LED displays. Each display has the segments a-g and the decimal point connected in parallel but has an individual enable GPIO (connected to the common anode or cathode).
+
+?3|test-APA102_py|2017-03-28|APA102 LED strip driver
+Script to drive an APA102 LED strip. Three different methods are demonstrated - using spidev SPI (only works on the local Pi), pigpio SPI, and pigpio waves. The SPI solutions only work with the dedicated SPI GPIO. Waves may use any spare GPIO. Four different examples are given including a LED strip clock.
+
+?3|BME280_py|2016-08-05|BME280 Sensor
+Class to read the relative humidity, temperature, and pressure from a BME280 sensor. The sensor has both an I2C and a SPI interface which are both
+supported by the class.
+
+?4|code/DHT.py|2019-11-07|DHT11/21/22/33/44 Sensor
+Class to read the relative humidity and temperature from a DHT sensor. It can automatically recognize the sensor type.
+
+The default script prints the reading from the specified DHT every 2 seconds. E.g. ./DHT.py 22 27 displays the data for DHT connected to GPIO 22 and 27.
+
+The following data is printed for each DHT: timestamp, GPIO, status, temperature, and humidity.
+
+The timestamp is the number of seconds since the epoch (start of 1970).
+
+The status will be one of: 0 - a good reading, 1 - checksum failure, 2 - data had one or more invalid values, 3 - no response from sensor.
+
+?3|DHT22_py|2014-07-11|DHT22 AM2302 Sensor
+Class to read the relative humidity and temperature from a DHT22/AM2302 sensor.
+
+?3|DS18B20-1_py|2016-06-29|DS18B20 Temperature Sensor
+Script to read the temperature from any DS18B20 sensors connected to the 1-wire bus.
+
+To enable the 1-wire bus add the following line to /boot/config.txt and reboot.
+
+dtoverlay=w1-gpio
+
+By default you should connect the DS18B20 data line to GPIO 4 (pin 7).
+
+Connect 3V3 or 5V for power, ground to ground, 4k7 pull-up on data line to 3V3, and data line to GPIO 4.
+
+This script uses the file features of pigpio to access the remote file system.
+
+The following entry must be in /opt/pigpio/access.
+
+/sys/bus/w1/devices/28*/w1_slave r
+
+?3|PPD42NS_py|2015-11-22|Dust Sensor
+Class to read a Shinyei PPD42NS Dust Sensor, e.g. as used in the Grove dust sensor.
+
+?3|gpio_status_py|2014-06-12|GPIO Status
+Script to display the status of GPIO 0-31.
+
+?3|hall|2014-06-13|Hall Effect Sensor
+Program to show status changes for a Hall effect sensor.
+
+?3|HX711_py|2018-03-05|HX711 24-bit ADC
+Class to read the channels of a HX711 24-bit ADC.
+
+?3|i2c_ADXL345_py|2015-04-01|I2C ADXL345 Accelerometer
+Script to display the X, Y, and Z values read from an ADXL345 accelerometer.
+
+?3|i2c_HMC5883L_py|2015-04-01|I2C HMC5883L Magnetometer
+Script to display the X, Y, and Z values read from a HMC5883L Magnetometer (compass).
+
+?3|i2c_ITG3205_py|2015-04-01|I2C ITG3205 Gyroscope
+Script to display the X, Y, Z, and temperature values read from an ITG3205 gyroscope.
+
+?3|i2c_lcd_py|2016-04-20|I2C LCD Display
+Class to display text on a LCD character display. The class supports the PCF8574T 8-bit I2C port expander connected to a HD44780 based LCD display. These displays are commonly available in 16x2 and 20x4 character formats.
+
+?3|bsc_arduino_py|2016-10-31|I2C slave device
+This script demonstrates how to transfer messages from an Arduino acting as the I2C bus master to the Pi acting as an I2C slave device.
+
+?3|I2C_sniffer|2015-06-15|I2C Sniffer
+A program to passively sniff I2C transactions (100kHz bus maximum) and display the results.
+
+?3|i2c_sonar_py|2016-03-24|I2C Sonar
+A class to read up to 8 HC-SR04 sonar rangers connected to an MCP23017 port expander.
+
+?3|ir_hasher_py|2014-06-12|IR Receiver
+Class to hash a code from an IR receiver (reading an IR remote control).
+
+?3|irrp_py|2015-12-21|IR Record and Playback
+This script may be used to record and play back arbitrary IR codes.
+
+To record the GPIO connected to the IR receiver, a file for the recorded codes, and the codes to be recorded are given.
+
+E.g. ./irrp.py -r -g4 -fir-codes vol+ vol- 1 2 3 4 5 6 7 8 9 0
+
+To playback the GPIO connected to the IR transmitter, the file containing the recorded codes, and the codes to be played back are given.
+
+E.g. ./irrp.py -p -g18 -fir-codes 2 3 4
+
+./irrp.py -h # for options
+
+?3|kivy_GPIO_py|2016-12-11|Kivy GPIO control
+This example shows how to use Kivy to control a Pi's GPIO. The GPIO may be configured as inputs, outputs, or to generate Servo or PWM pulses. Kivy is an Open source Python library for rapid development of applications.
+
+?3|MAX6675_py|2016-05-02|MAX6675 SPI Temperature Sensor
+A script to read the temperature from a MAX6675 connected to a K-type thermocouple. The MAX6675 supports readings in the range 0 - 1023.75 C. Up to 4 readings may be made per second.
+
+?3|monitor_py|2016-09-17|Monitor GPIO
+Script to monitor GPIO for level changes. By default all GPIO are monitored. At a level change the GPIO, new level, and microseconds since the last change is printed.
+
+?3|morse_code_py|2015-06-17|Morse Code
+Script to transmit the morse code corresponding to a text string.
+
+?4|code/NRF24.py|2018-01-06|NRF24 radio transceiver
+Script to transmit and receive messages using the nRF24L01 radio transceiver.
+
+?3|PCA9685_py|2016-01-31|PCA9685 16 Channel PWM
+Class to control the 16 PWM channels of the I2C PCA9685. All channels use the same frequency. The duty cycle or pulse width may be set independently for each channel.
+
+?3|PCF8591|2014-08-26|PCF8591 YL-40
+Script to display readings from the (I2C) PCF8591.
+
+?4|code/PPM.py|2016-02-19|PPM (Pulse Position Modulation) generation
+Script to generate PPM signals on a chosen GPIO.
+
+?4|code/PPM_to_servo.py|2019-10-09|PPM (Pulse Position Modulation) to servo pulses
+Script to read a PPM signal on a GPIO and generate the corresponding servo signals on chosen GPIO.
+
+?3|bench_1_py|2014-06-12|pigpio Benchmark
+Script to benchmark the pigpio Python module's performance.
+
+?3|pigpio_cgi_py|2015-05-04|pigpio CGI
+Script demonstrating how to access the pigpio daemon using CGI from a browser. Instructions on how to use with Apache2 on the Pi are given in the comments.
+
+?3|playback_py|2016-12-23|Playback piscope recordings
+Script to playback GPIO data recorded in piscope format.
+
+To playback GPIO 4 to GPIO 4 from file data.piscope
+./playback.py data.piscope 4
+
+To playback GPIO 4 to GPIO 7 from file rec.txt
+./playback.py rec.txt 7=4
+
+?3|pot_cap_py|2016-09-26|Pot + Capacitor Recharge Timing
+Class to time capacitor charging (through a resistance). The time can be used to estimate the resistance.
+
+?3|read_PWM_py|2015-12-08|PWM Monitor
+Class to monitor a PWM signal and calculate the frequency, pulse width, and duty cycle.
+
+?3|rotary_encoder_py|2014-06-12|Rotary Encoder
+Class to decode a mechanical rotary encoder.
+
+?3|read_RPM_py|2016-01-20|RPM Monitor
+Class to monitor speedometer pulses and calculate the RPM (Revolutions Per Minute).
+
+?3|Si7021_py|2016-05-07|Si7021 I2C Temperature and Humidity Sensor
+Class to read the temperature and relative humidity from a Si7021.
+
+?3|SPI_mon_py|2016-09-21|SPI Monitor
+A program to passively sniff SPI transactions and display the results. The SPI rate should be limited to about 70kbps if using the default pigpio 5µs sampling rate.
+
+?3|servo_demo_py|2016-10-07|Servo Pulse Generator
+This script generates servo pulses on one or more GPIO. Each connected servo is swept between 1000µs and 2000µs at a different speed.
+
+./servo_demo.py # Generate pulses on GPIO 4.
+
+./servo_demo.py 5 9 20 # Generate pulses on GPIO 5, 9, and 20.
+
+?3|sonar_trigger_echo_py|2014-06-12|Sonar Ranger
+Class to read sonar rangers with separate trigger and echo pins.
+
+?3|TCS3200_py|2015-07-03|TCS3200 Colour Sensor
+Class to read the TCS3200 colour sensor
+
+?3|vw|2015-10-31|Virtual Wire
+Class to send and receive radio messages compatible with the Virtual Wire library for Arduinos. This library is commonly used with 313MHz and 434MHz radio tranceivers.
+
+?4|code/create_wave.py|2019-11-18|Wave create
+Script to generate waves from a template defined in a text file.
+
+You can also specify one of py, c, or pdif - the script output will then be a complete program to generate the wave (py for Python script, c for a C program, pdif for a C program using the pigpio daemon I/F).
+
+If none of py, c, or pdif are chosen the waveform will be generated for 30 seconds.
+
+Example text file
+
+# GPIO levels
+23 11000001
+11 01110000
+12 00011100
+4 00000111
+
+To generate a pdif program with a bit time of 100 microseconds
+./create_wave.py wave_file 100 pdif >wave_pdif.c
+
+To just transmit the wave with a bit time of 50 microseconds
+./create_wave.py wave_file 50
+
+?3|wave_PWM_py|2016-03-19|Wave PWM 1
+Script to show how waves may be used to generate PWM at (one) arbitrary frequency on multiple GPIO. For instance PWM at 10kHz may be generated with 100 steps between off and fully on.
+
+?3|wavePWM_py|2016-10-06|Wave PWM 2
+Class to generate PWM on multiple GPIO. It is more flexible than the Wave PWM 1 example in that the start of the pulse within each cycle may be specified as well as the duty cycle. The start and length of each pulse may be specified on a GPIO by GPIO basis in microseconds or as a fraction of the cycle time. The class includes a __main__ to demostrate its ability to send servo pulses.
+
+?3|wiegand_py|2014-06-12|Wiegand Reader
+Class to read a Wiegand reader.
+
+?1|Misc|Miscellaneous related code
+
+The following code examples do not use pigpio.
+
+?3|adxl345_c|2014-03-12|ADXL345
+This C program reads x, y, and z accelerations from the ADXL345 via I2C address 0x53.
+
+?3|DS18B20_py|2016-04-25|DS18B20 Temperature Sensor
+This Python script reads the temperature from any DS18B20 sensors connected to the 1-wire bus.
+
+To enable the 1-wire bus add the following line to /boot/config.txt and reboot.
+
+dtoverlay=w1-gpio
+
+By default you should connect the DS18B20 data line to GPIO 4 (pin 7).
+
+Connect 3V3 or 5V for power, ground to ground, 4k7 pull-up on data line to 3V3, and data line to GPIO 4.
+
+?3|EasyAsPiServer|2014-09-15|Easy as Pi Server
+This Python class implements a simple server which allows broswer commands to be executed on the Pi.
+
+?3|minimal_clk|2015-05-20|Minimal Clock Access
+This C code sets GPIO 4 to a specified clock frequency. The frequency can be set between 4.6875 kHz and 500 MHz (untested). The clock can be preferentially set from one of the sources OSC (19.2MHz), HDMI (216MHz), PLLD (500MHz), or PLLC (1000MHz). MASH can be set between 0 and 3. MASH may not work properly for clock dividers less than 5.
+
+?3|minimal_gpio|2019-07-03|Minimal GPIO Access
+This C code has a minimal set of functions needed to control the GPIO and other Broadcom peripherals. The program requires root privileges to run. See Tiny GPIO access for an alternative which controls the GPIO (but not the other peripherals) and does not require root access.
+
+The code has been updated for the BCM2711 (Pi4B).
+
+The following functions are provided.
+
+gpioInitialise
+gpioSetMode
+gpioGetMode
+gpioSetPullUpDown
+gpioRead
+gpioWrite
+gpioTrigger
+gpioReadBank1
+gpioReadBank2
+gpioClearBank1
+gpioClearBank2
+gpioSetBank1
+gpioSetBank2
+gpioHardwareRevision
+gpioTick
+
+?3|nanopulse_c|2014-01-29|Nanosecond Pulse Generation
+This C program uses the PWM peripheral to generate precisely timed pulses of very short duration. Pulses as short as 4 nano seconds can be generated.
+
+?3|PCF8591-x|2014-08-26|PCF8591 YL-40
+C and Python code to read the (I2C) PCF8591.
+
+?4|code/spi-driver-speed.c|2016-11-06|SPI Linux driver speed test
+This C code is used to benchmark the Linux SPI driver on the Pi. The code executes a given number of loops at a given baud rate and bytes per transfer.
+
+?3|tiny_gpio|2016-04-30|Tiny GPIO Access
+This C code has a minimal set of functions needed to control the GPIO without needing root privileges (it uses /dev/gpiomem to access the GPIO).
+
+You may need to change the permissions and ownership of /dev/gpiomem if they have not been correctly set up.
+
+sudo chown root:gpio /dev/gpiomem
+sudo chmod g+rw /dev/gpiomem
+
+The user (default pi) needs to be in the gpio group.
+
+sudo adduser pi gpio
+
+The following functions are provided.
+
+gpioInitialise
+gpioSetMode
+gpioGetMode
+gpioSetPullUpDown
+gpioRead
+gpioWrite
+gpioTrigger
+gpioReadBank1
+gpioReadBank2
+gpioClearBank1
+gpioClearBank2
+gpioSetBank1
+gpioSetBank2
+gpioHardwareRevision
+
+?1|External|External links
+
+Related code.
+
+?4|https://pypi.org/project/nrf24/|2020-04-20|NRF24
+Python Package Index (Pypi) NRF24 module.
+pip install nrf24
+
+?4|https://github.com/bjarne-hansen/py-nrf24|2020-04-20|NRF24
+Code and example usage of the Pypi NRF24 module. Cleaned up and added support for reading from multiple pipes using open_reading_pipe(pipe, address) and open_writing_pipe(address) in order to be more "compatible" with the way NRF24 is used on Arduinos.
+
+?4|https://github.com/stripcode/pigpio-stepper-motor|2016-08-12|Stepper Motor
+Stepper motor code.
+
+?4|https://github.com/choeffer/360pibot|2018-11-03|Parallax ActivityBot 360
+Python 3 implementation for programming a Parallax ActivityBot 360 Robot Kit with a Raspberry Pi.
+
+?1|Index|Index
+
diff --git a/DOC/src/defs/pig2vcd.def b/DOC/src/defs/pig2vcd.def
new file mode 100644
index 0000000..48e1013
--- /dev/null
+++ b/DOC/src/defs/pig2vcd.def
@@ -0,0 +1,110 @@
+
+/*TEXT
+pig2vcd is a utility which reads notifications on stdin and writes the
+output as a Value Change Dump (VCD) file on stdout.
+
+The VCD file can be viewed using GTKWave.
+
+*Notifications*
+
+Notifications consist of 12 bytes with the following binary format.
+
+. .
+typedef struct
+{
+ uint16_t seqno;
+ uint16_t flags;
+ uint32_t tick;
+ uint32_t level;
+} gpioReport_t;
+. .
+
+seqno: starts at 0 each time the handle is opened and then increments by one for each report.
+
+flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags indicate a gpio which has had a watchdog timeout; if bit 6 is set (PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the pipe/socket and is sent once a minute in the absence of other notification activity.
+
+tick: the number of microseconds since system boot. It wraps around after 1h12m.
+
+level: indicates the level of each gpio. If bit 1<<x is set then gpio x is high. pig2vcd takes these notifications and outputs a text format VCD.
+
+*VCD format*
+
+The VCD starts with a header.
+
+. .
+$date 2013-05-31 18:49:36 $end
+$version pig2vcd V1 $end
+$timescale 1 us $end
+$scope module top $end
+$var wire 1 A 0 $end
+$var wire 1 B 1 $end
+$var wire 1 C 2 $end
+$var wire 1 D 3 $end
+$var wire 1 E 4 $end
+$var wire 1 F 5 $end
+$var wire 1 G 6 $end
+$var wire 1 H 7 $end
+$var wire 1 I 8 $end
+$var wire 1 J 9 $end
+$var wire 1 K 10 $end
+$var wire 1 L 11 $end
+$var wire 1 M 12 $end
+$var wire 1 N 13 $end
+$var wire 1 O 14 $end
+$var wire 1 P 15 $end
+$var wire 1 Q 16 $end
+$var wire 1 R 17 $end
+$var wire 1 S 18 $end
+$var wire 1 T 19 $end
+$var wire 1 U 20 $end
+$var wire 1 V 21 $end
+$var wire 1 W 22 $end
+$var wire 1 X 23 $end
+$var wire 1 Y 24 $end
+$var wire 1 Z 25 $end
+$var wire 1 a 26 $end
+$var wire 1 b 27 $end
+$var wire 1 c 28 $end
+$var wire 1 d 29 $end
+$var wire 1 e 30 $end
+$var wire 1 f 31 $end
+$upscope $end
+$enddefinitions $end
+. .
+
+The header defines gpio identifiers and their name. Each gpio identifier
+must be unique. pig2vcd arbitrarily uses 'A' through 'Z' for gpios 0
+through 25, and 'a' through 'f' for gpios 26 through 31.
+The corresponding names are 0 through 31.
+
+The VCD file may be edited to give a frendlier name, e.g. 8 could be
+changed to ENCODER_A if an encoder switch A is connected to gpio 8.
+
+Following the header pig2vcd takes notifications and outputs a timestamp
+followed by a list of one or more gpios which have changed state.
+The timestamp consists of a '#' followed by the microsecond tick.
+The state lines contain the new state followed by the gpio identifier.
+
+. .
+#1058747
+0H
+0I
+#1059012
+1H
+#1079777
+1I
+#1079782
+0I
+#1079852
+1I
+#1079857
+0I
+0H
+#1165113
+1H
+#1165118
+0H
+#1165153
+1H
+. .
+TEXT*/
diff --git a/DOC/src/defs/pigpiod.def b/DOC/src/defs/pigpiod.def
new file mode 100644
index 0000000..f4f0781
--- /dev/null
+++ b/DOC/src/defs/pigpiod.def
@@ -0,0 +1,101 @@
+
+/*TEXT
+pigpiod is a utility which launches the pigpio library as a daemon.
+
+Once launched the pigpio library runs in the background accepting commands from the pipe and socket interfaces.
+
+The pigpiod utility requires sudo privileges to launch the library but thereafter the pipe and socket commands may be issued by normal users.
+
+pigpiod accepts the following configuration options
+
+TEXT*/
+/*O
+-a value|DMA memory allocation mode|0=AUTO, 1=PMAP, 2=MBOX|Default AUTO
+-b value|GPIO sample buffer size in milliseconds|100-10000|Default 120
+-c value|Library internal settings||Default 0
+-d value|Primary DMA channel|0-14|Default 14
+-e value|Secondary DMA channel|0-14|Default 6. Preferably use one of DMA channels 0 to 6 for the secondary channel
+-f|Disable fifo interface||Default enabled
+-g|Run in foreground (do not fork)||Default disabled
+-k|Disable local and remote socket interface||Default enabled
+-l|Disable remote socket interface||Default enabled
+-m|Disable alerts (sampling)||Default enabled
+-n IP address|Allow IP address to use the socket interface|Name (e.g. paul) or dotted quad (e.g. 192.168.1.66)|If the -n option is not used all addresses are allowed (unless overridden by the -k or -l options). Multiple -n options are allowed. If -k has been used -n has no effect. If -l has been used only -n localhost has any effect
+-p value|Socket port|1024-32000|Default 8888
+-s value|Sample rate|1, 2, 4, 5, 8, or 10 microseconds|Default 5
+-t value|Clock peripheral|0=PWM 1=PCM|Default PCM. pigpio uses one or both of PCM and PWM. If PCM is used then PWM is available for audio. If PWM is used then PCM is available for audio. If waves or hardware PWM are used neither PWM nor PCM will be available for audio.
+-v -V|Display pigpio version and exit||
+-x mask|GPIO which may be updated|A 54 bit mask with (1<<n) set if the user may update GPIO #n|Default is the set of user GPIO for the board revision. Use -x -1 to allow all GPIO
+O*/
+
+/*TEXT
+
+*Example*
+
+. .
+sudo pigpiod -s 2 -b 200 -f
+. .
+
+Launch the pigpio library with a sample rate of 2 microseconds and a 200 millisecond buffer. Disable the fifo interface.
+
+*Permissions*
+
+pigpio provides a rudimentary permissions system for commands issued via the socket and pipe interfaces.
+
+All GPIO may be read.
+
+Only the user GPIO for the board type or those specified by the -x option may be updated.
+
+. .
+Type 1 boards 0x03E6CF93 (26 pin header)
+Type 2 boards 0xFBC6CF9C (26 pin + 8 pin header)
+Type 3 boards 0x0FFFFFFC (40 pin header)
+. .
+
+In this context an update includes the following:
+
+GPIO mode set
+GPIO pull/up down
+GPIO write
+GPIO set PWM (including range and frequency)
+GPIO set servo
+
+In addition the bank clear and set commands, and the wave commands will only
+affect updateable GPIO.
+
+*Exceptions*
+
+The following exceptions are made for particular models.
+
+^Models A and B^
+
+The green activity LED (GPIO 16) may be written.
+^Models A+ and B+^
+
+The green activity LED (GPIO 47) may be written.
+The red power LED (GPIO 35) may be written.
+The high USB power mode (GPIO 38) may be written.
+^Pi Zero^
+
+The green activity LED (GPIO 47) may be written.
+^Pi2B^
+
+The green activity LED (GPIO 47) may be written.
+The red power LED (GPIO 35) may be written.
+The high USB power mode (GPIO 38) may be written.
+^Pi3B^
+
+The green activity LED and the red power LED are not writable.
+The USB power mode is fixed at 1.2 amps (high power).
+
+*DMA Channels*
+
+The secondary channel is only used for the transmission of waves.
+
+If possible use one of channels 0 to 6 for the secondary channel (a full channel).
+
+A full channel only requires one DMA control block regardless of the length of a pulse delay. Channels 7 to 14 (lite channels) require one DMA control block for each 16383 microseconds of delay. I.e. a 10 second pulse delay requires one control block on a full channel and 611 control blocks on a lite channel.
+
+TEXT*/
+
+
diff --git a/DOC/src/defs/pigs.def b/DOC/src/defs/pigs.def
new file mode 100644
index 0000000..f678126
--- /dev/null
+++ b/DOC/src/defs/pigs.def
@@ -0,0 +1,3482 @@
+INTRO
+
+The socket and pipe interfaces allow control of the Pi's GPIO by
+passing messages to the running pigpio library.
+
+The normal way to start the pigpio library would be as a daemon during boot.
+
+...
+sudo pigpiod
+...
+
+*Features*
+
+o hardware timed PWM on any of GPIO 0-31
+
+o hardware timed servo pulses on any of GPIO 0-31
+
+o reading/writing all of the GPIO in a bank as one operation
+
+o individually setting GPIO modes, reading and writing
+
+o notifications when any of GPIO 0-31 change state
+
+o the construction of output waveforms with microsecond timing
+
+o I2C, SPI, and serial link wrappers
+
+o creating and running scripts on the pigpio daemon
+
+*GPIO*
+
+ALL GPIO are identified by their Broadcom number.
+
+*Usage*
+
+pigs is a program and internally uses the socket interface to pigpio
+whereas /dev/pigpio uses the pipe interface.
+
+pigs and the pipe interface share the same commands and are invoked in
+a similar fashion from the command line.
+
+The pigpio library must be running, either by running a program linked
+with the library or starting the pigpio daemon (sudo pigpiod).
+
+pigs {command}+
+
+echo "{command}+" >/dev/pigpio
+
+pigs will show the result of the command on screen.
+
+The pigs process returns an exit status (which can be displayed with
+the command echo $?).
+
+...
+PIGS_OK 0
+PIGS_CONNECT_ERR 255
+PIGS_OPTION_ERR 254
+PIGS_SCRIPT_ERR 253
+...
+
+The results of /dev/pigpio commands need to be read from /dev/pigout,
+e.g. cat /dev/pigout (try cat /dev/pigout& so that all subsequent
+results are shown on screen).
+
+In both cases if an error was detected a message will have been written
+to /dev/pigerr (try cat /dev/pigerr&). This is likely to be more
+informative than the message returned by pigs or the error code
+returned by the pipe interface.
+
+Several commands may be entered on a line. If present PROC and PARSE must
+be the last command on a line.
+
+E.g.
+
+...
+pigs w 22 1 mils 1000 w 22 0
+...
+
+is equivalent to
+
+...
+pigs w 22 1
+pigs mils 1000
+pigs w 22 0
+...
+
+and
+
+...
+echo "m 4 w w 4 0 mils 250 m 4 r r 4" >/dev/pigpio
+...
+
+is equivalent to
+
+...
+echo "m 4 w" >/dev/pigpio
+echo "w 4 0" >/dev/pigpio
+echo "mils 250" >/dev/pigpio
+echo "m 4 r" >/dev/pigpio
+echo "r 4" >/dev/pigpio
+...
+
+*Notes*
+
+The examples from now on will show the pigs interface but the same
+commands will also work on the pipe interface.
+
+pigs does not show the status of successful commands unless the
+command itself returns data. The status (0) will be returned to
+pigs but will be discarded.
+
+The status/data of each command sent to the pipe interface should
+be read from /dev/pigout.
+
+When a command takes a number as a parameter it may be entered as hex
+(precede by 0x), octal (precede by 0), or decimal.
+
+E.g. 23 is 23 decimal, 0x100 is 256 decimal, 070 is 56 decimal.
+
+Some commands can return a variable number of data bytes. By
+default this data is displayed as decimal. The pigs -a option
+can be used to force the display as ASCII and the pigs -x
+option can be used to force the display as hex.
+
+E.g. assuming the transmitted serial data is the letters ABCDEONM
+
+...
+$ pigs slr 4 100
+8 65 66 67 68 69 79 78 77
+
+$ pigs -a slr 4 100
+8 ABCDEONM
+
+$ pigs -x slr 4 100
+8 41 42 43 44 45 4f 4e 4d
+...
+
+OVERVIEW
+
+BASIC
+
+M/MODES g m :: Set GPIO mode :: gpioSetMode
+MG/MODEG g :: Get GPIO mode :: gpioGetMode
+
+PUD g p :: Set GPIO pull up/down :: gpioSetPullUpDown
+
+R/READ g :: Read GPIO level :: gpioRead
+W/WRITE g L :: Write GPIO level :: gpioWrite
+
+PWM (overrides servo commands on same GPIO)
+
+P/PWM u v :: Set GPIO PWM value :: gpioPWM
+PFS u v :: Set GPIO PWM frequency :: gpioSetPWMfrequency
+PRS u v :: Set GPIO PWM range :: gpioSetPWMrange
+
+GDC u :: Get GPIO PWM dutycycle :: gpioGetPWMdutycycle
+PFG u :: Get GPIO PWM frequency :: gpioGetPWMfrequency
+PRG u :: Get GPIO PWM range :: gpioGetPWMrange
+
+PRRG u :: Get GPIO PWM real range :: gpioGetPWMrealRange
+
+Servo (overrides PWM commands on same GPIO)
+
+S/SERVO u v :: Set GPIO servo pulsewidth :: gpioServo
+
+GPW u :: Get GPIO servo pulsewidth :: gpioGetServoPulsewidth
+
+INTERMEDIATE
+
+TRIG u pl L :: Send a trigger pulse :: gpioTrigger
+
+WDOG u v :: Set GPIO watchdog :: gpioSetWatchdog
+
+BR1 :: Read bank 1 GPIO :: gpioRead_Bits_0_31
+BR2 :: Read bank 2 GPIO :: gpioRead_Bits_32_53
+
+BC1 bits :: Clear specified GPIO in bank 1 :: gpioWrite_Bits_0_31_Clear
+BC2 bits :: Clear specified GPIO in bank 2 :: gpioWrite_Bits_32_53_Clear
+
+BS1 bits :: Set specified GPIO in bank 1 :: gpioWrite_Bits_0_31_Set
+BS2 bits :: Set specified GPIO in bank 2 :: gpioWrite_Bits_32_53_Set
+
+ADVANCED
+
+NO :: Request a notification :: gpioNotifyOpen
+NC h :: Close notification :: gpioNotifyClose
+NB h bits :: Start notification :: gpioNotifyBegin
+NP h :: Pause notification :: gpioNotifyPause
+
+HC g cf :: Set hardware clock frequency :: gpioHardwareClock
+
+HP g pf pdc :: Set hardware PWM frequency and dutycycle :: gpioHardwarePWM
+
+FG u stdy :: Set a glitch filter on a GPIO :: gpioGlitchFilter
+FN u stdy actv :: Set a noise filter on a GPIO :: gpioNoiseFilter
+
+PADS pad padma :: Set pad drive strength :: gpioSetPad
+PADG pad :: Get pad drive strength :: gpioGetPad
+
+SHELL name str :: Execute a shell command :: shell
+
+Custom
+
+CF1 uvs :: Custom function 1 :: gpioCustom1
+CF2 uvs :: Custom function 2 :: gpioCustom1
+
+Events
+
+EVM h bits :: Set events to monitor :: eventMonitor
+EVT event :: Trigger event :: eventTrigger
+
+Scripts
+
+PROC t :: Store script :: gpioStoreScript
+PROCR sid pars :: Run script :: gpioRunScript
+PROCU sid pars :: Set script parameters :: gpioUpdateScript
+PROCP sid :: Get script status and parameters :: gpioScriptStatus
+PROCS sid :: Stop script :: gpioStopScript
+PROCD sid :: Delete script :: gpioDeleteScript
+
+PARSE t :: Validate script :: gpioParseScript
+
+I2C
+
+I2CO ib id if :: Open I2C bus and device with flags :: i2cOpen
+I2CC h :: Close I2C handle :: i2cClose
+
+I2CWQ h bit :: smb Write Quick: write bit :: i2cWriteQuick
+
+I2CRS h :: smb Read Byte: read byte :: i2cReadByte
+I2CWS h bv :: smb Write Byte: write byte :: i2cWriteByte
+
+I2CRB h r :: smb Read Byte Data: read byte from register :: i2cReadByteData
+I2CWB h r bv :: smb Write Byte Data: write byte to register :: i2cWriteByteData
+
+I2CRW h r :: smb Read Word Data: read word from register :: i2cReadWordData
+I2CWW h r wv :: smb Write Word Data: write word to register :: i2cWriteWordData
+
+I2CRK h r :: smb Read Block Data: read data from register :: i2cReadBlockData
+I2CWK h r bvs :: smb Write Block Data: write data to register :: i2cWriteBlockData
+
+I2CWI h r bvs :: smb Write I2C Block Data :: i2cWriteI2CBlockData
+I2CRI h r num :: smb Read I2C Block Data: read bytes from register :: i2cReadI2CBlockData
+
+I2CRD h num :: i2c Read device :: i2cReadDevice
+I2CWD h bvs :: i2c Write device :: i2cWriteDevice
+
+I2CPC h r wv :: smb Process Call: exchange register with word :: i2cProcessCall
+I2CPK h r bvs :: smb Block Process Call: exchange data bytes with register :: i2cBlockProcessCall
+
+I2CZ h bvs :: Performs multiple I2C transactions :: i2cZip
+
+I2C BIT BANG
+
+BI2CO sda scl b :: Open bit bang I2C :: bbI2COpen
+BI2CC sda :: Close bit bang I2C :: bbI2CClose
+
+BI2CZ sda bvs :: I2C bit bang multiple transactions :: bbI2CZip
+
+I2C/SPI SLAVE
+
+BSCX bctl bvs :: BSC I2C/SPI transfer :: bscXfer
+
+SERIAL
+
+SERO dev b sef :: Open serial device dev at baud b with flags :: serOpen
+SERC h :: Close serial handle :: serClose
+
+SERRB :: Read byte from serial handle :: serReadByte
+SERWB h bv :: Write byte to serial handle :: serWriteByte
+
+SERR h num :: Read bytes from serial handle :: serRead
+SERW h bvs :: Write bytes to serial handle :: serWrite
+
+SERDA h :: Check for serial data ready to read :: serDataAvailable
+
+SERIAL BIT BANG (read only)
+
+SLRO u b db :: Open GPIO for bit bang serial data :: gpioSerialReadOpen
+SLRC u :: Close GPIO for bit bang serial data :: gpioSerialReadClose
+
+SLRI u v :: Sets bit bang serial data logic levels :: gpioSerialReadInvert
+
+SLR u num :: Read bit bang serial data from GPIO :: gpioSerialRead
+
+SPI
+
+SPIO c b spf :: SPI open channel at baud b with flags :: spiOpen
+SPIC h :: SPI close handle :: spiClose
+
+SPIR h num :: SPI read bytes from handle :: spiRead
+SPIW h bvs :: SPI write bytes to handle :: spiWrite
+SPIX h bvs :: SPI transfer bytes to handle :: spiXfer
+
+SPI BIT BANG
+
+BSPIO cs miso mosi sclk b spf :: Open bit bang SPI :: bbSPIOpen
+BSPIC cs :: Close bit bang SPI :: bbSPIClose
+
+BSPIX cs bvs :: SPI bit bang transfer :: bbSPIXfer
+
+FILES
+
+FO file mode :: Open a file in mode :: fileOpen
+FC h :: Close file handle :: fileClose
+
+FR h num :: Read bytes from file handle :: fileRead
+FW h bvs :: Write bytes to file handle :: fileWrite
+
+FS h num from :: Seek to file handle position :: fileSeek
+
+FL pat num :: List files which match pattern :: fileList
+
+WAVES
+
+WVCLR :: Clear all waveforms :: gpioWaveClear
+
+WVNEW :: Initialise a new waveform :: gpioWaveAddNew
+WVAG trips :: Add generic pulses to waveform :: gpioWaveAddGeneric
+WVAS u b db sb o bvs :: Add serial data to waveform :: gpioWaveAddSerial
+
+WVCRE :: Create a waveform :: gpioWaveCreate
+WVCAP percent :: Create a waveform of fixed size :: gpioWaveCreatePad
+WVDEL wid :: Delete selected waveform :: gpioWaveDelete
+
+WVTX wid :: Transmits waveform once :: gpioWaveTxSend
+WVTXM wid wmde :: Transmits waveform using mode :: gpioWaveTxSend
+WVTXR wid :: Transmits waveform repeatedly :: gpioWaveTxSend
+
+WVCHA bvs :: Transmits a chain of waveforms :: gpioWaveChain
+
+WVTAT :: Returns the current transmitting waveform :: gpioWaveTxAt
+
+WVBSY :: Check if waveform is being transmitted :: gpioWaveTxBusy
+
+WVHLT :: Stop waveform :: gpioWaveTxStop
+
+WVSC ws :: Get waveform DMA CB stats :: gpioWaveGetCbs
+WVSM ws :: Get waveform time stats :: gpioWaveGetMicros
+WVSP ws :: Get waveform pulse stats :: gpioWaveGetPulses
+
+UTILITIES
+
+H/HELP :: Display command help ::
+HWVER :: Get hardware version :: gpioHardwareRevision
+MICS v :: Microseconds delay :: gpioDelay
+MILS v :: Milliseconds delay :: gpioDelay
+PIGPV :: Get pigpio library version :: gpioVersion
+T/TICK :: Get current tick :: gpioTick
+
+CONFIGURATION
+
+CGI :: Configuration get internals :: gpioCfgGetInternals
+CSI v :: Configuration set internals :: gpioCfgSetInternals
+
+COMMANDS
+
+BC1 ::
+This command clears (sets low) the GPIO specified by [*bits*] in bank 1.
+Bank 1 consists of GPIO 0-31.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bc1 0x400010 # clear GPIO 4 (1<<4) and 22 (1<<22)
+
+$ pigs bc1 32 # clear GPIO 5 (1<<5)
+-42
+ERROR: no permission to update one or more GPIO
+...
+
+BC2 ::
+This command clears (sets low) the GPIO specified by [*bits*] in bank 2.
+Bank 2 consists of GPIO 32-53.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bc2 0x8000 # clear GPIO 47 (activity LED on A+/B+/Pi2/Pi3)
+
+$ pigs bc2 1 # clear GPIO 32 (first in bank 2)
+-42
+ERROR: no permission to update one or more GPIO
+...
+
+BI2CC ::
+This command signals that bit banging I2C on [*sda*] (and [*scl*]) is no
+longer required.
+
+...
+$ pigs bi2cc 5
+...
+
+BI2CO ::
+This command signals that GPIO [*sda*] and [*scl*] are to be used
+for bit banging I2C at [*b*] baud.
+
+Bit banging I2C allows for certain operations which are not possible
+with the standard I2C driver.
+
+o baud rates as low as 50
+o repeated starts
+o clock stretching
+o I2C on any pair of spare GPIO
+
+The baud rate may be between 50 and 500000 bits per second.
+
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
+a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
+
+BI2CZ ::
+This function executes a sequence of bit banged I2C operations. The
+operations to be performed are specified by the contents of [*bvs*]
+which contains the concatenated command codes and associated data.
+
+The following command codes are supported:
+
+Name @ Cmd & Data @ Meaning
+End @ 0 @ No more commands
+Escape @ 1 @ Next P is two bytes
+Start @ 2 @ Start condition
+Stop @ 3 @ Stop condition
+Address @ 4 P @ Set I2C address to P
+Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
+Read @ 6 P @ Read P bytes of data
+Write @ 7 P ... @ Write P bytes of data
+
+The address, read, and write commands take a parameter P.
+Normally P is one byte (0-255). If the command is preceded by
+the Escape command then P is two bytes (0-65535, least significant
+byte first).
+
+The address and flags default to 0. The address and flags maintain
+their previous value until updated.
+
+No flags are currently defined.
+
+...
+Set address 0x53
+start, write 0x32, (re)start, read 6 bytes, stop
+Set address 0x1E
+start, write 0x03, (re)start, read 6 bytes, stop
+Set address 0x68
+start, write 0x1B, (re)start, read 8 bytes, stop
+End
+
+0x04 0x53
+0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03
+
+0x04 0x1E
+0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03
+
+0x04 0x68
+0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03
+
+0x00
+...
+
+BR1 ::
+This command read GPIO 0-31 (bank 1) and returns the levels as a
+32-bit hexadecimal value.
+
+...
+$ pigs br1
+1001C1CF
+...
+
+BR2 ::
+This command read GPIO 32-53 (bank 2) and returns the levels as a
+32-bit hexadecimal value.
+
+...
+$ pigs br2
+003F0000
+...
+
+BS1 ::
+This command sets (sets high) the GPIO specified by [*bits*] in bank 1.
+Bank 1 consists of GPIO 0-31.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bs1 16 # set GPIO 4 (1<<4)
+
+$ pigs bs1 1 # set GPIO 1 (1<<0)
+-42
+ERROR: no permission to update one or more GPIO
+...
+
+BS2 ::
+This command sets (sets high) the GPIO specified by [*bits*] in bank 2.
+Bank 2 consists of GPIO 32-53.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bs2 0x40 # set GPIO 38 (enable high current mode A+/B+/Pi2/Pi3)
+
+$ pigs bs2 1 # set GPIO 32 (first in bank 2)
+-42
+ERROR: no permission to update one or more GPIO
+...
+
+BSCX ::
+
+This command performs a BSC I2C/SPI slave transfer as defined by
+[*bctl*] with data [*bvs*].
+
+This function provides a low-level interface to the SPI/I2C Slave
+peripheral on the BCM chip.
+
+This peripheral allows the Pi to act as a hardware slave device
+on an I2C or SPI bus.
+
+This is not a bit bang version and as such is OS timing
+independent. The bus timing is handled directly by the chip.
+
+The output process is simple. You simply append data to the FIFO
+buffer on the chip. This works like a queue, you add data to the
+queue and the master removes it.
+
+I can't get SPI to work properly. I tried with a
+control word of 0x303 and swapped MISO and MOSI.
+
+The command sets the BSC mode and writes any data [*bvs*]
+to the BSC transmit FIFO. It returns the data count (at least 1
+for the status word), the status word, followed by any data bytes
+read from the BSC receive FIFO.
+
+Note that the control word sets the BSC mode. The BSC will stay in
+that mode until a different control word is sent.
+
+For I2C use a control word of (I2C address << 16) + 0x305.
+
+E.g. to talk as I2C slave with address 0x13 use 0x130305.
+
+GPIO used for models other than those based on the BCM2711.
+
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+I2C @ 18 @ 19 @ - @ - @ - @ -
+SPI @ - @ - @ 18 @ 19 @ 20 @ 21
+
+GPIO used for models based on the BCM2711 (e.g. the Pi4B).
+
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+I2C @ 10 @ 11 @ - @ - @ - @ -
+SPI @ - @ - @ 10 @ 11 @ 9 @ 8
+
+When a zero control word is received the used GPIO will be reset
+to INPUT mode.
+
+The control word consists of the following bits.
+
+. .
+22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ a a a a a a a - - IT HC TF IR RE TE BK EC ES PL PH I2 SP EN
+. .
+
+Bits 0-13 are copied unchanged to the BSC CR register. See
+pages 163-165 of the Broadcom peripherals document for full
+details.
+
+aaaaaaa @ defines the I2C slave address (only relevant in I2C mode)
+IT @ invert transmit status flags
+HC @ enable host control
+TF @ enable test FIFO
+IR @ invert receive status flags
+RE @ enable receive
+TE @ enable transmit
+BK @ abort operation and clear FIFOs
+EC @ send control register as first I2C byte
+ES @ send status register as first I2C byte
+PL @ set SPI polarity high
+PH @ set SPI phase high
+I2 @ enable I2C mode
+SP @ enable SPI mode
+EN @ enable BSC peripheral
+
+The returned status has the following format
+
+. .
+20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ S S S S S R R R R R T T T T T RB TE RF TF RE TB
+. .
+
+Bits 0-15 are copied unchanged from the BSC FR register. See
+pages 165-166 of the Broadcom peripherals document for full
+details.
+
+SSSSS @ number of bytes successfully copied to transmit FIFO
+RRRRR @ number of bytes in receieve FIFO
+TTTTT @ number of bytes in transmit FIFO
+RB @ receive busy
+TE @ transmit FIFO empty
+RF @ receive FIFO full
+TF @ transmit FIFO full
+RE @ receive FIFO empty
+TB @ transmit busy
+
+This example assumes that GPIO 2/3 are connected to GPIO 18/19
+(GPIO 10/11 on the BCM2711).
+
+...
+$ pigs bscx 0x130305 # start BSC as I2C slave 0x13
+1 18
+
+$ i2cdetect -y 1
+ 0 1 2 3 4 5 6 7 8 9 a b c d e f
+00: -- -- -- -- -- -- -- -- -- -- -- -- --
+10: -- -- -- 13 -- -- -- -- -- -- -- -- -- -- -- --
+20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+70: -- -- -- -- -- -- -- --
+
+$ pigs i2co 1 0x13 0 # get handle for device 0x13 on bus 1
+0
+
+$ pigs i2cwd 0 90 87 51 9 23 # write 5 bytes
+
+$ pigs bscx 0x130305 # check for data
+6 18 90 87 51 9 23
+
+$ pigs bscx 0x130305 11 13 15 17 # check for data and send 4 bytes
+1 262338
+
+$ pigs i2crd 0 4 # read 4 bytes
+4 11 13 15 17
+
+$ pigs i2cwd 0 90 87 51 9 23 # write 5 bytes
+$ pigs bscx 0x130305 11 13 15 17 # check for data and send 4 bytes
+6 262338 90 87 51 9 23
+
+$ pigs i2crd 0 4
+4 11 13 15 17
+
+$ pigs bscx 0x130305 22 33 44 55 66
+1 327938
+$ pigs i2crd 0 5
+5 22 33 44 55 66
+...
+
+BSPIC ::
+
+This command stops bit banging SPI on a set of GPIO
+opened with [*BSPIO*].
+
+The set of GPIO is specifed by [*cs*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs bspic 10
+
+$ pigs bspic 10
+-142
+ERROR: no bit bang SPI in progress on GPIO
+...
+
+BSPIO ::
+
+This command starts bit banging SPI on a group of GPIO with slave
+select [*cs*], MISO [*miso*], MOSI [*mosi*], and clock [*sclk*].
+
+Data will be transferred at baud [*b*] bits per second (which may
+be set in the range 50-250000).
+
+The flags [*spf*] may be used to modify the default behaviour of
+mode 0, active low chip select.
+
+The flags consists of the least significant 22 bits.
+
+. .
+21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m
+. .
+
+mm defines the SPI mode.
+
+. .
+Mode POL PHA
+ 0 0 0
+ 1 0 1
+ 2 1 0
+ 3 1 1
+. .
+
+p is 0 if CS is active low (default) and 1 for active high.
+
+T is 1 if the least significant bit is transmitted on MOSI first, the
+default (0) shifts the most significant bit out first.
+
+R is 1 if the least significant bit is received on MISO first, the
+default (0) receives the most significant bit first.
+
+The other bits in flags should be set to zero.
+
+Upon success 0 is returned. On error a negative status code
+will be returned.
+
+If more than one device is connected to the SPI bus (defined by
+SCLK, MOSI, and MISO) each must have its own CS.
+
+...
+$ pigs bspio 9 11 12 13 50000 0
+
+$ pigs bspio 10 11 12 13 50000 0
+
+$ pigs bspio 29 19 20 21 50000 0 # GPIO 29 not avaialble on this Pi
+-41
+ERROR: no permission to update GPIO
+...
+
+BSPIX::
+
+This command writes bytes [*bvs*] to the bit bang SPI device
+associated with slave select [*cs*]. It returns the same
+number of bytes read from the device.
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs bspio 5 13 19 12 10000 0 # MCP4251 DAC
+$ pigs bspio 6 13 19 12 20000 3 # MCP3008 ADC
+
+$ pigs bspix 5 0 16 # set DAC to 16
+2 255 255
+
+$ pigs bspix 5 12 0 # read back DAC
+2 254 16
+
+$ pigs bspix 6 1 128 0 # read ADC input 0
+3 0 3 184 # 952
+
+$ pigs bspix 5 0 240 # set DAC to 240
+2 255 255
+
+$ pigs bspix 5 12 0 # read back DAC
+2 254 240
+
+$ pigs bspix 6 1 128 0 # read ADC input 0
+3 0 0 63 # 63
+
+$ pigs bspix 5 0 128 # set DAC to 128
+2 255 255
+
+$ pigs bspix 5 12 0 # read back DAC
+2 254 128
+
+$ pigs bspix 6 1 128 0 # read ADC input 0
+3 0 1 255 # 511
+
+$ pigs bspic 5 # close SPI CS 5
+$ pigs bspic 6 # close SPI CS 6
+
+$ pigs bspic 5 # try to close SPI CS 5 again
+-142
+ERROR: no bit bang SPI in progress on GPIO
+...
+
+
+CF1::
+
+This command calls a user customised function. The meaning of
+any paramaters and the returned value is defined by the
+customiser.
+
+CF2::
+
+This command calls a user customised function. The meaning of
+any paramaters and the returned value is defined by the
+customiser.
+
+CGI::
+This command returns the value of the internal library
+configuration settings.
+
+CSI::
+This command sets the value of the internal library
+configuration settings to [*v*].
+
+EVM ::
+This command starts event reporting on handle [*h*] (returned by
+a prior call to [*NO*]).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The notification gets reports for each event specified by [*bits*].
+
+...
+$ pigs evm 0 -1 # Shorthand for events 0-31.
+$ pigs evm 0 0xf0 # Get notifications for events 4-7.
+
+$ pigs evm 1 0xf
+-25
+ERROR: unknown handle
+...
+
+EVT ::
+This command triggers event [*event*].
+
+One event, number 31, is predefined. This event is
+auto generated on BSC slave activity.
+
+...
+$ pigs evt 12
+$ pigs evt 5
+
+$ pigs evt 32
+-143
+ERROR: bad event id
+...
+
+FC::
+This command closes a file handle [*h*] previously opened with [*FO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs fc 0 # First close okay.
+
+$ pigs fc 0 # Second fails.
+-25
+ERROR: unknown handle
+...
+
+FG ::
+
+Level changes on the GPIO [*u*] are not reported unless the level
+has been stable for at least [*stdy*] microseconds. The
+level is then reported. Level changes of less than [*stdy*]
+microseconds are ignored.
+
+The filter only affects callbacks (including pipe notifications).
+
+The [*R/READ*], [*BR1*], and [*BR2*] commands are not affected.
+
+Note, each (stable) edge will be timestamped [*stdy*] microseconds
+after it was first detected.
+
+...
+$ pigs fg 4 250
+
+$ pigs fg 4 1000000
+-125
+ERROR: bad filter parameter
+...
+
+FL ::
+This command returns a list of the files matching [*pat*]. Up
+to [*num*] bytes may be returned.
+
+Upon success the count of returned bytes followed by the matching
+files is returned. On error a negative status code will be returned.
+
+A newline (0x0a) character separates each file name.
+
+Only files which have a matching entry in /opt/pigpio/access may
+be listed.
+
+Suppose /opt/pigpio/access contains
+
+/sys/bus/w1/devices/28*/w1_slave r
+
+...
+$ pigs -a fl "/sys/bus/w1/devices/28*/w1_slave" 5000
+90 /sys/bus/w1/devices/28-000005d34cd2/w1_slave
+/sys/bus/w1/devices/28-001414abbeff/w1_slave
+
+$ pigs -a fl "/sys/bus/*" 5000
+ERROR: no permission to access file
+-137
+...
+
+FN ::
+
+Level changes on the GPIO [*u*] are ignored until a level which has
+been stable for [*stdy*] microseconds is detected. Level
+changes on the GPIO are then reported for [*actv*] microseconds
+after which the process repeats.
+
+The filter only affects callbacks (including pipe notifications).
+
+The [*R/READ*], [*BR1*], and [*BR2*] commands are not affected.
+
+Note, level changes before and after the active period may
+be reported. Your software must be designed to cope with
+such reports.
+
+...
+$ pigs fn 7 250 1000
+
+$ pigs fn 7 2500000 1000
+-125
+ERROR: bad filter parameter
+...
+
+FO ::
+This function returns a handle to a file [*file*] opened
+in a specified mode [*mode*].
+
+Upon success a handle (>=0) is returned. On error a negative status code
+will be returned.
+
+File
+
+A file may only be opened if permission is granted by an entry in
+/opt/pigpio/access. This is intended to allow remote access to files
+in a more or less controlled manner.
+
+Each entry in /opt/pigpio/access takes the form of a file path
+which may contain wildcards followed by a single letter permission.
+The permission may be R for read, W for write, U for read/write,
+and N for no access.
+
+Where more than one entry matches a file the most specific rule
+applies. If no entry matches a file then access is denied.
+
+Suppose /opt/pigpio/access contains the following entries
+
+. .
+/home/* n
+/home/pi/shared/dir_1/* w
+/home/pi/shared/dir_2/* r
+/home/pi/shared/dir_3/* u
+/home/pi/shared/dir_1/file.txt n
+. .
+
+Files may be written in directory dir_1 with the exception
+of file.txt.
+
+Files may be read in directory dir_2.
+
+Files may be read and written in directory dir_3.
+
+If a directory allows read, write, or read/write access then files may
+be created in that directory.
+
+In an attempt to prevent risky permissions the following paths are
+ignored in /opt/pigpio/access.
+
+. .
+a path containing ..
+a path containing only wildcards (*?)
+a path containing less than two non-wildcard parts
+. .
+
+Mode
+
+The mode may have the following values.
+
+ @ Value @ Meaning
+READ @ 1 @ open file for reading
+WRITE @ 2 @ open file for writing
+RW @ 3 @ open file for reading and writing
+
+The following values may be or'd into the mode.
+
+ @ Value @ Meaning
+APPEND @ 4 @ All writes append data to the end of the file
+CREATE @ 8 @ The file is created if it doesn't exist
+TRUNC @ 16 @ The file is truncated
+
+Newly created files are owned by root with permissions owner read and write.
+
+...
+$ ls /ram/*.c
+/ram/command.c /ram/pigpiod.c /ram/pigs.c
+/ram/x_pigpiod_if.c /ram/pig2vcd.c /ram/pigpiod_if2.c
+/ram/x_pigpio.c /ram/x_repeat.c /ram/pigpio.c
+/ram/pigpiod_if.c /ram/x_pigpiod_if2.c
+
+# assumes /opt/pigpio/access contains the following line
+# /ram/*.c r
+
+$ pigs fo /ram/pigpio.c 1
+0
+
+$ pigs fo /ram/new.c 1
+-128
+ERROR: file open failed
+
+$ pigs fo /ram/new.c 9
+1
+
+$ ls /ram/*.c -l
+-rw-r--r-- 1 joan joan 42923 Jul 10 11:22 /ram/command.c
+-rw------- 1 root root 0 Jul 10 16:54 /ram/new.c
+-rw-r--r-- 1 joan joan 2971 Jul 10 11:22 /ram/pig2vcd.c
+-rw------- 1 joan joan 296235 Jul 10 11:22 /ram/pigpio.c
+-rw-r--r-- 1 joan joan 9266 Jul 10 11:22 /ram/pigpiod.c
+-rw-r--r-- 1 joan joan 37331 Jul 10 11:22 /ram/pigpiod_if2.c
+-rw-r--r-- 1 joan joan 33088 Jul 10 11:22 /ram/pigpiod_if.c
+-rw-r--r-- 1 joan joan 7990 Jul 10 11:22 /ram/pigs.c
+-rw-r--r-- 1 joan joan 19970 Jul 10 11:22 /ram/x_pigpio.c
+-rw-r--r-- 1 joan joan 20804 Jul 10 11:22 /ram/x_pigpiod_if2.c
+-rw-r--r-- 1 joan joan 19844 Jul 10 11:22 /ram/x_pigpiod_if.c
+-rw-r--r-- 1 joan joan 19907 Jul 10 11:22 /ram/x_repeat.c
+...
+
+FR::
+This command returns up to [*num*] bytes of data read from the
+file associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs fr 0 10
+5 48 49 128 144 255
+
+$ pigs fr 0 10
+0
+...
+
+FS ::
+This command seeks to a position within the file associated
+with handle [*h*].
+
+The number of bytes to move is [*num*]. Positive offsets
+move forward, negative offsets backwards. The move start
+position is determined by [*from*] as follows.
+
+ @ From
+0 @ start
+1 @ current position
+2 @ end
+
+Upon success the new byte position within the file (>=0) is
+returned. On error a negative status code will be returned.
+
+...
+$ pigs fs 0 200 0 # Seek to start of file plus 200
+200
+
+$ pigs fs 0 0 1 # Return current position
+200
+
+$ pigs fs 0 0 2 # Seek to end of file, return size
+296235
+...
+
+FW::
+This command writes bytes [*bvs*] to the file
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs fw 0 23 45 67 89
+...
+
+GDC ::
+
+This command returns the PWM dutycycle in use on GPIO [*u*].
+
+Upon success the dutycycle is returned. On error a negative
+status code will be returned.
+
+For normal PWM the dutycycle will be out of the defined range
+for the GPIO (see [*PRG*]).
+
+If a hardware clock is active on the GPIO the reported
+dutycycle will be 500000 (500k) out of 1000000 (1M).
+
+If hardware PWM is active on the GPIO the reported dutycycle
+will be out of a 1000000 (1M).
+
+...
+$ pigs p 4 129
+$ pigs gdc 4
+129
+
+pigs gdc 5
+-92
+ERROR: GPIO is not in use for PWM
+...
+
+GPW ::
+
+This command returns the servo pulsewidth in use on GPIO [*u*].
+
+Upon success the servo pulsewidth is returned. On error a negative
+status code will be returned.
+
+...
+$ pigs s 4 1235
+$ pigs gpw 4
+1235
+
+$ pigs gpw 9
+-93
+ERROR: GPIO is not in use for servo pulses
+...
+
+H/HELP ::
+This command displays a brief list of the commands and their parameters.
+
+...
+$ pigs h
+
+$ pigs help
+...
+
+HC ::
+This command sets the hardware clock associated with GPIO [*g*] to
+frequency [*cf*]. Frequencies above 30MHz are unlikely to work.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs hc 4 5000 # start a 5 KHz clock on GPIO 4 (clock 0)
+
+$ pigs hc 5 5000000 # start a 5 MHz clcok on GPIO 5 (clock 1)
+-99
+ERROR: need password to use hardware clock 1
+...
+
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
+
+The GPIO must be one of the following.
+
+4 @clock 0 @All models
+5 @clock 1 @All models but A and B (reserved for system use)
+6 @clock 2 @All models but A and B
+20 @clock 0 @All models but A and B
+21 @clock 1 @All models but A and B Rev.2 (reserved for system use)
+
+32 @clock 0 @Compute module only
+34 @clock 0 @Compute module only
+42 @clock 1 @Compute module only (reserved for system use)
+43 @clock 2 @Compute module only
+44 @clock 1 @Compute module only (reserved for system use)
+
+Access to clock 1 is protected by a password as its use will
+likely crash the Pi. The password is given by or'ing 0x5A000000
+with the GPIO number.
+
+HP ::
+This command sets the hardware PWM associated with GPIO [*g*] to
+frequency [*pf*] with dutycycle [*pdc*]. Frequencies above 30MHz
+are unlikely to work.
+
+NOTE: Any waveform started by [*WVTX*], [*WVTXR*], or [*WVCHA*]
+will be cancelled.
+
+This function is only valid if the pigpio main clock is PCM. The
+main clock defaults to PCM but may be overridden when the pigpio
+daemon is started (option -t).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+. .
+$ pigs hp 18 100 800000 # 80% dutycycle
+
+$ pigs hp 19 100 200000 # 20% dutycycle
+
+$ pigs hp 19 400000000 100000
+-96
+ERROR: invalid hardware PWM frequency
+. .
+
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
+share a PWM channel.
+
+The GPIO must be one of the following.
+
+12 @PWM channel 0 @All models but A and B
+13 @PWM channel 1 @All models but A and B
+18 @PWM channel 0 @All models
+19 @PWM channel 1 @All models but A and B
+
+40 @PWM channel 0 @Compute module only
+41 @PWM channel 1 @Compute module only
+45 @PWM channel 1 @Compute module only
+52 @PWM channel 0 @Compute module only
+53 @PWM channel 1 @Compute module only
+
+The actual number of steps beween off and fully on is the
+integral part of 250M/[*pf*] (375M/[*pf*] for the BCM2711).
+
+The actual frequency set is 250M/steps (375M/steps for the BCM2711).
+
+There will only be a million steps for a [*pf*] of 250 (375 for
+the BCM2711). Lower frequencies will have more steps and higher
+frequencies will have fewer steps. [*pdc*] is
+automatically scaled to take this into account.
+
+HWVER ::
+This command returns the hardware revision of the Pi.
+
+The hardware revision is found in the last 4 characters on the revision
+line of /proc/cpuinfo.
+
+If the hardware revision can not be found or is not a valid hexadecimal
+number the command returns 0.
+
+The revision number can be used to determine the assignment of GPIO
+to pins (see [*g*]).
+
+There are currently three types of board.
+
+Type 1 boards have hardware revision numbers of 2 and 3.
+
+Type 2 boards have hardware revision numbers of 4, 5, 6, and 15.
+
+Type 3 boards have hardware revision numbers of 16 or greater.
+
+for "Revision : 0002" the command returns 2.
+
+for "Revision : 000f" the command returns 15.
+
+for "Revision : 000g" the command returns 0.
+
+...
+$ pigs hwver # On a B+
+16
+...
+
+I2CC ::
+This command closes an I2C handle [*h*] previously opened with [*I2CO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cc 0 # First close okay.
+
+$ pigs i2cc 0 # Second fails.
+-25
+ERROR: unknown handle
+...
+
+I2CO ::
+This command returns a handle to access device [*id*] on I2C bus [*ib*].
+The device is opened with flags [*if*].
+
+Physically buses 0 and 1 are available on the Pi. Higher
+numbered buses will be available if a kernel supported bus
+multiplexor is being used.
+
+The GPIO used are given in the following table.
+
+ @ SDA @ SCL
+I2C 0 @ 0 @ 1
+I2C 1 @ 2 @ 3
+
+No flags are currently defined. The parameter [*if*] should be 0.
+
+Upon success the next free handle (>=0) is returned. On error a
+negative status code will be returned.
+
+...
+$ pigs i2co 1 0x70 0 # Bus 1, device 0x70, flags 0.
+0
+
+$ pigs i2co 1 0x53 0 # Bus 1, device 0x53, flags 0.
+1
+...
+
+I2CPC ::
+This command writes [*wv*] to register [*r*] of the I2C device
+associated with handle [*h*] and returns a 16-bit word read from the
+device.
+
+Upon success a value between 0 and 65535 will be returned. On error
+a negative status code will be returned.
+
+...
+$ pigs i2cpc 0 37 43210
+39933
+
+$ pigs i2cpc 0 256 43210
+ERROR: bad i2c/spi/ser parameter
+-81
+...
+
+I2CPK ::
+
+This command writes the data bytes [*bvs*] to register [*r*] of the I2C device
+associated with handle [*h*] and returns a device specific number of bytes.
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs i2cpk 0 0 0x11 0x12
+6 0 0 0 0 0 0
+...
+
+I2CRB ::
+
+This command returns a single byte read from register [*r*] of the I2C device
+associated with handle [*h*].
+
+Upon success a value between 0 and 255 will be returned. On error
+a negative status code will be returned.
+
+...
+$ pigs i2crb 0 0
+6
+...
+
+I2CRD ::
+
+This command returns [*num*] bytes read from the I2C device associated with
+handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+This command operates on the raw I2C device. The maximum value of the
+parameter [*num*] is dependent on the I2C drivers and the device
+itself. pigs imposes a limit of about 8000 bytes.
+
+...
+$ pigs i2crd 0 16
+16 6 24 0 0 0 0 0 0 0 0 0 0 0 0 32 78
+...
+
+I2CRI ::
+
+This command returns [*num*] bytes from register [*r*] of the I2C device
+associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+The parameter [*num*] may be 1-32.
+
+...
+$ pigs i2cri 0 0 16
+16 237 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155
+...
+
+I2CRK ::
+
+This command returns between 1 and 32 bytes read from register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+The number of bytes of returned data is specific to the device and
+register.
+
+...
+$ pigs i2crk 0 0
+6 0 0 0 0 0 0
+
+$ pigs i2crk 0 1
+24 0 0 0 0 0 0 0 0 0 0 0 0 120 222 105 215 128 87 195 217 0 0 0 0
+...
+
+I2CRS ::
+
+This command returns a single byte read from the I2C device
+associated with handle [*h*].
+
+Upon success a value between 0 and 255 will be returned. On error
+a negative status code will be returned.
+
+...
+$ pigs i2crs 0
+0
+...
+
+I2CRW ::
+
+This command returns a single 16 bit word read from register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success a value between 0 and 65535 will be returned. On error
+a negative status code will be returned.
+
+...
+$ pigs i2crw 0 0
+6150
+...
+
+I2CWB ::
+
+This command writes a single byte [*bv*] to register [*r*] of the
+I2C device associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cwb 0 10 0x54
+...
+
+I2CWD ::
+
+This command writes a block of bytes [*bvs*] to the I2C device
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The number of bytes which may be written in one transaction is
+dependent on the I2C drivers and the device itself. pigs imposes
+a limit of about 500 bytes.
+
+This command operates on the raw I2C device.
+
+...
+$ pigs i2cwd 0 0x01 0x02 0x03 0x04
+...
+
+I2CWI ::
+
+This command writes between 1 and 32 bytes [*bvs*] to register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cwi 0 4 0x01 0x04 0xc0
+...
+
+I2CWK ::
+
+This command writes between 1 and 32 bytes [*bvs*] to register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+pigs i2cwk 0 4 0x01 0x04 0xc0
+...
+
+I2CWQ ::
+
+This command writes a single [*bit*] to the I2C device associated
+with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cwq 0 1
+...
+
+I2CWS ::
+
+This command writes a single byte [*bv*] to the I2C device associated
+with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cws 0 0x12
+
+$ pigs i2cws 0 0xff
+-82
+ERROR: I2C write failed
+...
+
+I2CWW ::
+
+This command writes a single 16 bit word [*wv*] to register [*r*] of
+the I2C device associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs i2cww 0 0 0xffff
+...
+
+I2CZ ::
+This command executes a sequence of I2C operations. The
+operations to be performed are specified by the contents of [*bvs*]
+which contains the concatenated command codes and associated data.
+
+The following command codes are supported:
+
+Name @ Cmd & Data @ Meaning
+End @ 0 @ No more commands
+Escape @ 1 @ Next P is two bytes
+On @ 2 @ Switch combined flag on
+Off @ 3 @ Switch combined flag off
+Address @ 4 P @ Set I2C address to P
+Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
+Read @ 6 P @ Read P bytes of data
+Write @ 7 P ... @ Write P bytes of data
+
+The address, read, and write commands take a parameter P.
+Normally P is one byte (0-255). If the command is preceded by
+the Escape command then P is two bytes (0-65535, least significant
+byte first).
+
+The address defaults to that associated with the handle [*h*].
+The flags default to 0. The address and flags maintain their
+previous value until updated.
+
+...
+Set address 0x53, write 0x32, read 6 bytes
+Set address 0x1E, write 0x03, read 6 bytes
+Set address 0x68, write 0x1B, read 8 bytes
+End
+
+0x04 0x53 0x07 0x01 0x32 0x06 0x06
+0x04 0x1E 0x07 0x01 0x03 0x06 0x06
+0x04 0x68 0x07 0x01 0x1B 0x06 0x08
+0x00
+...
+
+
+M/MODES ::
+
+This command sets GPIO [*g*] to mode [*m*], typically input (read)
+or output (write).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+Each GPIO can be configured to be in one of 8 different modes. The modes
+are named Input, Output, ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5.
+
+To set the mode use the code for the mode.
+
+Mode @Input@Output@ALT0@ALT1@ALT2@ALT3@ALT4@ALT5
+Code @ R@ W@ 0@ 1@ 2@ 3@ 4@ 5
+
+...
+$ pigs m 4 r # Input (read)
+$ pigs m 4 w # Output (write)
+$ pigs m 4 0 # ALT 0
+$ pigs m 4 5 # ALT 5
+...
+
+MG/MODEG ::
+
+This command returns the current mode of GPIO [*g*].
+
+Upon success the value of the GPIO mode is returned.
+On error a negative status code will be returned.
+
+Value @ 0@ 1@ 2@ 3@ 4@ 5@ 6@ 7
+Mode @Input@Output@ALT5@ALT4@ALT0@ALT1@ALT2@ALT3
+
+...
+$ pigs mg 4
+1
+...
+
+MICS ::
+This command delays execution for [*v*] microseconds.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The main use of this command is expected to be within [*Scripts*].
+
+...
+$ pigs mics 20 # Delay 20 microseconds.
+$ pigs mics 1000000 # Delay 1 second.
+
+$ pigs mics 2000000
+-64
+ERROR: bad MICS delay (too large)
+...
+
+MILS ::
+
+This command delays execution for [*v*] milliseconds.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs mils 2000 # Delay 2 seconds.
+
+$ pigs mils 61000
+-65
+ERROR: bad MILS delay (too large)
+...
+
+NB ::
+
+This command starts notifications on handle [*h*] returned by
+a prior call to [*NO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The notification gets state changes for each GPIO specified by [*bits*].
+
+...
+$ pigs nb 0 -1 # Shorthand for GPIO 0-31.
+$ pigs nb 0 0xf0 # Get notifications for GPIO 4-7.
+
+$ pigs nb 1 0xf
+-25
+ERROR: unknown handle
+...
+
+NC ::
+
+This command stops notifications on handle [*h*] returned by
+a prior call to [*NO*] and releases the handle for reuse.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs nc 0 # First call succeeds.
+
+$ pigs nc 1 # Second call fails.
+-25
+ERROR: unknown handle
+...
+
+NO ::
+
+This command requests a free notification handle.
+
+A notification is a method for being notified of GPIO state changes via a pipe.
+
+Upon success the command returns a handle greater than or equal to zero.
+On error a negative status code will be returned.
+
+Notifications for handle x will be available at the pipe named /dev/pigpiox
+(where x is the handle number).
+
+E.g. if the command returns 15 then the notifications must be read
+from /dev/pigpio15.
+
+...
+$ pigs no
+0
+...
+
+NP ::
+
+This command pauses notifications on handle [*h*] returned by
+a prior call to [*NO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+Notifications for the handle are suspended until a new [*NB*] command
+is given for the handle.
+
+...
+$ pigs np 0
+...
+
+P/PWM ::
+
+This command starts PWM on GPIO [*u*] with dutycycle [*v*]. The dutycycle
+varies from 0 (off) to range (fully on). The range defaults to 255.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+This and the servo functionality use the DMA and PWM or PCM peripherals
+to control and schedule the pulsewidths and dutycycles.
+
+The [*PRS*] command may be used to change the default range of 255.
+
+...
+$ pigs p 4 64 # Start PWM on GPIO 4 with 25% dutycycle
+$ pigs p 4 128 # 50%
+$ pigs p 4 192 # 75%
+$ pigs p 4 255 # 100%
+...
+
+PADG ::
+
+This command gets the [*pad*] drive strength [*padma*] in mA.
+
+Returns the pad drive strength if OK. On error a negative status code
+will be returned.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+...
+$ pigs padg 0
+8
+$ pigs pads 0 16
+$ pigs padg 0
+16
+pigs padg 3
+-126
+ERROR: bad pad number
+...
+
+PADS::
+
+This command sets the [*pad*] drive strength [*padma*] in mA.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+...
+$ pigs pads 0 16
+$ pigs padg 0
+16
+$ pigs pads 0 17
+-127
+ERROR: bad pad drive strength
+...
+
+PARSE ::
+
+Validates the text [*t*] of a script without storing the script.
+
+Upon success nothing is returned. On error a list of detected
+script errors will be given.
+
+See [*Scripts*].
+
+This command may be used to find script syntax faults.
+
+...
+$ pigs parse tag 100 w 22 1 mils 200 w 22 0 mils 800 jmp 100
+
+$ pigs parse tag 0 w 22 1 mills 50 w 22 0 dcr p10 jp 99
+Unknown command: mills
+Unknown command: 50
+Bad parameter to dcr
+Can't resolve tag 99
+...
+
+PFG ::
+
+This command returns the PWM frequency in Hz used for GPIO [*u*].
+
+Upon success the PWM frequency is returned. On error a negative
+status code will be returned.
+
+For normal PWM the frequency will be that defined for the GPIO
+by [*PFS*].
+
+If a hardware clock is active on the GPIO the reported frequency
+will be that set by [*HC*].
+
+If hardware PWM is active on the GPIO the reported frequency
+will be that set by [*HP*].
+
+...
+$ pigs pfg 4
+800
+
+$ pigs pfg 34
+ERROR: GPIO not 0-31
+-2
+...
+
+PFS ::
+This command sets the PWM frequency [*v*] to be used for GPIO [*u*].
+
+The numerically closest frequency to [*v*] will be selected.
+
+Upon success the new frequency is returned. On error a negative status code
+will be returned.
+
+If PWM is currently active on the GPIO it will be
+switched off and then back on at the new frequency.
+
+Each GPIO can be independently set to one of 18 different PWM
+frequencies.
+
+The selectable frequencies depend upon the sample rate which
+may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
+sample rate is set when the pigpio daemon is started.
+
+The frequencies for each sample rate are:
+
+. .
+ Hertz
+
+ 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
+ 1250 1000 800 500 400 250 200 100 50
+
+ 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
+ 625 500 400 250 200 125 100 50 25
+
+ 4: 10000 5000 2500 2000 1250 1000 625 500 400
+ 313 250 200 125 100 63 50 25 13
+sample
+ rate
+ (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
+ 250 200 160 100 80 50 40 20 10
+
+ 8: 5000 2500 1250 1000 625 500 313 250 200
+ 156 125 100 63 50 31 25 13 6
+
+ 10: 4000 2000 1000 800 500 400 250 200 160
+ 125 100 80 50 40 25 20 10 5
+. .
+
+...
+pigs pfs 4 0 # 0 selects the lowest frequency.
+10
+
+$ pigs pfs 4 1000 # Set 1000Hz PWM.
+1000
+
+$ pigs pfs 4 100000 # Very big number selects the highest frequency.
+8000
+...
+
+PIGPV ::
+
+This command returns the pigpio library version.
+
+...
+$ pigs pigpv
+17
+...
+
+PRG ::
+
+This command returns the dutycycle range for GPIO [*u*].
+
+Upon success the range is returned. On error a negative status code
+will be returned.
+
+If a hardware clock or hardware PWM is active on the GPIO the reported
+range will be 1000000 (1M).
+
+...
+$ pigs prg 4
+255
+...
+
+PROC ::
+
+This command stores a script [*t*] for later execution.
+
+If the script is valid a script id (>=0) is returned which is passed
+to the other script commands. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs proc tag 123 w 4 0 mils 200 w 4 1 mils 300 dcr p0 jp 123
+0
+
+$ pigs proc tag 123 w 4 0 mils 5 w 4 1 mils 5 jmp 12
+ERROR: script has unresolved tag
+-63
+...
+
+PROCD ::
+
+This command deletes script [*sid*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs procd 1
+
+$ pigs procd 1
+ERROR: unknown script id
+-48
+...
+
+PROCP ::
+
+This command returns the status of script [*sid*] as well as the
+current value of its 10 parameters.
+
+Upon success the script status and parameters are returned.
+On error a negative status code will be returned.
+
+The script status may be one of
+
+0 @ being initialised
+1 @ halted
+2 @ running
+3 @ waiting
+4 @ failed
+
+See [*Scripts*].
+
+...
+$ pigs procp 0
+1 0 0 0 0 0 0 0 0 0 0
+...
+
+PROCR ::
+
+This command runs stored script [*sid*] passing it up to 10 optional
+parameters.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs proc tag 123 w 4 0 mils 200 w 4 1 mils 300 dcr p0 jp 123
+0
+
+$ pigs procr 0 50 # Run script 0 with parameter 0 of 50.
+
+$ pigs procp 0
+2 44 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+2 37 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+2 10 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+2 5 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+2 2 0 0 0 0 0 0 0 0 0
+$ pigs procp 0
+1 -1 0 0 0 0 0 0 0 0 0
+...
+
+PROCS ::
+
+This command stops a running script [*sid*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs procs 0
+
+$ pigs procs 1
+-48
+ERROR: unknown script id
+...
+
+PROCU ::
+
+This command sets the parameters of a stored script [*sid*] passing
+it up to 10 parameters.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+See [*Scripts*].
+
+...
+$ pigs proc tag 0 hp 18 p0 p1 mils 1000 jmp 0
+0
+$ pigs procu 0 50 500000
+$ pigs procr 0
+$ pigs procu 0 100
+$ pigs procu 0 200
+$ pigs procu 0 200 100000
+...
+
+PRRG ::
+
+This command returns the real underlying range used by GPIO [*u*].
+
+If a hardware clock is active on the GPIO the reported
+real range will be 1000000 (1M).
+
+If hardware PWM is active on the GPIO the reported real range
+will be approximately 250M divided by the set PWM frequency.
+
+On error a negative status code will be returned.
+
+See [*PRS*].
+
+...
+$ pigs prrg 17
+250
+
+$ pigs pfs 17 0
+10
+$ pigs prrg 17
+20000
+
+$ pigs pfs 17 100000
+8000
+$ pigs prrg 17
+25
+...
+
+PRS ::
+
+This command sets the dutycycle range [*v*] to be used for GPIO [*u*].
+Subsequent uses of command [*P/PWM*] will use a dutycycle between 0 (off)
+and [*v*] (fully on).
+
+Upon success the real underlying range used by the GPIO is returned.
+On error a negative status code will be returned.
+
+If PWM is currently active on the GPIO its dutycycle will be scaled to
+reflect the new range.
+
+The real range, the number of steps between fully off and fully on
+for each frequency, is given in the following table.
+
+ #1@ #2@ #3@ #4@ #5@ #6@ #7@ #8@ #9
+ 25@ 50@ 100@ 125@ 200@ 250@ 400@ 500@ 625
+ @ @ @ @ @ @ @ @
+#10@ #11@ #12@ #13@ #14@ #15@ #16@ #17@ #18
+800@1000@1250@2000@2500@4000@5000@10000@20000
+
+The real value set by [*PRS*] is (dutycycle * real range) / range.
+
+See [*PRRG*]
+
+...
+$ pigs prs 18 1000
+250
+...
+
+PUD ::
+
+This command sets the internal pull/up down for GPIO [*g*] to mode [*p*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The mode may be pull-down (D), pull-up (U), or off (O).
+
+...
+$ pigs pud 4 d # Set pull-down on GPIO 4.
+$ pigs pud 4 u # Set pull-up on GPIO 4.
+$ pigs pud 4 o # No pull-up/down on GPIO 4.
+...
+
+R/READ ::
+
+This reads the current level of GPIO [*g*].
+
+Upon success the current level is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs r 17 # Get level of GPIO 17.
+0
+
+$ pigs r 4 # Get level of GPIO 4.
+1
+...
+
+S/SERVO ::
+
+This command starts servo pulses of [*v*] microseconds on GPIO [*u*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The servo pulsewidth may be 0 (off), 500 (most anti-clockwise)
+to 2500 (most clockwise).
+
+The range supported by servos varies and should probably be determined
+by experiment. Generally values between 1000-2000 should be safe.
+A value of 1500 should always be safe and represents
+the mid-point of rotation.
+
+You can DAMAGE a servo if you command it to move beyond its limits.
+
+...
+$ pigs SERVO 17 1500
+...
+
+This example causes an on pulse of 1500 microseconds duration to be
+transmitted on GPIO 17 at a rate of 50 times per second.
+
+This will command a servo connected to GPIO 17 to rotate to its mid-point.
+
+...
+pigs s 17 0 # Switch servo pulses off.
+...
+
+SERC ::
+
+This command closes a serial handle [*h*] previously opened with [*SERO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs serc 0 # First close okay.
+
+$ pigs serc 0 # Second close gives error.
+-25
+ERROR: unknown handle
+...
+
+SERDA ::
+
+This command returns the number of bytes of data available
+to be read from the serial device associated with handle [*h*].
+
+Upon success the count of bytes available to be read is
+returned (which may be 0). On error a negative status code
+will be returned.
+
+...
+$ pigs serda 0
+0
+...
+
+SERO::
+
+This command opens the serial [*dev*] at [*b*] bits per second.
+
+No flags are currently defined. [*sef*] should be set to zero.
+
+Upon success a handle (>=0) is returned. On error a negative status code
+will be returned.
+
+The device name must start with /dev/tty or /dev/serial.
+
+
+The baud rate must be one of 50, 75, 110, 134, 150,
+200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
+38400, 57600, 115200, or 230400.
+
+...
+$ pigs sero /dev/ttyAMA0 9600 0
+0
+
+$ pigs sero /dev/tty1 38400 0
+1
+...
+
+SERR::
+
+This command returns up to [*num*] bytes of data read from the
+serial device associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs serr 0 10
+5 48 49 128 144 255
+
+$ pigs serr 0 10
+0
+...
+
+SERRB::
+
+This command returns a byte of data read from the serial
+device associated with handle [*h*].
+
+Upon success a number between 0 and 255 is returned.
+On error a negative status code will be returned.
+
+...
+$ pigs serrb 0
+23
+$ pigs serrb 0
+45
+...
+
+SERW::
+
+This command writes bytes [*bvs*] to the serial device
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs serw 0 23 45 67 89
+...
+
+SERWB::
+
+This command writes a single byte [*bv*] to the serial device
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs serwb 0 23
+$ pigs serwb 0 0xf0
+...
+
+SHELL ::
+
+This command uses the system call to execute a shell script [*name*]
+with the given string [*str*] as its parameter.
+
+The exit status of the system call is returned if OK, otherwise
+PI_BAD_SHELL_STATUS.
+
+[*name*] must exist in /opt/pigpio/cgi and must be executable.
+
+The returned exit status is normally 256 times that set
+by the shell script exit function. If the script can't
+be found 32512 will be returned.
+
+The following table gives some example returned statuses.
+
+Script exit status @ Returned system call status
+1 @ 256
+5 @ 1280
+10 @ 2560
+200 @ 51200
+script not found @ 32512
+
+...
+# pass two parameters, hello and world
+$ pigs shell scr1 hello world
+256
+
+# pass three parameters, hello, string with spaces, and world
+$ pigs shell scr1 "hello 'string with spaces' world"
+256
+
+# pass one parameter, hello string with spaces world
+$ pigs shell scr1 "\"hello string with spaces world\""
+256
+
+# non-existent script
+$ pigs shell scr78 par1
+32512
+...
+
+SLR ::
+
+This command returns up to [*num*] bytes of bit bang serial data
+read from GPIO [*u*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+The GPIO [*u*] should have been initialised with the [*SLRO*] command.
+
+The bytes returned for each character depend upon the number of
+data bits [*db*] specified in the [*SLRO*] command.
+
+For [*db*] 1-8 there will be one byte per character.
+For [*db*] 9-16 there will be two bytes per character.
+For [*db*] 17-32 there will be four bytes per character.
+
+...
+$ pigs slr 15 20
+6 1 0 23 45 89 0
+...
+
+SLRC ::
+
+This command closes GPIO [*u*] for reading bit bang serial data.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs slrc 23
+
+$ pigs slrc 23
+-38
+ERROR: no serial read in progress on GPIO
+...
+
+SLRI ::
+
+This command sets the logic level for reading bit bang serial data
+on GPIO [*u*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The invert parameter [*v*] is 1 for inverted signal, 0 for normal.
+
+...
+$ pigs slri 17 1 # invert logic on GPIO 17
+
+$ pigs slri 23 0 # use normal logic on GPIO 23
+...
+
+SLRO ::
+
+This command opens GPIO [*u*] for reading bit bang serial data
+at [*b*] baud and [*db*] data bits.
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The baud rate may be between 50 and 250000 bits per second.
+
+The received data is held in a cyclic buffer.
+
+It is the user's responsibility to read the data (with [*SLR*])
+in a timely fashion.
+
+...
+$ pigs slro 23 19200 8
+
+$ pigs slro 23 19200 8
+-50
+ERROR: GPIO already in use
+...
+
+SPIC ::
+
+This command closes the SPI handle [*h*] returned by a prior
+call to [*SPIO*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs spic 1
+
+$ pigs spic 1
+-25
+ERROR: unknown handle
+...
+
+SPIO ::
+
+This command returns a handle to a SPI device on channel [*c*].
+
+Data will be transferred at [*b*] bits per second. The flags [*spf*]
+may be used to modify the default behaviour of 4-wire operation,
+mode 0, active low chip select.
+
+Speeds between 32kbps and 125Mbps are allowed. Speeds above 30Mbps
+are unlikely to work.
+
+The Pi has two SPI peripherals: main and auxiliary.
+
+The main SPI has two chip selects (channels), the auxiliary has
+three.
+
+The auxiliary SPI is available on all models but the A and B.
+
+The GPIO used are given in the following table.
+
+ @ MISO @ MOSI @ SCLK @ CE0 @ CE1 @ CE2
+Main SPI @ 9 @ 10 @ 11 @ 8 @ 7 @ -
+Aux SPI @ 19 @ 20 @ 21 @ 18 @ 17 @ 16
+
+The flags consists of the least significant 22 bits.
+
+. .
+21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m
+. .
+
+mm defines the SPI mode.
+
+Warning: modes 1 and 3 do not appear to work on the auxiliary SPI.
+
+. .
+Mode POL PHA
+ 0 0 0
+ 1 0 1
+ 2 1 0
+ 3 1 1
+. .
+
+px is 0 if CEx is active low (default) and 1 for active high.
+
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
+
+A is 0 for the main SPI, 1 for the auxiliary SPI.
+
+W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Main
+SPI only.
+
+nnnn defines the number of bytes (0-15) to write before switching
+the MOSI line to MISO to read data. This field is ignored
+if W is not set. Main SPI only.
+
+T is 1 if the least significant bit is transmitted on MOSI first, the
+default (0) shifts the most significant bit out first. Auxiliary SPI
+only.
+
+R is 1 if the least significant bit is received on MISO first, the
+default (0) receives the most significant bit first. Auxiliary SPI
+only.
+
+bbbbbb defines the word size in bits (0-32). The default (0)
+sets 8 bits per word. Auxiliary SPI only.
+
+The [*SPIR*], [*SPIW*], and [*SPIX*] commands transfer data
+packed into 1, 2, or 4 bytes according to the word size in bits.
+
+For bits 1-8 there will be one byte per character.
+For bits 9-16 there will be two bytes per character.
+For bits 17-32 there will be four bytes per character.
+
+Multi-byte transfers are made in least significant byte first order.
+
+E.g. to transfer 32 11-bit words 64 bytes need to be sent.
+
+E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed
+by 0x1A.
+
+The other bits in flags should be set to zero.
+
+Upon success a handle (>=0) is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs spio 0 100000 3 # Open channel 0 at 100kbps in mode 3.
+0
+
+$ pigs spio 0 32000 256 # Open channel 0 of auxiliary spi at 32kbps.
+1
+...
+
+SPIR ::
+
+This command returns [*num*] bytes read from the SPI device
+associated with handle [*h*].
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs spir 0 10 # Read 10 bytes from the SPI device.
+10 0 0 0 0 0 0 0 0 0 0
+...
+
+SPIW ::
+
+This command writes bytes [*bvs*] to the SPI device
+associated with handle [*h*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs spiw 0 0x22 0x33 0xcc 0xff
+...
+
+SPIX::
+
+This command writes bytes [*bvs*] to the SPI device
+associated with handle [*h*]. It returns the same
+number of bytes read from the device.
+
+Upon success the count of returned bytes followed by the bytes themselves
+is returned. On error a negative status code will be returned.
+
+...
+$ pigs spix 0 0x22 0x33 0xcc 0xff
+4 0 0 0 0
+...
+
+T/TICK ::
+
+This command returns the current system tick.
+
+Tick is the number of microseconds since system boot.
+
+As tick is an unsigned 32 bit quantity it wraps around after 2^32 microseconds,
+which is approximately 1 hour 12 minutes.
+
+...
+$ pigs t mils 1000 t
+3691823946
+3692833987
+...
+
+TRIG ::
+
+This command sends a trigger pulse of [*pl*] microseconds at level [*L*]
+to GPIO [*u*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The GPIO is set to not level at the end of the pulse.
+
+...
+$ pigs trig 4 10 1
+
+$ pigs trig 4 51 1
+-46
+ERROR: trigger pulse > 50 microseconds
+...
+
+W/WRITE ::
+
+This command sets GPIO [*g*] to level [*L*]. The level may be 0
+(low, off, clear) or 1 (high, on, set).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs w 23 0
+$ pigs w 23 1
+
+$ pigs w 23 2
+-5
+ERROR: level not 0-1
+...
+
+WDOG ::
+
+This command sets a watchdog of [*v*] milliseconds on GPIO [*u*].
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+The watchdog is nominally in milliseconds.
+
+One watchdog may be registered per GPIO.
+
+The watchdog may be cancelled by setting timeout to 0.
+
+Once a watchdog has been started monitors of the GPIO
+will be triggered every timeout interval after the last
+GPIO activity. The watchdog expiry will be indicated by
+a special TIMEOUT value.
+
+...
+$ pigs wdog 23 90000
+-15
+ERROR: timeout not 0-60000
+
+$ pigs wdog 23 9000
+...
+
+This example causes a report to be written to any notification pipes
+listening on GPIO 23 whenever GPIO 23 changes state or approximately
+every 9000 ms.
+
+WVAG ::
+
+This command adds 1 one or more triplets [*trips*] of GPIO on, GPIO off,
+delay to the existing waveform (if any).
+
+Upon success the total number of pulses in the waveform so far is
+returned. On error a negative status code will be returned.
+
+The triplets will be added at the start of the existing waveform. If
+they are to start offset from the start then the first triplet should
+consist solely of a delay i.e. 0 0 offset.
+
+...
+$ pigs wvag 0x10 0x80 1000 0x80 0x10 9000
+2
+
+$ pigs wvag 0 0 10000 0x10 0x80 1000 0x80 0x10 9000
+4
+...
+
+WVAS ::
+
+This command adds a waveform representing serial data [*bvs*] to
+GPIO [*u*] at [*b*] baud to the existing waveform (if any).
+The serial data starts [*o*] microseconds from the start of the
+waveform.
+
+Upon success the total number of pulses in the waveform so far is
+returned. On error a negative status code will be returned.
+
+The serial data is formatted as one start bit, [*db*] data bits, and
+[*sb*]/2 stop bits.
+
+The baud rate may be between 50 and 1000000 bits per second.
+
+It is legal to add serial data streams with different baud rates to
+the same waveform.
+
+The bytes required for each character depend upon [*db*].
+
+For [*db*] 1-8 there will be one byte per character.
+For [*db*] 9-16 there will be two bytes per character.
+For [*db*] 17-32 there will be four bytes per character.
+
+...
+$ pigs wvas 4 9600 8 2 0 0x30 0x31 0x32 0x33
+23
+
+$ pigs wvas 7 38400 8 2 0 0x41 0x42
+35
+...
+
+WVTAT ::
+
+This command returns the id of the waveform currently
+being transmitted. Chained waves are not supported.
+
+Returns the waveform id or one of the following special
+values:
+
+9998 - transmitted wave not found
+9999 - no wave being transmitted
+
+...
+$ pigs wvtat
+9999
+...
+
+WVBSY ::
+
+This command checks to see if a waveform is currently being transmitted.
+
+Returns 1 if a waveform is currently being transmitted, otherwise 0.
+
+...
+$ pigs wvbsy
+0
+...
+
+WVCHA ::
+
+This command transmits a chain of waveforms.
+
+NOTE: Any hardware PWM started by [*HP*] will
+be cancelled.
+
+The waves to be transmitted are specified by the contents of
+[*bvs*] which contains an ordered list of wave_ids and optional
+command codes and related data.
+
+Upon success 0 is returned. On error a negative status code
+will be returned.
+
+Each wave is transmitted in the order specified. A wave may
+occur multiple times per chain.
+
+A blocks of waves may be transmitted multiple times by using
+the loop commands. The block is bracketed by loop start and
+end commands. Loops may be nested.
+
+Delays between waves may be added with the delay command.
+
+The following command codes are supported:
+
+Name @ Cmd & Data @ Meaning
+Loop Start @ 255 0 @ Identify start of a wave block
+Loop Repeat @ 255 1 x y @ loop x + y*256 times
+Delay @ 255 2 x y @ delay x + y*256 microseconds
+Loop Forever @ 255 3 @ loop forever
+
+If present Loop Forever must be the last entry in the chain.
+
+The code is currently dimensioned to support a chain with roughly
+600 entries and 20 loop counters.
+
+...
+#!/bin/bash
+
+GPIO=4
+WAVES=5
+
+pigs m $GPIO w
+
+for ((i=0; i<$WAVES; i++))
+do
+ pigs wvag $((1<<GPIO)) 0 20 0 $((1<<GPIO)) $(((i+1)*200))
+ w[i]=$(pigs wvcre)
+done
+
+# transmit waves 4+3+2
+# loop start
+# transmit waves 0+0+0
+# loop start
+# transmit waves 0+1
+# delay 5000us
+# loop end (repeat 30 times)
+# loop start
+# transmit waves 2+3+0
+# transmit waves 3+1+2
+# loop end (repeat 10 times)
+# loop end (repeat 5 times)
+# transmit waves 4+4+4
+# delay 20000us
+# transmit waves 0+0+0
+
+pigs wvcha \
+ ${w[4]} ${w[3]} ${w[2]} \
+ 255 0 \
+ ${w[0]} ${w[0]} ${w[0]} \
+ 255 0 \
+ ${w[0]} ${w[1]} \
+ 255 2 0x88 0x13 \
+ 255 1 30 0 \
+ 255 0 \
+ ${w[2]} ${w[3]} ${w[0]} \
+ ${w[3]} ${w[1]} ${w[2]} \
+ 255 1 10 0 \
+ 255 1 5 0 \
+ ${w[4]} ${w[4]} ${w[4]} \
+ 255 2 0x20 0x4E \
+ ${w[0]} ${w[0]} ${w[0]}
+
+while [[ $(pigs wvbsy) -eq 1 ]]; do sleep 0.1; done
+
+for ((i=0; i<$WAVES; i++)); do echo ${w[i]}; pigs wvdel ${w[i]}; done
+...
+
+WVCLR ::
+
+This command clears all waveforms.
+
+Nothing is returned.
+
+...
+$ pigs wvclr
+...
+
+WVCRE ::
+
+This command creates a waveform from the data provided by the prior
+calls to the [*WVAG*] and [*WVAS*] commands.
+
+Upon success a wave id (>=0) is returned. On error a negative status
+code will be returned.
+
+The data provided by the [*WVAG*] and [*WVAS*] commands is
+consumed by this command.
+
+As many waveforms may be created as there is space available.
+The wave id is passed to [*WVTX*] or [*WVTXR*] to specify the
+waveform to transmit.
+
+Normal usage would be
+
+Step 1. [*WVCLR*] to clear all waveforms and added data.
+
+Step 2. [*WVAG*]/[*WVAS*] calls to supply the waveform data.
+
+Step 3. [*WVCRE*] to create the waveform and get a unique id.
+
+Repeat steps 2 and 3 as needed.
+
+Step 4. [*WVTX*] or [*WVTXR*] with the id of the waveform to transmit.
+
+A waveform comprises of one or more pulses.
+
+A pulse specifies
+
+1) the GPIO to be switched on at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
+3) the delay in microseconds before the next pulse.
+
+Any or all the fields can be zero. It doesn't make any sense to
+set all the fields to zero (the pulse will be ignored).
+
+When a waveform is started each pulse is executed in order with
+the specified delay between the pulse and the next.
+
+...
+$ pigs wvas 4 9600 0 23 45 67 89 90
+37
+$ pigs wvcre
+0
+
+$ pigs wvcre
+-69
+ERROR: attempt to create an empty waveform
+...
+
+WVCAP ::
+
+Create a waveform of fixed size. Similar to [*WVCRE*], this command creates a waveform but pads the consumed resources to a fixed size, specified as a [*percent*] of the total resources. Padded waves of equal size can be re-cycled efficiently allowing newly created waves to re-use the resources of deleted waves of the same dimension.
+
+Upon success a wave id (>=0) is returned. On error a negative status code will be returned.
+
+The data provided by the [*WVAG*] and [*WVAS*] commands are consumed by this command.
+
+As many waveforms may be created as there is space available. The wave id is passed to [*WVTX*] or [*WVTXR*] to specify the waveform to transmit.
+
+Normal usage would be
+
+Step 1. [*WVCLR*] to clear all waveforms and added data.
+
+Step 2. [*WVAG*]/[*WVAS*] calls to supply the waveform data.
+
+Step 3. [*WVCAP*] to create a waveform of a uniform size.
+
+Step 4. [*WVTX*] or [*WVTXR*] with the id of the waveform to transmit.
+
+Repeat steps 2 - 4 as needed.
+
+Step 5. Any wave id can now be deleted and another wave of the same size can be created in its place.
+
+Example
+
+...
+# Create a wave that consumes 50% of the total resource:
+
+$ pigs wvag 16 0 5000000 0 16 5000000
+2
+$ pigs wvcap 50
+0
+$ pigs wvtx 0
+11918
+...
+
+WVDEL ::
+
+This command deletes the waveform with id [*wid*].
+
+The wave is flagged for deletion. The resources used by the wave
+will only be reused when either of the following apply.
+
+- all waves with higher numbered wave ids have been deleted or have
+been flagged for deletion.
+
+- a new wave is created which uses exactly the same resources as
+the current wave (see the C source for gpioWaveCreate for details).
+
+Upon success nothing is returned. On error a negative status code
+will be returned.
+
+...
+$ pigs wvdel 0
+
+$ pigs wvdel 0
+-66
+ERROR: non existent wave id
+...
+
+WVHLT ::
+
+This command aborts the transmission of the current waveform.
+
+Nothing is returned.
+
+This command is intended to stop a waveform started in the repeat mode.
+
+...
+$ pigs wvhlt
+...
+
+WVNEW ::
+
+This clears any existing waveform data ready for the creation of a new
+waveform.
+
+Nothing is returned.
+
+...
+$ pigs wvnew
+...
+
+WVSC ::
+
+The statistic requested by [*ws*] is returned.
+
+[*ws*] identifies the subcommand as follows.
+
+0 Get Cbs
+1 Get High Cbs
+2 Get Max Cbs
+
+...
+$ pigs wvas 4 9600 0 23 45 67 89 90
+37
+
+$ pigs wvsc 0
+74
+$ pigs wvsc 1
+74
+$ pigs wvsc 2
+25016
+...
+
+WVSM ::
+
+The statistic requested by [*ws*] is returned.
+
+[*ws*] identifies the subcommand as follows.
+
+0 Get Micros
+1 Get High Micros
+2 Get Max Micros
+
+...
+$ pigs wvsm 0
+5314
+$ pigs wvsm 1
+5314
+$ pigs wvsm 2
+1800000000
+...
+
+WVSP ::
+
+The statistic requested by [*ws*] is returned.
+
+[*ws*] identifies the subcommand as follows.
+
+0 Get Pulses
+1 Get High Pulses
+2 Get Max Pulses
+
+...
+$ pigs wvsp 0
+37
+$ pigs wvsp 1
+37
+$ pigs wvsp 2
+12000
+...
+
+WVTX ::
+
+This command transmits the waveform with id [*wid*] once.
+
+NOTE: Any hardware PWM started by [*HP*] will be cancelled.
+
+Upon success the number of DMA control blocks in the waveform is returned.
+On error a negative status code will be returned.
+
+...
+$ pigs wvtx 1
+75
+
+$ pigs wvtx 2
+-66
+ERROR: non existent wave id
+...
+
+WVTXM ::
+
+This command transmits the waveform with id [*wid*] using mode [*wmde*].
+
+The mode may be send once (0), send repeatedly (1), send once but
+first sync with previous wave (2), or send repeatedly but first
+sync with previous wave (3).
+
+WARNING: bad things may happen if you delete the previous
+waveform before it has been synced to the new waveform.
+
+NOTE: Any hardware PWM started by [*HP*] will be cancelled.
+
+Upon success the number of DMA control blocks in the waveform is returned.
+On error a negative status code will be returned.
+
+...
+$ pigs wvtxm 1 3
+75
+
+$ pigs wvtxm 2 0
+-66
+ERROR: non existent wave id
+...
+
+WVTXR ::
+
+This command transmits the waveform with id [*wid*] repeatedly.
+
+NOTE: Any hardware PWM started by [*HP*] will be cancelled.
+
+Upon success the number of DMA control blocks in the waveform is returned.
+On error a negative status code will be returned.
+
+...
+$ pigs wvtxr 1
+75
+
+$ pigs wvtxr 2
+-66
+ERROR: non existent wave id
+...
+
+PARAMETERS
+
+actv :: 0-1000000
+
+The number of microseconds level changes are reported for once
+a noise filter has been triggered (by [*stdy*] microseconds of
+a stable level).
+
+b :: baud
+The command expects the baud rate in bits per second for
+the transmission of serial data (I2C/SPI/serial link, waves).
+
+bctl :: BSC control word
+The command expects a BSC control word, see [*BSCX*].
+
+bit :: bit value (0-1)
+The command expects 0 or 1.
+
+bits :: a bit mask
+A mask is used to select one or more GPIO. A GPIO is selected
+if bit (1<<GPIO) is set in the mask.
+
+E.g. a mask of 6 (binary 110) select GPIO 1 and 2, a mask of
+0x103 (binary 100000011) selects GPIO 0, 1, and 8.
+
+bv :: a byte value (0-255)
+The command expects a byte value.
+
+bvs :: byte values (0-255)
+The command expects one or more byte values.
+
+c :: SPI channel (0-1)
+The command expects a SPI channel.
+
+cf :: hardware clock frequency (4689-250M, 13184-375M for the BCM2711)
+The command expects a frequency.
+
+cs :: GPIO (0-31)
+The GPIO used for the slave select signal when bit banging SPI.
+
+db :: serial data bits (1-32)
+The command expects the number of data bits per serial character.
+
+dev :: a tty serial device (/dev/tty* or /dev/serial*)
+The command expects the name of a tty serial device, e.g.
+
+...
+/dev/ttyAMA0
+/dev/ttyUSB0
+/dev/tty0
+/dev/serial0
+...
+
+event :: 0-31
+An event is a signal used to inform one or more consumers
+to start an action.
+
+file :: a file name
+The file name must match an entry in /opt/pigpio/access.
+
+from :: 0-2
+Position to seek from [*FS*].
+
+ @ From
+0 @ start
+1 @ current position
+2 @ end
+
+g :: GPIO (0-53)
+The command expects a GPIO.
+
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through gpio53.
+
+They are split into two banks. Bank 1 consists of gpio0 through gpio31.
+Bank 2 consists of gpio32 through gpio53.
+
+All the GPIO which are safe for the user to read and write are in bank 1.
+Not all GPIO in bank 1 are safe though. Type 1 boards have 17 safe GPIO.
+Type 2 boards have 21. Type 3 boards have 26.
+
+See [*HWVER*].
+
+The user GPIO are marked with an X in the following table.
+
+ @ 0@ 1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@10@11@12@13@14@15
+Type 1 @ X@ X@ -@ -@ X@ -@ -@ X@ X@ X@ X@ X@ -@ -@ X@ X
+Type 2 @ -@ -@ X@ X@ X@ -@ -@ X@ X@ X@ X@ X@ -@ -@ X@ X
+Type 3 @ @ @ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X
+ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
+ @16@17@18@19@20@21@22@23@24@25@26@27@28@29@30@31
+Type 1 @ -@ X@ X@ -@ -@ X@ X@ X@ X@ X@ -@ -@ -@ -@ -@ -
+Type 2 @ -@ X@ X@ -@ -@ -@ X@ X@ X@ X@ -@ X@ X@ X@ X@ X
+Type 3 @ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ X@ -@ -@ -@ -
+
+You are not prevented from writing to unsafe GPIO. The consequences
+of doing so range from no effect, to a crash, or corrupted data.
+
+h :: handle (>=0)
+The command expects a handle.
+
+A handle is a number referencing an object opened by one of [*FO*],
+[*I2CO*], [*NO*], [*SERO*], [*SPIO*].
+
+ib :: I2C bus (>=0)
+The command expects an I2C bus number.
+
+id :: I2C device (0-0x7F)
+The command expects the address of an I2C device.
+
+if :: I2C flags (0)
+The command expects an I2C flags value. No flags are currently defined.
+
+L :: level (0-1)
+The command expects a GPIO level.
+
+m :: mode (RW540123)
+The command expects a mode character.
+
+Each GPIO can be configured to be in one of 8 different modes. The modes
+are named Input, Output, ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5.
+
+To set the mode use the code for the mode.
+
+The value is returned by the mode get command.
+
+Mode @ Input @ Output @ ALT0 @ ALT1 @ ALT2 @ ALT3 @ ALT4 @ ALT5
+Code @ R @ W @ 0 @ 1 @ 2 @ 3 @ 4 @ 5
+Value @ 0 @ 1 @ 4 @ 5 @ 6 @ 7 @ 3 @ 2
+
+miso :: GPIO (0-31)
+The GPIO used for the MISO signal when bit banging SPI.
+
+mode :: file open mode
+One of the following values.
+
+ @ Value @ Meaning
+READ @ 1 @ open file for reading
+WRITE @ 2 @ open file for writing
+RW @ 3 @ open file for reading and writing
+
+The following values can be or'd into the mode.
+
+ @ Value @ Meaning
+APPEND @ 4 @ All writes append data to the end of the file
+CREATE @ 8 @ The file is created if it doesn't exist
+TRUNC @ 16 @ The file is truncated
+
+mosi :: GPIO (0-31)
+The GPIO used for the MOSI signal when bit banging SPI.
+
+name :: the name of a script
+Only alphanumeric characters, '-' and '_' are allowed in the name.
+
+num :: maximum number of bytes to return (1-)
+The command expects the maximum number of bytes to return.
+
+For the I2C and SPI commands the requested number of bytes will always
+be returned.
+
+For the serial and file commands the smaller of the number of
+bytes available to be read (which may be zero) and [*num*] bytes
+will be returned.
+
+o :: offset (>=0)
+Serial data is stored offset microseconds from the start of the waveform.
+
+p :: PUD (ODU)
+The command expects a PUD character.
+
+Each GPIO can be configured to use or not use an internal pull up or
+pull down resistor. This is useful to provide a default state for inputs.
+
+A pull up will default the input to 1 (high).
+
+A pull down will default the input to 0 (low).
+
+To set the pull up down state use the command character for the state.
+
+Pull Up Down @Off@Pull Down@Pull Up
+Command Character@ O@ D@ U
+
+There is no mechanism to read the pull up down state.
+
+pad :: 0-2
+A set of GPIO which share common drivers.
+
+Pad @ GPIO
+0 @ 0-27
+1 @ 28-45
+2 @ 46-53
+
+padma:: 1-16
+The mA which may be drawn from each GPIO whilst still guaranteeing the
+high and low levels.
+
+pars :: script parameters
+The command expects 0 to 10 numbers as parameters to be passed to the script.
+
+pat :: a file name pattern
+A file path which may contain wildcards. To be accessible the path
+must match an entry in /opt/pigpio/access.
+
+pdc :: hardware PWM dutycycle (0-1000000)
+The command expects a dutycycle.
+
+percent :: percent (1-100)
+The percent of wave resources to allocate to a wave. It can be useful
+to create waves of fixed sizes to prevent wave fragmentation (where
+there are plenty of resources but not a large enough contiguous space).
+
+pf :: hardware PWM frequency (1-125M, 1-187.5M for the BCM2711)
+The command expects a frequency.
+
+pl :: pulse length (1-100)
+The command expects a pulse length in microseconds.
+
+r :: register (0-255)
+The command expects an I2C register number.
+
+sb :: serial stop (half) bits (2-8)
+The command expects the number of stop (half) bits per serial character.
+
+scl :: user GPIO (0-31)
+The command expects the number of the GPIO to be used for SCL
+when bit banging I2C.
+
+sclk :: user GPIO (0-31)
+The GPIO used for the SCLK signal when bit banging SPI.
+
+sda :: user GPIO (0-31)
+The command expects the number of the GPIO to be used for SDA
+when bit banging I2C.
+
+sef :: serial flags (32 bits)
+The command expects a flag value. No serial flags are currently defined.
+
+sid :: script id (>= 0)
+The command expects a script id as returned by a call to [*PROC*].
+
+spf :: SPI flags (32 bits)
+See [*SPIO*] and [*BSPIO*].
+
+stdy :: 0-300000
+
+The number of microseconds level changes must be stable for
+before reporting the level changed ([*FG*]) or triggering
+the active part of a noise filter ([*FN*]).
+
+str :: a string
+The command expects a string.
+
+t :: a string
+The command expects a string.
+
+trips :: triplets
+The command expects 1 or more triplets of GPIO on, GPIO off, delay.
+
+E.g. 0x400000 0 100000 0 0x400000 900000 defines two pulses as follows
+
+ GPIO on @ GPIO off @ delay
+0x400000 (GPIO 22)@ 0 (None)@100000 (1/10th s)
+ 0 (None)@0x400000 (GPIO 22)@900000 (9/10th s)
+
+u :: user GPIO (0-31)
+The command expects the number of a user GPIO.
+
+A number of commands are restricted to GPIO in bank 1,
+in particular the PWM commands, the servo command,
+the watchdog command, and the notification command.
+
+It is your responsibility to ensure that the PWM and servo commands
+are only used on safe GPIO.
+
+See [*g*]
+
+uvs :: values
+The command expects an arbitrary number of >=0 values (possibly none).
+Any after the first two must be <= 255.
+
+v :: value
+The command expects a number.
+
+wid :: wave id (>=0)
+The command expects a wave id.
+
+When a waveform is created it is given an id (0, 1, 2, ...).
+
+wmde :: mode (0-3)
+The command expects a wave transmission mode.
+
+0 = send once
+1 = send repeatedly
+2 = send once but first sync with previous wave
+3 = send repeatedly but first sync with previous wave
+
+ws :: wave stats sucommand (0-2)
+The command expects a subcommand.
+
+0 = current value.
+1 = highest value so far.
+2 = maximum possible value.
+
+wv :: word value (0-65535)
+The command expects a word value.
+
+SCRIPTS
+
+Scripts are programs to be stored and executed by the pigpio daemon.
+They are intended to mitigate any performance problems associated with
+the pigpio daemon server/client model.
+
+*Example*
+
+A trivial example might be useful. Suppose you want to toggle a GPIO
+on and off as fast as possible.
+
+From the command line you could write
+
+...
+for ((i=0; i<1000;i++)); do pigs w 22 1 w 22 0; done
+...
+
+Timing that you will see it takes about 14 seconds, or roughly
+70 toggles per second.
+
+Using the pigpio Python module you could use code such as
+
+...
+#!/usr/bin/env python
+
+import time
+
+import pigpio
+
+PIN=4
+
+TOGGLE=10000
+
+pi = pigpio.pi() # Connect to local Pi.
+
+s = time.time()
+
+for i in range(TOGGLE):
+ pi.write(PIN, 1)
+ pi.write(PIN, 0)
+
+e = time.time()
+
+print("pigpio did {} toggles per second".format(int(TOGGLE/(e-s))))
+
+pi.stop()
+...
+
+Timing that shows a speed improvement to roughly 800 toggles per second.
+
+Now let's use a script.
+
+...
+pigs proc tag 999 w 22 1 w 22 0 dcr p0 jp 999
+...
+
+Ignore the details for now.
+
+Let's time the script running.
+
+Again, ignore the details for now.
+
+...
+time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\
+ do sleep 0.2; done)
+...
+
+The script takes roughly 12 seconds to complete, or 800,000 toggles per second.
+
+That is the advantage of a stored script.
+
+Some details.
+
+...
+pigs proc tag 999 w 22 1 w 22 0 dcr p0 jp 999
+...
+
+proc introduces a script. Everything after proc is part of the script.
+tag 999 names the current position in the script.
+w 22 1 writes 1 to GPIO 22.
+w 22 0 writes 0 to GPIO 22.
+dcr p0 decrements parameter 0.
+jp 999 jumps to tag 999 if the result is positive.
+
+...
+time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\
+ do sleep 0.2; done)
+...
+
+pigs procr 0 10000000 starts script 0 with parameter 0 of 10 million.
+
+The rest is bash apart from
+
+pigs procp 0 asks for the status and parameters of script 0.
+The status will be 2 while the script is running and 1 when it is complete.
+
+*Virtual machine*
+
+A script runs within a virtual machine with
+
+a 32 bit accumulator A.
+a flags register F.
+a program counter PC.
+
+Each script has
+
+10 parameters named 0 through 9.
+150 variables named 0 through 149.
+50 labels which are named by any unique number.
+
+*Commands*
+
+Many pigpio commands may be used within a script. However
+some commands do not work within the script model as designed and
+are not permitted.
+
+The following commands are not permitted within a script:
+
+File - FL FO FR FW
+
+I2C - BI2CZ I2CPK I2CRD I2CRI I2CRK I2CWD I2CWI I2CWK I2CZ
+
+Misc - BSCX CF1 CF2 SHELL
+
+Script control - PARSE PROC PROCD PROCP PROCR PROCS PROCU
+
+Serial - SERO SERR SERW SLR
+
+SPI - BSPIO BSPIX SPIR SPIW SPIX
+
+Waves - WVAG WVAS WVCHA WVGO WVGOR
+
+The following commands are only permitted within a script:
+
+Command@Description @Definition
+ADD x @Add x to accumulator @A+=x; F=A
+AND x @And x with accumulator @A&=x; F=A
+CALL L @Call subroutine at tag L @push(PC+1); PC=L
+CMP x @Compare x with accumulator @F=A-x
+DCR y @Decrement register @--*y; F=*y
+DCRA @Decrement accumulator @--A; F=A
+DIV x @Divide x into accumulator @A/=x; F=A
+EVTWT @Wait for an event to occur @A=wait(x); F=A
+HALT @Halt @Halt
+INR y @Increment register @++*y; F=*y
+INRA @Increment accumulator @++A; F=A
+JM L @Jump if minus to tag L @if (F<0) PC=L
+JMP L @Jump to tag L @PC=L
+JNZ L @Jump if non-zero to tag L @if (F) PC=L
+JP L @Jump if positive to tag L @if (F>=0) PC=L
+JZ L @Jump if zero to tag L @if (!F) PC=L
+LD y x @Load register with x @*y=x
+LDA x @Load accumulator with x @A=x
+MLT x @Multiply x with accumulator @A*=x; F=A
+MOD x @Modulus x with accumulator @A%=x; F=A
+OR x @Or x with accumulator @A|=x; F=A
+POP y @Pop register @y=pop()
+POPA @Pop accumulator @A=pop()
+PUSH y @Push register @push(y)
+PUSHA @Push accumulator @push(A)
+RET @Return from subroutine @PC=pop()
+RL y x @Rotate left register x bits @*y<<=x; F=*y
+RLA x @Rotate left accumulator x bits @A<<=x; F=A
+RR y x @Rotate right register x bits @*y>>=x; F=*y
+RRA x @Rotate right accumulator x bits @A>>=x; F=A
+STA y @Store accumulator in register @y=A
+SUB x @Subtract x from accumulator @A-=x; F=A
+SYS str@Run external script (/opt/pigpio/cgi/str) @system(str); F=A
+TAG L @Label the current script position @N/A
+WAIT x @Wait for a GPIO in x to change state @A=wait(x); F=A
+X y1 y2@Exchange contents of registers y1 and y2 @t=*y1;*y1=*y2;*y2=t
+XA y @Exchange contents of accumulator and register@t=A;A=*y;*y=t
+XOR x @Xor x with accumulator @A^=x; F=A
+
+x may be a constant, a parameter (p0-p9), or a variable (v0-v149).
+
+y may be a parameter (p0-p9), or a variable (v0-v149). If p or v isn't
+specified y is assumed to be a variable.
+
+The EVTWT command parameter is a bit-mask with 1 set for events of interest.
+
+The WAIT command parameter is a bit-mask with 1 set for GPIO of interest.
+
+The SYS script receives two unsigned parameters: the accumulator A and
+the current GPIO levels.
+
diff --git a/DOC/src/html/download.html b/DOC/src/html/download.html
new file mode 100644
index 0000000..740a3c8
--- /dev/null
+++ b/DOC/src/html/download.html
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.11" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>download</title>
+</head>
+<body>
+If the pigpio daemon is running it should be killed (sudo killall
+pigpiod) before make install and restarted afterwards (sudo
+pigpiod).<br>
+<br>
+<span style="font-weight: bold;">The initial part of the make, the
+compilation of pigpio.c, takes 100 seconds on early model
+Pis.&nbsp; Be patient.&nbsp; The overall install takes just over 3
+minutes.</span><br style="font-weight: bold;">
+<h3>Download and install latest version<br></h3>
+<code>
+wget https://github.com/joan2937/pigpio/archive/master.zip<br>
+unzip master.zip<br>
+cd pigpio-master<br>
+make<br>
+sudo make install<br>
+</code>
+<br>
+If the Python part of the install fails it may be because you need
+the setup tools.<br>
+<br>
+<code>sudo apt install python-setuptools
+python3-setuptools<br></code><br>
+<br>
+<h3>To check the library</h3>
+These tests make extensive use of GPIO 25 (pin 22).&nbsp; Make sure
+nothing, or only a LED, is connected to the GPIO before running the
+tests.&nbsp; Most tests are statistical in nature and so may on
+occasion fail.&nbsp; Repeated failures on the same test or many
+failures in a group of tests indicate a problem.<br>
+<code><br>
+sudo ./x_pigpio # check C I/F<br>
+<br>
+sudo pigpiod&nbsp;&nbsp;&nbsp; # start daemon<br>
+<br>
+./x_pigpiod_if2 # check C&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I/F to
+daemon<br>
+./x_pigpio.py&nbsp;&nbsp; # check Python I/F to daemon<br>
+./x_pigs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # check
+pigs&nbsp;&nbsp; I/F to daemon<br>
+./x_pipe&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # check
+pipe&nbsp;&nbsp; I/F to daemon<br>
+<br>
+<br></code>
+<h3>To compile, link, and run a C program</h3>
+<code>gcc -Wall -pthread -o foobar foobar.c -lpigpio -lrt<br>
+sudo ./foobar</code><code><br></code><br>
+<h3>To start the pigpio daemon<br></h3>
+<code>sudo pigpiod<br></code>
+<h3>To stop the pigpio daemon<br></h3>
+<code>sudo killall pigpiod<br></code><br>
+<h3>github</h3>
+<code>git clone https://github.com/joan2937/pigpio</code><br>
+<h3>Raspbian (raspberrypi.org image)</h3>
+<p>This may not be the most recent version.&nbsp; You can check the
+version with the command pigpiod -v.<br></p>
+<code>sudo apt-get update<br>
+sudo apt-get install pigpio python-pigpio python3-pigpio</code><br>
+<br>
+</body>
+</html>
diff --git a/DOC/src/html/ex_LDR.html b/DOC/src/html/ex_LDR.html
new file mode 100644
index 0000000..3c54c68
--- /dev/null
+++ b/DOC/src/html/ex_LDR.html
@@ -0,0 +1,150 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>LDR example</title>
+</head>
+<body>
+<p>The following code shows a method of reading analogue sensors on
+the digital input only Pi.&nbsp; A Light Dependent Resistor (LDR)
+varies its resistance according to the incident light
+intensisty.</p>
+<h3>SETUP</h3>
+<img src="images/LDR-fritz.png" alt="fritzing diagram" style=
+"width: 200px; height: 300px;" align="left" hspace="10">The LDR
+used is a Cadmium Sulphide device with a 1MOhm dark resistance and
+2-4KOhm at 100 lux.&nbsp; The capacitor is a 104
+ceramic.<span itemprop="name"><br>
+<br>
+One end of the capacitor is connected to Pi ground.<br>
+<br>
+One end of the LDR is connected to Pi 3V3.<br>
+<br>
+The other ends of the capacitor and LDR are connected to a spare
+gpio.</span><br>
+<p>Here P1-1 is used for 3V3, P1-20 is used for ground, and gpio 18
+(P1-12) is used for the gpio.<br clear="all"></p>
+<p><img src="images/LDR-photo.jpg" style=
+"width: 500px; height: 667px;" alt="photo of set-up"></p>
+<h3>CODE</h3>
+<code>#include &lt;stdio.h&gt;<br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+/*
+-----------------------------------------------------------------------<br>
+
+<br>
+&nbsp;&nbsp; 3V3 ----- Light Dependent Resistor --+-- Capacitor
+----- Ground<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++-- gpio<br>
+<br>
+<br>
+&nbsp; cc -o LDR LDR.c -lpigpio -lpthread -lrt<br>
+&nbsp; sudo ./LDR<br>
+<br>
+*/<br>
+<br>
+#define LDR 18<br>
+<br>
+/* forward declaration */<br>
+<br>
+void alert(int pin, int level, uint32_t tick);<br>
+<br>
+int main (int argc, char *argv[])<br>
+{<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0) return 1;<br>
+<br>
+&nbsp;&nbsp; gpioSetAlertFunc(LDR, alert); /* call alert when LDR
+changes state */<br>
+&nbsp;&nbsp;&nbsp;&nbsp;<br>
+&nbsp;&nbsp; while (1)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioSetMode(LDR, PI_OUTPUT); /*
+drain capacitor */<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioWrite(LDR, PI_OFF);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(200); /* 50 micros is
+enough, 200 is overkill */<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioSetMode(LDR, PI_INPUT); /* start
+capacitor recharge */<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(10000); /* nominal 100
+readings per second */<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+}<br>
+<br>
+void alert(int pin, int level, uint32_t tick)<br>
+{<br>
+&nbsp;&nbsp; static uint32_t inited = 0;<br>
+&nbsp;&nbsp; static uint32_t lastTick, firstTick;<br>
+<br>
+&nbsp;&nbsp; uint32_t diffTick;<br>
+<br>
+&nbsp;&nbsp; if (inited)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diffTick = tick - lastTick;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastTick = tick;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (level == 1) printf("%u %d\ ",
+tick-firstTick, diffTick);<br>
+&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; else<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inited = 1;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; firstTick = tick;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastTick = firstTick;<br>
+&nbsp;&nbsp; }<br>
+}<br></code>
+<h3>BUILD</h3>
+<code>cc -o LDR LDR.c -lpigpio -lrt -lpthread<br></code>
+<h3>RUN</h3>
+<code>sudo ./LDR &gt;LDR.dat &amp;</code><br>
+<br>
+While the program is running you can capture the waveform using the
+notification feature built in to pigpio.&nbsp; Issue the following
+commands on the Pi.<br>
+<br>
+<code>pigs no<br>
+pig2vcd&nbsp; &lt;/dev/pigpio0 &gt;LDR.vcd &amp;<br>
+pigs nb 0 0x40000 # set bit for gpio 18<br></code>
+<p>Change the light falling on the LDR for a few seconds (e.g.
+shine a torch on it or shade it with your hands).<br></p>
+<code>pigs nc 0</code><br>
+<p>The file LDR.vcd will contain the captured waveform, which can
+be viewed using GTKWave.</p>
+<p>Overview</p>
+<img src="images/LDR-wave-1.png" style=
+"width: 600px; height: 100px;" alt="LDR waveform 1"><br>
+<p>Reading circa every 10ms<br></p>
+<img src="images/LDR-wave-2.png" style=
+"width: 600px; height: 100px;" alt="LDR waveform 2"><br>
+<p>One reading, circa 400us<br></p>
+<img src="images/LDR-wave-3.png" style=
+"width: 600px; height: 100px;" alt="LDR waveform 3"><br>
+<p>The file LDR.dat will contain pairs of timestamps and recharge
+time (in us).&nbsp; The following&nbsp; script will convert the
+timestamps into seconds.<span style=
+"font-style: italic;"><br></span></p>
+<p><code>awk '{print $1/1000000, $2}' LDR.dat
+&gt;LDR-secs.dat</code></p>
+<p>Gnuplot is a useful tool to graph data.<br></p>
+plot [14:24] 'LDR-secs.dat' with lines title 'LDR'
+<p>Gnuplot readings 14-24 seconds<br></p>
+<p><img src="images/LDR-gnup-1.png" style=
+"width: 600px; height: 321px;" alt="gnuplot 1"></p>
+plot [18:21] 'LDR-secs.dat' with lines title 'LDR'<br>
+<br>
+Gnuplot readings 18-21 seconds
+<p><img src="images/LDR-gnup-2.png" style=
+"width: 600px; height: 321px;" alt="Gnuplot 2"></p>
+</body>
+</html>
diff --git a/DOC/src/html/ex_ir_remote.html b/DOC/src/html/ex_ir_remote.html
new file mode 100644
index 0000000..2400a11
--- /dev/null
+++ b/DOC/src/html/ex_ir_remote.html
@@ -0,0 +1,253 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>IR remote example</title>
+</head>
+<body>
+<p>The following code shows one way to read an infrared remote
+control device (the sort used in TVs and stereo systems).</p>
+<h3>SETUP</h3>
+<img alt="fritzing diagram" style="width: 200px; height: 317px;"
+src="images/ir-fritz.png" align="left" hspace="10">The device used
+is a <span itemprop="name">SFH5110 (IR Receiver for remote control,
+carrier 38 kHz).<br>
+<br></span> Pin 1 (left from front) may be connected to any spare
+gpio.&nbsp; Here it's connected via a 4K7 current limiting
+resistor.&nbsp; This isn't really needed as the device has an
+internal 23K resistor in-line.&nbsp; It does no harm though.<br>
+<br>
+Pin 2 should be connected to a Pi ground pin.<br>
+<br>
+Pin 3 should be connected to a Pi 5V pin.<br>
+<p>Here pin 1 to gpio7 (P1-26) via a 4K7 resistor, pin 2 to ground
+(P1-14), and pin 3 to 5V (P1-2).<br clear="all"></p>
+<p><img src="images/ir-photo.jpg" style=
+"width: 500px; height: 500px;" alt="photo of set-up"></p>
+<h3>CODE</h3>
+<code>#include &lt;stdio.h&gt;<br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+#define IR_PIN 7<br>
+<br>
+#define OUTSIDE_CODE 0<br>
+#define INSIDE_CODE&nbsp; 1<br>
+<br>
+#define MIN_MESSAGE_GAP 3000<br>
+#define MAX_MESSAGE_END 3000<br>
+<br>
+#define MAX_TRANSITIONS 500<br>
+<br>
+/*<br>
+&nbsp;&nbsp; using the FNV-1a
+hash&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
+
+&nbsp;&nbsp; from
+http://isthe.com/chongo/tech/comp/fnv/#FNV-param<br>
+*/<br>
+<br>
+#define FNV_PRIME_32 16777619<br>
+#define FNV_BASIS_32 2166136261U<br>
+<br>
+static volatile uint32_t ir_hash = 0;<br>
+<br>
+typedef struct<br>
+{<br>
+&nbsp;&nbsp; int state;<br>
+&nbsp;&nbsp; int count;<br>
+&nbsp;&nbsp; int level;<br>
+&nbsp;&nbsp; uint16_t micros[MAX_TRANSITIONS];<br>
+} decode_t;<br>
+<br>
+/* forward declarations */<br>
+<br>
+void&nbsp;&nbsp;&nbsp;&nbsp; alert(int gpio, int level, uint32_t
+tick);<br>
+uint32_t getHash(decode_t * decode);<br>
+void&nbsp;&nbsp;&nbsp;&nbsp; updateState(decode_t * decode, int
+level, uint32_t micros);<br>
+<br>
+int main(int argc, char * argv[])<br>
+{<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1 ;<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; /* IR pin as input */<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(IR_PIN, PI_INPUT);<br>
+<br>
+&nbsp;&nbsp; /* 5ms max gap after last pulse */<br>
+<br>
+&nbsp;&nbsp; gpioSetWatchdog(IR_PIN, 5);<br>
+<br>
+&nbsp;&nbsp; /* monitor IR level changes */<br>
+<br>
+&nbsp;&nbsp; gpioSetAlertFunc(IR_PIN, alert);<br>
+<br>
+&nbsp;&nbsp; while (1)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ir_hash)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* non-zero means
+new decode */<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("ir code is
+%u\ ", ir_hash);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ir_hash = 0;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(100000); /* check remote
+10 times per second */<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+}<br>
+<br>
+void alert(int gpio, int level, uint32_t tick)<br>
+{<br>
+&nbsp;&nbsp; static int inited = 0;<br>
+<br>
+&nbsp;&nbsp; static decode_t activeHigh, activeLow;<br>
+<br>
+&nbsp;&nbsp; static uint32_t lastTick;<br>
+<br>
+&nbsp;&nbsp; uint32_t diffTick;<br>
+<br>
+&nbsp;&nbsp; if (!inited)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inited = 1;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; activeHigh.state = OUTSIDE_CODE;
+activeHigh.level = PI_LOW;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; activeLow.state&nbsp; =
+OUTSIDE_CODE; activeLow.level&nbsp; = PI_HIGH;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastTick = tick;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; diffTick = tick - lastTick;<br>
+<br>
+&nbsp;&nbsp; if (level != PI_TIMEOUT) lastTick = tick;<br>
+<br>
+&nbsp;&nbsp; updateState(&amp;activeHigh, level, diffTick);<br>
+&nbsp;&nbsp; updateState(&amp;activeLow, level, diffTick);<br>
+}<br>
+<br>
+void updateState(decode_t * decode, int level, uint32_t micros)<br>
+{<br>
+&nbsp;&nbsp; /*<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; We are dealing with active high as
+well as active low<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remotes.&nbsp; Abstract the common
+functionality.<br>
+&nbsp;&nbsp; */<br>
+<br>
+&nbsp;&nbsp; if (decode-&gt;state == OUTSIDE_CODE)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (level == decode-&gt;level)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (micros &gt;
+MIN_MESSAGE_GAP)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+decode-&gt;state = INSIDE_CODE;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+decode-&gt;count = 0;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; else<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (micros &gt; MAX_MESSAGE_END)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* end of message
+*/<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* ignore if last
+code not consumed */<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!ir_hash)
+ir_hash = getHash(decode);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decode-&gt;state =
+OUTSIDE_CODE;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
+(decode-&gt;count &lt; (MAX_TRANSITIONS-1))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+if (level != PI_TIMEOUT)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+decode-&gt;micros[decode-&gt;count++] = micros;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; }<br>
+}<br>
+<br>
+int compare(unsigned int oldval, unsigned int newval)<br>
+{<br>
+&nbsp;&nbsp; if&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (newval &lt; (oldval
+* 0.75)) {return 1;}<br>
+&nbsp;&nbsp; else if (oldval &lt; (newval * 0.75)) {return 2;}<br>
+&nbsp;&nbsp;
+else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+{return 4;}<br>
+}<br>
+<br>
+uint32_t getHash(decode_t * decode)<br>
+{<br>
+&nbsp;&nbsp; /* use FNV-1a */<br>
+<br>
+&nbsp;&nbsp; uint32_t hash;<br>
+&nbsp;&nbsp; int i, value;<br>
+<br>
+&nbsp;&nbsp; if (decode-&gt;count &lt; 6) {return 0;}<br>
+<br>
+&nbsp;&nbsp; hash = FNV_BASIS_32;<br>
+<br>
+&nbsp;&nbsp; for (i=0; i&lt;(decode-&gt;count-2); i++)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value =
+compare(decode-&gt;micros[i], decode-&gt;micros[i+2]);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = hash ^ value;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = (hash * FNV_PRIME_32);<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; return hash;<br>
+}<br></code>
+<h3>BUILD</h3>
+<code>cc -o ir_remote ir_remote.c -lpigpio -lrt
+-lpthread<br></code>
+<h3>RUN</h3>
+<code>sudo ./ir_remote</code><br>
+<p>A hash code is formed from the level transitions detected during
+a remote key press.&nbsp; This is likely to be unique over multiple
+remotes and keys.</p>
+<p>While the program is running you can capture the waveform using
+the notification feature built in to pigpio.&nbsp; Issue the
+following commands on the Pi.</p>
+<code>pigs no<br>
+pig2vcd&nbsp; &lt;/dev/pigpio0 &gt;ir.vcd &amp;<br>
+pigs nb 0 0x80 # set bits for gpios 7 (0x80)<br></code>
+<p>Press a few different remotes and keys.&nbsp; Then enter<br></p>
+<code>pigs nc 0</code><br>
+<p>The file ir.vcd will contain the captured waveform, which can be
+viewed using GTKWave.</p>
+<p>Overview</p>
+<img src="images/ir-wave-1.png" style=
+"width: 600px; height: 100px;" alt="ir remote waveform 1"><br>
+<p>Remote A typical waveform</p>
+<img src="images/ir-wave-2.png" style=
+"width: 600px; height: 100px;" alt="ir remote waveform 2"><br>
+<p>Remote B typical waveform</p>
+<img style="width: 600px; height: 100px;" alt=
+"ir remote waveform 3" src="images/ir-wave-3.png">
+</body>
+</html>
diff --git a/DOC/src/html/ex_motor_shield.html b/DOC/src/html/ex_motor_shield.html
new file mode 100644
index 0000000..777ba9e
--- /dev/null
+++ b/DOC/src/html/ex_motor_shield.html
@@ -0,0 +1,254 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Arduino motor shield example</title>
+</head>
+<body>
+The following example demonstrates the use of an Arduino shield
+from the Rasperry Pi.<br>
+<br>
+The shield used is a clone of the Adafruit motor shield.&nbsp; See
+<a href="http://shieldlist.org/adafruit/motor">shieldlist.org</a>
+for details.<br>
+<br>
+For the demonstration DC motors 3 and 4 are being driven forwards
+and backwards with changing speeds (speeds are controlled via
+PWM).<br>
+<br>
+Seven connections are made between the Pi and the shield.&nbsp;
+Four to latch the motor states (latch, enable, data, clock); Two to
+control motor speed (PWM 3 and 4); and ground.<br>
+<br>
+The code used was ported from the Adafruit Arduino code and
+converted to use the pigpio library.&nbsp; Only the DC motor code
+was ported.<br>
+<br>
+A video of the shield in use is available at <a href=
+"http://youtu.be/Z_l3C246oVI">youtube.com</a><br>
+<code><br>
+#include &lt;stdio.h&gt;</code> <code><br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+/*<br>
+&nbsp;&nbsp; This code may be used to drive the Adafruit (or
+clones) Motor Shield.<br>
+<br>
+&nbsp;&nbsp; The code as written only supports DC motors.<br>
+<br>
+&nbsp;&nbsp; http://shieldlist.org/adafruit/motor<br>
+<br>
+&nbsp;&nbsp; The shield pinouts are<br>
+<br>
+&nbsp;&nbsp; D12 MOTORLATCH<br>
+&nbsp;&nbsp; D11 PMW motor 1<br>
+&nbsp;&nbsp; D10 Servo 1<br>
+&nbsp;&nbsp; D9&nbsp; Servo 2<br>
+&nbsp;&nbsp; D8&nbsp; MOTORDATA<br>
+<br>
+&nbsp;&nbsp; D7&nbsp; MOTORENABLE<br>
+&nbsp;&nbsp; D6&nbsp; PWM motor 4<br>
+&nbsp;&nbsp; D5&nbsp; PWM motor 3<br>
+&nbsp;&nbsp; D4&nbsp; MOTORCLK<br>
+&nbsp;&nbsp; D3&nbsp; PWM motor 2<br>
+<br>
+&nbsp;&nbsp; The motor states (forward, backward, brake, release)
+are encoded using the<br>
+&nbsp;&nbsp; MOTOR_ latch pins.&nbsp; This saves four gpios.<br>
+*/<br>
+<br>
+typedef unsigned char uint8_t;<br>
+<br>
+#define BIT(bit) (1 &lt;&lt; (bit))<br>
+<br>
+/* assign gpios to drive the shield pins */<br>
+<br>
+/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+Shield&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pi */<br>
+<br>
+#define MOTORLATCH&nbsp; 14<br>
+#define MOTORCLK&nbsp;&nbsp;&nbsp; 24<br>
+#define MOTORENABLE 25<br>
+#define MOTORDATA&nbsp;&nbsp; 15<br>
+<br>
+#define MOTOR_3_PWM&nbsp; 7<br>
+#define MOTOR_4_PWM&nbsp; 8<br>
+<br>
+/*<br>
+&nbsp;&nbsp; The only other connection needed between the Pi and
+the shield<br>
+&nbsp;&nbsp; is ground to ground. I used Pi P1-6 to shield gnd
+(next to D13).<br>
+*/<br>
+<br>
+/* assignment of motor states to latch */<br>
+<br>
+#define MOTOR1_A 2<br>
+#define MOTOR1_B 3<br>
+#define MOTOR2_A 1<br>
+#define MOTOR2_B 4<br>
+#define MOTOR4_A 0<br>
+#define MOTOR4_B 6<br>
+#define MOTOR3_A 5<br>
+#define MOTOR3_B 7<br>
+<br>
+#define FORWARD&nbsp; 1<br>
+#define BACKWARD 2<br>
+#define BRAKE&nbsp;&nbsp;&nbsp; 3<br>
+#define RELEASE&nbsp; 4<br>
+<br>
+static uint8_t latch_state;<br>
+<br>
+void latch_tx(void)<br>
+{<br>
+&nbsp;&nbsp; unsigned char i;<br>
+<br>
+&nbsp;&nbsp; gpioWrite(MOTORLATCH, PI_LOW);<br>
+<br>
+&nbsp;&nbsp; gpioWrite(MOTORDATA, PI_LOW);<br>
+<br>
+&nbsp;&nbsp; for (i=0; i&lt;8; i++)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(10);&nbsp; // 10 micros
+delay<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioWrite(MOTORCLK, PI_LOW);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (latch_state &amp; BIT(7-i))
+gpioWrite(MOTORDATA, PI_HIGH);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+gpioWrite(MOTORDATA, PI_LOW);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(10);&nbsp; // 10 micros
+delay<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioWrite(MOTORCLK, PI_HIGH);<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioWrite(MOTORLATCH, PI_HIGH);<br>
+}<br>
+<br>
+void init(void)<br>
+{<br>
+&nbsp;&nbsp; latch_state = 0;<br>
+<br>
+&nbsp;&nbsp; latch_tx();<br>
+<br>
+&nbsp;&nbsp; gpioWrite(MOTORENABLE, PI_LOW);<br>
+}<br>
+<br>
+void DCMotorInit(uint8_t num)<br>
+{<br>
+&nbsp;&nbsp; switch (num)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 1: latch_state &amp;=
+~BIT(MOTOR1_A) &amp; ~BIT(MOTOR1_B); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 2: latch_state &amp;=
+~BIT(MOTOR2_A) &amp; ~BIT(MOTOR2_B); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 3: latch_state &amp;=
+~BIT(MOTOR3_A) &amp; ~BIT(MOTOR3_B); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 4: latch_state &amp;=
+~BIT(MOTOR4_A) &amp; ~BIT(MOTOR4_B); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default: return;<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; latch_tx();<br>
+<br>
+&nbsp;&nbsp; printf("Latch=%08X\ ", latch_state);<br>
+}<br>
+<br>
+void DCMotorRun(uint8_t motornum, uint8_t cmd)<br>
+{<br>
+&nbsp;&nbsp; uint8_t a, b;<br>
+<br>
+&nbsp;&nbsp; switch (motornum)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 1: a = MOTOR1_A; b = MOTOR1_B;
+break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 2: a = MOTOR2_A; b = MOTOR2_B;
+break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 3: a = MOTOR3_A; b = MOTOR3_B;
+break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 4: a = MOTOR4_A; b = MOTOR4_B;
+break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default: return;<br>
+&nbsp;&nbsp; }<br>
+&nbsp;<br>
+&nbsp;&nbsp; switch (cmd)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FORWARD:&nbsp; latch_state
+|=&nbsp; BIT(a); latch_state &amp;= ~BIT(b); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case BACKWARD: latch_state &amp;=
+~BIT(a); latch_state |=&nbsp; BIT(b); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case RELEASE:&nbsp; latch_state
+&amp;= ~BIT(a); latch_state &amp;= ~BIT(b); break;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default: return;<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; latch_tx();<br>
+<br>
+&nbsp;&nbsp; printf("Latch=%08X\ ", latch_state);<br>
+}<br>
+<br>
+int main (int argc, char *argv[])<br>
+{<br>
+&nbsp;&nbsp; int i;<br>
+<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0) return 1;<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(MOTORLATCH,&nbsp; PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioSetMode(MOTORENABLE, PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioSetMode(MOTORDATA,&nbsp;&nbsp; PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioSetMode(MOTORCLK,&nbsp;&nbsp;&nbsp;
+PI_OUTPUT);<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(MOTOR_3_PWM, PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioSetMode(MOTOR_4_PWM, PI_OUTPUT);<br>
+<br>
+&nbsp;&nbsp; gpioPWM(MOTOR_3_PWM, 0);<br>
+&nbsp;&nbsp; gpioPWM(MOTOR_4_PWM, 0);<br>
+<br>
+&nbsp;&nbsp; init();<br>
+<br>
+&nbsp;&nbsp; for (i=60; i&lt;160; i+=20)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioPWM(MOTOR_3_PWM, i);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioPWM(MOTOR_4_PWM, 220-i);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(3, FORWARD);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(4, BACKWARD);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(2);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(3, RELEASE);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(4, RELEASE);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(2);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioPWM(MOTOR_4_PWM, i);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioPWM(MOTOR_3_PWM, 220-i);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(3, BACKWARD);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(4, FORWARD);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(2);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(3, RELEASE);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DCMotorRun(4, RELEASE);<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep(2);<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioPWM(MOTOR_4_PWM, 0);<br>
+&nbsp;&nbsp; gpioPWM(MOTOR_3_PWM, 0);<br>
+<br>
+&nbsp;&nbsp; DCMotorRun(3, RELEASE);<br>
+&nbsp;&nbsp; DCMotorRun(4, RELEASE);<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+}<br></code>
+</body>
+</html>
diff --git a/DOC/src/html/ex_rotary_encoder.html b/DOC/src/html/ex_rotary_encoder.html
new file mode 100644
index 0000000..b95711e
--- /dev/null
+++ b/DOC/src/html/ex_rotary_encoder.html
@@ -0,0 +1,185 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Rotary encoder sample</title>
+</head>
+<body>
+<p>The following code shows one way to read an incremental
+mechanical rotary enoder (the sort used for volume control in audio
+systems).&nbsp; These rotary encoders have two switches A and B
+which return a quadrature output, i.e. they are 90 degrees out of
+phase.</p>
+<h3>SETUP</h3>
+<img alt="fritzing diagram" style="width: 200px; height: 300px;"
+src="images/re-fritz.png" align="left" hspace="10">The common
+(centre) terminal should be connected to a Pi ground.
+<p>The A and B terminals may be connected to any spare gpios.</p>
+<p>Here A to gpio18 (P1-12), common to ground (P1-20), B to gpio7
+(P1-26).<br clear="all"></p>
+<p><img src="images/re-photo.jpg" style=
+"width: 400px; height: 300px;" alt="photo of set-up"></p>
+<h3>CODE</h3>
+<code>#include &lt;stdio.h&gt;<br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+/*<br>
+&nbsp;&nbsp; Rotary encoder connections:<br>
+<br>
+&nbsp;&nbsp; Encoder A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - gpio
+18&nbsp;&nbsp; (pin P1-12)<br>
+&nbsp;&nbsp; Encoder B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - gpio
+7&nbsp;&nbsp;&nbsp; (pin P1-26)<br>
+&nbsp;&nbsp; Encoder Common - Pi ground (pin P1-20)<br>
+*/<br>
+<br>
+#define ENCODER_A 18<br>
+#define ENCODER_B&nbsp; 7<br>
+<br>
+static volatile int encoderPos;<br>
+<br>
+/* forward declaration */<br>
+<br>
+void encoderPulse(int gpio, int lev, uint32_t tick);<br>
+<br>
+int main(int argc, char * argv[])<br>
+{<br>
+&nbsp;&nbsp; int pos=0;<br>
+<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0) return 1;<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(ENCODER_A, PI_INPUT);<br>
+&nbsp;&nbsp; gpioSetMode(ENCODER_B, PI_INPUT);<br>
+<br>
+&nbsp;&nbsp; /* pull up is needed as encoder common is grounded
+*/<br>
+<br>
+&nbsp;&nbsp; gpioSetPullUpDown(ENCODER_A, PI_PUD_UP);<br>
+&nbsp;&nbsp; gpioSetPullUpDown(ENCODER_B, PI_PUD_UP);<br>
+<br>
+&nbsp;&nbsp; encoderPos = pos;<br>
+<br>
+&nbsp;&nbsp; /* monitor encoder level changes */<br>
+<br>
+&nbsp;&nbsp; gpioSetAlertFunc(ENCODER_A, encoderPulse);<br>
+&nbsp;&nbsp; gpioSetAlertFunc(ENCODER_B, encoderPulse);<br>
+<br>
+&nbsp;&nbsp; while (1)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (pos != encoderPos)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pos =
+encoderPos;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("pos=%d\ ",
+pos);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpioDelay(20000); /* check pos 50
+times per second */<br>
+&nbsp;&nbsp; }<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+}<br>
+<br>
+void encoderPulse(int gpio, int level, uint32_t tick)<br>
+{<br>
+&nbsp;&nbsp; /*<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp; A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +-----
+1<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+0<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp; B&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
+&nbsp;&nbsp; ----+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
++---------+&nbsp; 1<br>
+<br>
+&nbsp;&nbsp; */<br>
+<br>
+&nbsp;&nbsp; static int levA=0, levB=0, lastGpio = -1;<br>
+<br>
+&nbsp;&nbsp; if (gpio == ENCODER_A) levA = level; else levB =
+level;<br>
+<br>
+&nbsp;&nbsp; if (gpio != lastGpio) /* debounce */<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastGpio = gpio;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((gpio == ENCODER_A) &amp;&amp;
+(level == 0))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!levB)
+++encoderPos;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ((gpio == ENCODER_B)
+&amp;&amp; (level == 1))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (levA)
+--encoderPos;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; }<br>
+}<br></code>
+<h3>BUILD</h3>
+<code>cc -o rotary_encoder rotary_encoder.c -lpigpio -lrt
+-lpthread<br></code>
+<h3>RUN</h3>
+<code>sudo ./rotary_encoder</code><br>
+<p>While the program is running you can capture the waveform using
+the notification feature built in to pigpio.&nbsp; Issue the
+following commands on the Pi.</p>
+<code>pigs no<br>
+pig2vcd&nbsp; &lt;/dev/pigpio0 &gt;re.vcd &amp;<br>
+pigs nb 0 0x40080 # set bits for gpios 7 (0x80) and 18
+(0x40000)<br></code>
+<p>Twiddle the rotary encoder forwards and backwards for a few
+seconds.&nbsp; Then enter<br></p>
+<code>pigs nc 0</code><br>
+<p>The file re.vcd will contain the captured waveform, which can be
+viewed using GTKWave.</p>
+<br>
+Overview<br>
+<br>
+<img src="images/re-wave-1.png" style=
+"width: 600px; height: 100px;" alt=
+"rotary encoder waveform overview"><br>
+<br>
+Detail of switch bounce.&nbsp; Contact A bounces for circa 700 us
+before completing the level transition<br>
+<br>
+<img src="images/re-wave-2.png" style=
+"width: 600px; height: 100px;" alt=
+"rotary encoder waveform detail"><br>
+</body>
+</html>
diff --git a/DOC/src/html/ex_sonar_ranger.html b/DOC/src/html/ex_sonar_ranger.html
new file mode 100644
index 0000000..8edb9c2
--- /dev/null
+++ b/DOC/src/html/ex_sonar_ranger.html
@@ -0,0 +1,164 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Sonar ranger example</title>
+</head>
+<body>
+<p>The following code shows a method of reading a class of sonar
+rangers.&nbsp; These rangers requires a trigger pulse.&nbsp;
+Shortly after receiving a trigger they transmit a noise pulse and
+set the echo line high.&nbsp; When the echo is received the echo
+line is set low.<br></p>
+<h3>SETUP</h3>
+<img src="images/son-fritz.png" alt="fritzing diagram" style=
+"width: 200px; height: 600px;" align="left" hspace="10"><br>
+<br>
+<br>
+<br>
+<br>
+The ranger used is a SRF05 (check the pinouts, there are many
+variants).<br>
+<br>
+The fritzing diagram shows the back of the ranger, i.e. pin 1 is
+the rightmost.<br>
+<br>
+Pin 1 is 5V.<br>
+Pin 2 is the trigger line.<br>
+Pin 3 is the echo line.<br>
+Pin 4 is out (unused).<br>
+Pin 5 is ground.<br>
+<br clear="all">
+<p><img src="images/son-photo.jpg" style=
+"width: 500px; height: 376px;" alt="photo of set-up"></p>
+<h3>CODE</h3>
+<code>#include &lt;stdio.h&gt;<br>
+<br>
+#include &lt;pigpio.h&gt;<br>
+<br>
+/*<br>
+<br>
+P1&nbsp; Name&nbsp; gpio&nbsp;&nbsp;&nbsp; used for<br>
+<br>
+&nbsp;2&nbsp; 5V&nbsp;&nbsp;&nbsp; ---&nbsp;&nbsp;&nbsp;&nbsp;
+5V<br>
+&nbsp;6&nbsp; GND&nbsp;&nbsp; ---&nbsp;&nbsp;&nbsp;&nbsp;
+Ground<br>
+24&nbsp; CE0&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+Sonar echo<br>
+26&nbsp; CE1&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+Sonar trigger<br>
+<br>
+*/<br>
+<br>
+#define SONAR_TRIGGER 7<br>
+#define SONAR_ECHO&nbsp;&nbsp;&nbsp; 8<br>
+<br>
+/* forward prototypes */<br>
+<br>
+void sonarTrigger(void);<br>
+<br>
+void sonarEcho(int gpio, int level, uint32_t tick);<br>
+<br>
+int main(int argc, char *argv[])<br>
+{<br>
+&nbsp;&nbsp; if (gpioInitialise()&lt;0) return 1;<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(SONAR_TRIGGER, PI_OUTPUT);<br>
+&nbsp;&nbsp; gpioWrite&nbsp; (SONAR_TRIGGER, PI_OFF);<br>
+<br>
+&nbsp;&nbsp; gpioSetMode(SONAR_ECHO,&nbsp;&nbsp;&nbsp;
+PI_INPUT);<br>
+<br>
+&nbsp;&nbsp; /* update sonar 20 times a second, timer #0 */<br>
+<br>
+&nbsp;&nbsp; gpioSetTimerFunc(0, 50, sonarTrigger); /* every 50ms
+*/<br>
+<br>
+&nbsp;&nbsp; /* monitor sonar echos */<br>
+<br>
+&nbsp;&nbsp; gpioSetAlertFunc(SONAR_ECHO, sonarEcho);<br>
+<br>
+&nbsp;&nbsp; while (1) sleep(1);<br>
+<br>
+&nbsp;&nbsp; gpioTerminate();<br>
+<br>
+&nbsp;&nbsp; return 0;<br>
+}<br>
+<br>
+void sonarTrigger(void)<br>
+{<br>
+&nbsp;&nbsp; /* trigger a sonar reading */<br>
+<br>
+&nbsp;&nbsp; gpioWrite(SONAR_TRIGGER, PI_ON);<br>
+<br>
+&nbsp;&nbsp; gpioDelay(10); /* 10us trigger pulse */<br>
+<br>
+&nbsp;&nbsp; gpioWrite(SONAR_TRIGGER, PI_OFF);<br>
+}<br>
+<br>
+void sonarEcho(int gpio, int level, uint32_t tick)<br>
+{<br>
+&nbsp;&nbsp; static uint32_t startTick, firstTick=0;<br>
+<br>
+&nbsp;&nbsp; int diffTick;<br>
+<br>
+&nbsp;&nbsp; if (!firstTick) firstTick = tick;<br>
+<br>
+&nbsp;&nbsp; if (level == PI_ON)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; startTick = tick;<br>
+&nbsp;&nbsp; }<br>
+&nbsp;&nbsp; else if (level == PI_OFF)<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diffTick = tick - startTick;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%u %u\ ", tick-firstTick,
+diffTick);<br>
+&nbsp;&nbsp; }<br>
+}<br></code>
+<h3>BUILD</h3>
+<code>cc -o sonar sonar.c -lpigpio -lrt -lpthread<br></code>
+<h3>RUN</h3>
+<code>sudo ./sonar &gt;sonar.dat &amp;</code><br>
+<br>
+While the program is running you can capture the waveform using the
+notification feature built in to pigpio.&nbsp; Issue the following
+commands on the Pi.<br>
+<br>
+<code>pigs no<br>
+pig2vcd&nbsp; &lt;/dev/pigpio0 &gt;sonar.vcd &amp;<br>
+pigs nb 0 0x180 # set bits for gpios 7 and 8<br></code>
+<p>Move an object in front of the sonar ranger for a few
+seconds.<br></p>
+<code>pigs nc 0</code><br>
+<p>The file sonar.vcd will contain the captured waveform, which can
+be viewed using GTKWave.</p>
+<p>Overview</p>
+<img src="images/son-wave-1.png" style=
+"width: 600px; height: 100px;" alt="LDR waveform 1"><br>
+<p>Reading circa every 10ms<br></p>
+<img src="images/son-wave-2.png" style=
+"width: 600px; height: 100px;" alt="Sonar waveform 2"><br>
+<p>One reading, circa 400us<br></p>
+<img src="images/son-wave-3.png" style=
+"width: 600px; height: 100px;" alt="Sonar waveform 3"><br>
+<p>another</p>
+<img style="width: 600px; height: 100px;" alt="Sonar waveform 4"
+src="images/son-wave-4.png"><br>
+<p>The file sonar.dat will contain pairs of timestamps and echo
+length (in us).&nbsp; The following&nbsp; script will convert the
+timestamps into seconds.<span style=
+"font-style: italic;"><br></span></p>
+<p><code>awk '{print $1/1000000, $2}' sonar.dat
+&gt;sonar-secs.dat</code></p>
+<p>Gnuplot is a useful tool to graph data.<br></p>
+plot 'sonar-secs.dat' title 'Sonar'<br>
+<p><img src="images/son-gnup-1.png" style=
+"width: 600px; height: 321px;" alt="gnuplot 1"><br>
+&nbsp;plot [10:25] 'sonar-secs.dat' title 'Sonar'<br></p>
+<p><img src="images/son-gnup-2.png" style=
+"width: 600px; height: 321px;" alt="gnuplot 1"></p>
+</body>
+</html>
diff --git a/DOC/src/html/faq.html b/DOC/src/html/faq.html
new file mode 100644
index 0000000..b8d6df5
--- /dev/null
+++ b/DOC/src/html/faq.html
@@ -0,0 +1,462 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content=
+"HTML Tidy for HTML5 for Linux version 5.6.0">
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>faq</title>
+</head>
+<body>
+<a href="#Are_my_GPIO_broken">Are my GPIO broken?</a><br>
+<br>
+<a href="#Audio_is_broken">Audio is broken</a><br>
+<br>
+<a href="#Cant_initialise_pigpio_library">Can´t initialise pigpio
+library</a><br>
+<br>
+<a href="#Cant_lock_varrunpigpio.pid">Can´t lock
+var/run/pigpio.pid</a><br>
+<br>
+<a href="#Hello_World">Hello World!</a><br>
+<br>
+<a href="#make_fails">Clock skew, make fails</a><br>
+<br>
+<a href="#Have_I_fried_my_GPIO">Have I fried my GPIO?</a><br>
+<br>
+<a href="#How_do_I_debounce_inputs">How do I debounce
+inputs?</a><br>
+<br>
+<a href="#How_fast_is_SPI">How fast is SPI?</a><br>
+<br>
+<a href="#Library_update_fails">Library update didn't work</a><br>
+<br>
+<a href="#make_fails">make fails with clock skew</a><br>
+<br>
+<a href="#Porting_pigpio">Porting pigpio to another CPU/SoC</a><br>
+<br>
+<a href="#Sound_isnt_working">Sound isn't working</a><br>
+<br>
+<a href="#Library_update_fails">Symbol not found</a><br>
+<br>
+<a href="#What_is_I2C">What is I2C?</a><br>
+<br>
+<a href="#What_is_Serial">What is Serial?</a><br>
+<br>
+<a href="#What_is_SPI">What is SPI?</a><br>
+<br>
+<a href="#Which_library">Which library should I use?</a><br>
+<br>
+<h3><a name="Are_my_GPIO_broken" id="Are_my_GPIO_broken"></a>Are my
+GPIO broken?</h3>
+<p>See <a href="#Have_I_fried_my_GPIO">Have I fried my
+GPIO?</a><br></p>
+<h3><a name="Audio_is_broken" id="Audio_is_broken"></a>Audio is
+broken</h3>
+<p>See <a href="#Sound_isnt_working">Sound isn't
+working</a><br></p>
+<h3><a name="Cant_lock_varrunpigpio.pid" id=
+"Cant_lock_varrunpigpio.pid"></a>Can´t lock
+/var/run/pigpio.pid</h3>
+<p>See <a href=
+"#Cant_initialise_pigpio_library">Can´t_initialise_pigpio_library</a><br>
+</p>
+<h3><a name="Cant_initialise_pigpio_library" id=
+"Cant_initialise_pigpio_library"></a>Can´t initialise pigpio
+library</h3>
+<p>This message means the pigpio daemon is already running.<br></p>
+<p>The default daemon is called pigpiod and may be removed as
+follows.<br></p>
+Check that it is running with the command
+<p><code>ps aux | grep pigpiod</code></p>
+<p>Kill the daemon with<br></p>
+<p><code>sudo killall pigpiod</code></p>
+<p>If your own program is acting as the daemon it may be removed as
+follows.</p>
+<p>Find its process id (<span style=
+"font-style: italic;">pid</span>).<br></p>
+<p><code>cat /var/run/pigpio.pid</code><br></p>
+<p>Kill the program with<br></p>
+<p><code>sudo kill -9 <span style=
+"font-style: italic;">pid</span></code><br></p>
+If the above doesn't work do the following and try starting the
+daemon again
+<p><code>sudo rm /var/run/pigpio.pid<br></code></p>
+<p>To start the daemon do</p>
+<p><code>sudo pigpiod</code></p>
+<h3><a name="Have_I_fried_my_GPIO" id=
+"Have_I_fried_my_GPIO"></a>Have I fried my GPIO?</h3>
+<p>If you think you have damaged one or more GPIO you can carry out
+a diagnostic test.</p>
+<p>The test is a command line script called <a rel="nofollow"
+class="external text" href=
+"http://abyz.me.uk/rpi/pigpio/code/gpiotest.zip">gpiotest</a></p>
+For the duration of the test nothing must be connected to the GPIO
+(no LEDs, wires, ribbon cables etc.).
+<p>The test checks that each GPIO may be read and written and that
+the internal resistor pull-ups and pull-downs are functional.</p>
+<p>A <a rel="nofollow" class="external text" href=
+"https://www.youtube.com/watch?v=sCJFLKWaxHo&amp;feature=youtu.be">video</a>
+showing what happens to the GPIO during a test.</p>
+<p>A test with all GPIO okay.</p>
+<pre>This program checks the Pi's (user) gpios.
+
+The program reads and writes all the gpios. Make sure NOTHING
+is connected to the gpios during this test.
+
+The program uses the pigpio daemon which must be running.
+
+To start the daemon use the command sudo pigpiod.
+
+Press the ENTER key to continue or ctrl-C to abort...
+
+Testing...
+Skipped non-user gpios: 0 1 28 29 30 31
+Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18<br> 19 20 21 22 23 24 25 26 27
+Failed user gpios: None
+</pre>
+<p>A test showing failed GPIO.</p>
+<pre>This program checks the Pi's (user) gpios.
+
+The program reads and writes all the gpios. Make sure NOTHING
+is connected to the gpios during this test.
+
+The program uses the pigpio daemon which must be running.
+
+To start the daemon use the command sudo pigpiod.
+
+Press the ENTER key to continue or ctrl-C to abort...
+
+Testing...
+Write 1 to gpio 17 failed.
+Pull up on gpio 17 failed.
+Write 1 to gpio 18 failed.
+Pull up on gpio 18 failed.
+Write 0 to gpio 23 failed.
+Pull down on gpio 23 failed.
+Write 0 to gpio 24 failed.
+Pull down on gpio 24 failed.
+Write 1 to gpio 27 failed.
+Pull up on gpio 27 failed.
+Skipped non-user gpios: 0 1 28 29 30 31
+Tested user gpios: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18<br> 19 20 21 22 23 24 25 26 27
+Failed user gpios: 17 18 23 24 27
+</pre>
+<h3><a name="How_do_I_debounce_inputs" id=
+"How_do_I_debounce_inputs"></a>How do I debounce inputs?</h3>
+<p>Some devices like mechanical switches can generate multiple
+interrupts as they bounce between on and off.&nbsp; It is possible
+to debounce the inputs in hardware by the correct use of resistors
+and capacitors.<br></p>
+<p>In software use the glitch filter which ignores all events
+shorter than a set number of microseconds.&nbsp; C <a href=
+"cif.html#gpioGlitchFilter">gpioGlitchFilter</a>, Python <a href=
+"python.html#set_glitch_filter">set_glitch_filter</a>.<br></p>
+<h3><a name="How_fast_is_SPI" id="How_fast_is_SPI"></a>How fast is
+SPI?</h3>
+The SPI throughput in samples per second depends on a number of
+factors.<br>
+<br>
+<ul>
+<li>The SPI bit rate (transfer rate in bits per second)</li>
+</ul>
+<ul>
+<li>The number of bytes transferred per sample (a 12 bit ADC sample
+may require 3 bytes to transfer)</li>
+</ul>
+<ul>
+<li>The driver used</li>
+</ul>
+<p>Two of those factors are fixed, the variable is the driver
+used.</p>
+<p>The pigpio driver is considerably faster than the Linux SPI
+driver as is demonstrated by the following graphs.<br></p>
+<p>Each graph shows the SPI bit rate in bits per second along the
+horizontal axis.&nbsp; The samples per second achieved is shown on
+the vertical axis.&nbsp; Each graph contains plots assuming 1 to 5
+bytes per transfer.<br></p>
+<p>The source code used for the tests is <a href=
+"code/spi-driver-speed.c">spi-driver-speed.c</a> and <a href=
+"code/spi-pigpio-speed.c">spi-pigpio-speed.c</a><br></p>
+<p><img alt="spi-lnx-pibr1.png" src="images/spi-lnx-pibr1.png"></p>
+<hr>
+<p><img alt="spi-pig-pibr1.png" src="images/spi-pig-pibr1.png"></p>
+<hr>
+<p><img alt="spi-lnx-pi3b.png" src="images/spi-lnx-pi3b.png"></p>
+<hr>
+<p><img alt="spi-pig-pi3b.png" src="images/spi-pig-pi3b.png"></p>
+<h3><a name="Library_update_fails" id=
+"Library_update_fails"></a>Library update didn't work</h3>
+<p>pigpio places files in the following locations<br></p>
+<p>/usr/local/include (pigpio.h, pigpiod_if.h, pigpiod_if2.h)<br>
+/usr/local/lib (libpigpio.so, libpigpiod_if.so,
+libpigpiod_if2.so)<br>
+/usr/local/bin (pig2vcd, pigpiod, pigs)<br>
+/usr/local/man (man pages)<br></p>
+The raspberrypi.org image containing pigpio uses different
+locations.<br>
+<p>/usr/include (pigpio.h, pigpiod_if.h, pigpiod_if2.h)<br>
+/usr/lib (libpigpio.so, libpigpiod_if.so, libpigpiod_if2.so)<br>
+/usr/bin (pig2vcd, pigpiod, pigs)<br>
+/usr/man (man pages)<br></p>
+<p>Mostly this doesn't matter as the /usr/local directories will
+generally be earlier in the search path.&nbsp; The pigpio built
+includes, binaries, and manuals are normally found first.<br></p>
+<p>However the wrong libraries may be linked during the
+compilation.&nbsp; If this is the case remove the /usr/lib entries
+for libpigpio.so , libpigpiod_if.so, and libpigpiod_if2.so</p>
+<h3><a name="Hello_World" id="Hello_World"></a>Hello World!</h3>
+<p>The following examples show how to use the various components of
+the pigpio library.</p>
+<p>Each example shows how to read the level of a GPIO.</p>
+<h4>C</h4>
+read_cif.c
+<pre>
+#include &lt;stdio.h&gt;
+#include &lt;pigpio.h&gt;
+
+int main(int argc, char *argv[])
+{
+ int GPIO=4;
+ int level;
+
+ if (gpioInitialise() &lt; 0) return 1;
+
+ level = gpioRead(GPIO);
+
+ printf("GPIO %d is %d\n", GPIO, level);
+
+ gpioTerminate();
+}
+ </pre>
+<p>Build</p>
+<code>gcc -pthread -o read_cif read_cif.c -lpigpio</code>
+<p>Run</p>
+<code>sudo ./read_cif</code>
+<h4>C via pigpio daemon</h4>
+read_pdif.c
+<pre>
+#include &lt;stdio.h&gt;
+#include &lt;pigpiod_if2.h&gt;
+
+int main(int argc, char *argv[])
+{
+ int pi;
+ int GPIO=4;
+ int level;
+
+ pi = pigpio_start(0, 0); /* Connect to local Pi. */
+
+ if (pi &lt; 0)
+ {
+ printf("Can't connect to pigpio daemon\n");
+ return 1;
+ }
+
+ level = gpio_read(pi, GPIO);
+
+ printf("GPIO %d is %d\n", GPIO, level);
+
+ pigpio_stop(pi); /* Disconnect from local Pi. */
+
+ return 0;
+}
+</pre>
+<p>Build</p>
+<code>gcc -pthread -o read_pdif read_pdif.c -lpigpiod_if2</code>
+<p>Run</p>
+<code>./read_pdif</code>
+<h4>Python</h4>
+read_gpio.py
+<pre>
+#!/usr/bin/env python
+
+import pigpio
+
+GPIO=4
+
+pi = pigpio.pi()
+if not pi.connected:
+ exit()
+
+level = pi.read(GPIO)
+
+print("GPIO {} is {}".format(GPIO, level))
+
+pi.stop()
+ </pre>
+<p>Run</p>
+<code>python read_gpio.py</code>
+<h4>pigs</h4>
+<pre>
+pigs r 4
+ </pre>
+<h4>pipe I/F</h4>
+<pre>
+echo "r 4" &gt;/dev/pigpio
+cat /dev/pigout
+ </pre>
+<h3><a name="make_fails" id="make_fails"></a>make fails with clock
+skew</h3>
+<p>If make fails with one of the following messages it is probably
+because the Pi's clock is wrong.<br></p>
+<p><code>make: Warning: File 'xxx' has modification time x s in the
+future<br>
+make: warning: Clock skew detected. Your build may be
+incomplete.</code></p>
+<p>make uses the current time to work out which files need to be
+rebuilt (a file is rebuilt if it depends on other files which have
+a later time-stamp).<br></p>
+<p>The solution is to make sure the system clock is correct.&nbsp;
+If the Pi is networked this will not normally be a problem.<br></p>
+<p>To set the date and time use the date command as in the
+following example.</p>
+<p><code>sudo date -d "2017-03-01 18:47:00"</code></p>
+<h3><a name="Porting_pigpio" id="Porting_pigpio"></a>Porting pigpio
+to another CPU/SoC</h3>
+<h3><a name="Sound_isnt_working" id="Sound_isnt_working"></a>Sound
+isn't working</h3>
+<p>The Pi contains two pieces of hardware, a PWM peripheral and a
+PCM peripheral, to generate sound.&nbsp; The PWM peripheral is
+normally used and generates medium quality audio out of the
+headphone jack.&nbsp; The PCM peripheral may be used by add-ons
+such as HATs and generates high quality audio.<br></p>
+<p>pigpio uses at least one of these peripherals during normal
+operation (for timing DMA transfers).&nbsp; pigpio will use both
+peripherals if waves or the hardware PWM function is used.<br></p>
+<p>By default pigpio uses the PCM peripheral leaving the PWM
+peripheral free for medium quality audio.<br></p>
+<p>You can change the default with a configuration option.&nbsp;
+For C use <a href="cif.html#gpioCfgClock">gpioCfgClock</a>, for the
+<a href="pigpiod.html">pigpio daemon</a> use the -t option.</p>
+<h3><a name="What_is_I2C" id="What_is_I2C"></a>What is I2C?</h3>
+<p>I2C is a data link between the Pi (master) and one or more
+slaves.</p>
+<p>Data may be sent and received but the Pi initiates all
+transfers.<br></p>
+<p>I2C is a medium speed link.&nbsp; On the Pi the default speed is
+100 kbps, but 400 kbps also works.<br></p>
+<p>I2C is implemented as a bus with two lines called<br></p>
+<ul>
+<li>SDA - for data</li>
+<li>SCL - for a clock</li>
+</ul>
+On the Pi bus 1 is used which uses GPIO 2 (pin 3) for SDA and GPIO
+3 (pin 5) for SCL.<br>
+<br>
+Only one slave device may be communicated with at a time.&nbsp;
+Each message from the Pi includes the slave to be addressed and
+whether a read or write is to be performed.<br>
+<br>
+When the Pi (master) wishes to talk to a slave it begins by issuing
+a start sequence on the I2C bus. A start sequence is one of two
+special sequences defined for the I2C bus, the other being the stop
+sequence. The start sequence and stop sequence are special in that
+these are the only places where the SDA (data line) is allowed to
+change while the SCL (clock line) is high. When data is being
+transferred, SDA must remain stable and not change whilst SCL is
+high. The start and stop sequences mark the beginning and end of a
+transaction with the slave device.<br>
+<br>
+<img style="width: 600px;" alt="I2C start and stop sequences" src=
+"images/faq-i2c-ss.png"><br>
+<br>
+Data is transferred in 8-bit bytes. The bytes are placed on the SDA
+line starting with the most significant bit. The SCL line is then
+pulsed high, then low. For every byte transferred, the device
+receiving the data sends back an acknowledge bit, so there are
+actually 9 SCL clock pulses to transfer each 8-bit byte of data. If
+the receiving device sends back a low ACK bit, then it has received
+the data and is ready to accept another byte. If it sends back a
+high then it is indicating it cannot accept any further data and
+the master should terminate the transfer by sending a stop
+sequence.<br>
+<br>
+<p><img style="width: 600px;" alt="I2C waveform" src=
+"images/faq-i2c.jpg"><br></p>
+<h3><a name="What_is_Serial" id="What_is_Serial"></a>What is
+Serial?</h3>
+<p>Serial is a data link between the Pi and one other
+device.<br></p>
+<p>Data may be sent and received.&nbsp; Either the Pi or the device
+can initiate a transfer.<br></p>
+<p>Serial is a low to medium speed link.&nbsp; On the Pi speeds of
+50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600,
+19200, 38400, 57600, 115200, and 230400 bps may be used.<br></p>
+<p>Serial is implemented with one line for transmit called TXD and
+one line for receive called RXD.<br></p>
+<p>If only receive or transmit are required the other line need not
+be connected.<br></p>
+<p>The Pi uses GPIO 14 (pin 8) for TXD and GPIO 15 (pin 10) for
+RXD.<br></p>
+<p>Data is normally transmitted in 8-bit bytes with a start bit,
+eight data bits, no parity, and one stop bit.&nbsp; This is
+represented as 8N1.&nbsp; The number of transmitted bits per second
+(bps) is called the baud rate.&nbsp;&nbsp; The time for each bit,
+<span style="font-style: italic;">1 / baud rate</span> seconds, is
+referred to as the bit period.<br></p>
+<p>The lines are in the high state when no data is being
+transmitted.&nbsp; The start of a byte is signalled by the line
+going low for one bit period (the start bit).&nbsp; The data bits
+are then sent least significant bit firsts (low if the bit is 0,
+high if the bit is 1).&nbsp; The data bits are followed by the
+optional parity bit.&nbsp; Finally the line is set high for at
+least the number of stop bit periods.&nbsp; The line will stay high
+if there are no more bytes to be transmitted.<br></p>
+<p><img style="width: 600px;" alt="Serial waveform" src=
+"images/faq-serial.jpg"><br></p>
+<h3><a name="What_is_SPI" id="What_is_SPI"></a>What is SPI?</h3>
+<p>SPI is a data link between the Pi (master) and one or more
+slaves.</p>
+<p>Data may be sent and received but the Pi initiates all
+transfers.<br></p>
+<p>SPI is a medium to high speed link.&nbsp; On the Pi speeds of 32
+kbps to 8 Mbps may be used.<br></p>
+<p>SPI is implemented as a bus with three lines called<br></p>
+<ul>
+<li>MOSI - for data from the Pi to the slave</li>
+<li>MISO - for data from the slave to the Pi</li>
+<li>SCLK - for a clock</li>
+</ul>
+Only one slave device may be communicated with at a time.&nbsp; An
+additional line per slave called slave select is used to identify
+the slave to be addressed.
+<p>The Pi has two SPI buses<br></p>
+<ol>
+<li>the main SPI bus
+<ul>
+<li>MOSI GPIO 10 (pin 19)</li>
+<li>MISO GPIO 9 (pin 21)</li>
+<li>SCLK GPIO 11 (pin 23)</li>
+<li>Slave selects</li>
+<li style="list-style: none; display: inline">
+<ul>
+<li>CE0 GPIO 8 (pin 24)</li>
+<li>CE1 GPIO 7 (pin 26)</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>the auxiliary SPI bus
+<ul>
+<li>MOSI GPIO 20 (pin 38)</li>
+<li>MISO GPIO 19 (pin 35)</li>
+<li>SCLK GPIO 21 (pin 40)</li>
+<li>Slave selects</li>
+<li style="list-style: none; display: inline">
+<ul>
+<li>CE0 GPIO 18 (pin 12)</li>
+<li>CE1 GPIO 17 (pin 11)</li>
+<li>CE2 GPIO 16 (pin 36)<br></li>
+</ul>
+</li>
+</ul>
+</li>
+</ol>
+<p><img style="width: 600px;" alt="SPI waveform" src=
+"images/faq-spi.jpg"><br></p>
+<p><br></p>
+<h3><a name="Which_library" id="Which_library"></a>Which library
+should I use?</h3>
+<p><br></p>
+</body>
+</html>
diff --git a/DOC/src/html/index.html b/DOC/src/html/index.html
new file mode 100644
index 0000000..0b8e33c
--- /dev/null
+++ b/DOC/src/html/index.html
@@ -0,0 +1,659 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="content-type">
+<title>pigpio</title>
+</head>
+<body>
+pigpio is a library for the Raspberry which allows control of the
+General Purpose Input Outputs (GPIO).&nbsp; pigpio works on all
+versions of the Pi.
+<p><a href="download.html">Download</a><br></p>
+<h3>Features<br></h3>
+<ul>
+<li>
+<p>hardware timed sampling and time-stamping of GPIO 0-31 every 5
+us<br></p>
+</li>
+<li>
+<p>hardware timed PWM on all of GPIO 0-31<br></p>
+</li>
+<li>
+<p>hardware timed servo pulses on all of GPIO 0-31</p>
+</li>
+<li>
+<p>callbacks on GPIO 0-31 level change (time accurate to a few
+us)</p>
+</li>
+<li>
+<p>notifications via pipe on GPIO 0-31 level change<br></p>
+</li>
+<li>
+<p>callbacks at timed intervals</p>
+</li>
+<li>
+<p>reading/writing all of the GPIO in a bank (0-31, 32-53) as a
+single operation</p>
+</li>
+<li>
+<p>GPIO reading, writing, modes, and internal pulls<br></p>
+</li>
+<li>
+<p>socket and pipe interfaces for the bulk of the functionality</p>
+</li>
+<li>
+<p>waveforms to generate GPIO level changes (time accurate to a few
+us)</p>
+</li>
+<li>
+<p>software serial links using any user GPIO</p>
+</li>
+<li>
+<p>rudimentary permission control through the socket and pipe
+interfaces<br></p>
+</li>
+<li>creating and running scripts on the pigpio daemon</li>
+</ul>
+<h3>General</h3>
+The pigpio <a href="cif.html">library</a> is written in the C
+programming language.<br>
+<br>
+The <a href="pigpiod.html">pigpio daemon</a> offers a <a href=
+"sif.html">socket</a> and <a href="pif.html">pipe</a> interface to
+the underlying C library.<br>
+<br>
+A <a href="pdif2.html">C library</a> and a <a href=
+"python.html">Python module</a> allow control of the GPIO via the
+pigpio daemon.<br>
+<br>
+There is third party support for a number of <a href=
+"index.html#Other_Languages">other languages</a>.&nbsp;
+<h3>piscope</h3>
+<p><a href="piscope.html">piscope</a> is a logic analyser (digital
+waveform viewer).<br></p>
+piscope is a GTK+3 application and uses pigpio to provide raw GPIO
+level data.&nbsp; piscope may be run on a Pi or on any machine
+capable of compiling a GTK+3 application.
+<h3><a name="GPIO" id="GPIO"></a>GPIO</h3>
+<p><span style="font-weight: bold;">ALL GPIO</span> are identified
+by their <span style="font-weight: bold;">Broadcom
+number</span>.&nbsp; See <a href=
+"http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29">
+elinux.org</a><br></p>
+There are 54 GPIO in total, arranged in two banks.<br>
+<p>Bank 1 contains GPIO 0-31.&nbsp; Bank 2 contains GPIO
+32-53.<br></p>
+For all types of Pi it is safe to read all the GPIO. If you try to
+write a system GPIO or change its mode you can crash the Pi or
+corrupt the data on the SD card.<br>
+<br>
+There are several types of board, each with different expansion
+headers, giving physical access to different GPIO.&nbsp;
+<ul>
+<li><a href="#Type_1">Type 1</a> - Model B (original model)</li>
+<li><a href="#Type_2">Type 2</a> - Model A, B (revision 2)</li>
+<li><a href="#Type_3">Type 3</a> - Model A+, B+, Pi Zero, Pi2B,
+Pi3B</li>
+<li><a href="#CM">Compute Module</a> - Compute Module</li>
+</ul>
+<h4><a name="Type_1" id="Type_1"></a>Type 1 - Model B (original
+model)</h4>
+<ul>
+<li>26 pin header (P1).</li>
+</ul>
+<ul>
+<li>Hardware revision numbers of 2 and 3.</li>
+</ul>
+<ul>
+<li>User GPIO 0-1, 4, 7-11, 14-15, 17-18, 21-25.</li>
+</ul>
+<table summary="" style="width: 60%; text-align: left;"
+cellspacing="0" cellpadding="0" border="0">
+<tbody>
+<tr>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+<br></td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SDA</td>
+<td style="text-align: center;">0<br></td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SCL</td>
+<td style="text-align: center;">1<br></td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">TXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">RXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">ce1</td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">ce0</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">13</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">16</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">MOSI</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">19</td>
+<td style="text-align: center;">20</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;">MISO</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">SCLK</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">CE0</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;">26</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">CE1</td>
+</tr>
+</tbody>
+</table>
+<br>
+<h4><a name="Type_2" id="Type_2"></a>Type 2 - Model A, B (revision
+2)</h4>
+26 pin header (P1) and an additional 8 pin header (P5).
+<ul>
+<li>Hardware revision numbers of 4, 5, 6 (B), 7, 8, 9 (A), and 13,
+14, 15 (B).</li>
+</ul>
+<ul>
+<li>User GPIO 2-4, 7-11, 14-15, 17-18, 22-25, 27-31.<br></li>
+</ul>
+<table summary="" style="width: 60%; text-align: left;"
+cellspacing="0" cellpadding="0" border="0">
+<tbody>
+<tr>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+<br></td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SDA</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SCL</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">TXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">RXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">ce1</td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">ce0</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">27</td>
+<td style="text-align: center;">13</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">16</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">MOSI</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">19</td>
+<td style="text-align: center;">20</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;">MISO</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">SCLK</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">CE0</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;">26</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">CE1</td>
+</tr>
+</tbody>
+</table>
+<br>
+<table summary="" style="width: 60%; text-align: left;"
+cellspacing="0" cellpadding="0" border="0">
+<tbody>
+<tr>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+<br></td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">5V<br></td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">3V3</td>
+</tr>
+<tr>
+<td style="text-align: center;">SDA<br></td>
+<td style="text-align: center;">28</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">29</td>
+<td style="text-align: center;">SCL</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">30</td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">31</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground<br></td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">Ground</td>
+</tr>
+</tbody>
+</table>
+<br>
+<h4><a name="Type_3" id="Type_3"></a>Type 3 - Model A+, B+, Pi
+Zero, Pi Zero W, Pi2B, Pi3B, Pi4B<br></h4>
+<ul>
+<li>40 pin expansion header (J8).</li>
+</ul>
+<ul>
+<li>Hardware revision numbers of 16 or greater.</li>
+</ul>
+<ul>
+<li>User GPIO 2-27 (0 and 1 are reserved).<br></li>
+</ul>
+<table summary="" style="width: 60%; text-align: left;"
+cellspacing="0" cellpadding="0" border="0">
+<tbody>
+<tr>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+<br></td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style="font-weight: bold; text-align: center;">pin</td>
+<td style=
+"vertical-align: top; font-weight: bold; text-align: center;">
+GPIO</td>
+<td style="font-weight: bold; text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SDA</td>
+<td style="text-align: center;">2</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">5V</td>
+</tr>
+<tr>
+<td style="text-align: center;">SCL</td>
+<td style="text-align: center;">3</td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">4</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">TXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">RXD</td>
+</tr>
+<tr>
+<td style="text-align: center;">ce1</td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">ce0</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">27</td>
+<td style="text-align: center;">13</td>
+<td style="text-align: center;">14</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">15</td>
+<td style="text-align: center;">16</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">3V3</td>
+<td style="text-align: center;">-<br></td>
+<td style="text-align: center;">17</td>
+<td style="text-align: center;">18</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">MOSI</td>
+<td style="text-align: center;">10</td>
+<td style="text-align: center;">19</td>
+<td style="text-align: center;">20</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;">MISO</td>
+<td style="text-align: center;">9</td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">22</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;">SCLK</td>
+<td style="text-align: center;">11</td>
+<td style="text-align: center;">23</td>
+<td style="text-align: center;">24</td>
+<td style="text-align: center;">8</td>
+<td style="text-align: center;">CE0</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">25</td>
+<td style="text-align: center;">26</td>
+<td style="text-align: center;">7</td>
+<td style="text-align: center;">CE1</td>
+</tr>
+<tr>
+<td style="text-align: center;">ID_SD</td>
+<td style="text-align: center;">0</td>
+<td style="text-align: center;">27</td>
+<td style="text-align: center;">28</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: center;">ID_SC</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">5</td>
+<td style="text-align: center;">29</td>
+<td style="text-align: center;">30</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">6</td>
+<td style="text-align: center;">31</td>
+<td style="text-align: center;">32</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: center;"><br></td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">13</td>
+<td style="text-align: center;">33</td>
+<td style="text-align: center;">34</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">Ground</td>
+</tr>
+<tr>
+<td style="text-align: center;">miso</td>
+<td style="text-align: center;">19</td>
+<td style="text-align: center;">35</td>
+<td style="text-align: center;">36</td>
+<td style="text-align: center;">16</td>
+<td style="text-align: center;">ce2</td>
+</tr>
+<tr>
+<td style="text-align: center;"><br></td>
+<td style="text-align: center;">26</td>
+<td style="text-align: center;">37</td>
+<td style="text-align: center;">38</td>
+<td style="text-align: center;">20</td>
+<td style="text-align: center;">mosi</td>
+</tr>
+<tr>
+<td style="text-align: center;">Ground</td>
+<td style="text-align: center;">-</td>
+<td style="text-align: center;">39</td>
+<td style="text-align: center;">40</td>
+<td style="text-align: center;">21</td>
+<td style="text-align: center;">sclk</td>
+</tr>
+</tbody>
+</table>
+<br>
+<h4><a name="CM" id="CM"></a>Compute Module</h4>
+<p>All 54 GPIO may be physically accessed.&nbsp; Some are reserved
+for system use - refer to the Compute Module documentation.<br></p>
+<p>Only GPIO 0-31 are supported for hardware timed sampling, PWM,
+servo pulses, alert callbacks, waves, and software serial
+links.<br></p>
+<h3><a name="Other_Languages" id="Other_Languages"></a>Other
+Languages</h3>
+<p>There are several third party projects which provide wrappers
+for pigpio.<br></p>
+<p>Some are listed here:<br></p>
+<ul>
+<li><a href="https://github.com/skvamme/pigpio">Erlang</a>
+(skvamme)</li>
+<li><a href="https://github.com/mattjlewis/pigpioj">Java</a> JNI
+wrapper around the pigpio C library (mattlewis)</li>
+<li><a href="https://github.com/mattjlewis/diozero">Java</a> via
+diozero, a high level wrapper around pigpio, Pi4J, wiringPi etc
+(mattlewis)</li>
+<li><a href="https://github.com/nkolban/jpigpio">Java</a>
+(nkolban)</li>
+<li><a href=
+"https://github.com/unosquare/pigpio-dotnet">.NET/mono</a>
+(unosquare)</li>
+<li><a href="https://github.com/fivdi/pigpio">Node.js</a>
+A wrapper for the pigpio C library (fivdi)</li>
+<li><a href="https://github.com/guymcswain/pigpio-client">Node.js</a>
+A client for pigpio socket interface (guymcswain)</li>
+<li><a href="https://metacpan.org/pod/RPi::PIGPIO">Perl</a> (Gligan
+Calin Horea)</li>
+<li><a href=
+"https://github.com/nak1114/ruby-extension-pigpio">Ruby</a>
+(Nak)</li>
+<li><a href=
+"https://github.com/vasmalltalk/pigpio-vast">Smalltalk</a>(Instantiations)</li>
+<li><a href=
+"https://github.com/UBogun/Xojo-pigpio">Xojo</a>(UBogun)</li>
+<li><a href=
+"https://github.com/eugenedakin/pigpio-GPIO">Xojo</a>(Eugene Dakin)</li>
+</ul>
+<hr style="width: 100%; height: 2px;">
+<p><font size="-2">The PWM and servo pulses are timed using the DMA
+and PWM/PCM peripherals.&nbsp; This use was inspired by Richard
+Hirst's <a href="https://github.com/richardghirst/PiBits" target=
+"_blank">servoblaster</a> kernel module.</font></p>
+</body>
+</html>
diff --git a/DOC/src/html/misc.html b/DOC/src/html/misc.html
new file mode 100644
index 0000000..4c6f305
--- /dev/null
+++ b/DOC/src/html/misc.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Miscellaneous</title>
+</head>
+<body>
+There are two C libraries which provide a socket interface to the
+pigpio daemon.&nbsp; They provide an interface very similar to the
+pigpio Python module.<br>
+<ul>
+<li>The original <a href="./pdif.html">pigpiod_if</a> library is
+now deprecated and will no longer be updated.&nbsp; This library is
+limited to controlling one Pi at a time.</li>
+</ul>
+<ul>
+<li>The new <a href="./pdif2.html">pigpiod_if2</a> library which
+should be used for new code.&nbsp; This library allows multiple Pis
+to be controlled at one time.</li>
+</ul>
+Additional details of the pigpio <a href="./sif.html">socket</a>
+interface.<br>
+<br>
+Additional details of the pigpio <a href="./pif.html">pipe</a>
+interface.<br>
+<br>
+<a href="pig2vcd.html">pig2vcd</a> is a utility which converts
+pigpio notifications into the VCD (Value Change Dump) format.&nbsp;
+VCD can be read by many programs, in particular <a href=
+"http://gtkwave.sourceforge.net/">GTKWave</a>.
+</body>
+</html>
diff --git a/DOC/src/html/pif.html b/DOC/src/html/pif.html
new file mode 100644
index 0000000..bc924ff
--- /dev/null
+++ b/DOC/src/html/pif.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+<title>Pipe interface</title>
+</head>
+<body>
+pigpio provides a pipe interface to many of its functions.<br>
+<br>
+The pipe interface is available whenever pigpio is running, either
+because it has been started as a daemon, or it has been linked in
+to a running user program.&nbsp; The pipe interface can be disabled
+by the program which initialises the library.&nbsp; pigpiod offers
+the -f option to disable the pipe interface.&nbsp; User programs
+should call <a href=
+"http://abyz.me.uk/rpi/pigpio/cif.html#gpioCfgInterfaces">gpioCfgInterfaces</a>
+if they wish to disable the pipe interface.<br>
+<br>
+pigpio listens for commands on pipe /dev/pigpio.&nbsp; The commands
+consist of a command identifier with, depending on the command,
+zero, one, or two parameters.&nbsp; The result, if any, may be read
+from pipe /dev/pigout.&nbsp; If any errors are detected a message
+will be written to pipe /dev/pigerr.<br>
+<br>
+<br>
+The format of the commands is identical to those used by <a href=
+"pigs.html">pigs</a>.
+</body>
+</html>
diff --git a/DOC/src/html/piscope.html b/DOC/src/html/piscope.html
new file mode 100644
index 0000000..c381057
--- /dev/null
+++ b/DOC/src/html/piscope.html
@@ -0,0 +1,216 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta name="generator" content=
+"HTML Tidy for HTML5 for Linux version 5.6.0">
+<meta content="text/html; charset=utf-8" http-equiv="content-type">
+<title>piscope</title>
+</head>
+<body>
+<h2>Introduction<br></h2>
+<a href="piscope.tar">piscope</a> is a logic analyser (digital
+waveform viewer) for the Raspberry.&nbsp; It shows the state (high
+or low) of selected GPIO in real-time.<br>
+<br>
+See <a href="http://youtu.be/2apqOiLHEzs">video</a>.<br>
+<br>
+piscope uses the services of the pigpio <a href=
+"download.html">library</a>.&nbsp; pigpio needs to be running on
+the Pi whose GPIO are to be monitored.<br>
+<br>
+The pigpio library may be started as a daemon (background process)
+by the following command.<br>
+<br>
+<code>sudo pigpiod<br></code><br>
+piscope may be invoked in several different ways<br>
+<br>
+<table summary="" style=
+"text-align: left; width: 90%; height: 246px;" cellspacing="2"
+cellpadding="2" border="1">
+<tbody>
+<tr>
+<td style="width: 15%;"><small>Pi<br></small></td>
+<td style="vertical-align: top; width: 55%;"><small><span style=
+"font-style: italic;">pi_host</span> ~ $ piscope
+&amp;<br></small></td>
+<td style="vertical-align: top; width: 30%;"><small>Pi captures
+data<br>
+Pi processes data<br>
+Pi displays data<br></small></td>
+</tr>
+<tr>
+<td style="vertical-align: top;"><small>Pi plus Linux PC<br>
+<br>
+(with the<br>
+display on a remote<br>
+&nbsp; Linux PC)<br></small></td>
+<td style="vertical-align: top;"><small><span style=
+"font-style: italic;">remote_host</span> ~ $ ssh -X <span style=
+"font-style: italic;">pi_host</span><br></small><small><span style=
+"font-style: italic;">pi_host</span> ~ $ piscope
+&amp;</small><small><br></small></td>
+<td style="vertical-align: top;"><small>Pi captures data<br>
+Pi processes data<br>
+Remote Linux PC displays data<br></small></td>
+</tr>
+<tr>
+<td style="vertical-align: top;"><small>Pi plus Windows PC<br>
+<br>
+(with the<br>
+display on a remote<br>
+&nbsp; Windows PC)</small></td>
+<td style="vertical-align: top;"><small>You need to install an SSH
+client (putty suggested) and a X11 server (xming suggested).<br>
+<br>
+Run Program Files -&gt; Xming -&gt; XLaunch and accept the
+defaults.<br>
+<br>
+Run putty and enter the Pi's host name or IP address.&nbsp; Click
+on SSH X11 and tick Enable X11 forwarding and then select
+Open.</small><br>
+<small><br></small> <small><span style=
+"font-style: italic;">pi_host</span> ~ $ piscope
+&amp;</small><br></td>
+<td style="vertical-align: top;"><small>Pi captures data<br>
+Pi processes data<br>
+Remote Windows PC displays data</small></td>
+</tr>
+<tr>
+<td style="vertical-align: top;"><small>Pi plus Linux PC<br>
+<br>
+(with the display and processing on a remote Linux
+PC)<br></small></td>
+<td style="vertical-align: top;"><small><span style=
+"font-style: italic;">remote_host</span> ~ $ export
+PIGPIO_ADDR=<span style="font-style: italic;">pi_host</span><br>
+<span style="font-style: italic;">remote_host</span> ~ $ piscope
+&amp;<br></small></td>
+<td style="vertical-align: top;"><small>Pi captures data<br>
+Remote processes data<br>
+Remote displays data<br></small></td>
+</tr>
+</tbody>
+</table>
+<br>
+piscope operates in one of three modes<br>
+<br>
+<table summary="" style="text-align: left; width: 90%;"
+cellspacing="2" cellpadding="2" border="1">
+<tbody>
+<tr>
+<td style="vertical-align: top;">Live<br></td>
+<td style="vertical-align: top;">The latest GPIO samples are
+displayed.<br>
+<br>
+The mode will automatically change to Pause if a sampling trigger
+is detected.<br>
+<br>
+There are four triggers.&nbsp; Each trigger is made up of a
+combination of GPIO states (one of don't care, low, high, edge,
+falling, or rising per GPIO).&nbsp; Triggers are always
+counted.&nbsp; In addition a trigger may be sample to, sample
+around, or sample from, a so called sampling trigger.<br></td>
+<td style="vertical-align: top;">New samples are added to the
+sample buffer.<br>
+<br>
+Once the sample buffer is full the <span style=
+"font-weight: bold;">oldest</span> samples are discarded.</td>
+</tr>
+<tr>
+<td style="vertical-align: top;">Play<br></td>
+<td style="vertical-align: top;">Recorded GPIO samples are
+displayed.<br>
+<br>
+The play speed may be varied between 64 times real-time to 1/32768
+of real-time.<br>
+<br>
+The page up key increases the play speed by a factor of 2.&nbsp;
+The page down key decreases the play speed by a factor of 2.&nbsp;
+The home key sets the play speed to 1X.<br></td>
+<td style="vertical-align: top;">New samples are added to the
+sample buffer.<br>
+<br>
+Once the sample buffer is full <span style=
+"font-weight: bold;">new</span> samples are discarded.</td>
+</tr>
+<tr>
+<td style="vertical-align: top;">Pause<br></td>
+<td style="vertical-align: top;">Recorded GPIO samples are
+displayed.<br>
+<br>
+The left and right cursor keys move the blue marker to the previous
+or next edge.&nbsp; By default all GPIO edges are considered.&nbsp;
+Clicking on a GPIO name will limit edge searches to the highlighted
+GPIO only.<br>
+<br>
+The left and right square bracket keys move the blue marker to the
+previous or next trigger.<br>
+<br>
+The time between the blue and gold markers is displayed.&nbsp; The
+gold marker is set to the blue marker by a press of the 'g'
+key.<br></td>
+<td style="vertical-align: top;">New samples are added to the
+sample buffer.<br>
+<br>
+Once the sample buffer is full <span style=
+"font-weight: bold;">new</span> samples are discarded.</td>
+</tr>
+</tbody>
+</table>
+<br>
+In all modes the down and up cursor keys zoom the time scale in and
+out.<br>
+<br>
+Samples can be saved with File Save All Samples or File Save
+Selected Samples.
+<p>To select samples enter pause mode. Press 1 to specify the start
+of the samples (green marker) and 2 to specify the end of the
+samples (red marker).</p>
+<p>The samples may be saved in the native piscope format or in VCD
+format.</p>
+<p>Data saved in VCD format may be viewed and further processed
+with GTKWave.</p>
+<p>Data saved in the native piscope format may be restored later
+with File Restore Saved Data.</p>
+<h2>Installation</h2>
+<p>To download and install piscope.</p>
+<h3>Pi (pre-built image)</h3>
+<code>wget abyz.me.uk/rpi/pigpio/piscope.tar<br>
+tar xvf piscope.tar<br>
+cd PISCOPE<br>
+make hf<br>
+make install</code><span style="font-weight: bold;"><br></span>
+<h3>Linux 64 bit X86/AMD (pre-built image)</h3>
+<code>wget abyz.me.uk/rpi/pigpio/piscope.tar<br>
+tar xvf piscope.tar<br>
+cd PISCOPE<br>
+make x86_64<br>
+make install<br></code>
+<h3>All machines (building from source)</h3>
+You only need to perform this step if you want to build the
+executable from the source files.&nbsp; This is not needed if you
+use a pre-built image.<br>
+<span style="font-weight: bold;"><br>
+WARNING</span>: Installing gtk+-3.0 uses a lot of SD card
+space.<br>
+<br>
+Most of the space used by gtk+-3.0 is taken up by unneeded *-dbg
+packages.<br>
+<br>
+With *-dbg packages an additional 3753MB SD space is required.<br>
+<br>
+If you edit the list of packages to be downloaded and remove the
+*-dbg packages only 134MB of additional SD space is needed (as at
+the time of writing).<br>
+<br>
+<code>#<br></code> <code># *** This may take a lot of time and use
+a lot of SD card space ***<br></code> <code>#<br>
+sudo apt-get install gtk+-3.0<br></code> <code>#<br></code>
+<code>wget abyz.me.uk/rpi/pigpio/piscope.tar<br>
+tar xvf piscope.tar<br>
+cd PISCOPE<br>
+make<br>
+make install<br></code><br>
+</body>
+</html>
diff --git a/DOC/src/html/sif.html b/DOC/src/html/sif.html
new file mode 100644
index 0000000..67b880b
--- /dev/null
+++ b/DOC/src/html/sif.html
@@ -0,0 +1,2004 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta name="generator" content="Bluefish 2.2.10" >
+<meta content="text/html; charset=utf-8" http-equiv="content-type">
+<title>Socket interface</title>
+</head>
+<body>
+pigpio provides a socket interface to many of its functions.<br>
+<br>
+The socket interface is available whenever pigpio is running,
+either because it has been started as a daemon, or it has been
+linked in to a running user program.<br>
+<br>
+The socket interface can be disabled by the program which
+initialises the library.&nbsp; pigpiod offers the -k option to
+disable the socket interface.&nbsp; User programs should call
+<a href="cif.html#gpioCfgInterfaces">gpioCfgInterfaces</a> if they
+wish to disable the socket interface.<br>
+<br>
+pigpio listens for connections on port 8888 by default.&nbsp; This
+default may be overridden when pigpio starts by the <a href=
+"cif.html#gpioCfgSocketPort">gpioCfgSocketPort</a> function
+call.&nbsp; The pigpio daemon uses this function to provide an
+option to change the port number.<br>
+<br>
+The pigs utility is an example of using the socket interface from
+C.<span style="font-weight: bold;"><br></span>
+<h3><a name="Request" id="Request"></a>Request</h3>
+<p>pigpio expects messages of type <a href=
+"sif.html#cmdCmd_t">cmdCmd_t</a> immediately followed with an
+extension for a few commands.<br>
+<br>
+The caller should fill in cmd, p1, p2, p3/res, and any extension as
+needed.&nbsp; p3 will always be zero unless the command requires an
+extension in which case p3 will be the length in bytes of the
+extension.<br>
+<br>
+The <a href="sif.html#cmdCmd_t">cmdCmd_t</a> is echoed back with
+the result, if any, in p3/res, and an extension immediately
+afterwards for a few commands.<br></p>
+<table summary="" style="width: 80%;" cellspacing="2" cellpadding=
+"2" border="1">
+<tbody>
+<tr>
+<td style="font-weight: bold;">COMMAND</td>
+<td style="font-weight: bold;">cmd<br></td>
+<td style="font-weight: bold;">p1</td>
+<td style="font-weight: bold;">p2</td>
+<td style="font-weight: bold;">p3</td>
+<td style="font-weight: bold;">Extension<br></td>
+</tr>
+<tr>
+<td>MODES</td>
+<td>0</td>
+<td>gpio</td>
+<td>mode</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MODEG</td>
+<td>1</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PUD</td>
+<td>2</td>
+<td>gpio</td>
+<td>pud</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>READ</td>
+<td>3</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WRITE</td>
+<td>4</td>
+<td>gpio</td>
+<td>level</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PWM</td>
+<td>5</td>
+<td>gpio</td>
+<td>dutycycle</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRS</td>
+<td>6</td>
+<td>gpio</td>
+<td>range</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PFS</td>
+<td>7</td>
+<td>gpio</td>
+<td>frequency</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERVO</td>
+<td>8</td>
+<td>gpio</td>
+<td>pulsewidth</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WDOG</td>
+<td>9</td>
+<td>gpio</td>
+<td>timeout</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BR1</td>
+<td>10</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BR2</td>
+<td>11</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BC1</td>
+<td>12</td>
+<td>bits</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BC2</td>
+<td>13</td>
+<td>bits</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BS1</td>
+<td>14</td>
+<td>bits</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BS2</td>
+<td>15</td>
+<td>bits</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>TICK</td>
+<td>16</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>HWVER</td>
+<td>17</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NO</td>
+<td>18</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NB</td>
+<td>19</td>
+<td>handle</td>
+<td>bits</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NP</td>
+<td>20</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NC</td>
+<td>21</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRG</td>
+<td>22</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PFG</td>
+<td>23</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRRG</td>
+<td>24</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>HELP<br></td>
+<td>25</td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+</tr>
+<tr>
+<td>PIGPV</td>
+<td>26</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVCLR</td>
+<td>27</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVAG</td>
+<td>28</td>
+<td>0</td>
+<td>0</td>
+<td>12*X</td>
+<td>gpioPulse_t pulse[X]</td>
+</tr>
+<tr>
+<td>WVAS</td>
+<td>29</td>
+<td>gpio</td>
+<td>baud</td>
+<td>12+X</td>
+<td>uint32_t databits<br>
+uint32_t stophalfbits<br>
+uint32_t offset<br>
+uint8_t data[X]</td>
+</tr>
+<tr>
+<td>N/A<br></td>
+<td>30</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>N/A<br></td>
+<td>31</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVBSY</td>
+<td>32</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVHLT</td>
+<td>33</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSM</td>
+<td>34</td>
+<td>subcmd</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSP</td>
+<td>35</td>
+<td>subcmd</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSC</td>
+<td>36</td>
+<td>subcmd</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>TRIG</td>
+<td>37</td>
+<td>gpio</td>
+<td>pulselen</td>
+<td>4</td>
+<td>uint32_t level</td>
+</tr>
+<tr>
+<td>PROC</td>
+<td>38</td>
+<td>0</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t text[X]</td>
+</tr>
+<tr>
+<td>PROCD</td>
+<td>39</td>
+<td>script_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCR</td>
+<td>40</td>
+<td>script_id</td>
+<td>0</td>
+<td>4*X<br></td>
+<td>uint32_t pars[X]<br></td>
+</tr>
+<tr>
+<td>PROCS</td>
+<td>41</td>
+<td>script_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SLRO</td>
+<td>42</td>
+<td>gpio</td>
+<td>baud</td>
+<td>4</td>
+<td>uint32_t databits<br></td>
+</tr>
+<tr>
+<td>SLR</td>
+<td>43</td>
+<td>gpio</td>
+<td>count</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SLRC</td>
+<td>44</td>
+<td>gpio</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCP</td>
+<td>45</td>
+<td>script_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MICS</td>
+<td>46</td>
+<td>micros</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MILS</td>
+<td>47</td>
+<td>millis</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PARSE</td>
+<td>48</td>
+<td>N/A</td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+<td>N/A</td>
+</tr>
+<tr>
+<td>WVCRE</td>
+<td>49</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVDEL</td>
+<td>50</td>
+<td>wave_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVTX</td>
+<td>51</td>
+<td>wave_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVTXR</td>
+<td>52</td>
+<td>wave_id</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVNEW</td>
+<td>53</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CO</td>
+<td>54</td>
+<td>bus</td>
+<td>device</td>
+<td>4</td>
+<td>uint32_t flags</td>
+</tr>
+<tr>
+<td>I2CC</td>
+<td>55</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRD</td>
+<td>56</td>
+<td>handle</td>
+<td>count</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWD</td>
+<td>57</td>
+<td>handle</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>I2CWQ</td>
+<td>58</td>
+<td>handle</td>
+<td>bit</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRS</td>
+<td>59</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWS</td>
+<td>60</td>
+<td>handle</td>
+<td>byte</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRB</td>
+<td>61</td>
+<td>handle</td>
+<td>register</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWB</td>
+<td>62</td>
+<td>handle</td>
+<td>register</td>
+<td>4</td>
+<td>uint32_t byte</td>
+</tr>
+<tr>
+<td>I2CRW</td>
+<td>63</td>
+<td>handle</td>
+<td>register</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWW</td>
+<td>64</td>
+<td>handle</td>
+<td>register</td>
+<td>4</td>
+<td>uint32_t word</td>
+</tr>
+<tr>
+<td>I2CRK</td>
+<td>65</td>
+<td>handle</td>
+<td>register<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWK</td>
+<td>66</td>
+<td>handle</td>
+<td>register<br></td>
+<td>X</td>
+<td>uint8_t bvs[X]<br></td>
+</tr>
+<tr>
+<td>I2CRI</td>
+<td>67</td>
+<td>handle</td>
+<td>register<br></td>
+<td>4</td>
+<td>uint32_t num<br></td>
+</tr>
+<tr>
+<td>I2CWI</td>
+<td>68</td>
+<td>handle</td>
+<td>register<br></td>
+<td>X<br></td>
+<td>uint8_t bvs[X]<br></td>
+</tr>
+<tr>
+<td>I2CPC</td>
+<td>69</td>
+<td>handle</td>
+<td>register<br></td>
+<td>4</td>
+<td>uint32_t word<br></td>
+</tr>
+<tr>
+<td>I2CPK</td>
+<td>70</td>
+<td>handle</td>
+<td>register<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SPIO<br></td>
+<td>71</td>
+<td>channel</td>
+<td>baud</td>
+<td>4</td>
+<td>uint32_t flags</td>
+</tr>
+<tr>
+<td>SPIC</td>
+<td>72</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIR</td>
+<td>73</td>
+<td>handle</td>
+<td>count</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIW</td>
+<td>74</td>
+<td>handle</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>SPIX</td>
+<td>75</td>
+<td>handle</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>SERO</td>
+<td>76</td>
+<td>baud</td>
+<td>flags</td>
+<td>X</td>
+<td>uint8_t device[X]</td>
+</tr>
+<tr>
+<td>SERC</td>
+<td>77</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERRB</td>
+<td>78</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERWB</td>
+<td>79</td>
+<td>handle</td>
+<td>byte</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERR</td>
+<td>80</td>
+<td>handle</td>
+<td>count</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERW</td>
+<td>81</td>
+<td>handle</td>
+<td>0</td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>SERDA</td>
+<td>82</td>
+<td>handle</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">GDC<br></td>
+<td style="vertical-align: top;">83<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">GPW<br></td>
+<td style="vertical-align: top;">84<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">HC<br></td>
+<td style="vertical-align: top;">85<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">frequency<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">HP<br></td>
+<td style="vertical-align: top;">86<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">frequency<br></td>
+<td style="vertical-align: top;">4<br></td>
+<td style="vertical-align: top;">uint32_t dutycycle<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CF1<br></td>
+<td style="vertical-align: top;">87<br></td>
+<td style="vertical-align: top;">arg1<br></td>
+<td style="vertical-align: top;">arg2<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t argx[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CF2<br></td>
+<td style="vertical-align: top;">88<br></td>
+<td style="vertical-align: top;">arg1<br></td>
+<td style="vertical-align: top;">retMax<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t argx[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CC<br></td>
+<td style="vertical-align: top;">89<br></td>
+<td style="vertical-align: top;">sda<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CO<br></td>
+<td style="vertical-align: top;">90<br></td>
+<td style="vertical-align: top;">sda<br></td>
+<td style="vertical-align: top;">scl<br></td>
+<td style="vertical-align: top;">4<br></td>
+<td style="vertical-align: top;">uint32_t baud<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CZ<br></td>
+<td style="vertical-align: top;">91<br></td>
+<td style="vertical-align: top;">sda<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">I2CZ<br></td>
+<td style="vertical-align: top;">92<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVCHA<br></td>
+<td style="vertical-align: top;">93<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">SLRI<br></td>
+<td style="vertical-align: top;">94<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">invert<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CGI<br></td>
+<td style="vertical-align: top;">95<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CSI<br></td>
+<td style="vertical-align: top;">96<br></td>
+<td style="vertical-align: top;">config<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FG<br></td>
+<td style="vertical-align: top;">97<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">steady<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FN<br></td>
+<td style="vertical-align: top;">98<br></td>
+<td style="vertical-align: top;">gpio<br></td>
+<td style="vertical-align: top;">steady<br></td>
+<td style="vertical-align: top;">4<br></td>
+<td style="vertical-align: top;">uint32_t active<br></td>
+</tr>
+<tr>
+<td>NOIB</td>
+<td>99</td>
+<td>0</td>
+<td>0</td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVTXM<br></td>
+<td style="vertical-align: top;">100<br></td>
+<td style="vertical-align: top;">wave_id<br></td>
+<td style="vertical-align: top;">mode<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVTAT<br></td>
+<td style="vertical-align: top;">101<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">PADS<br></td>
+<td style="vertical-align: top;">102<br></td>
+<td style="vertical-align: top;">pad<br></td>
+<td style="vertical-align: top;">strength<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">PADG<br></td>
+<td style="vertical-align: top;">103<br></td>
+<td style="vertical-align: top;">pad<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FO<br></td>
+<td style="vertical-align: top;">104<br></td>
+<td style="vertical-align: top;">mode<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t file[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FC<br></td>
+<td style="vertical-align: top;">105<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FR<br></td>
+<td style="vertical-align: top;">106<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">count<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FW<br></td>
+<td style="vertical-align: top;">107<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FS<br></td>
+<td style="vertical-align: top;">108<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">offset<br></td>
+<td style="vertical-align: top;">4<br></td>
+<td style="vertical-align: top;">uint32_t from<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FL<br></td>
+<td style="vertical-align: top;">109<br></td>
+<td style="vertical-align: top;">count<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t pattern[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">SHELL<br></td>
+<td style="vertical-align: top;">110<br></td>
+<td style="vertical-align: top;">len(name)<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">len(name)+<br>
+1+<br>
+len(string)<br></td>
+<td style="vertical-align: top;">uint8_t name[len(name)]<br>
+uint8_t null (0)<br>
+uint8_t string[len(string)]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIC<br></td>
+<td style="vertical-align: top;">111<br></td>
+<td style="vertical-align: top;">CS<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIO<br></td>
+<td style="vertical-align: top;">112<br></td>
+<td style="vertical-align: top;">CS<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">20<br></td>
+<td style="vertical-align: top;">uint32_t MISO<br>
+uint32_t MOSI<br>
+uint32_t SCLK<br>
+uint32_t baud<br>
+uint32_t spi_flags<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIX<br></td>
+<td style="vertical-align: top;">113<br></td>
+<td style="vertical-align: top;">CS<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSCX<br></td>
+<td style="vertical-align: top;">114<br></td>
+<td style="vertical-align: top;">control<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">EVM<br></td>
+<td style="vertical-align: top;">115<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">bits<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">EVT<br></td>
+<td style="vertical-align: top;">116<br></td>
+<td style="vertical-align: top;">event<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td valign="top">PROCU<br></td>
+<td valign="top">117<br></td>
+<td valign="top">script_id<br></td>
+<td valign="top">0<br></td>
+<td valign="top">4*X<br></td>
+<td valign="top">uint32_t pars[X]<br></td>
+</tr>
+</tbody>
+</table>
+<h3><a name="Response" id="Response"></a>Response</h3>
+<p>The response has cmd/p1/p2 as in the request.&nbsp; p3/res holds
+the return value.&nbsp; If the command returns additional values
+they will be in the immediately following extension.<br></p>
+Normally res should be treated as a 32 bit signed value and will be
+greater than or equal to zero.&nbsp; Upon failure res will be less
+than 0 and contains an error code.<br>
+<p>There are a few commands where the returned value should be
+treated as a 32 bit unsigned value.&nbsp; These commands can not
+fail.&nbsp; They are indicated with a * after the command
+name.<br></p>
+<p>Commands with an extension have the size of the extension in
+bytes returned in res (or &lt;0 on error as above).</p>
+<table summary="" style="width: 80%;" cellspacing="2" cellpadding=
+"2" border="1">
+<tbody>
+<tr>
+<td style="font-weight: bold;">COMMAND</td>
+<td style="font-weight: bold;">cmd<br></td>
+<td style="vertical-align: top; font-weight: bold;">p1<br></td>
+<td style="vertical-align: top; font-weight: bold;">p2<br></td>
+<td style="font-weight: bold;">res<br></td>
+<td style="font-weight: bold;">Extension<br></td>
+</tr>
+<tr>
+<td>MODES</td>
+<td>0</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MODEG</td>
+<td>1</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>mode<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PUD</td>
+<td>2</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>READ</td>
+<td>3</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>level<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WRITE</td>
+<td>4</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PWM</td>
+<td>5</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRS</td>
+<td>6</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PFS</td>
+<td>7</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERVO</td>
+<td>8</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WDOG</td>
+<td>9</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BR1 *</td>
+<td>10</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>bits<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BR2 *</td>
+<td>11</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>bits<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BC1</td>
+<td>12</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BC2</td>
+<td>13</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BS1</td>
+<td>14</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>BS2</td>
+<td>15</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>TICK *<br></td>
+<td>16</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>tick<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>HWVER *<br></td>
+<td>17</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>version<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NO</td>
+<td>18</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>handle<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NB</td>
+<td>19</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NP</td>
+<td>20</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>NC</td>
+<td>21</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRG</td>
+<td>22</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>range<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PFG</td>
+<td>23</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>frequency<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PRRG</td>
+<td>24</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>real range<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>HELP</td>
+<td>25</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>N/A<br></td>
+<td>N/A<br></td>
+</tr>
+<tr>
+<td>PIGPV *<br></td>
+<td>26</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>version<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVCLR</td>
+<td>27</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVAG</td>
+<td>28</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave pulses<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVAS</td>
+<td>29</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave pulses<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>N/A<br></td>
+<td>30</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>-<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>N/A<br></td>
+<td>31</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>-<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVBSY</td>
+<td>32</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>busy (1) or not busy (0)<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVHLT</td>
+<td>33</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSM</td>
+<td>34</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave micros<br>
+wave micros - high<br>
+wave micros - max<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSP</td>
+<td>35</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave pulses<br>
+wave pulses - high<br>
+wave pulses - max<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVSC</td>
+<td>36</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave DMA CBs<br>
+wave DMA CBs - high<br>
+wave DMA CBs - max<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>TRIG</td>
+<td>37</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-</td>
+</tr>
+<tr>
+<td>PROC</td>
+<td>38</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>script id<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCD</td>
+<td>39</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCR</td>
+<td>40</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>script status<br></td>
+<td>-</td>
+</tr>
+<tr>
+<td>PROCS</td>
+<td>41</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SLRO</td>
+<td>42</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SLR</td>
+<td>43</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SLRC</td>
+<td>44</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PROCP</td>
+<td>45</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>44</td>
+<td>uint32_t script_status<br>
+uint32_t pars[10]<br></td>
+</tr>
+<tr>
+<td>MICS</td>
+<td>46</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>MILS</td>
+<td>47</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>PARSE</td>
+<td>48</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>N/A<br></td>
+<td>-</td>
+</tr>
+<tr>
+<td>WVCRE</td>
+<td>49</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave id<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVDEL</td>
+<td>50</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVTX</td>
+<td>51</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave DMA CBs<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVTXR</td>
+<td>52</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>wave DMA CBs<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>WVNEW</td>
+<td>53</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CO</td>
+<td>54</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>handle</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CC</td>
+<td>55</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRD</td>
+<td>56</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>I2CWD</td>
+<td>57</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWQ</td>
+<td>58</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRS</td>
+<td>59</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>byte value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWS</td>
+<td>60</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRB</td>
+<td>61</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>byte value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWB</td>
+<td>62</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRW</td>
+<td>63</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>word value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWW</td>
+<td>64</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRK</td>
+<td>65</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CWK</td>
+<td>66</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CRI</td>
+<td>67</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>I2CWI</td>
+<td>68</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CPC</td>
+<td>69</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>word value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>I2CPK</td>
+<td>70</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SPIO<br></td>
+<td>71</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>handle<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIC</td>
+<td>72</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIR</td>
+<td>73</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SPIW</td>
+<td>74</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SPIX</td>
+<td>75</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X</td>
+<td>uint8_t data[X]</td>
+</tr>
+<tr>
+<td>SERO</td>
+<td>76</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>handle<br></td>
+<td>-</td>
+</tr>
+<tr>
+<td>SERC</td>
+<td>77</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERRB</td>
+<td>78</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>byte value<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERWB</td>
+<td>79</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERR</td>
+<td>80</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>X<br></td>
+<td>uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td>SERW</td>
+<td>81</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td>SERDA</td>
+<td>82</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>data ready count<br></td>
+<td>-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">GDC<br></td>
+<td style="vertical-align: top;">83<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">dutycycle<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">GPW<br></td>
+<td style="vertical-align: top;">84<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">pulsewidth<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">HC<br></td>
+<td style="vertical-align: top;">85<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">HP<br></td>
+<td style="vertical-align: top;">86<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CF1<br></td>
+<td style="vertical-align: top;">87<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">value<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CF2<br></td>
+<td style="vertical-align: top;">88<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t retBuf[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CC<br></td>
+<td style="vertical-align: top;">89<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CO<br></td>
+<td style="vertical-align: top;">90<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BI2CZ<br></td>
+<td style="vertical-align: top;">91<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">I2CZ<br></td>
+<td style="vertical-align: top;">92<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVCHA<br></td>
+<td style="vertical-align: top;">93<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">SLRI<br></td>
+<td style="vertical-align: top;">94<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CGI<br></td>
+<td style="vertical-align: top;">95<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">config<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">CSI<br></td>
+<td style="vertical-align: top;">96<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FG<br></td>
+<td style="vertical-align: top;">97<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FN<br></td>
+<td style="vertical-align: top;">98<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td>NOIB</td>
+<td>99</td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td>0</td>
+<td>-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVTXM<br></td>
+<td style="vertical-align: top;">100<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">wave DMA CBs<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">WVTAT<br></td>
+<td style="vertical-align: top;">101<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">wave id<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">PADS<br></td>
+<td style="vertical-align: top;">102<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">PADG<br></td>
+<td style="vertical-align: top;">103<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">strength<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FO<br></td>
+<td style="vertical-align: top;">104<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">handle<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FC<br></td>
+<td style="vertical-align: top;">105<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FR<br></td>
+<td style="vertical-align: top;">106<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FW<br></td>
+<td style="vertical-align: top;">107<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FS<br></td>
+<td style="vertical-align: top;">108<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">position<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">FL<br></td>
+<td style="vertical-align: top;">109<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t filenames[X]<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">SHELL<br></td>
+<td style="vertical-align: top;">110<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">exit status<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIC<br></td>
+<td style="vertical-align: top;">111<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIO<br></td>
+<td style="vertical-align: top;">112<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSPIX<br></td>
+<td style="vertical-align: top;">113<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X<br></td>
+<td style="vertical-align: top;">uint8_t data[X]</td>
+</tr>
+<tr>
+<td style="vertical-align: top;">BSCX<br></td>
+<td style="vertical-align: top;">114<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">X+4<br></td>
+<td style="vertical-align: top;">uint32_t status<br>
+uint8_t data[X]</td>
+</tr>
+<tr>
+<td style="vertical-align: top;">EVM<br></td>
+<td style="vertical-align: top;">115<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td style="vertical-align: top;">EVT<br></td>
+<td style="vertical-align: top;">116<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">-<br></td>
+<td style="vertical-align: top;">0<br></td>
+<td style="vertical-align: top;">-<br></td>
+</tr>
+<tr>
+<td valign="top">PROCU<br></td>
+<td valign="top">117<br></td>
+<td valign="top">-<br></td>
+<td valign="top">-<br></td>
+<td valign="top">0<br></td>
+<td valign="top">-<br></td>
+</tr>
+</tbody>
+</table>
+<code><br></code>
+<h3><a name="cmdCmd_t" id="cmdCmd_t"></a>cmdCmd_t</h3>
+<code>typedef struct<br>
+{<br>
+&nbsp;&nbsp; uint32_t cmd;<br>
+&nbsp;&nbsp; uint32_t p1;<br>
+&nbsp;&nbsp; uint32_t p2;<br>
+&nbsp;&nbsp; union<br>
+&nbsp;&nbsp; {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32_t p3;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32_t ext_len;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint32_t res;<br>
+&nbsp;&nbsp; };<br>
+} cmdCmd_t;<br></code><br>
+</body>
+</html>
diff --git a/README.md b/README.md
index e326fca..8727e74 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,12 @@
pigpio is a C library for the Raspberry which allows control of the
General Purpose Input Outputs (GPIO).
+**At the moment pigpio on the Pi4B is experimental. I am not sure if the DMA channels
+ being used are safe. The Pi4B defaults are primary channel 7, secondary channel 6.
+ If these channels do not work you will have to experiment. You can set the channels
+ used by the pigpio daemon by invoking it with the -d and -e options, e.g.
+ <small>sudo pigpiod -d 5 -e 8</small> to specify primary 5, secondary 8.**
+
## Features
* Sampling and time-stamping of GPIO 0-31 between 100,000 and 1,000,000 times per second
diff --git a/SUPPORT.md b/SUPPORT.md
new file mode 100644
index 0000000..c9a5eda
--- /dev/null
+++ b/SUPPORT.md
@@ -0,0 +1,8 @@
+Questions about the pigpio library are welcome but we ask that you check these resources first:
+* [pigpio library web page](http://abyz.me.uk/rpi/pigpio)
+Noobs should start with the FAQ. All
+APIs are documented extensively.
+* Search the repository issues with a 'question' label
+For example, to search for information on PWM type in search box:
+`label:question pwm`
+* Check the repository's Wiki - WIP, help wanted.
diff --git a/cmake/FindRT.cmake b/cmake/FindRT.cmake
new file mode 100644
index 0000000..db7c4de
--- /dev/null
+++ b/cmake/FindRT.cmake
@@ -0,0 +1,39 @@
+# FindRT.cmake - Try to find the RT library
+# Once done this will define
+#
+# RT_FOUND - System has rt
+# RT_INCLUDE_DIR - The rt include directory
+# RT_LIBRARIES - The libraries needed to use rt
+# RT_DEFINITIONS - Compiler switches required for using rt
+#
+# Also creates an import target called RT::RT
+
+find_path (RT_INCLUDE_DIR NAMES time.h
+ PATHS
+ /usr
+ /usr/local
+ /opt
+ PATH_SUFFIXES
+)
+
+find_library(RT_LIBRARIES NAMES rt
+ PATHS
+ /usr
+ /usr/local
+ /opt
+)
+
+include(FindPackageHandleStandardArgs)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(rt DEFAULT_MSG RT_LIBRARIES RT_INCLUDE_DIR)
+
+mark_as_advanced(RT_INCLUDE_DIR RT_LIBRARIES)
+
+if (NOT TARGET RT::RT)
+ add_library(RT::RT INTERFACE IMPORTED)
+
+ set_target_properties(RT::RT PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES ${RT_INCLUDE_DIR}
+ INTERFACE_LINK_LIBRARIES ${RT_LIBRARIES}
+ )
+endif() \ No newline at end of file
diff --git a/cmake/pigpioConfig.cmake b/cmake/pigpioConfig.cmake
new file mode 100644
index 0000000..7912526
--- /dev/null
+++ b/cmake/pigpioConfig.cmake
@@ -0,0 +1 @@
+include (${CMAKE_CURRENT_LIST_DIR}/pigpioTargets.cmake) \ No newline at end of file
diff --git a/cmake/setup.py.in b/cmake/setup.py.in
new file mode 100644
index 0000000..a5913a2
--- /dev/null
+++ b/cmake/setup.py.in
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+from distutils.core import setup
+
+setup(name='pigpio',
+ version='1.44',
+ author='joan',
+ author_email='joan@abyz.me.uk',
+ maintainer='joan',
+ maintainer_email='joan@abyz.me.uk',
+ url='http://abyz.me.uk/rpi/pigpio/python.html',
+ description='Raspberry Pi GPIO module',
+ long_description='Raspberry Pi Python module to access the pigpio daemon',
+ download_url='http://abyz.me.uk/rpi/pigpio/pigpio.zip',
+ license='unlicense.org',
+ py_modules=['pigpio'],
+ keywords=['raspberrypi', 'gpio',],
+ classifiers=[
+ "Programming Language :: Python :: 2",
+ "Programming Language :: Python :: 3",
+ ],
+ package_dir={ '': '${CMAKE_CURRENT_SOURCE_DIR}'}
+ )
+
diff --git a/command.c b/command.c
index 7b339ea..ffc3463 100644
--- a/command.c
+++ b/command.c
@@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
-This version is for pigpio version 67+
+This version is for pigpio version 70+
*/
#include <stdio.h>
@@ -41,223 +41,224 @@ This version is for pigpio version 67+
cmdInfo_t cmdInfo[]=
{
- /* num str vfyt retv */
+ /* num str vfyt retv script*/
- {PI_CMD_BC1, "BC1", 111, 1}, // gpioWrite_Bits_0_31_Clear
- {PI_CMD_BC2, "BC2", 111, 1}, // gpioWrite_Bits_32_53_Clear
+ {PI_CMD_BC1, "BC1", 111, 1, 1}, // gpioWrite_Bits_0_31_Clear
+ {PI_CMD_BC2, "BC2", 111, 1, 1}, // gpioWrite_Bits_32_53_Clear
- {PI_CMD_BI2CC, "BI2CC", 112, 0}, // bbI2CClose
- {PI_CMD_BI2CO, "BI2CO", 131, 0}, // bbI2COpen
- {PI_CMD_BI2CZ, "BI2CZ", 193, 6}, // bbI2CZip
+ {PI_CMD_BI2CC, "BI2CC", 112, 0, 1}, // bbI2CClose
+ {PI_CMD_BI2CO, "BI2CO", 131, 0, 1}, // bbI2COpen
+ {PI_CMD_BI2CZ, "BI2CZ", 193, 6, 0}, // bbI2CZip
- {PI_CMD_BR1, "BR1", 101, 3}, // gpioRead_Bits_0_31
- {PI_CMD_BR2, "BR2", 101, 3}, // gpioRead_Bits_32_53
+ {PI_CMD_BR1, "BR1", 101, 3, 1}, // gpioRead_Bits_0_31
+ {PI_CMD_BR2, "BR2", 101, 3, 1}, // gpioRead_Bits_32_53
- {PI_CMD_BS1, "BS1", 111, 1}, // gpioWrite_Bits_0_31_Set
- {PI_CMD_BS2, "BS2", 111, 1}, // gpioWrite_Bits_32_53_Set
+ {PI_CMD_BS1, "BS1", 111, 1, 1}, // gpioWrite_Bits_0_31_Set
+ {PI_CMD_BS2, "BS2", 111, 1, 1}, // gpioWrite_Bits_32_53_Set
- {PI_CMD_BSCX, "BSCX", 193, 8}, // bscXfer
+ {PI_CMD_BSCX, "BSCX", 193, 8, 0}, // bscXfer
- {PI_CMD_BSPIC, "BSPIC", 112, 0}, // bbSPIClose
- {PI_CMD_BSPIO, "BSPIO", 134, 0}, // bbSPIOpen
- {PI_CMD_BSPIX, "BSPIX", 193, 6}, // bbSPIXfer
+ {PI_CMD_BSPIC, "BSPIC", 112, 0, 1}, // bbSPIClose
+ {PI_CMD_BSPIO, "BSPIO", 134, 0, 0}, // bbSPIOpen
+ {PI_CMD_BSPIX, "BSPIX", 193, 6, 0}, // bbSPIXfer
- {PI_CMD_CF1, "CF1", 195, 2}, // gpioCustom1
- {PI_CMD_CF2, "CF2", 195, 6}, // gpioCustom2
+ {PI_CMD_CF1, "CF1", 195, 2, 0}, // gpioCustom1
+ {PI_CMD_CF2, "CF2", 195, 6, 0}, // gpioCustom2
- {PI_CMD_CGI, "CGI", 101, 4}, // gpioCfgGetInternals
- {PI_CMD_CSI, "CSI", 111, 1}, // gpioCfgSetInternals
+ {PI_CMD_CGI, "CGI", 101, 4, 1}, // gpioCfgGetInternals
+ {PI_CMD_CSI, "CSI", 111, 1, 1}, // gpioCfgSetInternals
- {PI_CMD_EVM, "EVM", 122, 1}, // eventMonitor
- {PI_CMD_EVT, "EVT", 112, 0}, // eventTrigger
+ {PI_CMD_EVM, "EVM", 122, 1, 1}, // eventMonitor
+ {PI_CMD_EVT, "EVT", 112, 0, 1}, // eventTrigger
- {PI_CMD_FC, "FC", 112, 0}, // fileClose
+ {PI_CMD_FC, "FC", 112, 0, 1}, // fileClose
- {PI_CMD_FG, "FG", 121, 0}, // gpioGlitchFilter
+ {PI_CMD_FG, "FG", 121, 0, 1}, // gpioGlitchFilter
- {PI_CMD_FL, "FL", 127, 6}, // fileList
+ {PI_CMD_FL, "FL", 127, 6, 0}, // fileList
- {PI_CMD_FN, "FN", 131, 0}, // gpioNoiseFilter
+ {PI_CMD_FN, "FN", 131, 0, 1}, // gpioNoiseFilter
- {PI_CMD_FO, "FO", 127, 2}, // fileOpen
- {PI_CMD_FR, "FR", 121, 6}, // fileRead
- {PI_CMD_FS, "FS", 133, 2}, // fileSeek
- {PI_CMD_FW, "FW", 193, 0}, // fileWrite
+ {PI_CMD_FO, "FO", 127, 2, 0}, // fileOpen
+ {PI_CMD_FR, "FR", 121, 6, 0}, // fileRead
+ {PI_CMD_FS, "FS", 133, 2, 1}, // fileSeek
+ {PI_CMD_FW, "FW", 193, 0, 0}, // fileWrite
- {PI_CMD_GDC, "GDC", 112, 2}, // gpioGetPWMdutycycle
- {PI_CMD_GPW, "GPW", 112, 2}, // gpioGetServoPulsewidth
+ {PI_CMD_GDC, "GDC", 112, 2, 1}, // gpioGetPWMdutycycle
+ {PI_CMD_GPW, "GPW", 112, 2, 1}, // gpioGetServoPulsewidth
- {PI_CMD_HELP, "H", 101, 5}, // cmdUsage
- {PI_CMD_HELP, "HELP", 101, 5}, // cmdUsage
+ {PI_CMD_HELP, "H", 101, 5, 0}, // cmdUsage
+ {PI_CMD_HELP, "HELP", 101, 5, 0}, // cmdUsage
- {PI_CMD_HC, "HC", 121, 0}, // gpioHardwareClock
- {PI_CMD_HP, "HP", 131, 0}, // gpioHardwarePWM
+ {PI_CMD_HC, "HC", 121, 0, 1}, // gpioHardwareClock
+ {PI_CMD_HP, "HP", 131, 0, 1}, // gpioHardwarePWM
- {PI_CMD_HWVER, "HWVER", 101, 4}, // gpioHardwareRevision
+ {PI_CMD_HWVER, "HWVER", 101, 4, 1}, // gpioHardwareRevision
- {PI_CMD_I2CC, "I2CC", 112, 0}, // i2cClose
- {PI_CMD_I2CO, "I2CO", 131, 2}, // i2cOpen
+ {PI_CMD_I2CC, "I2CC", 112, 0, 1}, // i2cClose
+ {PI_CMD_I2CO, "I2CO", 131, 2, 1}, // i2cOpen
- {PI_CMD_I2CPC, "I2CPC", 131, 2}, // i2cProcessCall
- {PI_CMD_I2CPK, "I2CPK", 194, 6}, // i2cBlockProcessCall
+ {PI_CMD_I2CPC, "I2CPC", 131, 2, 1}, // i2cProcessCall
+ {PI_CMD_I2CPK, "I2CPK", 194, 6, 0}, // i2cBlockProcessCall
- {PI_CMD_I2CRB, "I2CRB", 121, 2}, // i2cReadByteData
- {PI_CMD_I2CRD, "I2CRD", 121, 6}, // i2cReadDevice
- {PI_CMD_I2CRI, "I2CRI", 131, 6}, // i2cReadI2CBlockData
- {PI_CMD_I2CRK, "I2CRK", 121, 6}, // i2cReadBlockData
- {PI_CMD_I2CRS, "I2CRS", 112, 2}, // i2cReadByte
- {PI_CMD_I2CRW, "I2CRW", 121, 2}, // i2cReadWordData
+ {PI_CMD_I2CRB, "I2CRB", 121, 2, 1}, // i2cReadByteData
+ {PI_CMD_I2CRD, "I2CRD", 121, 6, 0}, // i2cReadDevice
+ {PI_CMD_I2CRI, "I2CRI", 131, 6, 0}, // i2cReadI2CBlockData
+ {PI_CMD_I2CRK, "I2CRK", 121, 6, 0}, // i2cReadBlockData
+ {PI_CMD_I2CRS, "I2CRS", 112, 2, 1}, // i2cReadByte
+ {PI_CMD_I2CRW, "I2CRW", 121, 2, 1}, // i2cReadWordData
- {PI_CMD_I2CWB, "I2CWB", 131, 0}, // i2cWriteByteData
- {PI_CMD_I2CWD, "I2CWD", 193, 0}, // i2cWriteDevice
- {PI_CMD_I2CWI, "I2CWI", 194, 0}, // i2cWriteI2CBlockData
- {PI_CMD_I2CWK, "I2CWK", 194, 0}, // i2cWriteBlockData
- {PI_CMD_I2CWQ, "I2CWQ", 121, 0}, // i2cWriteQuick
- {PI_CMD_I2CWS, "I2CWS", 121, 0}, // i2cWriteByte
- {PI_CMD_I2CWW, "I2CWW", 131, 0}, // i2cWriteWordData
+ {PI_CMD_I2CWB, "I2CWB", 131, 0, 1}, // i2cWriteByteData
+ {PI_CMD_I2CWD, "I2CWD", 193, 0, 0}, // i2cWriteDevice
+ {PI_CMD_I2CWI, "I2CWI", 194, 0, 0}, // i2cWriteI2CBlockData
+ {PI_CMD_I2CWK, "I2CWK", 194, 0, 0}, // i2cWriteBlockData
+ {PI_CMD_I2CWQ, "I2CWQ", 121, 0, 1}, // i2cWriteQuick
+ {PI_CMD_I2CWS, "I2CWS", 121, 0, 1}, // i2cWriteByte
+ {PI_CMD_I2CWW, "I2CWW", 131, 0, 1}, // i2cWriteWordData
- {PI_CMD_I2CZ, "I2CZ", 193, 6}, // i2cZip
+ {PI_CMD_I2CZ, "I2CZ", 193, 6, 0}, // i2cZip
- {PI_CMD_MICS, "MICS", 112, 0}, // gpioDelay
- {PI_CMD_MILS, "MILS", 112, 0}, // gpioDelay
+ {PI_CMD_MICS, "MICS", 112, 0, 1}, // gpioDelay
+ {PI_CMD_MILS, "MILS", 112, 0, 1}, // gpioDelay
- {PI_CMD_MODEG, "MG" , 112, 2}, // gpioGetMode
- {PI_CMD_MODEG, "MODEG", 112, 2}, // gpioGetMode
+ {PI_CMD_MODEG, "MG" , 112, 2, 1}, // gpioGetMode
+ {PI_CMD_MODEG, "MODEG", 112, 2, 1}, // gpioGetMode
- {PI_CMD_MODES, "M", 125, 0}, // gpioSetMode
- {PI_CMD_MODES, "MODES", 125, 0}, // gpioSetMode
+ {PI_CMD_MODES, "M", 125, 0, 1}, // gpioSetMode
+ {PI_CMD_MODES, "MODES", 125, 0, 1}, // gpioSetMode
- {PI_CMD_NB, "NB", 122, 0}, // gpioNotifyBegin
- {PI_CMD_NC, "NC", 112, 0}, // gpioNotifyClose
- {PI_CMD_NO, "NO", 101, 2}, // gpioNotifyOpen
- {PI_CMD_NP, "NP", 112, 0}, // gpioNotifyPause
+ {PI_CMD_NB, "NB", 122, 0, 1}, // gpioNotifyBegin
+ {PI_CMD_NC, "NC", 112, 0, 1}, // gpioNotifyClose
+ {PI_CMD_NO, "NO", 101, 2, 1}, // gpioNotifyOpen
+ {PI_CMD_NP, "NP", 112, 0, 1}, // gpioNotifyPause
- {PI_CMD_PADG, "PADG", 112, 2}, // gpioGetPad
- {PI_CMD_PADS, "PADS", 121, 0}, // gpioSetPad
+ {PI_CMD_PADG, "PADG", 112, 2, 1}, // gpioGetPad
+ {PI_CMD_PADS, "PADS", 121, 0, 1}, // gpioSetPad
- {PI_CMD_PARSE, "PARSE", 115, 0}, // cmdParseScript
-
- {PI_CMD_PFG, "PFG", 112, 2}, // gpioGetPWMfrequency
- {PI_CMD_PFS, "PFS", 121, 2}, // gpioSetPWMfrequency
-
- {PI_CMD_PIGPV, "PIGPV", 101, 4}, // gpioVersion
-
- {PI_CMD_PRG, "PRG", 112, 2}, // gpioGetPWMrange
-
- {PI_CMD_PROC, "PROC", 115, 2}, // gpioStoreScript
- {PI_CMD_PROCD, "PROCD", 112, 0}, // gpioDeleteScript
- {PI_CMD_PROCP, "PROCP", 112, 7}, // gpioScriptStatus
- {PI_CMD_PROCR, "PROCR", 191, 0}, // gpioRunScript
- {PI_CMD_PROCS, "PROCS", 112, 0}, // gpioStopScript
- {PI_CMD_PROCU, "PROCU", 191, 0}, // gpioUpdateScript
-
- {PI_CMD_PRRG, "PRRG", 112, 2}, // gpioGetPWMrealRange
- {PI_CMD_PRS, "PRS", 121, 2}, // gpioSetPWMrange
-
- {PI_CMD_PUD, "PUD", 126, 0}, // gpioSetPullUpDown
-
- {PI_CMD_PWM, "P", 121, 0}, // gpioPWM
- {PI_CMD_PWM, "PWM", 121, 0}, // gpioPWM
-
- {PI_CMD_READ, "R", 112, 2}, // gpioRead
- {PI_CMD_READ, "READ", 112, 2}, // gpioRead
-
- {PI_CMD_SERRB, "SERRB", 112, 2}, // serReadByte
- {PI_CMD_SERWB, "SERWB", 121, 0}, // serWriteByte
- {PI_CMD_SERC, "SERC", 112, 0}, // serClose
- {PI_CMD_SERDA, "SERDA", 112, 2}, // serDataAvailable
- {PI_CMD_SERO, "SERO", 132, 2}, // serOpen
- {PI_CMD_SERR, "SERR", 121, 6}, // serRead
- {PI_CMD_SERW, "SERW", 193, 0}, // serWrite
-
- {PI_CMD_SERVO, "S", 121, 0}, // gpioServo
- {PI_CMD_SERVO, "SERVO", 121, 0}, // gpioServo
-
- {PI_CMD_SHELL, "SHELL", 128, 2}, // shell
-
- {PI_CMD_SLR, "SLR", 121, 6}, // gpioSerialRead
- {PI_CMD_SLRC, "SLRC", 112, 0}, // gpioSerialReadClose
- {PI_CMD_SLRO, "SLRO", 131, 0}, // gpioSerialReadOpen
- {PI_CMD_SLRI, "SLRI", 121, 0}, // gpioSerialReadInvert
-
- {PI_CMD_SPIC, "SPIC", 112, 0}, // spiClose
- {PI_CMD_SPIO, "SPIO", 131, 2}, // spiOpen
- {PI_CMD_SPIR, "SPIR", 121, 6}, // spiRead
- {PI_CMD_SPIW, "SPIW", 193, 0}, // spiWrite
- {PI_CMD_SPIX, "SPIX", 193, 6}, // spiXfer
-
- {PI_CMD_TICK, "T", 101, 4}, // gpioTick
- {PI_CMD_TICK, "TICK", 101, 4}, // gpioTick
-
- {PI_CMD_TRIG, "TRIG", 131, 0}, // gpioTrigger
-
- {PI_CMD_WDOG, "WDOG", 121, 0}, // gpioSetWatchdog
-
- {PI_CMD_WRITE, "W", 121, 0}, // gpioWrite
- {PI_CMD_WRITE, "WRITE", 121, 0}, // gpioWrite
-
- {PI_CMD_WVAG, "WVAG", 192, 2}, // gpioWaveAddGeneric
- {PI_CMD_WVAS, "WVAS", 196, 2}, // gpioWaveAddSerial
- {PI_CMD_WVTAT, "WVTAT", 101, 2}, // gpioWaveTxAt
- {PI_CMD_WVBSY, "WVBSY", 101, 2}, // gpioWaveTxBusy
- {PI_CMD_WVCHA, "WVCHA", 197, 0}, // gpioWaveChain
- {PI_CMD_WVCLR, "WVCLR", 101, 0}, // gpioWaveClear
- {PI_CMD_WVCRE, "WVCRE", 101, 2}, // gpioWaveCreate
- {PI_CMD_WVDEL, "WVDEL", 112, 0}, // gpioWaveDelete
- {PI_CMD_WVGO, "WVGO" , 101, 2}, // gpioWaveTxStart
- {PI_CMD_WVGOR, "WVGOR", 101, 2}, // gpioWaveTxStart
- {PI_CMD_WVHLT, "WVHLT", 101, 0}, // gpioWaveTxStop
- {PI_CMD_WVNEW, "WVNEW", 101, 0}, // gpioWaveAddNew
- {PI_CMD_WVSC, "WVSC", 112, 2}, // gpioWaveGet*Cbs
- {PI_CMD_WVSM, "WVSM", 112, 2}, // gpioWaveGet*Micros
- {PI_CMD_WVSP, "WVSP", 112, 2}, // gpioWaveGet*Pulses
- {PI_CMD_WVTX, "WVTX", 112, 2}, // gpioWaveTxSend
- {PI_CMD_WVTXM, "WVTXM", 121, 2}, // gpioWaveTxSend
- {PI_CMD_WVTXR, "WVTXR", 112, 2}, // gpioWaveTxSend
-
- {PI_CMD_ADD , "ADD" , 111, 0},
- {PI_CMD_AND , "AND" , 111, 0},
- {PI_CMD_CALL , "CALL" , 114, 0},
- {PI_CMD_CMDR ,"CMDR" , 111, 0},
- {PI_CMD_CMDW , "CMDW" , 111, 0},
- {PI_CMD_CMP , "CMP" , 111, 0},
- {PI_CMD_DCR , "DCR" , 113, 0},
- {PI_CMD_DCRA , "DCRA" , 101, 0},
- {PI_CMD_DIV , "DIV" , 111, 0},
- {PI_CMD_EVTWT, "EVTWT", 111, 0},
- {PI_CMD_HALT , "HALT" , 101, 0},
- {PI_CMD_INR , "INR" , 113, 0},
- {PI_CMD_INRA , "INRA" , 101, 0},
- {PI_CMD_JM , "JM" , 114, 0},
- {PI_CMD_JMP , "JMP" , 114, 0},
- {PI_CMD_JNZ , "JNZ" , 114, 0},
- {PI_CMD_JP , "JP" , 114, 0},
- {PI_CMD_JZ , "JZ" , 114, 0},
- {PI_CMD_LD , "LD" , 123, 0},
- {PI_CMD_LDA , "LDA" , 111, 0},
- {PI_CMD_LDAB , "LDAB" , 111, 0},
- {PI_CMD_MLT , "MLT" , 111, 0},
- {PI_CMD_MOD , "MOD" , 111, 0},
- {PI_CMD_NOP , "NOP" , 101, 0},
- {PI_CMD_OR , "OR" , 111, 0},
- {PI_CMD_POP , "POP" , 113, 0},
- {PI_CMD_POPA , "POPA" , 101, 0},
- {PI_CMD_PUSH , "PUSH" , 113, 0},
- {PI_CMD_PUSHA, "PUSHA", 101, 0},
- {PI_CMD_RET , "RET" , 101, 0},
- {PI_CMD_RL , "RL" , 123, 0},
- {PI_CMD_RLA , "RLA" , 111, 0},
- {PI_CMD_RR , "RR" , 123, 0},
- {PI_CMD_RRA , "RRA" , 111, 0},
- {PI_CMD_STA , "STA" , 113, 0},
- {PI_CMD_STAB , "STAB" , 111, 0},
- {PI_CMD_SUB , "SUB" , 111, 0},
- {PI_CMD_SYS , "SYS" , 116, 0},
- {PI_CMD_TAG , "TAG" , 114, 0},
- {PI_CMD_WAIT , "WAIT" , 111, 0},
- {PI_CMD_X , "X" , 124, 0},
- {PI_CMD_XA , "XA" , 113, 0},
- {PI_CMD_XOR , "XOR" , 111, 0},
+ {PI_CMD_PARSE, "PARSE", 115, 0, 0}, // cmdParseScript
+
+ {PI_CMD_PFG, "PFG", 112, 2, 1}, // gpioGetPWMfrequency
+ {PI_CMD_PFS, "PFS", 121, 2, 1}, // gpioSetPWMfrequency
+
+ {PI_CMD_PIGPV, "PIGPV", 101, 4, 1}, // gpioVersion
+
+ {PI_CMD_PRG, "PRG", 112, 2, 1}, // gpioGetPWMrange
+
+ {PI_CMD_PROC, "PROC", 115, 2, 0}, // gpioStoreScript
+ {PI_CMD_PROCD, "PROCD", 112, 0, 0}, // gpioDeleteScript
+ {PI_CMD_PROCP, "PROCP", 112, 7, 0}, // gpioScriptStatus
+ {PI_CMD_PROCR, "PROCR", 191, 0, 0}, // gpioRunScript
+ {PI_CMD_PROCS, "PROCS", 112, 0, 0}, // gpioStopScript
+ {PI_CMD_PROCU, "PROCU", 191, 0, 0}, // gpioUpdateScript
+
+ {PI_CMD_PRRG, "PRRG", 112, 2, 1}, // gpioGetPWMrealRange
+ {PI_CMD_PRS, "PRS", 121, 2, 1}, // gpioSetPWMrange
+
+ {PI_CMD_PUD, "PUD", 126, 0, 1}, // gpioSetPullUpDown
+
+ {PI_CMD_PWM, "P", 121, 0, 1}, // gpioPWM
+ {PI_CMD_PWM, "PWM", 121, 0, 1}, // gpioPWM
+
+ {PI_CMD_READ, "R", 112, 2, 1}, // gpioRead
+ {PI_CMD_READ, "READ", 112, 2, 1}, // gpioRead
+
+ {PI_CMD_SERC, "SERC", 112, 0, 1}, // serClose
+ {PI_CMD_SERDA, "SERDA", 112, 2, 1}, // serDataAvailable
+ {PI_CMD_SERO, "SERO", 132, 2, 0}, // serOpen
+ {PI_CMD_SERR, "SERR", 121, 6, 0}, // serRead
+ {PI_CMD_SERRB, "SERRB", 112, 2, 1}, // serReadByte
+ {PI_CMD_SERW, "SERW", 193, 0, 0}, // serWrite
+ {PI_CMD_SERWB, "SERWB", 121, 0, 1}, // serWriteByte
+
+ {PI_CMD_SERVO, "S", 121, 0, 1}, // gpioServo
+ {PI_CMD_SERVO, "SERVO", 121, 0, 1}, // gpioServo
+
+ {PI_CMD_SHELL, "SHELL", 128, 2, 0}, // shell
+
+ {PI_CMD_SLR, "SLR", 121, 6, 0}, // gpioSerialRead
+ {PI_CMD_SLRC, "SLRC", 112, 0, 1}, // gpioSerialReadClose
+ {PI_CMD_SLRO, "SLRO", 131, 0, 1}, // gpioSerialReadOpen
+ {PI_CMD_SLRI, "SLRI", 121, 0, 1}, // gpioSerialReadInvert
+
+ {PI_CMD_SPIC, "SPIC", 112, 0, 1}, // spiClose
+ {PI_CMD_SPIO, "SPIO", 131, 2, 1}, // spiOpen
+ {PI_CMD_SPIR, "SPIR", 121, 6, 0}, // spiRead
+ {PI_CMD_SPIW, "SPIW", 193, 0, 0}, // spiWrite
+ {PI_CMD_SPIX, "SPIX", 193, 6, 0}, // spiXfer
+
+ {PI_CMD_TICK, "T", 101, 4, 1}, // gpioTick
+ {PI_CMD_TICK, "TICK", 101, 4, 1}, // gpioTick
+
+ {PI_CMD_TRIG, "TRIG", 131, 0, 1}, // gpioTrigger
+
+ {PI_CMD_WDOG, "WDOG", 121, 0, 1}, // gpioSetWatchdog
+
+ {PI_CMD_WRITE, "W", 121, 0, 1}, // gpioWrite
+ {PI_CMD_WRITE, "WRITE", 121, 0, 1}, // gpioWrite
+
+ {PI_CMD_WVAG, "WVAG", 192, 2, 0}, // gpioWaveAddGeneric
+ {PI_CMD_WVAS, "WVAS", 196, 2, 0}, // gpioWaveAddSerial
+ {PI_CMD_WVBSY, "WVBSY", 101, 2, 1}, // gpioWaveTxBusy
+ {PI_CMD_WVCHA, "WVCHA", 197, 0, 0}, // gpioWaveChain
+ {PI_CMD_WVCLR, "WVCLR", 101, 0, 1}, // gpioWaveClear
+ {PI_CMD_WVCRE, "WVCRE", 101, 2, 1}, // gpioWaveCreate
+ {PI_CMD_WVCAP, "WVCAP", 112, 2, 1}, // gpioWaveCreatePad
+ {PI_CMD_WVDEL, "WVDEL", 112, 0, 1}, // gpioWaveDelete
+ {PI_CMD_WVGO, "WVGO" , 101, 2, 0}, // gpioWaveTxStart
+ {PI_CMD_WVGOR, "WVGOR", 101, 2, 0}, // gpioWaveTxStart
+ {PI_CMD_WVHLT, "WVHLT", 101, 0, 1}, // gpioWaveTxStop
+ {PI_CMD_WVNEW, "WVNEW", 101, 0, 1}, // gpioWaveAddNew
+ {PI_CMD_WVSC, "WVSC", 112, 2, 1}, // gpioWaveGet*Cbs
+ {PI_CMD_WVSM, "WVSM", 112, 2, 1}, // gpioWaveGet*Micros
+ {PI_CMD_WVSP, "WVSP", 112, 2, 1}, // gpioWaveGet*Pulses
+ {PI_CMD_WVTAT, "WVTAT", 101, 2, 1}, // gpioWaveTxAt
+ {PI_CMD_WVTX, "WVTX", 112, 2, 1}, // gpioWaveTxSend
+ {PI_CMD_WVTXM, "WVTXM", 121, 2, 1}, // gpioWaveTxSend
+ {PI_CMD_WVTXR, "WVTXR", 112, 2, 1}, // gpioWaveTxSend
+
+ {PI_CMD_ADD , "ADD" , 111, 0, 1},
+ {PI_CMD_AND , "AND" , 111, 0, 1},
+ {PI_CMD_CALL , "CALL" , 114, 0, 1},
+ {PI_CMD_CMDR ,"CMDR" , 111, 0, 1},
+ {PI_CMD_CMDW , "CMDW" , 111, 0, 1},
+ {PI_CMD_CMP , "CMP" , 111, 0, 1},
+ {PI_CMD_DCR , "DCR" , 113, 0, 1},
+ {PI_CMD_DCRA , "DCRA" , 101, 0, 1},
+ {PI_CMD_DIV , "DIV" , 111, 0, 1},
+ {PI_CMD_EVTWT, "EVTWT", 111, 0, 1},
+ {PI_CMD_HALT , "HALT" , 101, 0, 1},
+ {PI_CMD_INR , "INR" , 113, 0, 1},
+ {PI_CMD_INRA , "INRA" , 101, 0, 1},
+ {PI_CMD_JM , "JM" , 114, 0, 1},
+ {PI_CMD_JMP , "JMP" , 114, 0, 1},
+ {PI_CMD_JNZ , "JNZ" , 114, 0, 1},
+ {PI_CMD_JP , "JP" , 114, 0, 1},
+ {PI_CMD_JZ , "JZ" , 114, 0, 1},
+ {PI_CMD_LD , "LD" , 123, 0, 1},
+ {PI_CMD_LDA , "LDA" , 111, 0, 1},
+ {PI_CMD_LDAB , "LDAB" , 111, 0, 1},
+ {PI_CMD_MLT , "MLT" , 111, 0, 1},
+ {PI_CMD_MOD , "MOD" , 111, 0, 1},
+ {PI_CMD_NOP , "NOP" , 101, 0, 1},
+ {PI_CMD_OR , "OR" , 111, 0, 1},
+ {PI_CMD_POP , "POP" , 113, 0, 1},
+ {PI_CMD_POPA , "POPA" , 101, 0, 1},
+ {PI_CMD_PUSH , "PUSH" , 113, 0, 1},
+ {PI_CMD_PUSHA, "PUSHA", 101, 0, 1},
+ {PI_CMD_RET , "RET" , 101, 0, 1},
+ {PI_CMD_RL , "RL" , 123, 0, 1},
+ {PI_CMD_RLA , "RLA" , 111, 0, 1},
+ {PI_CMD_RR , "RR" , 123, 0, 1},
+ {PI_CMD_RRA , "RRA" , 111, 0, 1},
+ {PI_CMD_STA , "STA" , 113, 0, 1},
+ {PI_CMD_STAB , "STAB" , 111, 0, 1},
+ {PI_CMD_SUB , "SUB" , 111, 0, 1},
+ {PI_CMD_SYS , "SYS" , 116, 0, 1},
+ {PI_CMD_TAG , "TAG" , 114, 0, 1},
+ {PI_CMD_WAIT , "WAIT" , 111, 0, 1},
+ {PI_CMD_X , "X" , 124, 0, 1},
+ {PI_CMD_XA , "XA" , 113, 0, 1},
+ {PI_CMD_XOR , "XOR" , 111, 0, 1},
};
@@ -515,9 +516,9 @@ static errInfo_t errInfo[]=
{PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"},
{PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"},
{PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"},
- {PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"},
+ {PI_BAD_HPWM_FREQ , "invalid hardware PWM frequency"},
{PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"},
- {PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"},
+ {PI_BAD_HCLK_FREQ , "invalid hardware clock frequency"},
{PI_BAD_HCLK_PASS , "need password to use hardware clock 1"},
{PI_HPWM_ILLEGAL , "illegal, PWM in use for main clock"},
{PI_BAD_DATABITS , "serial data bits not 1-32"},
@@ -564,6 +565,8 @@ static errInfo_t errInfo[]=
{PI_NOT_SPI_GPIO , "no bit bang SPI in progress on GPIO"},
{PI_BAD_EVENT_ID , "bad event id"},
{PI_CMD_INTERRUPTED , "command interrupted, Python"},
+ {PI_NOT_ON_BCM2711 , "not available on BCM2711"},
+ {PI_ONLY_ON_BCM2711 , "only available on BCM2711"},
};
@@ -621,6 +624,7 @@ static int getNum(char *str, uintptr_t *val, int8_t *opt)
}
static char intCmdStr[32];
+static int intCmdIdx;
char *cmdStr(void)
{
@@ -651,6 +655,8 @@ int cmdParse(
idx = cmdMatch(intCmdStr);
+ intCmdIdx = idx;
+
if (idx < 0) return idx;
valid = 0;
@@ -688,7 +694,7 @@ int cmdParse(
case 112: /* BI2CC FC GDC GPW I2CC I2CRB
MG MICS MILS MODEG NC NP PADG PFG PRG
PROCD PROCP PROCS PRRG R READ SLRC SPIC
- WVDEL WVSC WVSM WVSP WVTX WVTXR BSPIC
+ WVCAP WVDEL WVSC WVSM WVSP WVTX WVTXR BSPIC
One positive parameter.
*/
@@ -1302,6 +1308,13 @@ int cmdParseScript(char *script, cmdScript_t *s, int diags)
{
idx = cmdParse(script, p, CMD_MAX_EXTENSION, v, &ctl);
+ /* abort if command is illegal in a script */
+
+ if ((idx >= 0) || (idx != CMD_UNKNOWN_CMD))
+ {
+ if (!cmdInfo[intCmdIdx].cvis) idx = CMD_NOT_IN_SCRIPT;
+ }
+
if (idx >= 0)
{
if (p[3])
@@ -1354,6 +1367,8 @@ int cmdParseScript(char *script, cmdScript_t *s, int diags)
{
if (idx == CMD_UNKNOWN_CMD)
fprintf(stderr, "Unknown command: %s\n", cmdStr());
+ else if (idx == CMD_NOT_IN_SCRIPT)
+ fprintf(stderr, "Command illegal in script: %s\n", cmdStr());
else
fprintf(stderr, "Bad parameter to %s\n", cmdStr());
}
diff --git a/command.h b/command.h
index d95eb49..3e5c336 100644
--- a/command.h
+++ b/command.h
@@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
-This version is for pigpio version 57+
+This version is for pigpio version 70+
*/
#ifndef COMMAND_H
@@ -43,6 +43,7 @@ This version is for pigpio version 57+
#define CMD_UNKNOWN_CMD -1
#define CMD_BAD_PARAMETER -2
#define CMD_EXT_TOO_SMALL -3
+#define CMD_NOT_IN_SCRIPT -4
#define CMD_P_ARR 10
#define CMD_V_ARR 10
@@ -76,6 +77,7 @@ typedef struct
char *name; /* command name */
int vt; /* command verification type */
int rv; /* command return value type */
+ int cvis; /* command valid in a script */
} cmdInfo_t;
typedef struct
diff --git a/pig2vcd.1 b/pig2vcd.1
index 3964d22..dc50b8c 100644
--- a/pig2vcd.1
+++ b/pig2vcd.1
@@ -1,5 +1,5 @@
-.TH pig2vcd 1 2012-2018 Linux "pigpio archive"
+.TH pig2vcd 1 2012-2020 Linux "pigpio archive"
.SH NAME
pig2vd - A utility to convert pigpio notifications to VCD.
diff --git a/pigpio.3 b/pigpio.3
index 0bb28c8..675c2ec 100644
--- a/pigpio.3
+++ b/pigpio.3
@@ -2,7 +2,7 @@
." Process this file with
." groff -man -Tascii pigpio.3
."
-.TH pigpio 3 2012-2018 Linux "pigpio archive"
+.TH pigpio 3 2012-2020 Linux "pigpio archive"
.SH NAME
pigpio - A C library to manipulate the Pi's GPIO.
@@ -116,11 +116,6 @@ This use was inspired by Richard Hirst's servoblaster kernel module.
.br
.br
-See \fBhttps://github.com/richardghirst/PiBits/tree/master/ServoBlaster\fP
-
-.br
-
-.br
.SS Usage
.br
@@ -195,6 +190,562 @@ error PI_INITIALISED.
.br
.br
+If you intend to rely on signals sent to your application, you should
+turn off the internal signal handling as shown in this example:
+
+.br
+
+.br
+
+.EX
+int cfg = gpioCfgGetInternals();
+.br
+cfg |= PI_CFG_NOSIGHANDLER; // (1<<10)
+.br
+gpioCfgSetInternals(cfg);
+.br
+int status = gpioInitialise();
+.br
+
+.EE
+
+.br
+
+.br
+
+.SH OVERVIEW
+
+.br
+.SS ESSENTIAL
+.br
+
+.br
+gpioInitialise Initialise library
+.br
+gpioTerminate Stop library
+.br
+.SS BASIC
+.br
+
+.br
+gpioSetMode Set a GPIO mode
+.br
+gpioGetMode Get a GPIO mode
+.br
+
+.br
+gpioSetPullUpDown Set/clear GPIO pull up/down resistor
+.br
+
+.br
+gpioRead Read a GPIO
+.br
+gpioWrite Write a GPIO
+.br
+.SS PWM (overrides servo commands on same GPIO)
+.br
+
+.br
+gpioPWM Start/stop PWM pulses on a GPIO
+.br
+gpioSetPWMfrequency Configure PWM frequency for a GPIO
+.br
+gpioSetPWMrange Configure PWM range for a GPIO
+.br
+
+.br
+gpioGetPWMdutycycle Get dutycycle setting on a GPIO
+.br
+gpioGetPWMfrequency Get configured PWM frequency for a GPIO
+.br
+gpioGetPWMrange Get configured PWM range for a GPIO
+.br
+
+.br
+gpioGetPWMrealRange Get underlying PWM range for a GPIO
+.br
+.SS Servo (overrides PWM commands on same GPIO)
+.br
+
+.br
+gpioServo Start/stop servo pulses on a GPIO
+.br
+
+.br
+gpioGetServoPulsewidth Get pulsewidth setting on a GPIO
+.br
+.SS INTERMEDIATE
+.br
+
+.br
+gpioTrigger Send a trigger pulse to a GPIO
+.br
+
+.br
+gpioSetWatchdog Set a watchdog on a GPIO
+.br
+
+.br
+gpioRead_Bits_0_31 Read all GPIO in bank 1
+.br
+gpioRead_Bits_32_53 Read all GPIO in bank 2
+.br
+
+.br
+gpioWrite_Bits_0_31_Clear Clear selected GPIO in bank 1
+.br
+gpioWrite_Bits_32_53_Clear Clear selected GPIO in bank 2
+.br
+
+.br
+gpioWrite_Bits_0_31_Set Set selected GPIO in bank 1
+.br
+gpioWrite_Bits_32_53_Set Set selected GPIO in bank 2
+.br
+
+.br
+gpioSetAlertFunc Request a GPIO level change callback
+.br
+gpioSetAlertFuncEx Request a GPIO change callback, extended
+.br
+
+.br
+gpioSetTimerFunc Request a regular timed callback
+.br
+gpioSetTimerFuncEx Request a regular timed callback, extended
+.br
+
+.br
+gpioStartThread Start a new thread
+.br
+gpioStopThread Stop a previously started thread
+.br
+.SS ADVANCED
+.br
+
+.br
+gpioNotifyOpen Request a notification handle
+.br
+gpioNotifyClose Close a notification
+.br
+gpioNotifyOpenWithSize Request a notification with sized pipe
+.br
+gpioNotifyBegin Start notifications for selected GPIO
+.br
+gpioNotifyPause Pause notifications
+.br
+
+.br
+gpioHardwareClock Start hardware clock on supported GPIO
+.br
+
+.br
+gpioHardwarePWM Start hardware PWM on supported GPIO
+.br
+
+.br
+gpioGlitchFilter Set a glitch filter on a GPIO
+.br
+gpioNoiseFilter Set a noise filter on a GPIO
+.br
+
+.br
+gpioSetPad Sets a pads drive strength
+.br
+gpioGetPad Gets a pads drive strength
+.br
+
+.br
+shell Executes a shell command
+.br
+
+.br
+gpioSetISRFunc Request a GPIO interrupt callback
+.br
+gpioSetISRFuncEx Request a GPIO interrupt callback, extended
+.br
+
+.br
+gpioSetSignalFunc Request a signal callback
+.br
+gpioSetSignalFuncEx Request a signal callback, extended
+.br
+
+.br
+gpioSetGetSamplesFunc Requests a GPIO samples callback
+.br
+gpioSetGetSamplesFuncEx Requests a GPIO samples callback, extended
+.br
+.SS Custom
+.br
+
+.br
+gpioCustom1 User custom function 1
+.br
+gpioCustom2 User custom function 2
+.br
+.SS Events
+.br
+
+.br
+eventMonitor Sets the events to monitor
+.br
+eventSetFunc Request an event callback
+.br
+eventSetFuncEx Request an event callback, extended
+.br
+
+.br
+eventTrigger Trigger an event
+.br
+.SS Scripts
+.br
+
+.br
+gpioStoreScript Store a script
+.br
+gpioRunScript Run a stored script
+.br
+gpioUpdateScript Set a scripts parameters
+.br
+gpioScriptStatus Get script status and parameters
+.br
+gpioStopScript Stop a running script
+.br
+gpioDeleteScript Delete a stored script
+.br
+.SS I2C
+.br
+
+.br
+i2cOpen Opens an I2C device
+.br
+i2cClose Closes an I2C device
+.br
+
+.br
+i2cWriteQuick SMBus write quick
+.br
+
+.br
+i2cReadByte SMBus read byte
+.br
+i2cWriteByte SMBus write byte
+.br
+
+.br
+i2cReadByteData SMBus read byte data
+.br
+i2cWriteByteData SMBus write byte data
+.br
+
+.br
+i2cReadWordData SMBus read word data
+.br
+i2cWriteWordData SMBus write word data
+.br
+
+.br
+i2cReadBlockData SMBus read block data
+.br
+i2cWriteBlockData SMBus write block data
+.br
+
+.br
+i2cReadI2CBlockData SMBus read I2C block data
+.br
+i2cWriteI2CBlockData SMBus write I2C block data
+.br
+
+.br
+i2cReadDevice Reads the raw I2C device
+.br
+i2cWriteDevice Writes the raw I2C device
+.br
+
+.br
+i2cProcessCall SMBus process call
+.br
+i2cBlockProcessCall SMBus block process call
+.br
+
+.br
+i2cSwitchCombined Sets or clears the combined flag
+.br
+
+.br
+i2cSegments Performs multiple I2C transactions
+.br
+
+.br
+i2cZip Performs multiple I2C transactions
+.br
+.SS I2C BIT BANG
+.br
+
+.br
+bbI2COpen Opens GPIO for bit banging I2C
+.br
+bbI2CClose Closes GPIO for bit banging I2C
+.br
+
+.br
+bbI2CZip Performs bit banged I2C transactions
+.br
+.SS I2C/SPI SLAVE
+.br
+
+.br
+bscXfer I2C/SPI as slave transfer
+.br
+.SS SERIAL
+.br
+
+.br
+serOpen Opens a serial device
+.br
+serClose Closes a serial device
+.br
+
+.br
+serReadByte Reads a byte from a serial device
+.br
+serWriteByte Writes a byte to a serial device
+.br
+
+.br
+serRead Reads bytes from a serial device
+.br
+serWrite Writes bytes to a serial device
+.br
+
+.br
+serDataAvailable Returns number of bytes ready to be read
+.br
+.SS SERIAL BIT BANG (read only)
+.br
+
+.br
+gpioSerialReadOpen Opens a GPIO for bit bang serial reads
+.br
+gpioSerialReadClose Closes a GPIO for bit bang serial reads
+.br
+
+.br
+gpioSerialReadInvert Configures normal/inverted for serial reads
+.br
+
+.br
+gpioSerialRead Reads bit bang serial data from a GPIO
+.br
+.SS SPI
+.br
+
+.br
+spiOpen Opens a SPI device
+.br
+spiClose Closes a SPI device
+.br
+
+.br
+spiRead Reads bytes from a SPI device
+.br
+spiWrite Writes bytes to a SPI device
+.br
+spiXfer Transfers bytes with a SPI device
+.br
+.SS SPI BIT BANG
+.br
+
+.br
+bbSPIOpen Opens GPIO for bit banging SPI
+.br
+bbSPIClose Closes GPIO for bit banging SPI
+.br
+
+.br
+bbSPIXfer Performs bit banged SPI transactions
+.br
+.SS FILES
+.br
+
+.br
+fileOpen Opens a file
+.br
+fileClose Closes a file
+.br
+
+.br
+fileRead Reads bytes from a file
+.br
+fileWrite Writes bytes to a file
+.br
+
+.br
+fileSeek Seeks to a position within a file
+.br
+
+.br
+fileList List files which match a pattern
+.br
+.SS WAVES
+.br
+
+.br
+gpioWaveClear Deletes all waveforms
+.br
+
+.br
+gpioWaveAddNew Starts a new waveform
+.br
+gpioWaveAddGeneric Adds a series of pulses to the waveform
+.br
+gpioWaveAddSerial Adds serial data to the waveform
+.br
+
+.br
+gpioWaveCreate Creates a waveform from added data
+.br
+gpioWaveCreatePad Creates a waveform of fixed size from added data
+.br
+gpioWaveDelete Deletes a waveform
+.br
+
+.br
+gpioWaveTxSend Transmits a waveform
+.br
+
+.br
+gpioWaveChain Transmits a chain of waveforms
+.br
+
+.br
+gpioWaveTxAt Returns the current transmitting waveform
+.br
+
+.br
+gpioWaveTxBusy Checks to see if the waveform has ended
+.br
+
+.br
+gpioWaveTxStop Aborts the current waveform
+.br
+
+.br
+gpioWaveGetCbs Length in CBs of the current waveform
+.br
+gpioWaveGetHighCbs Length of longest waveform so far
+.br
+gpioWaveGetMaxCbs Absolute maximum allowed CBs
+.br
+
+.br
+gpioWaveGetMicros Length in micros of the current waveform
+.br
+gpioWaveGetHighMicros Length of longest waveform so far
+.br
+gpioWaveGetMaxMicros Absolute maximum allowed micros
+.br
+
+.br
+gpioWaveGetPulses Length in pulses of the current waveform
+.br
+gpioWaveGetHighPulses Length of longest waveform so far
+.br
+gpioWaveGetMaxPulses Absolute maximum allowed pulses
+.br
+.SS UTILITIES
+.br
+
+.br
+gpioDelay Delay for a number of microseconds
+.br
+
+.br
+gpioTick Get current tick (microseconds)
+.br
+
+.br
+gpioHardwareRevision Get hardware revision
+.br
+gpioVersion Get the pigpio version
+.br
+
+.br
+getBitInBytes Get the value of a bit
+.br
+putBitInBytes Set the value of a bit
+.br
+
+.br
+gpioTime Get current time
+.br
+gpioSleep Sleep for specified time
+.br
+
+.br
+time_sleep Sleeps for a float number of seconds
+.br
+time_time Float number of seconds since the epoch
+.br
+.SS CONFIGURATION
+.br
+
+.br
+gpioCfgBufferSize Configure the GPIO sample buffer size
+.br
+gpioCfgClock Configure the GPIO sample rate
+.br
+gpioCfgDMAchannel Configure the DMA channel (DEPRECATED)
+.br
+gpioCfgDMAchannels Configure the DMA channels
+.br
+gpioCfgPermissions Configure the GPIO access permissions
+.br
+gpioCfgInterfaces Configure user interfaces
+.br
+gpioCfgSocketPort Configure socket port
+.br
+gpioCfgMemAlloc Configure DMA memory allocation mode
+.br
+gpioCfgNetAddr Configure allowed network addresses
+.br
+
+.br
+gpioCfgGetInternals Get internal configuration settings
+.br
+gpioCfgSetInternals Set internal configuration settings
+.br
+.SS EXPERT
+.br
+
+.br
+rawWaveAddSPI Not intended for general use
+.br
+rawWaveAddGeneric Not intended for general use
+.br
+rawWaveCB Not intended for general use
+.br
+rawWaveCBAdr Not intended for general use
+.br
+rawWaveGetOOL Not intended for general use
+.br
+rawWaveSetOOL Not intended for general use
+.br
+rawWaveGetOut Not intended for general use
+.br
+rawWaveSetOut Not intended for general use
+.br
+rawWaveGetIn Not intended for general use
+.br
+rawWaveSetIn Not intended for general use
+.br
+rawWaveInfo Not intended for general use
+.br
+rawDumpWave Not intended for general use
+.br
+rawDumpScript Not intended for general use
+.br
.SH FUNCTIONS
.IP "\fBint gpioInitialise(void)\fP"
@@ -1154,6 +1705,15 @@ will be a latency.
.br
.br
+If you want to track the level of more than one GPIO do so by
+maintaining the state in the callback. Do not use \fBgpioRead\fP.
+Remember the event that triggered the callback may have
+happened several milliseconds before and the GPIO may have
+changed level many times since then.
+
+.br
+
+.br
The tick value is the time stamp of the sample in microseconds, see
\fBgpioTick\fP for more details.
@@ -2124,6 +2684,89 @@ specified delay between the pulse and the next.
Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
+.IP "\fBint gpioWaveCreatePad(int pctCB, int pctBOOL, int pctTOOL)\fP"
+.IP "" 4
+Similar to \fBgpioWaveCreate\fP, this function creates a waveform but pads the consumed
+resources. Padded waves of equal dimension can be re-cycled efficiently allowing
+newly created waves to re-use the resources of deleted waves of the same dimension.
+
+.br
+
+.br
+
+.EX
+pctCB: 0-100, the percent of all DMA control blocks to consume.
+.br
+pctBOOL: 0-100, percent On-Off-Level (OOL) buffer to consume for wave output.
+.br
+pctTOOL: 0-100, the percent of OOL buffer to consume for wave input (flags).
+.br
+
+.EE
+
+.br
+
+.br
+Upon success a wave id greater than or equal to 0 is returned, otherwise
+PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
+
+.br
+
+.br
+Waveform data provided by \fBgpioWaveAdd*\fP and \fBrawWaveAdd*\fP functions are
+consumed by this function.
+
+.br
+
+.br
+A usage would be the creation of two waves where one is filled while the other
+is being transmitted. Each wave is assigned 50% of the resources.
+This buffer structure allows the transmission of infinite wave sequences.
+
+.br
+
+.br
+\fBExample\fP
+.br
+
+.EX
+ // get firstWaveChunk, somehow
+.br
+ gpioWaveAddGeneric(firstWaveChunk);
+.br
+ wid = gpioWaveCreatePad(50, 50, 0);
+.br
+ gpioWaveTxSend(wid, PI_WAVE_MODE_ONE_SHOT);
+.br
+ // get nextWaveChunk
+.br
+
+.br
+ while (nextWaveChunk) {
+.br
+ gpioWaveAddGeneric(nextWaveChunk);
+.br
+ nextWid = gpioWaveCreatePad(50, 50, 0);
+.br
+ gpioWaveTxSend(nextWid, PI_WAVE_MODE_ONE_SHOT_SYNC);
+.br
+ while(gpioWaveTxAt() == wid) time_sleep(0.1);
+.br
+ gpioWaveDelete(wid);
+.br
+ wid = nextWid;
+.br
+ // get nextWaveChunk
+.br
+ }
+.br
+
+.EE
+
+.br
+
+.br
+
.IP "\fBint gpioWaveDelete(unsigned wave_id)\fP"
.IP "" 4
This function deletes the waveform with id wave_id.
@@ -2403,7 +3046,7 @@ int main(int argc, char *argv[])
.IP "\fBint gpioWaveTxAt(void)\fP"
.IP "" 4
This function returns the id of the waveform currently being
-transmitted.
+transmitted using \fBgpioWaveTxSend\fP. Chained waves are not supported.
.br
@@ -3628,9 +4271,27 @@ End
.IP "\fBint bscXfer(bsc_xfer_t *bsc_xfer)\fP"
.IP "" 4
-This function provides a low-level interface to the
-SPI/I2C Slave peripheral. This peripheral allows the
-Pi to act as a slave device on an I2C or SPI bus.
+This function provides a low-level interface to the SPI/I2C Slave
+peripheral on the BCM chip.
+
+.br
+
+.br
+This peripheral allows the Pi to act as a hardware slave device
+on an I2C or SPI bus.
+
+.br
+
+.br
+This is not a bit bang version and as such is OS timing
+independent. The bus timing is handled directly by the chip.
+
+.br
+
+.br
+The output process is simple. You simply append data to the FIFO
+buffer on the chip. This works like a queue, you add data to the
+queue and the master removes it.
.br
@@ -3677,8 +4338,9 @@ typedef struct
.br
.br
-To start a transfer set control (see below) and copy the bytes to
-be sent (if any) to txBuf and set the byte count in txCnt.
+To start a transfer set control (see below), copy the bytes to
+be added to the transmit FIFO (if any) to txBuf and set txCnt to
+the number of copied bytes.
.br
@@ -3695,14 +4357,37 @@ that mode until a different control word is sent.
.br
.br
-The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
-and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
-need to swap MISO/MOSI between master and slave.
+GPIO used for models other than those based on the BCM2711.
+
+.br
+
+.br
+ SDA SCL MOSI SCLK MISO CE
+.br
+I2C 18 19 - - - -
+.br
+SPI - - 18 19 20 21
+.br
+
+.br
+
+.br
+GPIO used for models based on the BCM2711 (e.g. the Pi4B).
.br
.br
-When a zero control word is received GPIO 18-21 will be reset
+ SDA SCL MOSI SCLK MISO CE
+.br
+I2C 10 11 - - - -
+.br
+SPI - - 10 11 9 8
+.br
+
+.br
+
+.br
+When a zero control word is received the used GPIO will be reset
to INPUT mode.
.br
@@ -5579,7 +6264,7 @@ Frequencies above 30MHz are unlikely to work.
.EX
gpio: see description
.br
-clkfreq: 0 (off) or 4689-250000000 (250M)
+clkfreq: 0 (off) or 4689-250M (13184-375M for the BCM2711)
.br
.EE
@@ -5663,7 +6348,7 @@ main clock defaults to PCM but may be overridden by a call to
.EX
gpio: see description
.br
-PWMfreq: 0 (off) or 1-125000000 (125M)
+PWMfreq: 0 (off) or 1-125M (1-187.5M for the BCM2711)
.br
PWMduty: 0 (off) to 1000000 (1M)(fully on)
.br
@@ -5720,18 +6405,18 @@ The GPIO must be one of the following.
.br
The actual number of steps beween off and fully on is the
-integral part of 250 million divided by PWMfreq.
+integral part of 250M/PWMfreq (375M/PWMfreq for the BCM2711).
.br
.br
-The actual frequency set is 250 million / steps.
+The actual frequency set is 250M/steps (375M/steps for the BCM2711).
.br
.br
-There will only be a million steps for a PWMfreq of 250.
-Lower frequencies will have more steps and higher
+There will only be a million steps for a PWMfreq of 250 (375 for
+the BCM2711). Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
@@ -7029,8 +7714,20 @@ secondaryChannel: 0-14
.br
.br
-The default setting is to use channel 14 for the primary channel and
-channel 6 for the secondary channel.
+The default setting depends on whether the Pi has a BCM2711 chip or
+not (currently only the Pi4B has a BCM2711).
+
+.br
+
+.br
+The default setting for a non-BCM2711 is to use channel 14 for the
+primary channel and channel 6 for the secondary channel.
+
+.br
+
+.br
+The default setting for a BCM2711 is to use channel 7 for the
+primary channel and channel 6 for the secondary channel.
.br
@@ -7219,22 +7916,6 @@ numSockAddr: 0-256 (0 means all addresses allowed)
.EE
-.IP "\fBint gpioCfgInternals(unsigned cfgWhat, unsigned cfgVal)\fP"
-.IP "" 4
-Used to tune internal settings.
-
-.br
-
-.br
-
-.EX
-cfgWhat: see source code
-.br
- cfgVal: see source code
-.br
-
-.EE
-
.IP "\fBuint32_t gpioCfgGetInternals(void)\fP"
.IP "" 4
This function returns the current library internal configuration
@@ -7255,6 +7936,10 @@ cfgVal: see source code
.EE
+.br
+
+.br
+
.IP "\fBint gpioCustom1(unsigned arg1, unsigned arg2, char *argx, unsigned argc)\fP"
.IP "" 4
This function is available for user customisation.
@@ -7960,7 +8645,7 @@ A single character, an 8 bit quantity able to store 0-255.
.br
-.IP "\fBclkfreq\fP: 4689-250M" 0
+.IP "\fBclkfreq\fP: 4689-250M (13184-375M for the BCM2711)" 0
.br
@@ -7976,6 +8661,8 @@ PI_HW_CLK_MIN_FREQ 4689
.br
PI_HW_CLK_MAX_FREQ 250000000
.br
+PI_HW_CLK_MAX_FREQ_2711 375000000
+.br
.EE
@@ -8022,12 +8709,12 @@ PI_MAX_WAVE_DATABITS 32
.br
-.IP "\fBDMAchannel\fP: 0-14" 0
+.IP "\fBDMAchannel\fP: 0-15" 0
.EX
PI_MIN_DMA_CHANNEL 0
.br
-PI_MAX_DMA_CHANNEL 14
+PI_MAX_DMA_CHANNEL 15
.br
.EE
@@ -8890,6 +9577,27 @@ An array of script parameters.
.br
+.IP "\fBpctBOOL\fP: 0-100" 0
+percent On-Off-Level (OOL) buffer to consume for wave output.
+
+.br
+
+.br
+
+.IP "\fBpctCB\fP: 0-100" 0
+the percent of all DMA control blocks to consume.
+
+.br
+
+.br
+
+.IP "\fBpctTOOL\fP: 0-100" 0
+the percent of OOL buffer to consume for wave input (flags).
+
+.br
+
+.br
+
.IP "\fBpi_i2c_msg_t\fP" 0
.EX
@@ -8928,7 +9636,7 @@ The position of an item.
.br
-.IP "\fBprimaryChannel\fP: 0-14" 0
+.IP "\fBprimaryChannel\fP: 0-15" 0
The DMA channel used to time the sampling of GPIO and to time servo and
PWM pulses.
@@ -9039,7 +9747,7 @@ PI_HW_PWM_RANGE 1000000
.br
-.IP "\fBPWMfreq\fP: 5-250K" 0
+.IP "\fBPWMfreq\fP: 1-125M (1-187.5M for the BCM2711)" 0
The hardware PWM frequency.
.br
@@ -9051,6 +9759,8 @@ PI_HW_PWM_MIN_FREQ 1
.br
PI_HW_PWM_MAX_FREQ 125000000
.br
+PI_HW_PWM_MAX_FREQ_2711 187500000
+.br
.EE
@@ -10040,6 +10750,8 @@ A 16-bit word value.
.br
#define PI_CMD_PROCU 117
.br
+#define PI_CMD_WVCAP 118
+.br
.br
@@ -10103,15 +10815,15 @@ A 16-bit word value.
.br
#define PI_BAD_IF_FLAGS -26 // ifFlags > 4
.br
-#define PI_BAD_CHANNEL -27 // DMA channel not 0-14
+#define PI_BAD_CHANNEL -27 // DMA channel not 0-15
.br
-#define PI_BAD_PRIM_CHANNEL -27 // DMA primary channel not 0-14
+#define PI_BAD_PRIM_CHANNEL -27 // DMA primary channel not 0-15
.br
#define PI_BAD_SOCKET_PORT -28 // socket port not 1024-32000
.br
#define PI_BAD_FIFO_COMMAND -29 // unrecognized fifo command
.br
-#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-6
+#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-15
.br
#define PI_NOT_INITIALISED -31 // function called before gpioInitialise
.br
@@ -10245,11 +10957,11 @@ A 16-bit word value.
.br
#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM
.br
-#define PI_BAD_HPWM_FREQ -96 // hardware PWM frequency not 1-125M
+#define PI_BAD_HPWM_FREQ -96 // invalid hardware PWM frequency
.br
#define PI_BAD_HPWM_DUTY -97 // hardware PWM dutycycle not 0-1M
.br
-#define PI_BAD_HCLK_FREQ -98 // hardware clock frequency not 4689-250M
+#define PI_BAD_HCLK_FREQ -98 // invalid hardware clock frequency
.br
#define PI_BAD_HCLK_PASS -99 // need password to use hardware clock 1
.br
@@ -10343,6 +11055,10 @@ A 16-bit word value.
.br
#define PI_CMD_INTERRUPTED -144 // Used by Python
.br
+#define PI_NOT_ON_BCM2711 -145 // not available on BCM2711
+.br
+#define PI_ONLY_ON_BCM2711 -146 // only available on BCM2711
+.br
.br
#define PI_PIGIF_ERR_0 -2000
@@ -10380,11 +11096,17 @@ A 16-bit word value.
.br
#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
.br
+#define PI_DEFAULT_DMA_PRIMARY_CH_2711 7
+.br
+#define PI_DEFAULT_DMA_SECONDARY_CH_2711 6
+.br
+#define PI_DEFAULT_DMA_NOT_SET 15
+.br
#define PI_DEFAULT_SOCKET_PORT 8888
.br
#define PI_DEFAULT_SOCKET_PORT_STR "8888"
.br
-#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
+#define PI_DEFAULT_SOCKET_ADDR_STR "localhost"
.br
#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0x0000000FFFFFFCLL
.br
@@ -10400,6 +11122,8 @@ A 16-bit word value.
.br
#define PI_DEFAULT_UPDATE_MASK_PI3B 0x0000000FFFFFFCLL
.br
+#define PI_DEFAULT_UPDATE_MASK_PI4B 0x0000000FFFFFFCLL
+.br
#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
.br
#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
diff --git a/pigpio.c b/pigpio.c
index 3102e32..92b9bf7 100644
--- a/pigpio.c
+++ b/pigpio.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
-/* pigpio version 68 */
+/* pigpio version 78 */
/* include ------------------------------------------------------- */
@@ -114,6 +114,11 @@ For more information, please refer to <http://unlicense.org/>
39 GPPUDCLK1 GPIO Pin Pull-up/down Enable Clock 1
40 - Reserved
41 - Test
+42-56 Reserved
+57 GPPUPPDN1 Pin pull-up/down for pins 15:0
+58 GPPUPPDN1 Pin pull-up/down for pins 31:16
+59 GPPUPPDN2 Pin pull-up/down for pins 47:32
+60 GPPUPPDN3 Pin pull-up/down for pins 57:48
*/
/*
@@ -317,7 +322,7 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define BSCS_LEN 0x40
#define CLK_LEN 0xA8
#define DMA_LEN 0x1000 /* allow access to all channels */
-#define GPIO_LEN 0xB4
+#define GPIO_LEN 0xF4 /* 2711 has more registers */
#define PADS_LEN 0x38
#define PCM_LEN 0x24
#define PWM_LEN 0x28
@@ -357,18 +362,26 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define GPPUDCLK0 38
#define GPPUDCLK1 39
+/* BCM2711 has different pulls */
+
+#define GPPUPPDN0 57
+#define GPPUPPDN1 58
+#define GPPUPPDN2 59
+#define GPPUPPDN3 60
+
#define DMA_CS 0
#define DMA_CONBLK_AD 1
#define DMA_DEBUG 8
/* DMA CS Control and Status bits */
#define DMA_CHANNEL_RESET (1<<31)
+#define DMA_CHANNEL_ABORT (1<<30)
#define DMA_WAIT_ON_WRITES (1<<28)
#define DMA_PANIC_PRIORITY(x) ((x)<<20)
#define DMA_PRIORITY(x) ((x)<<16)
#define DMA_INTERRUPT_STATUS (1<< 2)
#define DMA_END_FLAG (1<< 1)
-#define DMA_ACTIVATE (1<< 0)
+#define DMA_ACTIVE (1<< 0)
/* DMA control block "info" field bits */
#define DMA_NO_WIDE_BURSTS (1<<26)
@@ -383,6 +396,7 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define DMA_DEST_WIDTH (1<< 5)
#define DMA_DEST_INC (1<< 4)
#define DMA_WAIT_RESP (1<< 3)
+#define DMA_TDMODE (1<< 1)
#define DMA_DEBUG_READ_ERR (1<<2)
#define DMA_DEBUG_FIFO_ERR (1<<1)
@@ -498,8 +512,10 @@ bit 0 READ_LAST_NOT_SET_ERROR
#define CLK_CTL_SRC_OSC 1
#define CLK_CTL_SRC_PLLD 6
-#define CLK_OSC_FREQ 19200000
-#define CLK_PLLD_FREQ 500000000
+#define CLK_OSC_FREQ 19200000
+#define CLK_OSC_FREQ_2711 54000000
+#define CLK_PLLD_FREQ 500000000
+#define CLK_PLLD_FREQ_2711 750000000
#define CLK_DIV_DIVI(x) ((x)<<12)
#define CLK_DIV_DIVF(x) ((x)<< 0)
@@ -649,6 +665,7 @@ bit 0 READ_LAST_NOT_SET_ERROR
/* --------------------------------------------------------------- */
#define NORMAL_DMA (DMA_NO_WIDE_BURSTS | DMA_WAIT_RESP)
+#define TWO_BEAT_DMA (DMA_TDMODE | DMA_BURST_LENGTH(1))
#define TIMED_DMA(x) (DMA_DEST_DREQ | DMA_PERIPHERAL_MAPPING(x))
@@ -933,6 +950,7 @@ typedef struct
uint32_t nfRBitV;
uint32_t gfSteadyUs;
+ uint8_t gfInitialised;
uint32_t gfTick;
uint32_t gfLBitV;
uint32_t gfRBitV;
@@ -957,6 +975,7 @@ typedef struct
int timeout;
unsigned ex;
void *userdata;
+ int fd;
int inited;
} gpioISR_t;
@@ -1199,11 +1218,17 @@ typedef struct
/* initialise once then preserve */
-static volatile uint32_t piCores = 0;
-static volatile uint32_t pi_ispi = 0;
-static volatile uint32_t pi_peri_phys = 0x20000000;
-static volatile uint32_t pi_dram_bus = 0x40000000;
-static volatile uint32_t pi_mem_flag = 0x0C;
+static volatile uint32_t piCores = 0;
+static volatile uint32_t pi_peri_phys = 0x20000000;
+static volatile uint32_t pi_dram_bus = 0x40000000;
+static volatile uint32_t pi_mem_flag = 0x0C;
+static volatile uint32_t pi_ispi = 0;
+static volatile uint32_t pi_is_2711 = 0;
+static volatile uint32_t clk_osc_freq = CLK_OSC_FREQ;
+static volatile uint32_t clk_plld_freq = CLK_PLLD_FREQ;
+static volatile uint32_t hw_pwm_max_freq = PI_HW_PWM_MAX_FREQ;
+static volatile uint32_t hw_clk_min_freq = PI_HW_CLK_MIN_FREQ;
+static volatile uint32_t hw_clk_max_freq = PI_HW_CLK_MAX_FREQ;
static int libInitialised = 0;
@@ -1341,8 +1366,8 @@ static volatile gpioCfg_t gpioCfg =
PI_DEFAULT_BUFFER_MILLIS,
PI_DEFAULT_CLK_MICROS,
PI_DEFAULT_CLK_PERIPHERAL,
- PI_DEFAULT_DMA_PRIMARY_CHANNEL,
- PI_DEFAULT_DMA_SECONDARY_CHANNEL,
+ PI_DEFAULT_DMA_NOT_SET, /* primary DMA */
+ PI_DEFAULT_DMA_NOT_SET, /* secondary DMA */
PI_DEFAULT_SOCKET_PORT,
PI_DEFAULT_IF_FLAGS,
PI_DEFAULT_MEM_ALLOC_MODE,
@@ -1547,6 +1572,9 @@ int myPathBad(char *name)
in_part = 0;
last_char_dot = 0;
+ if (strstr(name, "..")) return 1;
+ if (strstr(name, "\\.")) return 1;
+
len = strlen(name);
for (i=0; i<len; i++)
@@ -2412,6 +2440,27 @@ static int myDoCommand(uintptr_t *p, unsigned bufSize, char *buf)
case PI_CMD_WVCRE: res = gpioWaveCreate(); break;
+ case PI_CMD_WVCAP:
+ /* Make WVCAP variadic */
+ if (p[3] == 4)
+ {
+ memcpy(&tmp3, buf, 4); /* percent TOOL */
+ res = gpioWaveCreatePad(p[1], p[2], tmp3); /* rawWaveAdd* usage */
+ break;
+ }
+ if (p[2] && p[3]==0)
+ {
+ res = gpioWaveCreatePad(p[1], p[2], 0);
+ break;
+ }
+ if (p[2]==0 && p[3]==0)
+ {
+ res = gpioWaveCreatePad(p[1], p[1], 0); /* typical usage */
+ break;
+ }
+ res = PI_BAD_WAVE_ID; // FIX?
+ break;
+
case PI_CMD_WVDEL: res = gpioWaveDelete(p[1]); break;
case PI_CMD_WVGO: res = gpioWaveTxStart(PI_WAVE_MODE_ONE_SHOT); break;
@@ -2955,8 +3004,9 @@ static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs)
for (i=0; i<numWaves; i++)
{
- if (waves[i].gpioOn) {numCB++; numBOOL++;}
- if (waves[i].gpioOff) {numCB++; numBOOL++;}
+ if (waves[i].gpioOn) {numBOOL++;}
+ if (waves[i].gpioOff) {numBOOL++;}
+ if (waves[i].gpioOn || waves[i].gpioOff) {numCB++;}
if (waves[i].flags & WAVE_FLAG_READ) {numCB++; numTOOL++;}
if (waves[i].flags & WAVE_FLAG_TICK) {numCB++; numTOOL++;}
@@ -2970,11 +3020,12 @@ static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs)
/* ----------------------------------------------------------------------- */
-static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
+static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL,
+ int numCB, int numBOOL, int numTOOL)
{
int botCB=*CB, botOOL=*BOOL, topOOL=*TOOL;
- int status;
+ int status, s_stride;
rawCbs_t *p=NULL;
@@ -3018,7 +3069,22 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
for (i=0; i<numWaves; i++)
{
- if (waves[i].gpioOn)
+ if (waves[i].gpioOn && waves[i].gpioOff)
+ /* Use 2-beat burst */
+ {
+ p = rawWaveCBAdr(botCB++);
+
+ p->info = TWO_BEAT_DMA;
+ p->src = waveOOLPOadr(botOOL);
+ waveSetOOL(botOOL++, waves[i].gpioOn);
+ s_stride = waveOOLPOadr(botOOL) - p->src;
+ waveSetOOL(botOOL++, waves[i].gpioOff);
+ p->dst = ((GPIO_BASE + (GPSET0*4)) & 0x00ffffff) | PI_PERI_BUS;
+ p->length = (2<<16) + 4; // 2 transfers of 4 bytes each
+ p->stride = (12<<16) + s_stride; // d_stride = (GPCLR0-GPSET0)*4 = 12
+ p->next = waveCbPOadr(botCB);
+ }
+ if (waves[i].gpioOn && !waves[i].gpioOff)
{
waveSetOOL(botOOL, waves[i].gpioOn);
@@ -3030,8 +3096,7 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
p->length = 4;
p->next = waveCbPOadr(botCB);
}
-
- if (waves[i].gpioOff)
+ if (waves[i].gpioOff && !waves[i].gpioOn)
{
waveSetOOL(botOOL, waves[i].gpioOff);
@@ -3043,7 +3108,6 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
p->length = 4;
p->next = waveCbPOadr(botCB);
}
-
if (waves[i].flags & WAVE_FLAG_READ)
{
p = rawWaveCBAdr(botCB++);
@@ -3108,6 +3172,28 @@ static int wave2Cbs(unsigned wave_mode, int *CB, int *BOOL, int *TOOL)
}
}
+ if (numCB)
+ {
+ /* Pad the wave */
+
+ botCB = *CB + numCB - 1;
+ botOOL = *BOOL + numBOOL - 1;
+ topOOL = *TOOL - numTOOL;
+
+ /* Link the last CB to end of wave */
+
+ p->next = waveCbPOadr(botCB);
+
+ /* Insert sentinel CB at end of DMA */
+
+ p = rawWaveCBAdr(botCB++);
+ p->info = NORMAL_DMA | DMA_DEST_IGNORE;
+ p->src = waveOOLPOadr(botOOL++);
+ p->dst = ((GPIO_BASE + (GPSET0*4)) & 0x00ffffff) | PI_PERI_BUS;
+ p->length = 4;
+ p->next = 0;
+ }
+
if (p != NULL)
{
if (wave_mode == PI_WAVE_MODE_ONE_SHOT)
@@ -3220,7 +3306,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
unsigned numIn2, numOut;
- uint32_t tNow, tNext1, tNext2, tDelay;
+ uint32_t tNow, tNext1, tNext2, tDelay, tMax;
rawWave_t *in2, *out;
@@ -3231,6 +3317,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
out = wf[1-wfcur];
tNow = 0;
+ tMax = 0;
if (!numIn1) tNext1 = -1; else tNext1 = 0;
if (!numIn2) tNext2 = -1; else tNext2 = 0;
@@ -3253,6 +3340,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
out[outPos].flags = in1[inPos1].flags;
tNext1 = tNow + in1[inPos1].usDelay; ++inPos1;
+ if (tMax < tNext1) tMax = tNext1;
}
else if (tNext2 < tNext1)
{
@@ -3270,6 +3358,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
out[outPos].flags = in2[inPos2].flags;
tNext2 = tNow + in2[inPos2].usDelay; ++inPos2;
+ if (tMax < tNext2) tMax = tNext2;
}
else
{
@@ -3288,6 +3377,8 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
tNext1 = tNow + in1[inPos1].usDelay; ++inPos1;
tNext2 = tNow + in2[inPos2].usDelay; ++inPos2;
+ if (tMax < tNext1) tMax = tNext1;
+ if (tMax < tNext2) tMax = tNext2;
}
if (tNext1 <= tNext2) { tDelay = tNext1 - tNow; tNow = tNext1; }
@@ -3297,9 +3388,7 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
cbs += waveDelayCBs(tDelay);
- if (out[outPos].gpioOn) cbs++; /* one cb if gpio on */
-
- if (out[outPos].gpioOff) cbs++; /* one cb if gpio off */
+ if (out[outPos].gpioOn || out[outPos].gpioOff) cbs++;
if (out[outPos].flags & WAVE_FLAG_READ)
{
@@ -3320,6 +3409,13 @@ int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
}
+ if (tNow < tMax)
+ {
+ /* extend previous delay */
+ out[outPos-1].usDelay += (tMax - tNow);
+ tNow = tMax;
+ }
+
if ((outPos < numOut) && (outPos < level))
{
wfStats.micros = tNow;
@@ -4336,7 +4432,7 @@ static void spiGoA(
cs = PI_SPI_FLAGS_GET_CSPOLS(flags) & (1<<channel);
- spiDefaults = AUXSPI_CNTL0_SPEED(125000000/speed) |
+ spiDefaults = AUXSPI_CNTL0_SPEED((125000000/speed)-1)|
AUXSPI_CNTL0_IN_RISING(bit_ir[mode]) |
AUXSPI_CNTL0_OUT_RISING(bit_or[mode]) |
AUXSPI_CNTL0_INVERT_CLK(bit_ic[mode]) |
@@ -4734,7 +4830,7 @@ int spiClose(unsigned handle)
if (spiInfo[handle].state != PI_SPI_OPENED)
SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
- spiInfo[handle].state = PI_I2C_CLOSED;
+ spiInfo[handle].state = PI_SPI_CLOSED;
if (!spiAnyOpen(spiInfo[handle].flags))
spiTerm(spiInfo[handle].flags); /* terminate on last close */
@@ -5065,51 +5161,33 @@ int serDataAvailable(unsigned handle)
static int chooseBestClock
(clkInf_t *clkInf, unsigned f, unsigned numc, unsigned *cf)
{
- int c, valid, offby, offby2, best_offby;
- uint32_t div;
- uint64_t frac;
+ int c, valid;
+ double fdiv, offby, best_offby;
+ unsigned div, frac;
valid = 0;
best_offby = 0;
for (c=0; c<numc; c++)
{
- div = cf[c] / f;
+ fdiv = (double)cf[c] / (double)f;
+ if (f < PI_MASH_MAX_FREQ)
+ {
+ fdiv += (0.5 / 4096.0);
+ div = fdiv;
+ frac = (fdiv - div) * 4096.0;
+ }
+ else
+ {
+ fdiv += 0.5;
+ div = fdiv;
+ frac = 0;
+ }
if ((div > 1) && (div < 4096))
{
- if (f < PI_MASH_MAX_FREQ)
- {
- frac = cf[c] - (div * f);
- frac = (frac * 4096) / f;
- offby = cf[c] - (div * f) - ((frac * f) / 4096);
- if (frac < 4095)
- {
- offby2 = cf[c] - (div * f) - (((frac+1) * f) / 4096);
- if (offby2 < 0) offby2 = -offby2;
- if (offby2 < offby)
- {
- offby = offby2;
- frac++;
- }
- }
- }
- else
- {
- frac = 0;
- offby = cf[c] - (div * f);
- if (div < 4095)
- {
- offby2 = cf[c] - ((div+1) * f);
- if (offby2 < 0) offby2 = -offby2;
- if (offby2 < offby)
- {
- offby = offby2;
- div++;
- }
- }
- }
-
+ offby = f - (cf[c] / (div + (frac / 4096.0)));
+ if (offby < 0) offby = - offby;
if ((!valid) || (offby <= best_offby))
{
valid = 1;
@@ -5611,7 +5689,7 @@ unsigned alert_delays[]=
static void alertGlitchFilter(gpioSample_t *sample, int numSamples)
{
int i, j, diff;
- uint32_t steadyUs, changedTick, RBitV, LBitV;
+ uint32_t steadyUs, changedTick, RBitV, LBitV, initialised;
uint32_t bit, bitV;
for (i=0; i<=PI_MAX_USER_GPIO; i++)
@@ -5620,6 +5698,17 @@ static void alertGlitchFilter(gpioSample_t *sample, int numSamples)
if (monitorBits & bit & gFilterBits)
{
+ initialised = gpioAlert[i].gfInitialised;
+ if (!initialised && numSamples > 0)
+ {
+ /* Initialise filter with first sample */
+ bitV = sample[0].level & bit;
+ gpioAlert[i].gfRBitV = bitV;
+ gpioAlert[i].gfLBitV = bitV;
+ gpioAlert[i].gfTick = sample[0].tick;
+ gpioAlert[i].gfInitialised = 1;
+ }
+
steadyUs = gpioAlert[i].gfSteadyUs;
RBitV = gpioAlert[i].gfRBitV;
LBitV = gpioAlert[i].gfLBitV;
@@ -6932,6 +7021,8 @@ static void *pthSocketThreadHandler(void *fdC)
{
int sock = *(int*)fdC;
uintptr_t p[10];
+ uint32_t tmp, response[4];
+ int i;
int opt;
char buf[CMD_MAX_EXTENSION];
@@ -6943,7 +7034,21 @@ static void *pthSocketThreadHandler(void *fdC)
while (1)
{
- if (recv(sock, p, 16, MSG_WAITALL) != 16) break;
+ if (sizeof(uintptr_t) == 8)
+ {
+ if (recv(sock, &tmp, 4, MSG_WAITALL) != 4) break;
+ p[0] = (uintptr_t)tmp;
+ if (recv(sock, &tmp, 4, MSG_WAITALL) != 4) break;
+ p[1] = (uintptr_t)tmp;
+ if (recv(sock, &tmp, 4, MSG_WAITALL) != 4) break;
+ p[2] = (uintptr_t)tmp;
+ if (recv(sock, &tmp, 4, MSG_WAITALL) != 4) break;
+ p[3] = (uintptr_t)tmp;
+ }
+ else
+ {
+ if (recv(sock, p, 16, MSG_WAITALL) != 16) break;
+ }
if (p[3])
{
@@ -6966,8 +7071,8 @@ static void *pthSocketThreadHandler(void *fdC)
else
{
/* Serious error. No point continuing. */
- DBG(DBG_ALWAYS,
- "ext too large %"PRIdPTR"(%zd), sock=%d", p[3], sizeof(buf), sock);
+ DBG(DBG_ALWAYS, "ext too large %"PRIdPTR"(%zd), sock=%d",
+ p[3], sizeof(buf), sock);
closeOrphanedNotifications(-1, sock);
@@ -7007,7 +7112,16 @@ static void *pthSocketThreadHandler(void *fdC)
p[3] = myDoCommand(p, sizeof(buf)-1, buf);
}
- if (write(sock, p, 16) == -1) { /* ignore errors */ }
+ if (sizeof(uintptr_t) == 8) // 64-bit system
+ {
+ for (i = 0; i < 4; i++)
+ response[i] = (uint32_t)p[i];
+ if (write(sock, response, 16) == -1) { /* ignore errors */ }
+ }
+ else // 32-bit system
+ {
+ if (write(sock, p, 16) == -1) { /* ignore errors */ }
+ }
switch (p[0])
{
@@ -7045,7 +7159,7 @@ static void *pthSocketThreadHandler(void *fdC)
close(sock);
- DBG(DBG_ALWAYS, "Socket %d closed", sock);
+ DBG(DBG_USER, "Socket %d closed", sock);
return 0;
}
@@ -7110,7 +7224,7 @@ static void * pthSocketThread(void *x)
if (addrAllowed((struct sockaddr *)&client))
{
- DBG(DBG_ALWAYS, "Connection accepted on socket %d", fdC);
+ DBG(DBG_USER, "Connection accepted on socket %d", fdC);
sock = malloc(sizeof(int));
@@ -7120,12 +7234,13 @@ static void * pthSocketThread(void *x)
int optval = 1;
socklen_t optlen = sizeof(optval);
- if (setsockopt(fdC, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) {
- DBG(0, "setsockopt() fail, closing socket %d", fdC);
+ if (setsockopt(fdC, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0)
+ {
+ DBG(DBG_ALWAYS, "setsockopt() fail, closing socket %d", fdC);
close(fdC);
}
- DBG(DBG_ALWAYS, "SO_KEEPALIVE enabled on socket %d\n", fdC);
+ DBG(DBG_USER, "SO_KEEPALIVE enabled on socket %d\n", fdC);
if (pthread_create
(&thr, &attr, pthSocketThreadHandler, (void*) sock) < 0)
@@ -7220,7 +7335,7 @@ static int initGrabLockFile(void)
static uint32_t * initMapMem(int fd, uint32_t addr, uint32_t len)
{
return (uint32_t *) mmap(0, len,
- PROT_READ|PROT_WRITE|PROT_EXEC,
+ PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_LOCKED,
fd, addr);
}
@@ -7259,36 +7374,41 @@ static int initCheckPermitted(void)
static int initPeripherals(void)
{
- uint32_t dmaBase;
-
DBG(DBG_STARTUP, "");
gpioReg = initMapMem(fdMem, GPIO_BASE, GPIO_LEN);
if (gpioReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap gpio failed (%m) GPIO_BASE=%08X GPIO_LEN=%08X REV=%08X",GPIO_BASE,GPIO_LEN,gpioHardwareRevision());
-
- /* dma channels 0-14 share one page, 15 has another */
-
- if (gpioCfg.DMAprimaryChannel < 15)
- {
- dmaBase = DMA_BASE;
- }
- else dmaBase = DMA15_BASE;
+ SOFT_ERROR(PI_INIT_FAILED, "mmap gpio failed (%m)");
- dmaReg = initMapMem(fdMem, dmaBase, DMA_LEN);
+ dmaReg = initMapMem(fdMem, DMA_BASE, DMA_LEN);
if (dmaReg == MAP_FAILED)
SOFT_ERROR(PI_INIT_FAILED, "mmap dma failed (%m)");
- if (gpioCfg.DMAprimaryChannel < 15)
+ /* we should know if we are running on a BCM2711 by now */
+
+ if (gpioCfg.DMAprimaryChannel == PI_DEFAULT_DMA_NOT_SET)
{
- dmaIn = dmaReg + (gpioCfg.DMAprimaryChannel * 0x40);
- dmaOut = dmaReg + (gpioCfg.DMAsecondaryChannel * 0x40);
+ if (pi_is_2711)
+ gpioCfg.DMAprimaryChannel = PI_DEFAULT_DMA_PRIMARY_CH_2711;
+ else
+ gpioCfg.DMAprimaryChannel = PI_DEFAULT_DMA_PRIMARY_CHANNEL;
}
+
+ if (gpioCfg.DMAsecondaryChannel == PI_DEFAULT_DMA_NOT_SET)
+ {
+ if (pi_is_2711)
+ gpioCfg.DMAsecondaryChannel = PI_DEFAULT_DMA_SECONDARY_CH_2711;
+ else
+ gpioCfg.DMAsecondaryChannel = PI_DEFAULT_DMA_SECONDARY_CHANNEL;
+ }
+
+ dmaIn = dmaReg + (gpioCfg.DMAprimaryChannel * 0x40);
+ dmaOut = dmaReg + (gpioCfg.DMAsecondaryChannel * 0x40);
- DBG(DBG_STARTUP, "DMA #%d @ %08X @ %08"PRIXPTR,
- gpioCfg.DMAprimaryChannel, dmaBase, (uintptr_t)dmaIn);
+ DBG(DBG_STARTUP, "DMA #%d @ %08"PRIXPTR,
+ gpioCfg.DMAprimaryChannel, (uintptr_t)dmaIn);
DBG(DBG_STARTUP, "debug reg is %08X", dmaIn[DMA_DEBUG]);
@@ -7780,7 +7900,7 @@ static void initClock(int mainClock)
}
clkSrc = CLK_CTL_SRC_PLLD;
- clkDivI = 50 * micros; /* 10 MHz - 1 MHz */
+ clkDivI = clk_plld_freq / (10000000 / micros); /* 10 MHz - 1 MHz */
clkBits = BITS; /* 10/BITS MHz - 1/BITS MHz */
clkDivF = 0;
clkMash = 0;
@@ -7796,13 +7916,22 @@ static void initClock(int mainClock)
myGpioDelay(2000);
}
+static void initKillDMA(volatile uint32_t *dmaAddr)
+{
+ dmaAddr[DMA_CS] = DMA_CHANNEL_ABORT;
+ dmaAddr[DMA_CS] = 0;
+ dmaAddr[DMA_CS] = DMA_CHANNEL_RESET;
+
+ dmaAddr[DMA_CONBLK_AD] = 0;
+}
+
/* ----------------------------------------------------------------------- */
static void initDMAgo(volatile uint32_t *dmaAddr, uint32_t cbAddr)
{
DBG(DBG_STARTUP, "");
- dmaAddr[DMA_CS] = DMA_CHANNEL_RESET;
+ initKillDMA(dmaAddr);
dmaAddr[DMA_CS] = DMA_INTERRUPT_STATUS | DMA_END_FLAG;
@@ -7818,7 +7947,7 @@ static void initDMAgo(volatile uint32_t *dmaAddr, uint32_t cbAddr)
dmaAddr[DMA_CS] = DMA_WAIT_ON_WRITES |
DMA_PANIC_PRIORITY(8) |
DMA_PRIORITY(8) |
- DMA_ACTIVATE;
+ DMA_ACTIVE;
}
/* ----------------------------------------------------------------------- */
@@ -8115,7 +8244,8 @@ static void initReleaseResources(void)
int initInitialise(void)
{
- int rev, i, model;
+ int i;
+ unsigned rev, model;
struct sockaddr_in server;
struct sockaddr_in6 server6;
char * portStr;
@@ -8163,13 +8293,27 @@ int initInitialise(void)
7=Unknown
8=Pi3B
9=Zero
+ 12=Zero W
+ 13=Pi3B+
+ 14=Pi3A+
+ 17=Pi4B
*/
if (model < 2) gpioMask = PI_DEFAULT_UPDATE_MASK_A_B2;
else if (model < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS;
else if (model == 4) gpioMask = PI_DEFAULT_UPDATE_MASK_PI2B;
- else if (model == 6) gpioMask = PI_DEFAULT_UPDATE_MASK_COMPUTE;
- else if (model == 8) gpioMask = PI_DEFAULT_UPDATE_MASK_PI3B;
- else if (model == 9) gpioMask = PI_DEFAULT_UPDATE_MASK_ZERO;
+
+ else if (model == 6
+ || model ==10
+ || model ==16) gpioMask = PI_DEFAULT_UPDATE_MASK_COMPUTE;
+
+ else if (model == 8
+ || model ==13
+ || model ==14) gpioMask = PI_DEFAULT_UPDATE_MASK_PI3B;
+
+ else if (model == 9
+ || model ==12) gpioMask = PI_DEFAULT_UPDATE_MASK_ZERO;
+
+ else if (model ==17) gpioMask = PI_DEFAULT_UPDATE_MASK_PI4B;
else gpioMask = PI_DEFAULT_UPDATE_MASK_UNKNOWN;
}
@@ -8248,7 +8392,7 @@ int initInitialise(void)
}
server6.sin6_port = htons(port);
- int opt;
+ int opt = 1;
setsockopt(fdSock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
if (bind(fdSock,(struct sockaddr *)&server6, sizeof(server6)) < 0)
SOFT_ERROR(PI_INIT_FAILED, "bind to port %d failed (%m)", port);
@@ -8263,7 +8407,7 @@ int initInitialise(void)
SOFT_ERROR(PI_INIT_FAILED, "socket failed (%m)");
else
{
- int opt;
+ int opt = 1;
setsockopt(fdSock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
}
server.sin_family = AF_INET;
@@ -8580,8 +8724,11 @@ void gpioTerminate(void)
/* reset DMA */
- if (dmaReg != MAP_FAILED) dmaIn[DMA_CS] = DMA_CHANNEL_RESET;
- if (dmaReg != MAP_FAILED) dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
+ if (dmaReg != MAP_FAILED)
+ {
+ initKillDMA(dmaIn);
+ initKillDMA(dmaOut);
+ }
#ifndef EMBEDDED_IN_VM
if ((gpioCfg.internals & PI_CFG_STATS) &&
@@ -8732,6 +8879,10 @@ int gpioGetMode(unsigned gpio)
int gpioSetPullUpDown(unsigned gpio, unsigned pud)
{
+ int shift = (gpio & 0xf) << 1;
+ uint32_t bits;
+ uint32_t pull;
+
DBG(DBG_USER, "gpio=%d pud=%d", gpio, pud);
CHECK_INITED;
@@ -8742,17 +8893,34 @@ int gpioSetPullUpDown(unsigned gpio, unsigned pud)
if (pud > PI_PUD_UP)
SOFT_ERROR(PI_BAD_PUD, "gpio %d, bad pud (%d)", gpio, pud);
- *(gpioReg + GPPUD) = pud;
+ if (pi_is_2711)
+ {
+ switch (pud)
+ {
+ case PI_PUD_OFF: pull = 0; break;
+ case PI_PUD_UP: pull = 1; break;
+ case PI_PUD_DOWN: pull = 2; break;
+ }
- myGpioDelay(1);
+ bits = *(gpioReg + GPPUPPDN0 + (gpio>>4));
+ bits &= ~(3 << shift);
+ bits |= (pull << shift);
+ *(gpioReg + GPPUPPDN0 + (gpio>>4)) = bits;
+ }
+ else
+ {
+ *(gpioReg + GPPUD) = pud;
+
+ myGpioDelay(1);
- *(gpioReg + GPPUDCLK0 + BANK) = BIT;
+ *(gpioReg + GPPUDCLK0 + BANK) = BIT;
- myGpioDelay(1);
+ myGpioDelay(1);
- *(gpioReg + GPPUD) = 0;
+ *(gpioReg + GPPUD) = 0;
- *(gpioReg + GPPUDCLK0 + BANK) = 0;
+ *(gpioReg + GPPUDCLK0 + BANK) = 0;
+ }
return 0;
}
@@ -9471,7 +9639,7 @@ int gpioWaveCreate(void)
/* What resources are needed? */
- waveCBsOOLs(&numCB, &numBOOL, &numTOOL);
+ waveCBsOOLs(&numCB, &numBOOL, &numTOOL);
wid = -1;
@@ -9494,10 +9662,10 @@ int gpioWaveCreate(void)
{
/* Are there enough spare resources? */
- if ((numCB+waveOutBotCB) >= NUM_WAVE_CBS)
+ if ((numCB+waveOutBotCB) > NUM_WAVE_CBS)
return PI_TOO_MANY_CBS;
- if ((numBOOL+waveOutBotOOL) >= (waveOutTopOOL-numTOOL))
+ if ((numBOOL+waveOutBotOOL) > (waveOutTopOOL-numTOOL))
return PI_TOO_MANY_OOL;
if (wid >= PI_MAX_WAVES)
@@ -9524,7 +9692,7 @@ int gpioWaveCreate(void)
BOOL = waveInfo[wid].botOOL;
TOOL = waveInfo[wid].topOOL;
- wave2Cbs(PI_WAVE_MODE_ONE_SHOT, &CB, &BOOL, &TOOL);
+ wave2Cbs(PI_WAVE_MODE_ONE_SHOT, &CB, &BOOL, &TOOL, 0, 0, 0);
/* Sanity check. */
@@ -9538,6 +9706,9 @@ int gpioWaveCreate(void)
numTOOL, waveInfo[wid].topOOL-TOOL);
}
+ DBG(DBG_USER, "Wave Stats: wid=%d CBs %d BOOL %d TOOL %d", wid,
+ numCB, numBOOL, numTOOL);
+
waveInfo[wid].deleted = 0;
/* Consume waves. */
@@ -9551,6 +9722,124 @@ int gpioWaveCreate(void)
return wid;
}
+int gpioWaveCreatePad(int pctCB, int pctBOOL, int pctTOOL)
+{
+ int i, wid;
+ int numCB, numBOOL, numTOOL;
+ int CB, BOOL, TOOL;
+
+ DBG(DBG_USER, "%d, %d, %d", pctCB, pctBOOL, pctTOOL);
+
+ CHECK_INITED;
+
+ if (pctCB < 0 || pctCB > 100)
+ SOFT_ERROR(PI_BAD_PARAM, "bad wave param, pctCB=(%d)", pctCB);
+ if (pctBOOL < 0 || pctBOOL > 100)
+ SOFT_ERROR(PI_BAD_PARAM, "bad wave param, pctBOOL=(%d)", pctBOOL);
+ if (pctTOOL < 0 || pctTOOL > 100)
+ SOFT_ERROR(PI_BAD_PARAM, "bad wave param, pctTOOL=(%d)", pctTOOL);
+
+ if (wfc[wfcur] == 0) return PI_EMPTY_WAVEFORM;
+
+ /* What resources are needed? */
+ waveCBsOOLs(&numCB, &numBOOL, &numTOOL);
+
+ /* Amount of pad required */
+ CB = (NUM_WAVE_CBS - PI_WAVE_COUNT_PAGES*CBS_PER_OPAGE) * pctCB / 100;
+ BOOL = (NUM_WAVE_OOL - PI_WAVE_COUNT_PAGES*OOL_PER_OPAGE) * pctBOOL /100;
+ TOOL = (NUM_WAVE_OOL - PI_WAVE_COUNT_PAGES*OOL_PER_OPAGE) * pctTOOL /100;
+
+ /* Reject if wave is too big */
+ if (numCB > CB) return PI_TOO_MANY_CBS;
+ if (numBOOL > BOOL) return PI_TOO_MANY_OOL;
+ if (numTOOL > TOOL) return PI_TOO_MANY_OOL;
+
+ /* Set the padding */
+ numCB = CB;
+ numBOOL = BOOL;
+ numTOOL = TOOL;
+
+
+ wid = -1;
+
+ /* Is there an exact fit with a deleted wave. */
+
+ for (i=0; i<waveOutCount; i++)
+ {
+ if (waveInfo[i].deleted &&
+ (waveInfo[i].numCB == numCB) &&
+ (waveInfo[i].numBOOL == numBOOL) &&
+ (waveInfo[i].numTOOL == numTOOL))
+ {
+ /* Reuse the deleted waves resources. */
+ wid = i;
+ break;
+ }
+ }
+
+ if (wid == -1)
+ {
+ /* Are there enough spare resources? */
+
+ if ((numCB+waveOutBotCB) > NUM_WAVE_CBS)
+ return PI_TOO_MANY_CBS;
+
+ if ((numBOOL+waveOutBotOOL) > (waveOutTopOOL-numTOOL))
+ return PI_TOO_MANY_OOL;
+
+ if (wid >= PI_MAX_WAVES)
+ return PI_NO_WAVEFORM_ID;
+
+ wid = waveOutCount++;
+
+ waveInfo[wid].botCB = waveOutBotCB;
+ waveInfo[wid].topCB = waveOutBotCB + numCB -1;
+ waveInfo[wid].botOOL = waveOutBotOOL;
+ waveInfo[wid].topOOL = waveOutTopOOL;
+ waveInfo[wid].numCB = numCB;
+ waveInfo[wid].numBOOL = numBOOL;
+ waveInfo[wid].numTOOL = numTOOL;
+
+ waveOutBotCB += numCB;
+ waveOutBotOOL += numBOOL;
+ waveOutTopOOL -= numTOOL;
+ }
+
+ /* Must be room if got this far. */
+
+ CB = waveInfo[wid].botCB;
+ BOOL = waveInfo[wid].botOOL;
+ TOOL = waveInfo[wid].topOOL;
+
+ wave2Cbs(PI_WAVE_MODE_ONE_SHOT, &CB, &BOOL, &TOOL, numCB, numBOOL, numTOOL);
+
+ /* Sanity check. */
+
+ if ( (numCB != (CB-waveInfo[wid].botCB)) ||
+ (numBOOL != (BOOL-waveInfo[wid].botOOL)) ||
+ (numTOOL != (waveInfo[wid].topOOL-TOOL)) )
+ {
+ DBG(DBG_ALWAYS, "ERROR wid=%d CBs %d=%d BOOL %d=%d TOOL %d=%d", wid,
+ numCB, CB-waveInfo[wid].botCB,
+ numBOOL, BOOL-waveInfo[wid].botOOL,
+ numTOOL, waveInfo[wid].topOOL-TOOL);
+ }
+
+ DBG(DBG_USER, "Wave padding: wid=%d CBs %d BOOL %d TOOL %d", wid,
+ numCB, numBOOL, numTOOL);
+
+ waveInfo[wid].deleted = 0;
+
+ /* Consume waves. */
+
+ wfc[0] = 0;
+ wfc[1] = 0;
+ wfc[2] = 0;
+
+ wfcur = 0;
+
+ return wid;
+}
/* ----------------------------------------------------------------------- */
int gpioWaveDelete(unsigned wave_id)
@@ -9615,11 +9904,7 @@ int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode)
PWMClockInited = 0;
}
- if (wave_mode < PI_WAVE_MODE_ONE_SHOT_SYNC)
- {
- dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
- dmaOut[DMA_CONBLK_AD] = 0;
- }
+ if (wave_mode < PI_WAVE_MODE_ONE_SHOT_SYNC) initKillDMA(dmaOut);
p = rawWaveCBAdr(waveInfo[wave_id].topCB);
@@ -9862,8 +10147,8 @@ int gpioWaveChain(char *buf, unsigned bufSize)
PWMClockInited = 0;
}
- dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
- dmaOut[DMA_CONBLK_AD] = 0;
+ initKillDMA(dmaOut);
+
waveEndPtr = NULL;
endPtr = NULL;
@@ -10184,8 +10469,7 @@ int gpioWaveTxStop(void)
CHECK_INITED;
- dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
- dmaOut[DMA_CONBLK_AD] = 0;
+ initKillDMA(dmaOut);
waveEndPtr = NULL;
@@ -10640,35 +10924,69 @@ int bbI2CZip(
void bscInit(int mode)
{
+ int sda, scl, miso, ce;
+
bscsReg[BSC_CR]=0; /* clear device */
bscsReg[BSC_RSR]=0; /* clear underrun and overrun errors */
bscsReg[BSC_SLV]=0; /* clear I2C slave address */
bscsReg[BSC_IMSC]=0xf; /* mask off all interrupts */
bscsReg[BSC_ICR]=0x0f; /* clear all interrupts */
- gpioSetMode(BSC_SDA_MOSI, PI_ALT3);
- gpioSetMode(BSC_SCL_SCLK, PI_ALT3);
+ if (pi_is_2711)
+ {
+ sda = BSC_SDA_MOSI_2711;
+ scl = BSC_SCL_SCLK_2711;
+ miso = BSC_MISO_2711;
+ ce = BSC_CE_N_2711;
+ }
+ else
+ {
+ sda = BSC_SDA_MOSI;
+ scl = BSC_SCL_SCLK;
+ miso = BSC_MISO;
+ ce = BSC_CE_N;
+ }
+
+ gpioSetMode(sda, PI_ALT3);
+ gpioSetMode(scl, PI_ALT3);
if (mode > 1) /* SPI uses all GPIO */
{
- gpioSetMode(BSC_MISO, PI_ALT3);
- gpioSetMode(BSC_CE_N, PI_ALT3);
+ gpioSetMode(miso, PI_ALT3);
+ gpioSetMode(ce, PI_ALT3);
}
}
void bscTerm(int mode)
{
+ int sda, scl, miso, ce;
+
bscsReg[BSC_CR] = 0; /* clear device */
bscsReg[BSC_RSR]=0; /* clear underrun and overrun errors */
bscsReg[BSC_SLV]=0; /* clear I2C slave address */
- gpioSetMode(BSC_SDA_MOSI, PI_INPUT);
- gpioSetMode(BSC_SCL_SCLK, PI_INPUT);
+ if (pi_is_2711)
+ {
+ sda = BSC_SDA_MOSI_2711;
+ scl = BSC_SCL_SCLK_2711;
+ miso = BSC_MISO_2711;
+ ce = BSC_CE_N_2711;
+ }
+ else
+ {
+ sda = BSC_SDA_MOSI;
+ scl = BSC_SCL_SCLK;
+ miso = BSC_MISO;
+ ce = BSC_CE_N;
+ }
+
+ gpioSetMode(sda, PI_INPUT);
+ gpioSetMode(scl, PI_INPUT);
if (mode > 1)
{
- gpioSetMode(BSC_MISO, PI_INPUT);
- gpioSetMode(BSC_CE_N, PI_INPUT);
+ gpioSetMode(miso, PI_INPUT);
+ gpioSetMode(ce, PI_INPUT);
}
}
@@ -10701,7 +11019,7 @@ int bscXfer(bsc_xfer_t *xfer)
if (mode > bscMode)
{
- bscInit(bscMode);
+ bscInit(mode);
bscMode = mode;
}
}
@@ -11436,12 +11754,16 @@ static void *pthISRThread(void *x)
sprintf(buf, "/sys/class/gpio/gpio%d/value", isr->gpio);
+ isr->fd = -1; /* no fd assigned */
+
if ((fd = open(buf, O_RDONLY)) < 0)
{
DBG(DBG_ALWAYS, "gpio %d not exported", isr->gpio);
return NULL;
}
+ isr->fd = fd; /* store fd so it can be closed */
+
pfd.fd = fd;
pfd.events = POLLPRI;
@@ -11561,6 +11883,13 @@ static int intGpioSetISRFunc(
if (gpioISR[gpio].pth) /* delete any existing ISR */
{
gpioStopThread(gpioISR[gpio].pth);
+
+ if (gpioISR[gpio].fd >= 0)
+ {
+ close(gpioISR[gpio].fd);
+ gpioISR[gpio].fd = -1;
+ }
+
gpioISR[gpio].func = NULL;
gpioISR[gpio].pth = NULL;
}
@@ -11881,6 +12210,8 @@ int gpioNotifyPause (unsigned handle)
int gpioNotifyClose(unsigned handle)
{
+ char fifo[32];
+
DBG(DBG_USER, "handle=%d", handle);
CHECK_INITED;
@@ -11897,7 +12228,24 @@ int gpioNotifyClose(unsigned handle)
intNotifyBits();
- /* actual close done in alert thread */
+ if (gpioCfg.ifFlags & PI_DISABLE_ALERT)
+ {
+ if (gpioNotify[handle].pipe)
+ {
+ DBG(DBG_INTERNAL, "close notify pipe %d", gpioNotify[handle].fd);
+ close(gpioNotify[handle].fd);
+
+ sprintf(fifo, "/dev/pigpio%d", handle);
+
+ unlink(fifo);
+ }
+
+ gpioNotify[handle].state = PI_NOTIFY_CLOSED;
+ }
+ else
+ {
+ /* actual close done in alert thread */
+ }
return 0;
}
@@ -12002,18 +12350,8 @@ int gpioGlitchFilter(unsigned gpio, unsigned steady)
if (steady)
{
- gpioAlert[gpio].gfTick = systReg[SYST_CLO];
-
- if (gpioRead_Bits_0_31() & (1<<gpio))
- {
- gpioAlert[gpio].gfLBitV = (1<<gpio);
- gpioAlert[gpio].gfRBitV = 0 ;
- }
- else
- {
- gpioAlert[gpio].gfLBitV = 0 ;
- gpioAlert[gpio].gfRBitV = (1<<gpio);
- }
+ /* Initialise values next time we process alerts */
+ gpioAlert[gpio].gfInitialised = 0;
}
gpioAlert[gpio].gfSteadyUs = steady;
@@ -12611,7 +12949,7 @@ int gpioHardwareClock(unsigned gpio, unsigned frequency)
int cctl[] = {CLK_GP0_CTL, CLK_GP1_CTL, CLK_GP2_CTL};
int cdiv[] = {CLK_GP0_DIV, CLK_GP1_DIV, CLK_GP2_DIV};
int csrc[CLK_SRCS] = {CLK_CTL_SRC_OSC, CLK_CTL_SRC_PLLD};
- uint32_t cfreq[CLK_SRCS]={CLK_OSC_FREQ, CLK_PLLD_FREQ};
+ uint32_t cfreq[CLK_SRCS]={clk_osc_freq, clk_plld_freq};
unsigned clock, mode, mash;
int password = 0;
double f;
@@ -12631,11 +12969,12 @@ int gpioHardwareClock(unsigned gpio, unsigned frequency)
if (!clkDef[gpio])
SOFT_ERROR(PI_NOT_HCLK_GPIO, "bad gpio for clock (%d)", gpio);
- if (((frequency < PI_HW_CLK_MIN_FREQ) ||
- (frequency > PI_HW_CLK_MAX_FREQ)) &&
+ if (((frequency < hw_clk_min_freq) ||
+ (frequency > hw_clk_max_freq)) &&
(frequency))
SOFT_ERROR(PI_BAD_HCLK_FREQ,
- "bad hardware clock frequency (%d)", frequency);
+ "bad hardware clock frequency %d-%d: (%d)",
+ hw_clk_min_freq, hw_clk_max_freq, frequency);
clock = (clkDef[gpio] >> 4) & 3;
@@ -12670,7 +13009,8 @@ int gpioHardwareClock(unsigned gpio, unsigned frequency)
else
{
SOFT_ERROR(PI_BAD_HCLK_FREQ,
- "bad hardware clock frequency (%d)", frequency);
+ "bad hardware clock frequency %d-%d: (%d)",
+ hw_clk_min_freq, hw_clk_max_freq, frequency);
}
}
else
@@ -12709,10 +13049,12 @@ int gpioHardwarePWM(
SOFT_ERROR(PI_BAD_HPWM_DUTY, "bad PWM dutycycle (%d)", dutycycle);
if (((frequency < PI_HW_PWM_MIN_FREQ) ||
- (frequency > PI_HW_PWM_MAX_FREQ)) &&
+ (frequency > hw_pwm_max_freq)) &&
(frequency))
SOFT_ERROR(PI_BAD_HPWM_FREQ,
- "bad hardware PWM frequency (%d)", frequency);
+ "bad hardware PWM frequency %d-%d: (%d)",
+ PI_HW_PWM_MIN_FREQ, hw_pwm_max_freq, frequency);
+
if (gpioCfg.clockPeriph == PI_CLOCK_PWM)
SOFT_ERROR(PI_HPWM_ILLEGAL, "illegal, PWM in use for main clock");
@@ -12722,13 +13064,13 @@ int gpioHardwarePWM(
if (frequency)
{
- real_range = ((double)CLK_PLLD_FREQ / (2.0 * frequency)) + 0.5;
+ real_range = ((double)clk_plld_freq / (2.0 * frequency)) + 0.5;
real_dutycycle = ((uint64_t)dutycycle * real_range) / PI_HW_PWM_RANGE;
/* record the set PWM frequency and dutycycle */
hw_pwm_freq[pwm] =
- ((double)CLK_PLLD_FREQ / ( 2.0 * real_range)) + 0.5;
+ ((double)clk_plld_freq / ( 2.0 * real_range)) + 0.5;
hw_pwm_duty[pwm] = dutycycle;
@@ -12882,6 +13224,8 @@ int fileApprove(char *filename)
buffer[0] = 0;
match[0] = 0;
+ if (myPathBad(filename)) return PI_FILE_NONE;
+
f = fopen("/opt/pigpio/access", "r");
if (!f) return PI_FILE_NONE;
@@ -12938,7 +13282,7 @@ int fileOpen(char *file, unsigned mode)
{
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int fd=-1;
- int i, slot, oflag, omode;
+ int i, slot, oflag, omode, pmode, rmode;
struct stat statbuf;
DBG(DBG_USER, "file=%s mode=%d", file, mode);
@@ -12950,9 +13294,15 @@ int fileOpen(char *file, unsigned mode)
((mode & PI_FILE_RW) == 0) )
SOFT_ERROR(PI_BAD_FILE_MODE, "bad mode (%d)", mode);
- if ((fileApprove(file) & mode) == PI_FILE_NONE)
+ pmode = fileApprove(file); // 0=NONE, 1=READ, 2=WRITE, 3=RW
+ rmode = mode & PI_FILE_RW; // 0=NONE, 1=READ, 2=WRITE, 3=RW
+
+ if (((pmode & rmode) != rmode) || (rmode == PI_FILE_NONE))
SOFT_ERROR(PI_NO_FILE_ACCESS, "no permission to access file (%s)", file);
+ if ((mode > 3) && ((mode & PI_FILE_WRITE) == 0))
+ SOFT_ERROR(PI_NO_FILE_ACCESS, "no permission to write file (%s)", file);
+
slot = -1;
pthread_mutex_lock(&mutex);
@@ -12976,7 +13326,6 @@ int fileOpen(char *file, unsigned mode)
if (mode & PI_FILE_APPEND)
{
- mode |= PI_FILE_WRITE;
oflag |= O_APPEND;
}
@@ -12988,7 +13337,6 @@ int fileOpen(char *file, unsigned mode)
if (mode & PI_FILE_TRUNC)
{
- mode |= PI_FILE_WRITE;
oflag |= O_TRUNC;
}
@@ -13173,7 +13521,7 @@ int fileList(char *fpat, char *buf, unsigned count)
CHECK_INITED;
- if (fileApprove(fpat) == PI_FILE_NONE)
+ if ((fileApprove(fpat) & PI_FILE_READ) != PI_FILE_READ)
SOFT_ERROR(PI_NO_FILE_ACCESS, "no permission to access file (%s)", fpat);
bufpos = 0;
@@ -13331,13 +13679,14 @@ W warranty void if either bit is set
S 0=old (bits 0-22 are revision number) 1=new (following fields apply)
-M 0=256 1=512 2=1024
+M 0=256 1=512 2=1024 3=2GB 4=4GB
-B 0=Sony 1=Egoman 2=Embest 3=Unknown 4=Embest
+B 0=Sony 1=Egoman 2=Embest 3=Sony Japan 4=Embest 5=Stadium
-P 0=2835, 1=2836, 2=2837
+P 0=2835, 1=2836, 2=2837 3=2711
-T 0=A 1=B 2=A+ 3=B+ 4=Pi2B 5=Alpha 6=Compute Module 7=Unknown 8=Pi3B 9=Zero
+T 0=A 1=B 2=A+ 3=B+ 4=Pi2B 5=Alpha 6=CM1 8=Pi3B 9=Zero a=CM3 c=Zero W
+ d=3B+ e=3A+ 10=CM3+ 11=4B
R PCB board revision
@@ -13355,98 +13704,119 @@ unsigned gpioHardwareRevision(void)
if (rev) return rev;
- piCores = 0;
-
filp = fopen ("/proc/cpuinfo", "r");
+
if (filp != NULL)
{
while (fgets(buf, sizeof(buf), filp) != NULL)
{
- if (piCores == 0)
- {
- if (!strncasecmp("model name", buf, 10))
- {
- if (strstr (buf, "ARMv6") != NULL)
- {
- piCores = 1;
- pi_peri_phys = 0x20000000;
- pi_dram_bus = 0x40000000;
- pi_mem_flag = 0x0C;
- }
- else if (strstr (buf, "ARMv7") != NULL)
- {
- piCores = 4;
- pi_peri_phys = 0x3F000000;
- pi_dram_bus = 0xC0000000;
- pi_mem_flag = 0x04;
- }
- else if (strstr (buf, "ARMv8") != NULL)
- {
- piCores = 4;
- pi_peri_phys = 0x3F000000;
- pi_dram_bus = 0xC0000000;
- pi_mem_flag = 0x04;
- }
- }
- }
-
- if (!strncasecmp("hardware\t: BCM", buf, 14)) {
- int bcmno = atoi(buf+14);
- if ((bcmno == 2708) || (bcmno == 2709) || (bcmno == 2710) || (bcmno == 2835) || (bcmno == 2836) || (bcmno == 2837))
- {
- pi_ispi = 1;
- }
- }
-
if (!strncasecmp("revision\t:", buf, 10))
{
if (sscanf(buf+10, "%x%c", &rev, &term) == 2)
{
if (term != '\n') rev = 0;
- else rev &= 0xFFFFFF; /* mask out warranty bit */
}
}
}
-
fclose(filp);
- //raspberry pi 3 running arm64 don't put all the information we need in /proc/cpuinfo, but we can get it elsewhere.
- if (!pi_ispi)
+ }
+
+ /* (some) arm64 operating systems get revision number here */
+
+ if (rev == 0)
+ {
+ DBG(DBG_USER, "searching /proc/device-tree for revision");
+ filp = fopen ("/proc/device-tree/system/linux,revision", "r");
+
+ if (filp != NULL)
{
- filp = fopen ("/proc/device-tree/model", "r");
- if (filp != NULL)
+ uint32_t tmp;
+ if (fread(&tmp,1 , 4, filp) == 4)
{
- if (fgets(buf, sizeof(buf), filp) != NULL)
- {
- if (!strncmp("Raspberry Pi 3", buf, 14))
- {
- pi_ispi = 1;
- piCores = 4;
- pi_peri_phys = 0x3F000000;
- pi_dram_bus = 0xC0000000;
- pi_mem_flag = 0x04;
- }
- }
+ /*
+ for some reason the value returned by reading
+ this /proc entry seems to be big endian,
+ convert it.
+ */
+ rev = ntohl(tmp);
+ rev &= 0xFFFFFF; /* mask out warranty bit */
}
fclose(filp);
}
- if (rev == 0)
+ }
+
+ piCores = 0;
+ pi_ispi = 0;
+ rev &= 0xFFFFFF; /* mask out warranty bit */
+
+ /* Decode revision code */
+
+ if ((rev & 0x800000) == 0) /* old rev code */
+ {
+ if (rev < 0x0016) /* all BCM2835 */
{
- filp = fopen ("/proc/device-tree/system/linux,revision", "r");
- if (filp != NULL)
- {
- uint32_t tmp;
- if (fread(&tmp,1 , 4, filp) == 4)
- {
- // for some reason the value returned by reading this
- // /proc entry seems to be big endian, convert it.
- rev = ntohl(tmp);
- rev &= 0xFFFFFF; /* mask out warranty bit */
- }
- }
- fclose(filp);
+ pi_ispi = 1;
+ piCores = 1;
+ pi_peri_phys = 0x20000000;
+ pi_dram_bus = 0x40000000;
+ pi_mem_flag = 0x0C;
+ }
+ else
+ {
+ DBG(DBG_ALWAYS, "unknown revision=%x", rev);
+ rev = 0;
+ }
+ }
+ else /* new rev code */
+ {
+ switch ((rev >> 12) & 0xF) /* just interested in BCM model */
+ {
+
+ case 0x0: /* BCM2835 */
+ pi_ispi = 1;
+ piCores = 1;
+ pi_peri_phys = 0x20000000;
+ pi_dram_bus = 0x40000000;
+ pi_mem_flag = 0x0C;
+ break;
+
+ case 0x1: /* BCM2836 */
+ case 0x2: /* BCM2837 */
+ pi_ispi = 1;
+ piCores = 4;
+ pi_peri_phys = 0x3F000000;
+ pi_dram_bus = 0xC0000000;
+ pi_mem_flag = 0x04;
+ break;
+
+ case 0x3: /* BCM2711 */
+ pi_ispi = 1;
+ piCores = 4;
+ pi_peri_phys = 0xFE000000;
+ pi_dram_bus = 0xC0000000;
+ pi_mem_flag = 0x04;
+ pi_is_2711 = 1;
+ clk_osc_freq = CLK_OSC_FREQ_2711;
+ clk_plld_freq = CLK_PLLD_FREQ_2711;
+ hw_pwm_max_freq = PI_HW_PWM_MAX_FREQ_2711;
+ hw_clk_min_freq = PI_HW_CLK_MIN_FREQ_2711;
+ hw_clk_max_freq = PI_HW_CLK_MAX_FREQ_2711;
+ break;
+
+ default:
+ DBG(DBG_ALWAYS, "unknown rev code (%x)", rev);
+ rev=0;
+ pi_ispi = 0;
+ break;
}
}
+
+ DBG(DBG_USER, "revision=%x", rev);
+ DBG(DBG_USER, "pi_peri_phys=%x", pi_peri_phys);
+ DBG(DBG_USER, "pi_dram_bus=%x", pi_dram_bus);
+ DBG(DBG_USER, "pi_mem_flag=%x", pi_mem_flag);
+
return rev;
}
@@ -13523,7 +13893,8 @@ int gpioCfgDMAchannels(unsigned primaryChannel, unsigned secondaryChannel)
primaryChannel);
if ((secondaryChannel > PI_MAX_DMA_CHANNEL) ||
- (secondaryChannel == primaryChannel))
+ ((secondaryChannel == primaryChannel) &&
+ (secondaryChannel != PI_DEFAULT_DMA_NOT_SET)))
SOFT_ERROR(PI_BAD_SECO_CHANNEL, "bad secondary channel (%d)",
secondaryChannel);
@@ -13640,44 +14011,6 @@ int gpioCfgSetInternals(uint32_t cfgVal)
return 0;
}
-int gpioCfgInternals(unsigned cfgWhat, unsigned cfgVal)
-{
- int retVal = PI_BAD_CFG_INTERNAL;
-
- DBG(DBG_USER, "cfgWhat=%u, cfgVal=%d", cfgWhat, cfgVal);
-
- switch(cfgWhat)
- {
- case 562484977:
-
- if (cfgVal) gpioCfg.internals |= PI_CFG_STATS;
- else gpioCfg.internals &= (~PI_CFG_STATS);
-
- DBG(DBG_ALWAYS, "show stats is %u", cfgVal);
-
- retVal = 0;
-
- break;
-
- case 984762879:
-
- if ((cfgVal >= DBG_ALWAYS) && (cfgVal <= DBG_MAX_LEVEL))
- {
-
- gpioCfg.dbgLevel = cfgVal;
- gpioCfg.internals = (gpioCfg.internals & (~0xF)) | cfgVal;
-
- DBG(DBG_ALWAYS, "Debug level is %u", cfgVal);
-
- retVal = 0;
- }
-
- break;
- }
-
- return retVal;
-}
-
/* include any user customisations */
diff --git a/pigpio.h b/pigpio.h
index 8c79d2c..40d21fc 100644
--- a/pigpio.h
+++ b/pigpio.h
@@ -13,7 +13,6 @@ of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
-
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.
@@ -31,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
#include <stdint.h>
#include <pthread.h>
-#define PIGPIO_VERSION 68
+#define PIGPIO_VERSION 78
/*TEXT
@@ -73,8 +72,6 @@ The PWM and servo pulses are timed using the DMA and PWM peripherals.
This use was inspired by Richard Hirst's servoblaster kernel module.
-See [[https://github.com/richardghirst/PiBits/tree/master/ServoBlaster]]
-
*Usage*
Include <pigpio.h> in your source files.
@@ -109,6 +106,16 @@ return error PI_NOT_INITIALISED.
If the library is initialised the [*gpioCfg**] functions will return
error PI_INITIALISED.
+If you intend to rely on signals sent to your application, you should
+turn off the internal signal handling as shown in this example:
+
+. .
+int cfg = gpioCfgGetInternals();
+cfg |= PI_CFG_NOSIGHANDLER; // (1<<10)
+gpioCfgSetInternals(cfg);
+int status = gpioInitialise();
+. .
+
TEXT*/
/*OVERVIEW
@@ -118,7 +125,7 @@ ESSENTIAL
gpioInitialise Initialise library
gpioTerminate Stop library
-BEGINNER
+BASIC
gpioSetMode Set a GPIO mode
gpioGetMode Get a GPIO mode
@@ -128,29 +135,29 @@ gpioSetPullUpDown Set/clear GPIO pull up/down resistor
gpioRead Read a GPIO
gpioWrite Write a GPIO
+PWM_(overrides_servo_commands_on_same_GPIO)
+
gpioPWM Start/stop PWM pulses on a GPIO
+gpioSetPWMfrequency Configure PWM frequency for a GPIO
+gpioSetPWMrange Configure PWM range for a GPIO
+
gpioGetPWMdutycycle Get dutycycle setting on a GPIO
+gpioGetPWMfrequency Get configured PWM frequency for a GPIO
+gpioGetPWMrange Get configured PWM range for a GPIO
-gpioServo Start/stop servo pulses on a GPIO
-gpioGetServoPulsewidth Get pulsewidth setting on a GPIO
+gpioGetPWMrealRange Get underlying PWM range for a GPIO
-gpioDelay Delay for a number of microseconds
+Servo_(overrides_PWM_commands_on_same_GPIO)
-gpioSetAlertFunc Request a GPIO level change callback
+gpioServo Start/stop servo pulses on a GPIO
-gpioSetTimerFunc Request a regular timed callback
+gpioGetServoPulsewidth Get pulsewidth setting on a GPIO
INTERMEDIATE
-gpioTrigger Send a trigger pulse to a GPIO.
-
-gpioSetWatchdog Set a watchdog on a GPIO.
-
-gpioSetPWMrange Configure PWM range for a GPIO
-gpioGetPWMrange Get configured PWM range for a GPIO
+gpioTrigger Send a trigger pulse to a GPIO
-gpioSetPWMfrequency Configure PWM frequency for a GPIO
-gpioGetPWMfrequency Get configured PWM frequency for a GPIO
+gpioSetWatchdog Set a watchdog on a GPIO
gpioRead_Bits_0_31 Read all GPIO in bank 1
gpioRead_Bits_32_53 Read all GPIO in bank 2
@@ -161,88 +168,65 @@ gpioWrite_Bits_32_53_Clear Clear selected GPIO in bank 2
gpioWrite_Bits_0_31_Set Set selected GPIO in bank 1
gpioWrite_Bits_32_53_Set Set selected GPIO in bank 2
-gpioStartThread Start a new thread
-gpioStopThread Stop a previously started thread
-
-ADVANCED
-
-gpioGetPWMrealRange Get underlying PWM range for a GPIO
-
+gpioSetAlertFunc Request a GPIO level change callback
gpioSetAlertFuncEx Request a GPIO change callback, extended
-gpioSetISRFunc Request a GPIO interrupt callback
-gpioSetISRFuncEx Request a GPIO interrupt callback, extended
-
-gpioSetSignalFunc Request a signal callback
-gpioSetSignalFuncEx Request a signal callback, extended
+gpioSetTimerFunc Request a regular timed callback
+gpioSetTimerFuncEx Request a regular timed callback, extended
-gpioSetGetSamplesFunc Requests a GPIO samples callback
-gpioSetGetSamplesFuncEx Requests a GPIO samples callback, extended
+gpioStartThread Start a new thread
+gpioStopThread Stop a previously started thread
-gpioSetTimerFuncEx Request a regular timed callback, extended
+ADVANCED
gpioNotifyOpen Request a notification handle
-gpioNotifyOpenWithSize Request a notification handle with sized pipe
+gpioNotifyClose Close a notification
+gpioNotifyOpenWithSize Request a notification with sized pipe
gpioNotifyBegin Start notifications for selected GPIO
gpioNotifyPause Pause notifications
-gpioNotifyClose Close a notification
-
-gpioSerialReadOpen Opens a GPIO for bit bang serial reads
-gpioSerialReadInvert Configures normal/inverted for serial reads
-gpioSerialRead Reads bit bang serial data from a GPIO
-gpioSerialReadClose Closes a GPIO for bit bang serial reads
gpioHardwareClock Start hardware clock on supported GPIO
+
gpioHardwarePWM Start hardware PWM on supported GPIO
gpioGlitchFilter Set a glitch filter on a GPIO
gpioNoiseFilter Set a noise filter on a GPIO
-gpioGetPad Gets a pads drive strength
gpioSetPad Sets a pads drive strength
+gpioGetPad Gets a pads drive strength
shell Executes a shell command
-SCRIPTS
-
-gpioStoreScript Store a script
-gpioRunScript Run a stored script
-gpioUpdateScript Set a scripts parameters
-gpioScriptStatus Get script status and parameters
-gpioStopScript Stop a running script
-gpioDeleteScript Delete a stored script
-
-WAVES
-
-gpioWaveClear Deletes all waveforms
+gpioSetISRFunc Request a GPIO interrupt callback
+gpioSetISRFuncEx Request a GPIO interrupt callback, extended
-gpioWaveAddNew Starts a new waveform
-gpioWaveAddGeneric Adds a series of pulses to the waveform
-gpioWaveAddSerial Adds serial data to the waveform
+gpioSetSignalFunc Request a signal callback
+gpioSetSignalFuncEx Request a signal callback, extended
-gpioWaveCreate Creates a waveform from added data
-gpioWaveDelete Deletes a waveform
+gpioSetGetSamplesFunc Requests a GPIO samples callback
+gpioSetGetSamplesFuncEx Requests a GPIO samples callback, extended
-gpioWaveTxSend Transmits a waveform
+Custom
-gpioWaveChain Transmits a chain of waveforms
+gpioCustom1 User custom function 1
+gpioCustom2 User custom function 2
-gpioWaveTxAt Returns the current transmitting waveform
+Events
-gpioWaveTxBusy Checks to see if the waveform has ended
-gpioWaveTxStop Aborts the current waveform
+eventMonitor Sets the events to monitor
+eventSetFunc Request an event callback
+eventSetFuncEx Request an event callback, extended
-gpioWaveGetMicros Length in microseconds of the current waveform
-gpioWaveGetHighMicros Length of longest waveform so far
-gpioWaveGetMaxMicros Absolute maximum allowed micros
+eventTrigger Trigger an event
-gpioWaveGetPulses Length in pulses of the current waveform
-gpioWaveGetHighPulses Length of longest waveform so far
-gpioWaveGetMaxPulses Absolute maximum allowed pulses
+Scripts
-gpioWaveGetCbs Length in control blocks of the current waveform
-gpioWaveGetHighCbs Length of longest waveform so far
-gpioWaveGetMaxCbs Absolute maximum allowed control blocks
+gpioStoreScript Store a script
+gpioRunScript Run a stored script
+gpioUpdateScript Set a scripts parameters
+gpioScriptStatus Get script status and parameters
+gpioStopScript Stop a running script
+gpioDeleteScript Delete a stored script
I2C
@@ -250,45 +234,40 @@ i2cOpen Opens an I2C device
i2cClose Closes an I2C device
i2cWriteQuick SMBus write quick
-i2cWriteByte SMBus write byte
+
i2cReadByte SMBus read byte
-i2cWriteByteData SMBus write byte data
-i2cWriteWordData SMBus write word data
+i2cWriteByte SMBus write byte
+
i2cReadByteData SMBus read byte data
+i2cWriteByteData SMBus write byte data
+
i2cReadWordData SMBus read word data
-i2cProcessCall SMBus process call
-i2cWriteBlockData SMBus write block data
+i2cWriteWordData SMBus write word data
+
i2cReadBlockData SMBus read block data
-i2cBlockProcessCall SMBus block process call
+i2cWriteBlockData SMBus write block data
-i2cWriteI2CBlockData SMBus write I2C block data
i2cReadI2CBlockData SMBus read I2C block data
+i2cWriteI2CBlockData SMBus write I2C block data
i2cReadDevice Reads the raw I2C device
i2cWriteDevice Writes the raw I2C device
+i2cProcessCall SMBus process call
+i2cBlockProcessCall SMBus block process call
+
i2cSwitchCombined Sets or clears the combined flag
i2cSegments Performs multiple I2C transactions
i2cZip Performs multiple I2C transactions
+I2C_BIT_BANG
+
bbI2COpen Opens GPIO for bit banging I2C
bbI2CClose Closes GPIO for bit banging I2C
-bbI2CZip Performs multiple bit banged I2C transactions
-
-SPI
-
-spiOpen Opens a SPI device
-spiClose Closes a SPI device
-spiRead Reads bytes from a SPI device
-spiWrite Writes bytes to a SPI device
-spiXfer Transfers bytes with a SPI device
-
-bbSPIOpen Opens GPIO for bit banging SPI
-bbSPIClose Closes GPIO for bit banging SPI
-bbSPIXfer Performs multiple bit banged SPI transactions
+bbI2CZip Performs bit banged I2C transactions
I2C/SPI_SLAVE
@@ -301,50 +280,87 @@ serClose Closes a serial device
serReadByte Reads a byte from a serial device
serWriteByte Writes a byte to a serial device
+
serRead Reads bytes from a serial device
serWrite Writes bytes to a serial device
serDataAvailable Returns number of bytes ready to be read
+SERIAL_BIT_BANG_(read_only)
+
+gpioSerialReadOpen Opens a GPIO for bit bang serial reads
+gpioSerialReadClose Closes a GPIO for bit bang serial reads
+
+gpioSerialReadInvert Configures normal/inverted for serial reads
+
+gpioSerialRead Reads bit bang serial data from a GPIO
+
+SPI
+
+spiOpen Opens a SPI device
+spiClose Closes a SPI device
+
+spiRead Reads bytes from a SPI device
+spiWrite Writes bytes to a SPI device
+spiXfer Transfers bytes with a SPI device
+
+SPI_BIT_BANG
+
+bbSPIOpen Opens GPIO for bit banging SPI
+bbSPIClose Closes GPIO for bit banging SPI
+
+bbSPIXfer Performs bit banged SPI transactions
+
FILES
fileOpen Opens a file
fileClose Closes a file
+
fileRead Reads bytes from a file
fileWrite Writes bytes to a file
+
fileSeek Seeks to a position within a file
+
fileList List files which match a pattern
-EVENTS
+WAVES
-eventMonitor Sets the events to monitor
-eventSetFunc Request an event callback
-eventSetFuncEx Request an event callback, extended
-eventTrigger Trigger an event
+gpioWaveClear Deletes all waveforms
-CONFIGURATION
+gpioWaveAddNew Starts a new waveform
+gpioWaveAddGeneric Adds a series of pulses to the waveform
+gpioWaveAddSerial Adds serial data to the waveform
-gpioCfgBufferSize Configure the GPIO sample buffer size
-gpioCfgClock Configure the GPIO sample rate
-gpioCfgDMAchannel Configure the DMA channel (DEPRECATED)
-gpioCfgDMAchannels Configure the DMA channels
-gpioCfgPermissions Configure the GPIO access permissions
-gpioCfgInterfaces Configure user interfaces
-gpioCfgSocketPort Configure socket port
-gpioCfgMemAlloc Configure DMA memory allocation mode
-gpioCfgNetAddr Configure allowed network addresses
+gpioWaveCreate Creates a waveform from added data
+gpioWaveCreatePad Creates a waveform of fixed size from added data
+gpioWaveDelete Deletes a waveform
-gpioCfgInternals Configure miscellaneous internals (DEPRECATED)
-gpioCfgGetInternals Get internal configuration settings
-gpioCfgSetInternals Set internal configuration settings
+gpioWaveTxSend Transmits a waveform
-CUSTOM
+gpioWaveChain Transmits a chain of waveforms
-gpioCustom1 User custom function 1
-gpioCustom2 User custom function 2
+gpioWaveTxAt Returns the current transmitting waveform
+
+gpioWaveTxBusy Checks to see if the waveform has ended
+
+gpioWaveTxStop Aborts the current waveform
+
+gpioWaveGetCbs Length in CBs of the current waveform
+gpioWaveGetHighCbs Length of longest waveform so far
+gpioWaveGetMaxCbs Absolute maximum allowed CBs
+
+gpioWaveGetMicros Length in micros of the current waveform
+gpioWaveGetHighMicros Length of longest waveform so far
+gpioWaveGetMaxMicros Absolute maximum allowed micros
+
+gpioWaveGetPulses Length in pulses of the current waveform
+gpioWaveGetHighPulses Length of longest waveform so far
+gpioWaveGetMaxPulses Absolute maximum allowed pulses
UTILITIES
+gpioDelay Delay for a number of microseconds
+
gpioTick Get current tick (microseconds)
gpioHardwareRevision Get hardware revision
@@ -359,6 +375,21 @@ gpioSleep Sleep for specified time
time_sleep Sleeps for a float number of seconds
time_time Float number of seconds since the epoch
+CONFIGURATION
+
+gpioCfgBufferSize Configure the GPIO sample buffer size
+gpioCfgClock Configure the GPIO sample rate
+gpioCfgDMAchannel Configure the DMA channel (DEPRECATED)
+gpioCfgDMAchannels Configure the DMA channels
+gpioCfgPermissions Configure the GPIO access permissions
+gpioCfgInterfaces Configure user interfaces
+gpioCfgSocketPort Configure socket port
+gpioCfgMemAlloc Configure DMA memory allocation mode
+gpioCfgNetAddr Configure allowed network addresses
+
+gpioCfgGetInternals Get internal configuration settings
+gpioCfgSetInternals Set internal configuration settings
+
EXPERT
rawWaveAddSPI Not intended for general use
@@ -611,13 +642,16 @@ typedef void *(gpioThreadFunc_t) (void *);
/* hardware PWM */
#define PI_HW_PWM_MIN_FREQ 1
-#define PI_HW_PWM_MAX_FREQ 125000000
+#define PI_HW_PWM_MAX_FREQ 125000000
+#define PI_HW_PWM_MAX_FREQ_2711 187500000
#define PI_HW_PWM_RANGE 1000000
/* hardware clock */
-#define PI_HW_CLK_MIN_FREQ 4689
-#define PI_HW_CLK_MAX_FREQ 250000000
+#define PI_HW_CLK_MIN_FREQ 4689
+#define PI_HW_CLK_MIN_FREQ_2711 13184
+#define PI_HW_CLK_MAX_FREQ 250000000
+#define PI_HW_CLK_MAX_FREQ_2711 375000000
#define PI_NOTIFY_SLOTS 32
@@ -678,7 +712,7 @@ typedef void *(gpioThreadFunc_t) (void *);
/* Files, I2C, SPI, SER */
#define PI_FILE_SLOTS 16
-#define PI_I2C_SLOTS 64
+#define PI_I2C_SLOTS 512
#define PI_SPI_SLOTS 32
#define PI_SER_SLOTS 16
@@ -773,6 +807,11 @@ typedef void *(gpioThreadFunc_t) (void *);
#define BSC_MISO 20
#define BSC_CE_N 21
+#define BSC_SDA_MOSI_2711 10
+#define BSC_SCL_SCLK_2711 11
+#define BSC_MISO_2711 9
+#define BSC_CE_N_2711 8
+
/* Longest busy delay */
#define PI_MAX_BUSY_DELAY 100
@@ -831,10 +870,10 @@ typedef void *(gpioThreadFunc_t) (void *);
#define PI_CLOCK_PWM 0
#define PI_CLOCK_PCM 1
-/* DMA channel: 0-14 */
+/* DMA channel: 0-15, 15 is unset */
#define PI_MIN_DMA_CHANNEL 0
-#define PI_MAX_DMA_CHANNEL 14
+#define PI_MAX_DMA_CHANNEL 15
/* port */
@@ -1415,6 +1454,12 @@ once per level change since the last time the thread was activated.
i.e. The active alert functions will get all level changes but there
will be a latency.
+If you want to track the level of more than one GPIO do so by
+maintaining the state in the callback. Do not use [*gpioRead*].
+Remember the event that triggered the callback may have
+happened several milliseconds before and the GPIO may have
+changed level many times since then.
+
The tick value is the time stamp of the sample in microseconds, see
[*gpioTick*] for more details.
@@ -1953,6 +1998,49 @@ D*/
/*F*/
+int gpioWaveCreatePad(int pctCB, int pctBOOL, int pctTOOL);
+/*D
+Similar to [*gpioWaveCreate*], this function creates a waveform but pads the consumed
+resources. Padded waves of equal dimension can be re-cycled efficiently allowing
+newly created waves to re-use the resources of deleted waves of the same dimension.
+
+. .
+pctCB: 0-100, the percent of all DMA control blocks to consume.
+pctBOOL: 0-100, percent On-Off-Level (OOL) buffer to consume for wave output.
+pctTOOL: 0-100, the percent of OOL buffer to consume for wave input (flags).
+. .
+
+Upon success a wave id greater than or equal to 0 is returned, otherwise
+PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
+
+Waveform data provided by [*gpioWaveAdd**] and [*rawWaveAdd**] functions are
+consumed by this function.
+
+A usage would be the creation of two waves where one is filled while the other
+is being transmitted. Each wave is assigned 50% of the resources.
+This buffer structure allows the transmission of infinite wave sequences.
+
+...
+ // get firstWaveChunk, somehow
+ gpioWaveAddGeneric(firstWaveChunk);
+ wid = gpioWaveCreatePad(50, 50, 0);
+ gpioWaveTxSend(wid, PI_WAVE_MODE_ONE_SHOT);
+ // get nextWaveChunk
+
+ while (nextWaveChunk) {
+ gpioWaveAddGeneric(nextWaveChunk);
+ nextWid = gpioWaveCreatePad(50, 50, 0);
+ gpioWaveTxSend(nextWid, PI_WAVE_MODE_ONE_SHOT_SYNC);
+ while(gpioWaveTxAt() == wid) time_sleep(0.1);
+ gpioWaveDelete(wid);
+ wid = nextWid;
+ // get nextWaveChunk
+ }
+...
+
+D*/
+
+/*F*/
int gpioWaveDelete(unsigned wave_id);
/*D
This function deletes the waveform with id wave_id.
@@ -2102,7 +2190,7 @@ D*/
int gpioWaveTxAt(void);
/*D
This function returns the id of the waveform currently being
-transmitted.
+transmitted using [*gpioWaveTxSend*]. Chained waves are not supported.
Returns the waveform id or one of the following special values:
@@ -2876,9 +2964,18 @@ D*/
/*F*/
int bscXfer(bsc_xfer_t *bsc_xfer);
/*D
-This function provides a low-level interface to the
-SPI/I2C Slave peripheral. This peripheral allows the
-Pi to act as a slave device on an I2C or SPI bus.
+This function provides a low-level interface to the SPI/I2C Slave
+peripheral on the BCM chip.
+
+This peripheral allows the Pi to act as a hardware slave device
+on an I2C or SPI bus.
+
+This is not a bit bang version and as such is OS timing
+independent. The bus timing is handled directly by the chip.
+
+The output process is simple. You simply append data to the FIFO
+buffer on the chip. This works like a queue, you add data to the
+queue and the master removes it.
I can't get SPI to work properly. I tried with a
control word of 0x303 and swapped MISO and MOSI.
@@ -2901,8 +2998,9 @@ typedef struct
} bsc_xfer_t;
. .
-To start a transfer set control (see below) and copy the bytes to
-be sent (if any) to txBuf and set the byte count in txCnt.
+To start a transfer set control (see below), copy the bytes to
+be added to the transmit FIFO (if any) to txBuf and set txCnt to
+the number of copied bytes.
Upon return rxCnt will be set to the number of received bytes placed
in rxBuf.
@@ -2910,11 +3008,19 @@ in rxBuf.
Note that the control word sets the BSC mode. The BSC will stay in
that mode until a different control word is sent.
-The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
-and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
-need to swap MISO/MOSI between master and slave.
+GPIO used for models other than those based on the BCM2711.
+
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+I2C @ 18 @ 19 @ - @ - @ - @ -
+SPI @ - @ - @ 18 @ 19 @ 20 @ 21
+
+GPIO used for models based on the BCM2711 (e.g. the Pi4B).
-When a zero control word is received GPIO 18-21 will be reset
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+I2C @ 10 @ 11 @ - @ - @ - @ -
+SPI @ - @ - @ 10 @ 11 @ 9 @ 8
+
+When a zero control word is received the used GPIO will be reset
to INPUT mode.
The returned function value is the status of the transfer (see below).
@@ -3980,7 +4086,7 @@ Frequencies above 30MHz are unlikely to work.
. .
gpio: see description
-clkfreq: 0 (off) or 4689-250000000 (250M)
+clkfreq: 0 (off) or 4689-250M (13184-375M for the BCM2711)
. .
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HCLK_GPIO,
@@ -4025,7 +4131,7 @@ main clock defaults to PCM but may be overridden by a call to
. .
gpio: see description
-PWMfreq: 0 (off) or 1-125000000 (125M)
+PWMfreq: 0 (off) or 1-125M (1-187.5M for the BCM2711)
PWMduty: 0 (off) to 1000000 (1M)(fully on)
. .
@@ -4052,12 +4158,12 @@ The GPIO must be one of the following.
. .
The actual number of steps beween off and fully on is the
-integral part of 250 million divided by PWMfreq.
+integral part of 250M/PWMfreq (375M/PWMfreq for the BCM2711).
-The actual frequency set is 250 million / steps.
+The actual frequency set is 250M/steps (375M/steps for the BCM2711).
-There will only be a million steps for a PWMfreq of 250.
-Lower frequencies will have more steps and higher
+There will only be a million steps for a PWMfreq of 250 (375 for
+the BCM2711). Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
D*/
@@ -4745,8 +4851,7 @@ D*/
/*F*/
-int gpioCfgDMAchannels(
- unsigned primaryChannel, unsigned secondaryChannel);
+int gpioCfgDMAchannels(unsigned primaryChannel, unsigned secondaryChannel);
/*D
Configures pigpio to use the specified DMA channels.
@@ -4757,8 +4862,14 @@ This function is only effective if called before [*gpioInitialise*].
secondaryChannel: 0-14
. .
-The default setting is to use channel 14 for the primary channel and
-channel 6 for the secondary channel.
+The default setting depends on whether the Pi has a BCM2711 chip or
+not (currently only the Pi4B has a BCM2711).
+
+The default setting for a non-BCM2711 is to use channel 14 for the
+primary channel and channel 6 for the secondary channel.
+
+The default setting for a BCM2711 is to use channel 7 for the
+primary channel and channel 6 for the secondary channel.
The secondary channel is only used for the transmission of waves.
@@ -4874,18 +4985,6 @@ D*/
/*F*/
-int gpioCfgInternals(unsigned cfgWhat, unsigned cfgVal);
-/*D
-Used to tune internal settings.
-
-. .
-cfgWhat: see source code
- cfgVal: see source code
-. .
-D*/
-
-
-/*F*/
uint32_t gpioCfgGetInternals(void);
/*D
This function returns the current library internal configuration
@@ -4901,6 +5000,7 @@ settings.
. .
cfgVal: see source code
. .
+
D*/
@@ -5305,13 +5405,14 @@ char::
A single character, an 8 bit quantity able to store 0-255.
-clkfreq::4689-250M
+clkfreq::4689-250M (13184-375M for the BCM2711)
The hardware clock frequency.
. .
PI_HW_CLK_MIN_FREQ 4689
PI_HW_CLK_MAX_FREQ 250000000
+PI_HW_CLK_MAX_FREQ_2711 375000000
. .
count::
@@ -5331,10 +5432,10 @@ PI_MIN_WAVE_DATABITS 1
PI_MAX_WAVE_DATABITS 32
. .
-DMAchannel::0-14
+DMAchannel::0-15
. .
PI_MIN_DMA_CHANNEL 0
-PI_MAX_DMA_CHANNEL 14
+PI_MAX_DMA_CHANNEL 15
. .
double::
@@ -5701,6 +5802,15 @@ high and low levels.
*param::
An array of script parameters.
+pctBOOL:: 0-100
+percent On-Off-Level (OOL) buffer to consume for wave output.
+
+pctCB:: 0-100
+the percent of all DMA control blocks to consume.
+
+pctTOOL:: 0-100
+the percent of OOL buffer to consume for wave input (flags).
+
pi_i2c_msg_t::
. .
typedef struct
@@ -5718,7 +5828,7 @@ The port used to bind to the pigpio socket. Defaults to 8888.
pos::
The position of an item.
-primaryChannel:: 0-14
+primaryChannel:: 0-15
The DMA channel used to time the sampling of GPIO and to time servo and
PWM pulses.
@@ -5763,12 +5873,13 @@ The hardware PWM dutycycle.
PI_HW_PWM_RANGE 1000000
. .
-PWMfreq::5-250K
+PWMfreq::1-125M (1-187.5M for the BCM2711)
The hardware PWM frequency.
. .
PI_HW_PWM_MIN_FREQ 1
PI_HW_PWM_MAX_FREQ 125000000
+PI_HW_PWM_MAX_FREQ_2711 187500000
. .
range::25-40000
@@ -6211,6 +6322,7 @@ PARAMS*/
#define PI_CMD_EVT 116
#define PI_CMD_PROCU 117
+#define PI_CMD_WVCAP 118
/*DEF_E*/
@@ -6301,11 +6413,11 @@ after this command is issued.
#define PI_NO_HANDLE -24 // no handle available
#define PI_BAD_HANDLE -25 // unknown handle
#define PI_BAD_IF_FLAGS -26 // ifFlags > 4
-#define PI_BAD_CHANNEL -27 // DMA channel not 0-14
-#define PI_BAD_PRIM_CHANNEL -27 // DMA primary channel not 0-14
+#define PI_BAD_CHANNEL -27 // DMA channel not 0-15
+#define PI_BAD_PRIM_CHANNEL -27 // DMA primary channel not 0-15
#define PI_BAD_SOCKET_PORT -28 // socket port not 1024-32000
#define PI_BAD_FIFO_COMMAND -29 // unrecognized fifo command
-#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-6
+#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-15
#define PI_NOT_INITIALISED -31 // function called before gpioInitialise
#define PI_INITIALISED -32 // function called after gpioInitialise
#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3
@@ -6372,9 +6484,9 @@ after this command is issued.
#define PI_NOT_SERVO_GPIO -93 // GPIO is not in use for servo pulses
#define PI_NOT_HCLK_GPIO -94 // GPIO has no hardware clock
#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM
-#define PI_BAD_HPWM_FREQ -96 // hardware PWM frequency not 1-125M
+#define PI_BAD_HPWM_FREQ -96 // invalid hardware PWM frequency
#define PI_BAD_HPWM_DUTY -97 // hardware PWM dutycycle not 0-1M
-#define PI_BAD_HCLK_FREQ -98 // hardware clock frequency not 4689-250M
+#define PI_BAD_HCLK_FREQ -98 // invalid hardware clock frequency
#define PI_BAD_HCLK_PASS -99 // need password to use hardware clock 1
#define PI_HPWM_ILLEGAL -100 // illegal, PWM in use for main clock
#define PI_BAD_DATABITS -101 // serial data bits not 1-32
@@ -6421,6 +6533,8 @@ after this command is issued.
#define PI_NOT_SPI_GPIO -142 // no bit bang SPI in progress on GPIO
#define PI_BAD_EVENT_ID -143 // bad event id
#define PI_CMD_INTERRUPTED -144 // Used by Python
+#define PI_NOT_ON_BCM2711 -145 // not available on BCM2711
+#define PI_ONLY_ON_BCM2711 -146 // only available on BCM2711
#define PI_PIGIF_ERR_0 -2000
#define PI_PIGIF_ERR_99 -2099
@@ -6440,9 +6554,12 @@ after this command is issued.
#define PI_DEFAULT_DMA_CHANNEL 14
#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
+#define PI_DEFAULT_DMA_PRIMARY_CH_2711 7
+#define PI_DEFAULT_DMA_SECONDARY_CH_2711 6
+#define PI_DEFAULT_DMA_NOT_SET 15
#define PI_DEFAULT_SOCKET_PORT 8888
#define PI_DEFAULT_SOCKET_PORT_STR "8888"
-#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
+#define PI_DEFAULT_SOCKET_ADDR_STR "localhost"
#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0x0000000FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93
#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C
@@ -6450,6 +6567,7 @@ after this command is issued.
#define PI_DEFAULT_UPDATE_MASK_ZERO 0x0080000FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_PI2B 0x0080480FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_PI3B 0x0000000FFFFFFCLL
+#define PI_DEFAULT_UPDATE_MASK_PI4B 0x0000000FFFFFFCLL
#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
diff --git a/pigpio.py b/pigpio.py
index ae7be89..edb6734 100644
--- a/pigpio.py
+++ b/pigpio.py
@@ -95,41 +95,45 @@ the pigpio.pi class.
OVERVIEW
-Essential
+ESSENTIAL
pigpio.pi Initialise Pi connection
stop Stop a Pi connection
-Beginner
+BASIC
set_mode Set a GPIO mode
get_mode Get a GPIO mode
+
set_pull_up_down Set/clear GPIO pull up/down resistor
read Read a GPIO
write Write a GPIO
+PWM_(overrides_servo_commands_on_same_GPIO)
+
set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+set_PWM_frequency Set PWM frequency of a GPIO
+set_PWM_range Configure PWM range of a GPIO
+
get_PWM_dutycycle Get PWM dutycycle set on a GPIO
+get_PWM_frequency Get PWM frequency of a GPIO
+get_PWM_range Get configured PWM range of a GPIO
+
+get_PWM_real_range Get underlying PWM range for a GPIO
+
+Servo_(overrides_PWM_commands_on_same_GPIO)
set_servo_pulsewidth Start/Stop servo pulses on a GPIO
-get_servo_pulsewidth Get servo pulsewidth set on a GPIO
-callback Create GPIO level change callback
-wait_for_edge Wait for GPIO level change
+get_servo_pulsewidth Get servo pulsewidth set on a GPIO
-Intermediate
+INTERMEDIATE
gpio_trigger Send a trigger pulse to a GPIO
set_watchdog Set a watchdog on a GPIO
-set_PWM_range Configure PWM range of a GPIO
-get_PWM_range Get configured PWM range of a GPIO
-
-set_PWM_frequency Set PWM frequency of a GPIO
-get_PWM_frequency Get PWM frequency of a GPIO
-
read_bank_1 Read all bank 1 GPIO
read_bank_2 Read all bank 2 GPIO
@@ -139,31 +143,42 @@ clear_bank_2 Clear selected GPIO in bank 2
set_bank_1 Set selected GPIO in bank 1
set_bank_2 Set selected GPIO in bank 2
-Advanced
+callback Create GPIO level change callback
-get_PWM_real_range Get underlying PWM range for a GPIO
+wait_for_edge Wait for GPIO level change
+
+ADVANCED
notify_open Request a notification handle
notify_begin Start notifications for selected GPIO
notify_pause Pause notifications
notify_close Close a notification
-bb_serial_read_open Open a GPIO for bit bang serial reads
-bb_serial_read Read bit bang serial data from a GPIO
-bb_serial_read_close Close a GPIO for bit bang serial reads
-bb_serial_invert Invert serial logic (1 invert, 0 normal)
-
hardware_clock Start hardware clock on supported GPIO
+
hardware_PWM Start hardware PWM on supported GPIO
set_glitch_filter Set a glitch filter on a GPIO
set_noise_filter Set a noise filter on a GPIO
-get_pad_strength Gets a pads drive strength
set_pad_strength Sets a pads drive strength
+get_pad_strength Gets a pads drive strength
shell Executes a shell command
+Custom
+
+custom_1 User custom function 1
+custom_2 User custom function 2
+
+Events
+
+event_callback Sets a callback for an event
+
+event_trigger Triggers an event
+
+wait_for_event Wait for an event
+
Scripts
store_script Store a script
@@ -173,50 +188,24 @@ script_status Get script status and parameters
stop_script Stop a running script
delete_script Delete a stored script
-Waves
-
-wave_clear Deletes all waveforms
-
-wave_add_new Starts a new waveform
-wave_add_generic Adds a series of pulses to the waveform
-wave_add_serial Adds serial data to the waveform
-
-wave_create Creates a waveform from added data
-wave_delete Deletes a waveform
-
-wave_send_once Transmits a waveform once
-wave_send_repeat Transmits a waveform repeatedly
-wave_send_using_mode Transmits a waveform in the chosen mode
-
-wave_chain Transmits a chain of waveforms
-
-wave_tx_at Returns the current transmitting waveform
-wave_tx_busy Checks to see if a waveform has ended
-wave_tx_stop Aborts the current waveform
-
-wave_get_micros Length in microseconds of the current waveform
-wave_get_max_micros Absolute maximum allowed micros
-wave_get_pulses Length in pulses of the current waveform
-wave_get_max_pulses Absolute maximum allowed pulses
-wave_get_cbs Length in cbs of the current waveform
-wave_get_max_cbs Absolute maximum allowed cbs
-
I2C
i2c_open Opens an I2C device
i2c_close Closes an I2C device
i2c_write_quick SMBus write quick
-i2c_write_byte SMBus write byte
+
i2c_read_byte SMBus read byte
-i2c_write_byte_data SMBus write byte data
-i2c_write_word_data SMBus write word data
+i2c_write_byte SMBus write byte
+
i2c_read_byte_data SMBus read byte data
+i2c_write_byte_data SMBus write byte data
+
i2c_read_word_data SMBus read word data
-i2c_process_call SMBus process call
-i2c_write_block_data SMBus write block data
+i2c_write_word_data SMBus write word data
+
i2c_read_block_data SMBus read block data
-i2c_block_process_call SMBus block process call
+i2c_write_block_data SMBus write block data
i2c_read_i2c_block_data SMBus read I2C block data
i2c_write_i2c_block_data SMBus write I2C block data
@@ -224,64 +213,106 @@ i2c_write_i2c_block_data SMBus write I2C block data
i2c_read_device Reads the raw I2C device
i2c_write_device Writes the raw I2C device
+i2c_process_call SMBus process call
+i2c_block_process_call SMBus block process call
+
i2c_zip Performs multiple I2C transactions
+I2C_BIT_BANG
+
bb_i2c_open Opens GPIO for bit banging I2C
bb_i2c_close Closes GPIO for bit banging I2C
-bb_i2c_zip Performs multiple bit banged I2C transactions
-SPI
-
-spi_open Opens a SPI device
-spi_close Closes a SPI device
-
-spi_read Reads bytes from a SPI device
-spi_write Writes bytes to a SPI device
-spi_xfer Transfers bytes with a SPI device
-
-bb_spi_open Opens GPIO for bit banging SPI
-bb_spi_close Closes GPIO for bit banging SPI
-bb_spi_xfer Transfers bytes with bit banging SPI
+bb_i2c_zip Performs multiple bit banged I2C transactions
-I2C/SPI_Slave
+I2C/SPI_SLAVE
bsc_xfer I2C/SPI as slave transfer
bsc_i2c I2C as slave transfer
-Serial
+SERIAL
serial_open Opens a serial device
serial_close Closes a serial device
-serial_read Reads bytes from a serial device
serial_read_byte Reads a byte from a serial device
+serial_write_byte Writes a byte to a serial device
+serial_read Reads bytes from a serial device
serial_write Writes bytes to a serial device
-serial_write_byte Writes a byte to a serial device
serial_data_available Returns number of bytes ready to be read
-Files
+SERIAL_BIT_BANG_(read_only)
+
+bb_serial_read_open Open a GPIO for bit bang serial reads
+bb_serial_read_close Close a GPIO for bit bang serial reads
+
+bb_serial_invert Invert serial logic (1 invert, 0 normal)
+
+bb_serial_read Read bit bang serial data from a GPIO
+
+SPI
+
+spi_open Opens a SPI device
+spi_close Closes a SPI device
+
+spi_read Reads bytes from a SPI device
+spi_write Writes bytes to a SPI device
+spi_xfer Transfers bytes with a SPI device
+
+SPI_BIT_BANG
+
+bb_spi_open Opens GPIO for bit banging SPI
+bb_spi_close Closes GPIO for bit banging SPI
+bb_spi_xfer Transfers bytes with bit banging SPI
+
+FILES
file_open Opens a file
file_close Closes a file
+
file_read Reads bytes from a file
file_write Writes bytes to a file
+
file_seek Seeks to a position within a file
+
file_list List files which match a pattern
-Events
+WAVES
-event_callback Sets a callback for an event
-event_trigger Triggers an event
-wait_for_event Wait for an event
+wave_clear Deletes all waveforms
-Custom
+wave_add_new Starts a new waveform
+wave_add_generic Adds a series of pulses to the waveform
+wave_add_serial Adds serial data to the waveform
-custom_1 User custom function 1
-custom_2 User custom function 2
+wave_create Creates a waveform from added data
+wave_create_and_pad Creates a waveform of fixed size from added data
+wave_delete Deletes a waveform
-Utility
+wave_send_once Transmits a waveform once
+wave_send_repeat Transmits a waveform repeatedly
+wave_send_using_mode Transmits a waveform in the chosen mode
+
+wave_chain Transmits a chain of waveforms
+
+wave_tx_at Returns the current transmitting waveform
+
+wave_tx_busy Checks to see if a waveform has ended
+
+wave_tx_stop Aborts the current waveform
+
+wave_get_cbs Length in cbs of the current waveform
+wave_get_max_cbs Absolute maximum allowed cbs
+
+wave_get_micros Length in microseconds of the current waveform
+wave_get_max_micros Absolute maximum allowed micros
+
+wave_get_pulses Length in pulses of the current waveform
+wave_get_max_pulses Absolute maximum allowed pulses
+
+UTILITIES
get_current_tick Get current tick (microseconds)
@@ -300,7 +331,7 @@ import threading
import os
import atexit
-VERSION = "1.42"
+VERSION = "1.78" # sync minor number to pigpio library version
exceptions = True
@@ -541,6 +572,7 @@ _PI_CMD_EVM =115
_PI_CMD_EVT =116
_PI_CMD_PROCU=117
+_PI_CMD_WVCAP=118
# pigpio error numbers
@@ -689,6 +721,8 @@ PI_BAD_SPI_BAUD =-141
PI_NOT_SPI_GPIO =-142
PI_BAD_EVENT_ID =-143
PI_CMD_INTERRUPTED =-144
+PI_NOT_ON_BCM2711 =-145
+PI_ONLY_ON_BCM2711 =-146
# pigpio error text
@@ -786,9 +820,9 @@ _errors=[
[PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"],
[PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"],
[PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"],
- [PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"],
+ [PI_BAD_HPWM_FREQ , "invalid hardware PWM frequency"],
[PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"],
- [PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"],
+ [PI_BAD_HCLK_FREQ , "invalid hardware clock frequency"],
[PI_BAD_HCLK_PASS , "need password to use hardware clock 1"],
[PI_HPWM_ILLEGAL , "illegal, PWM in use for main clock"],
[PI_BAD_DATABITS , "serial data bits not 1-32"],
@@ -835,6 +869,8 @@ _errors=[
[PI_NOT_SPI_GPIO , "no bit bang SPI in progress on GPIO"],
[PI_BAD_EVENT_ID , "bad event id"],
[PI_CMD_INTERRUPTED , "pigpio command interrupted"],
+ [PI_NOT_ON_BCM2711 , "not available on BCM2711"],
+ [PI_ONLY_ON_BCM2711 , "only available on BCM2711"],
]
_except_a = "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n{}"
@@ -1905,7 +1941,7 @@ class pi():
Frequencies above 30MHz are unlikely to work.
gpio:= see description
- clkfreq:= 0 (off) or 4689-250000000 (250M)
+ clkfreq:= 0 (off) or 4689-250M (13184-375M for the BCM2711)
Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
@@ -1955,7 +1991,7 @@ class pi():
pigpio daemon is started (option -t).
gpio:= see descripton
- PWMfreq:= 0 (off) or 1-125000000 (125M).
+ PWMfreq:= 0 (off) or 1-125M (1-187.5M for the BCM2711).
PWMduty:= 0 (off) to 1000000 (1M)(fully on).
Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
@@ -1981,14 +2017,15 @@ class pi():
. .
The actual number of steps beween off and fully on is the
- integral part of 250 million divided by PWMfreq.
+ integral part of 250M/PWMfreq (375M/PWMfreq for the BCM2711).
- The actual frequency set is 250 million / steps.
+ The actual frequency set is 250M/steps (375M/steps
+ for the BCM2711).
- There will only be a million steps for a PWMfreq of 250.
- Lower frequencies will have more steps and higher
- frequencies will have fewer steps. PWMduty is
- automatically scaled to take this into account.
+ There will only be a million steps for a PWMfreq of 250
+ (375 for the BCM2711). Lower frequencies will have more
+ steps and higher frequencies will have fewer steps.
+ PWMduty is automatically scaled to take this into account.
...
pi.hardware_PWM(18, 800, 250000) # 800Hz 25% dutycycle
@@ -2269,6 +2306,51 @@ class pi():
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_WVCRE, 0, 0))
+ def wave_create_and_pad(self, percent):
+ """
+ This function creates a waveform like [*wave_create*] but pads the consumed
+ resources. Where percent gives the percentage of the resources to use
+ (in terms of the theoretical maximum, not the current amount free).
+ This allows the reuse of deleted waves while a transmission is active.
+
+ Upon success a wave id greater than or equal to 0 is returned, otherwise
+ PI_EMPTY_WAVEFORM, PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
+
+ . .
+ percent: 0-100, size of waveform as percentage of maximum available.
+ . .
+
+ The data provided by the [*wave_add_**] functions are consumed by this
+ function.
+
+ As many waveforms may be created as there is space available. The
+ wave id is passed to [*wave_send_**] to specify the waveform to transmit.
+
+ A usage would be the creation of two waves where one is filled while the
+ other is being transmitted. Each wave is assigned 50% of the resources.
+ This buffer structure allows the transmission of infinite wave sequences.
+
+ Normal usage:
+
+ Step 1. [*wave_clear*] to clear all waveforms and added data.
+
+ Step 2. [*wave_add_**] calls to supply the waveform data.
+
+ Step 3. [*wave_create_and_pad*] to create a waveform of uniform size.
+
+ Step 4. [*wave_send_**] with the id of the waveform to transmit.
+
+ Repeat steps 2-4 as needed.
+
+ Step 5. Any wave id can now be deleted and another wave of the same size
+ can be created in its place.
+
+ ...
+ wid = pi.wave_create_and_pad(50)
+ ...
+ """
+ return _u2i(_pigpio_command(self.sl, _PI_CMD_WVCAP, percent, 0))
+
def wave_delete(self, wave_id):
"""
This function deletes the waveform with id wave_id.
@@ -2384,7 +2466,7 @@ class pi():
def wave_tx_at(self):
"""
Returns the id of the waveform currently being
- transmitted.
+ transmitted using [*wave_send**]. Chained waves are not supported.
Returns the waveform id or one of the following special
values:
@@ -3509,14 +3591,22 @@ class pi():
def bsc_xfer(self, bsc_control, data):
"""
- This function provides a low-level interface to the
- SPI/I2C Slave peripheral. This peripheral allows the
- Pi to act as a slave device on an I2C or SPI bus.
+ This function provides a low-level interface to the SPI/I2C Slave
+ peripheral on the BCM chip.
+
+ This peripheral allows the Pi to act as a hardware slave device
+ on an I2C or SPI bus.
+
+ This is not a bit bang version and as such is OS timing
+ independent. The bus timing is handled directly by the chip.
+
+ The output process is simple. You simply append data to the FIFO
+ buffer on the chip. This works like a queue, you add data to the
+ queue and the master removes it.
I can't get SPI to work properly. I tried with a
control word of 0x303 and swapped MISO and MOSI.
-
The function sets the BSC mode, writes any data in
the transmit buffer to the BSC transmit FIFO, and
copies any data in the BSC receive FIFO to the
@@ -3533,12 +3623,19 @@ class pi():
Note that the control word sets the BSC mode. The BSC will
stay in that mode until a different control word is sent.
- The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL)
- in I2C mode and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO),
- and 21 (CE) in SPI mode. You need to swap MISO/MOSI
- between master and slave.
+ GPIO used for models other than those based on the BCM2711.
+
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+ I2C @ 18 @ 19 @ - @ - @ - @ -
+ SPI @ - @ - @ 18 @ 19 @ 20 @ 21
- When a zero control word is received GPIO 18-21 will be reset
+ GPIO used for models based on the BCM2711 (e.g. the Pi4B).
+
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+ I2C @ 10 @ 11 @ - @ - @ - @ -
+ SPI @ - @ - @ 10 @ 11 @ 9 @ 8
+
+ When a zero control word is received the used GPIO will be reset
to INPUT mode.
bsc_control consists of the following bits:
@@ -3619,6 +3716,9 @@ class pi():
"""
This function allows the Pi to act as a slave I2C device.
+ This function is not available on the BCM2711 (e.g. as
+ used in the Pi4B).
+
The data bytes (if any) are written to the BSC transmit
FIFO and the bytes in the BSC receive FIFO are returned.
@@ -3634,10 +3734,10 @@ class pi():
(and will contain the error code).
Note that an i2c_address of 0 may be used to close
- the BSC device and reassign the used GPIO (18/19)
- as inputs.
+ the BSC device and reassign the used GPIO as inputs.
- This example assumes GPIO 2/3 are connected to GPIO 18/19.
+ This example assumes GPIO 2/3 are connected to GPIO 18/19
+ (GPIO 10/11 on the BCM2711).
...
#!/usr/bin/env python
@@ -4889,6 +4989,37 @@ class pi():
A GPIO may have multiple callbacks (although I can't think of
a reason to do so).
+ The GPIO are sampled at a rate set when the pigpio daemon
+ is started (default 5 us).
+
+ The number of samples per second is given in the following table.
+
+ . .
+ samples
+ per sec
+
+ 1 1,000,000
+ 2 500,000
+ sample 4 250,000
+ rate 5 200,000
+ (us) 8 125,000
+ 10 100,000
+ . .
+
+ GPIO level changes shorter than the sample rate may be missed.
+
+ The daemon software which generates the callbacks is triggered
+ 1000 times per second. The callbacks will be called once per
+ level change since the last time they were called.
+ i.e. The callbacks will get all level changes but there will
+ be a latency.
+
+ If you want to track the level of more than one GPIO do so by
+ maintaining the state in the callback. Do not use [*read*].
+ Remember the event that triggered the callback may have
+ happened several milliseconds before and the GPIO may have
+ changed level many times since then.
+
...
def cbf(gpio, level, tick):
print(gpio, level, tick)
@@ -4924,7 +5055,7 @@ class pi():
by calling the tally function. The count may be reset to zero
by calling the reset_tally function.
- The callback may be cancelled by calling the event_cancel function.
+ The callback may be canceled by calling the cancel function.
An event may have multiple callbacks (although I can't think of
a reason to do so).
@@ -4941,7 +5072,7 @@ class pi():
cb2.reset_tally()
- cb1.event_cancel() # To cancel callback cb1.
+ cb1.cancel() # To cancel callback cb1.
...
"""
@@ -5174,7 +5305,7 @@ def xref():
byte_val: 0-255
A whole number.
- clkfreq: 4689-250M
+ clkfreq: 4689-250M (13184-375M for the BCM2711)
The hardware clock frequency.
connected:
@@ -5330,6 +5461,8 @@ def xref():
PI_NOT_SPI_GPIO = -142
PI_BAD_EVENT_ID = -143
PI_CMD_INTERRUPTED = -144
+ PI_NOT_ON_BCM2711 = -145
+ PI_ONLY_ON_BCM2711 = -146
. .
event:0-31
@@ -5496,6 +5629,9 @@ def xref():
When scripts are started they can receive up to 10 parameters
to define their operation.
+ percent:: 0-100
+ The size of waveform as percentage of maximum available.
+
port:
The port used by the pigpio daemon, defaults to 8888.
@@ -5522,7 +5658,7 @@ def xref():
PWMduty: 0-1000000 (1M)
The hardware PWM dutycycle.
- PWMfreq: 1-125000000 (125M)
+ PWMfreq: 1-125M (1-187.5M for the BCM2711)
The hardware PWM frequency.
range_: 25-40000
diff --git a/pigpiod.1 b/pigpiod.1
index 1f7d3d1..29f8326 100644
--- a/pigpiod.1
+++ b/pigpiod.1
@@ -2,7 +2,7 @@
." Process this file with
." groff -man -Tascii pigpiod.1
."
-.TH pigpiod 1 2012-2018 Linux "pigpio archive"
+.TH pigpiod 1 2012-2020 Linux "pigpio archive"
.SH NAME
pigpiod - A utility to start the pigpio library as a daemon.
diff --git a/pigpiod.c b/pigpiod.c
index ce3833a..899ddf8 100644
--- a/pigpiod.c
+++ b/pigpiod.c
@@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
-This version is for pigpio version 65+
+This version is for pigpio version 69+
*/
#include <sys/types.h>
@@ -56,8 +56,8 @@ static unsigned clockMicros = PI_DEFAULT_CLK_MICROS;
static unsigned clockPeripheral = PI_DEFAULT_CLK_PERIPHERAL;
static unsigned ifFlags = PI_DEFAULT_IF_FLAGS;
static int foreground = PI_DEFAULT_FOREGROUND;
-static unsigned DMAprimaryChannel = PI_DEFAULT_DMA_PRIMARY_CHANNEL;
-static unsigned DMAsecondaryChannel = PI_DEFAULT_DMA_SECONDARY_CHANNEL;
+static unsigned DMAprimaryChannel = PI_DEFAULT_DMA_NOT_SET;
+static unsigned DMAsecondaryChannel = PI_DEFAULT_DMA_NOT_SET;
static unsigned socketPort = PI_DEFAULT_SOCKET_PORT;
static unsigned memAllocMode = PI_DEFAULT_MEM_ALLOC_MODE;
static uint64_t updateMask = -1;
diff --git a/pigpiod_if.3 b/pigpiod_if.3
index b372d9b..0e143a6 100644
--- a/pigpiod_if.3
+++ b/pigpiod_if.3
@@ -1,5 +1,5 @@
-.TH pigpiod_if 3 2012-2018 Linux "pigpio archive"
+.TH pigpiod_if 3 2012-2020 Linux "pigpio archive"
.SH NAME
pigpiod_if - A C library to interface to the pigpio daemon.
@@ -173,6 +173,342 @@ All the functions which return an int return < 0 on error
.br
.br
+
+.SH OVERVIEW
+
+.br
+.SS ESSENTIAL
+.br
+
+.br
+pigpio_start Connects to the pigpio daemon
+.br
+pigpio_stop Disconnects from the pigpio daemon
+.br
+.SS BEGINNER
+.br
+
+.br
+set_mode Set a GPIO mode
+.br
+get_mode Get a GPIO mode
+.br
+
+.br
+set_pull_up_down Set/clear GPIO pull up/down resistor
+.br
+
+.br
+gpio_read Read a GPIO
+.br
+gpio_write Write a GPIO
+.br
+
+.br
+set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+.br
+get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
+.br
+
+.br
+set_servo_pulsewidth Start/stop servo pulses on a GPIO
+.br
+get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
+.br
+
+.br
+callback Create GPIO level change callback
+.br
+callback_ex Create GPIO level change callback
+.br
+callback_cancel Cancel a callback
+.br
+wait_for_edge Wait for GPIO level change
+.br
+.SS INTERMEDIATE
+.br
+
+.br
+gpio_trigger Send a trigger pulse to a GPIO.
+.br
+
+.br
+set_watchdog Set a watchdog on a GPIO.
+.br
+
+.br
+set_PWM_range Configure PWM range for a GPIO
+.br
+get_PWM_range Get configured PWM range for a GPIO
+.br
+
+.br
+set_PWM_frequency Configure PWM frequency for a GPIO
+.br
+get_PWM_frequency Get configured PWM frequency for a GPIO
+.br
+
+.br
+read_bank_1 Read all GPIO in bank 1
+.br
+read_bank_2 Read all GPIO in bank 2
+.br
+
+.br
+clear_bank_1 Clear selected GPIO in bank 1
+.br
+clear_bank_2 Clear selected GPIO in bank 2
+.br
+
+.br
+set_bank_1 Set selected GPIO in bank 1
+.br
+set_bank_2 Set selected GPIO in bank 2
+.br
+
+.br
+start_thread Start a new thread
+.br
+stop_thread Stop a previously started thread
+.br
+.SS ADVANCED
+.br
+
+.br
+get_PWM_real_range Get underlying PWM range for a GPIO
+.br
+
+.br
+notify_open Request a notification handle
+.br
+notify_begin Start notifications for selected GPIO
+.br
+notify_pause Pause notifications
+.br
+notify_close Close a notification
+.br
+
+.br
+bb_serial_read_open Opens a GPIO for bit bang serial reads
+.br
+bb_serial_read Reads bit bang serial data from a GPIO
+.br
+bb_serial_read_close Closes a GPIO for bit bang serial reads
+.br
+bb_serial_invert Invert serial logic (1 invert, 0 normal)
+.br
+
+.br
+hardware_clock Start hardware clock on supported GPIO
+.br
+hardware_PWM Start hardware PWM on supported GPIO
+.br
+
+.br
+set_glitch_filter Set a glitch filter on a GPIO
+.br
+set_noise_filter Set a noise filter on a GPIO
+.br
+.SS SCRIPTS
+.br
+
+.br
+store_script Store a script
+.br
+run_script Run a stored script
+.br
+script_status Get script status and parameters
+.br
+stop_script Stop a running script
+.br
+delete_script Delete a stored script
+.br
+.SS WAVES
+.br
+
+.br
+wave_clear Deletes all waveforms
+.br
+
+.br
+wave_add_new Starts a new waveform
+.br
+wave_add_generic Adds a series of pulses to the waveform
+.br
+wave_add_serial Adds serial data to the waveform
+.br
+
+.br
+wave_create Creates a waveform from added data
+.br
+wave_delete Deletes one or more waveforms
+.br
+
+.br
+wave_send_once Transmits a waveform once
+.br
+wave_send_repeat Transmits a waveform repeatedly
+.br
+
+.br
+wave_chain Transmits a chain of waveforms
+.br
+
+.br
+wave_tx_busy Checks to see if the waveform has ended
+.br
+wave_tx_stop Aborts the current waveform
+.br
+
+.br
+wave_get_micros Length in microseconds of the current waveform
+.br
+wave_get_high_micros Length of longest waveform so far
+.br
+wave_get_max_micros Absolute maximum allowed micros
+.br
+
+.br
+wave_get_pulses Length in pulses of the current waveform
+.br
+wave_get_high_pulses Length of longest waveform so far
+.br
+wave_get_max_pulses Absolute maximum allowed pulses
+.br
+
+.br
+wave_get_cbs Length in cbs of the current waveform
+.br
+wave_get_high_cbs Length of longest waveform so far
+.br
+wave_get_max_cbs Absolute maximum allowed cbs
+.br
+.SS I2C
+.br
+
+.br
+i2c_open Opens an I2C device
+.br
+i2c_close Closes an I2C device
+.br
+
+.br
+i2c_write_quick smbus write quick
+.br
+i2c_write_byte smbus write byte
+.br
+i2c_read_byte smbus read byte
+.br
+i2c_write_byte_data smbus write byte data
+.br
+i2c_write_word_data smbus write word data
+.br
+i2c_read_byte_data smbus read byte data
+.br
+i2c_read_word_data smbus read word data
+.br
+i2c_process_call smbus process call
+.br
+i2c_write_block_data smbus write block data
+.br
+i2c_read_block_data smbus read block data
+.br
+i2c_block_process_call smbus block process call
+.br
+
+.br
+i2c_write_i2c_block_data smbus write I2C block data
+.br
+i2c_read_i2c_block_data smbus read I2C block data
+.br
+
+.br
+i2c_read_device Reads the raw I2C device
+.br
+i2c_write_device Writes the raw I2C device
+.br
+
+.br
+i2c_zip Performs multiple I2C transactions
+.br
+
+.br
+bb_i2c_open Opens GPIO for bit banging I2C
+.br
+bb_i2c_close Closes GPIO for bit banging I2C
+.br
+bb_i2c_zip Performs multiple bit banged I2C transactions
+.br
+.SS SPI
+.br
+
+.br
+spi_open Opens a SPI device
+.br
+spi_close Closes a SPI device
+.br
+
+.br
+spi_read Reads bytes from a SPI device
+.br
+spi_write Writes bytes to a SPI device
+.br
+spi_xfer Transfers bytes with a SPI device
+.br
+.SS SERIAL
+.br
+
+.br
+serial_open Opens a serial device
+.br
+serial_close Closes a serial device
+.br
+
+.br
+serial_write_byte Writes a byte to a serial device
+.br
+serial_read_byte Reads a byte from a serial device
+.br
+serial_write Writes bytes to a serial device
+.br
+serial_read Reads bytes from a serial device
+.br
+
+.br
+serial_data_available Returns number of bytes ready to be read
+.br
+.SS CUSTOM
+.br
+
+.br
+custom_1 User custom function 1
+.br
+custom_2 User custom function 2
+.br
+.SS UTILITIES
+.br
+
+.br
+get_current_tick Get current tick (microseconds)
+.br
+
+.br
+get_hardware_revision Get hardware revision
+.br
+get_pigpio_version Get the pigpio version
+.br
+pigpiod_if_version Get the pigpiod_if version
+.br
+
+.br
+pigpio_error Get a text description of an error code.
+.br
+
+.br
+time_sleep Sleeps for a float number of seconds
+.br
+time_time Float number of seconds since the epoch
+.br
.SH FUNCTIONS
.IP "\fBdouble time_time(void)\fP"
diff --git a/pigpiod_if.c b/pigpiod_if.c
index 7802e57..c62b3e8 100644
--- a/pigpiod_if.c
+++ b/pigpiod_if.c
@@ -1064,7 +1064,7 @@ int i2c_process_call(unsigned handle, unsigned reg, uint32_t val)
ext[0].ptr = &val;
return pigpio_command_ext
- (gPigCommand, PI_CMD_I2CPK, handle, reg, 4, 1, ext, 1);
+ (gPigCommand, PI_CMD_I2CPC, handle, reg, 4, 1, ext, 1);
}
int i2c_write_block_data(
diff --git a/pigpiod_if2.3 b/pigpiod_if2.3
index 248a7c3..0f95b2d 100644
--- a/pigpiod_if2.3
+++ b/pigpiod_if2.3
@@ -1,5 +1,5 @@
-.TH pigpiod_if2 3 2012-2018 Linux "pigpio archive"
+.TH pigpiod_if2 3 2012-2020 Linux "pigpio archive"
.SH NAME
pigpiod_if2 - A C library to interface to the pigpio daemon.
@@ -167,6 +167,458 @@ All the functions which return an int return < 0 on error
.br
.br
+
+.SH OVERVIEW
+
+.br
+.SS ESSENTIAL
+.br
+
+.br
+pigpio_start Connects to a pigpio daemon
+.br
+pigpio_stop Disconnects from a pigpio daemon
+.br
+.SS BASIC
+.br
+
+.br
+set_mode Set a GPIO mode
+.br
+get_mode Get a GPIO mode
+.br
+
+.br
+set_pull_up_down Set/clear GPIO pull up/down resistor
+.br
+
+.br
+gpio_read Read a GPIO
+.br
+gpio_write Write a GPIO
+.br
+.SS PWM (overrides servo commands on same GPIO)
+.br
+
+.br
+set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+.br
+set_PWM_frequency Configure PWM frequency for a GPIO
+.br
+set_PWM_range Configure PWM range for a GPIO
+.br
+
+.br
+get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
+.br
+get_PWM_frequency Get configured PWM frequency for a GPIO
+.br
+get_PWM_range Get configured PWM range for a GPIO
+.br
+
+.br
+get_PWM_real_range Get underlying PWM range for a GPIO
+.br
+.SS Servo (overrides PWM commands on same GPIO)
+.br
+
+.br
+set_servo_pulsewidth Start/stop servo pulses on a GPIO
+.br
+
+.br
+get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
+.br
+.SS INTERMEDIATE
+.br
+
+.br
+gpio_trigger Send a trigger pulse to a GPIO.
+.br
+
+.br
+set_watchdog Set a watchdog on a GPIO.
+.br
+
+.br
+read_bank_1 Read all GPIO in bank 1
+.br
+read_bank_2 Read all GPIO in bank 2
+.br
+
+.br
+clear_bank_1 Clear selected GPIO in bank 1
+.br
+clear_bank_2 Clear selected GPIO in bank 2
+.br
+
+.br
+set_bank_1 Set selected GPIO in bank 1
+.br
+set_bank_2 Set selected GPIO in bank 2
+.br
+
+.br
+callback Create GPIO level change callback
+.br
+callback_ex Create GPIO level change callback, extended
+.br
+
+.br
+callback_cancel Cancel a callback
+.br
+
+.br
+wait_for_edge Wait for GPIO level change
+.br
+
+.br
+start_thread Start a new thread
+.br
+stop_thread Stop a previously started thread
+.br
+.SS ADVANCED
+.br
+
+.br
+notify_open Request a notification handle
+.br
+notify_begin Start notifications for selected GPIO
+.br
+notify_pause Pause notifications
+.br
+notify_close Close a notification
+.br
+
+.br
+hardware_clock Start hardware clock on supported GPIO
+.br
+
+.br
+hardware_PWM Start hardware PWM on supported GPIO
+.br
+
+.br
+set_glitch_filter Set a glitch filter on a GPIO
+.br
+set_noise_filter Set a noise filter on a GPIO
+.br
+
+.br
+set_pad_strength Sets a pads drive strength
+.br
+get_pad_strength Gets a pads drive strength
+.br
+
+.br
+shell_ Executes a shell command
+.br
+.SS Custom
+.br
+
+.br
+custom_1 User custom function 1
+.br
+custom_2 User custom function 2
+.br
+.SS Events
+.br
+
+.br
+event_callback Sets a callback for an event
+.br
+event_callback_ex Sets a callback for an event, extended
+.br
+
+.br
+event_callback_cancel Cancel an event callback
+.br
+
+.br
+event_trigger Triggers an event
+.br
+
+.br
+wait_for_event Wait for an event
+.br
+.SS Scripts
+.br
+
+.br
+store_script Store a script
+.br
+run_script Run a stored script
+.br
+update_script Set a scripts parameters
+.br
+script_status Get script status and parameters
+.br
+stop_script Stop a running script
+.br
+delete_script Delete a stored script
+.br
+.SS I2C
+.br
+
+.br
+i2c_open Opens an I2C device
+.br
+i2c_close Closes an I2C device
+.br
+
+.br
+i2c_write_quick smbus write quick
+.br
+
+.br
+i2c_read_byte smbus read byte
+.br
+i2c_write_byte smbus write byte
+.br
+
+.br
+i2c_read_byte_data smbus read byte data
+.br
+i2c_write_byte_data smbus write byte data
+.br
+
+.br
+i2c_read_word_data smbus read word data
+.br
+i2c_write_word_data smbus write word data
+.br
+
+.br
+i2c_read_block_data smbus read block data
+.br
+i2c_write_block_data smbus write block data
+.br
+
+.br
+i2c_read_i2c_block_data smbus read I2C block data
+.br
+i2c_write_i2c_block_data smbus write I2C block data
+.br
+
+.br
+i2c_read_device Reads the raw I2C device
+.br
+i2c_write_device Writes the raw I2C device
+.br
+
+.br
+i2c_process_call smbus process call
+.br
+i2c_block_process_call smbus block process call
+.br
+
+.br
+i2c_zip Performs multiple I2C transactions
+.br
+.SS I2C BIT BANG
+.br
+
+.br
+bb_i2c_open Opens GPIO for bit banging I2C
+.br
+bb_i2c_close Closes GPIO for bit banging I2C
+.br
+
+.br
+bb_i2c_zip Performs bit banged I2C transactions
+.br
+.SS I2C/SPI SLAVE
+.br
+
+.br
+bsc_xfer I2C/SPI as slave transfer
+.br
+bsc_i2c I2C as slave transfer
+.br
+.SS SERIAL
+.br
+
+.br
+serial_open Opens a serial device
+.br
+serial_close Closes a serial device
+.br
+
+.br
+serial_read_byte Reads a byte from a serial device
+.br
+serial_write_byte Writes a byte to a serial device
+.br
+
+.br
+serial_read Reads bytes from a serial device
+.br
+serial_write Writes bytes to a serial device
+.br
+
+.br
+serial_data_available Returns number of bytes ready to be read
+.br
+.SS SERIAL BIT BANG (read only)
+.br
+
+.br
+bb_serial_read_open Opens a GPIO for bit bang serial reads
+.br
+bb_serial_read_close Closes a GPIO for bit bang serial reads
+.br
+
+.br
+bb_serial_invert Invert serial logic (1 invert, 0 normal)
+.br
+
+.br
+bb_serial_read Reads bit bang serial data from a GPIO
+.br
+.SS SPI
+.br
+
+.br
+spi_open Opens a SPI device
+.br
+spi_close Closes a SPI device
+.br
+
+.br
+spi_read Reads bytes from a SPI device
+.br
+spi_write Writes bytes to a SPI device
+.br
+spi_xfer Transfers bytes with a SPI device
+.br
+.SS SPI BIT BANG
+.br
+
+.br
+bb_spi_open Opens GPIO for bit banging SPI
+.br
+bb_spi_close Closes GPIO for bit banging SPI
+.br
+
+.br
+bb_spi_xfer Transfers bytes with bit banging SPI
+.br
+.SS FILES
+.br
+
+.br
+file_open Opens a file
+.br
+file_close Closes a file
+.br
+
+.br
+file_read Reads bytes from a file
+.br
+file_write Writes bytes to a file
+.br
+
+.br
+file_seek Seeks to a position within a file
+.br
+
+.br
+file_list List files which match a pattern
+.br
+.SS WAVES
+.br
+
+.br
+wave_clear Deletes all waveforms
+.br
+
+.br
+wave_add_new Starts a new waveform
+.br
+wave_add_generic Adds a series of pulses to the waveform
+.br
+wave_add_serial Adds serial data to the waveform
+.br
+
+.br
+wave_create Creates a waveform from added data
+.br
+wave_create_and_pad Creates a waveform of fixed size from added data
+.br
+wave_delete Deletes one or more waveforms
+.br
+
+.br
+wave_send_once Transmits a waveform once
+.br
+wave_send_repeat Transmits a waveform repeatedly
+.br
+wave_send_using_mode Transmits a waveform in the chosen mode
+.br
+
+.br
+wave_chain Transmits a chain of waveforms
+.br
+
+.br
+wave_tx_at Returns the current transmitting waveform
+.br
+
+.br
+wave_tx_busy Checks to see if the waveform has ended
+.br
+
+.br
+wave_tx_stop Aborts the current waveform
+.br
+
+.br
+wave_get_cbs Length in cbs of the current waveform
+.br
+wave_get_high_cbs Length of longest waveform so far
+.br
+wave_get_max_cbs Absolute maximum allowed cbs
+.br
+
+.br
+wave_get_micros Length in micros of the current waveform
+.br
+wave_get_high_micros Length of longest waveform so far
+.br
+wave_get_max_micros Absolute maximum allowed micros
+.br
+
+.br
+wave_get_pulses Length in pulses of the current waveform
+.br
+wave_get_high_pulses Length of longest waveform so far
+.br
+wave_get_max_pulses Absolute maximum allowed pulses
+.br
+.SS UTILITIES
+.br
+
+.br
+get_current_tick Get current tick (microseconds)
+.br
+
+.br
+get_hardware_revision Get hardware revision
+.br
+get_pigpio_version Get the pigpio version
+.br
+pigpiod_if_version Get the pigpiod_if2 version
+.br
+
+.br
+pigpio_error Get a text description of an error code.
+.br
+
+.br
+time_sleep Sleeps for a float number of seconds
+.br
+time_time Float number of seconds since the epoch
+.br
.SH FUNCTIONS
.IP "\fBdouble time_time(void)\fP"
@@ -1409,7 +1861,7 @@ Frequencies above 30MHz are unlikely to work.
.br
gpio: see description
.br
-frequency: 0 (off) or 4689-250000000 (250M)
+frequency: 0 (off) or 4689-250M (13184-375M for the BCM2711)
.br
.EE
@@ -1495,7 +1947,7 @@ daemon is started (option -t).
.br
gpio: see descripton
.br
-PWMfreq: 0 (off) or 1-125000000 (125M)
+PWMfreq: 0 (off) or 1-125M (1-187.5M for the BCM2711)
.br
PWMduty: 0 (off) to 1000000 (1M)(fully on)
.br
@@ -1553,18 +2005,18 @@ The GPIO must be one of the following.
.br
The actual number of steps beween off and fully on is the
-integral part of 250 million divided by PWMfreq.
+integral part of 250M/PWMfreq (375M/PWMfreq for the BCM2711).
.br
.br
-The actual frequency set is 250 million / steps.
+The actual frequency set is 250M/steps (375M/steps for the BCM2711).
.br
.br
-There will only be a million steps for a PWMfreq of 250.
-Lower frequencies will have more steps and higher
+There will only be a million steps for a PWMfreq of 250 (375 for
+the BCM2711). Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
@@ -1938,6 +2390,87 @@ specified delay between the pulse and the next.
Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
+.IP "\fBint wave_create_and_pad(int pi, int percent)\fP"
+.IP "" 4
+This function creates a waveform like \fBwave_create\fP but pads the consumed
+resources. Where percent gives the percentage of the resources to use (in terms
+of the theoretical maximum, not the current amount free). This allows the reuse
+.br
+of deleted waves while a transmission is active.
+
+.br
+
+.br
+
+.EX
+pi: >=0 (as returned by \fBpigpio_start\fP).
+.br
+percent: 0-100, size of waveform as percentage of maximum available.
+.br
+
+.EE
+
+.br
+
+.br
+The data provided by the \fBwave_add_*\fP functions are consumed by this
+function.
+
+.br
+
+.br
+As many waveforms may be created as there is space available. The
+wave id is passed to \fBwave_send_*\fP to specify the waveform to transmit.
+
+.br
+
+.br
+A usage would be the creation of two waves where one is filled while the other
+is being transmitted. Each wave is assigned 50% of the resources.
+This buffer structure allows the transmission of infinite wave sequences.
+
+.br
+
+.br
+Normal usage:
+
+.br
+
+.br
+Step 1. \fBwave_clear\fP to clear all waveforms and added data.
+
+.br
+
+.br
+Step 2. \fBwave_add_*\fP calls to supply the waveform data.
+
+.br
+
+.br
+Step 3. \fBwave_create_and_pad\fP to create a waveform of uniform size.
+
+.br
+
+.br
+Step 4. \fBwave_send_*\fP with the id of the waveform to transmit.
+
+.br
+
+.br
+Repeat steps 2-4 as needed.
+
+.br
+
+.br
+Step 5. Any wave id can now be deleted and another wave of the same size
+ can be created in its place.
+
+.br
+
+.br
+Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
+PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
+
.IP "\fBint wave_delete(int pi, unsigned wave_id)\fP"
.IP "" 4
This function deletes the waveform with id wave_id.
@@ -2293,7 +2826,7 @@ int main(int argc, char *argv[])
.IP "\fBint wave_tx_at(int pi)\fP"
.IP "" 4
This function returns the id of the waveform currently being
-transmitted.
+transmitted by \fBwave_send*\fP. Chained waves are not supported.
.br
@@ -5467,6 +6000,66 @@ tick 32 bit The number of microseconds since boot
.EE
+.br
+
+.br
+The GPIO are sampled at a rate set when the pigpio daemon
+is started (default 5 us).
+
+.br
+
+.br
+The number of samples per second is given in the following table.
+
+.br
+
+.br
+
+.EX
+ samples
+.br
+ per sec
+.br
+
+.br
+ 1 1,000,000
+.br
+ 2 500,000
+.br
+sample 4 250,000
+.br
+rate 5 200,000
+.br
+(us) 8 125,000
+.br
+ 10 100,000
+.br
+
+.EE
+
+.br
+
+.br
+GPIO level changes shorter than the sample rate may be missed.
+
+.br
+
+.br
+The daemon software which generates the callbacks is triggered
+1000 times per second. The callbacks will be called once per
+level change since the last time they were called.
+i.e. The callbacks will get all level changes but there will
+be a latency.
+
+.br
+
+.br
+If you want to track the level of more than one GPIO do so by
+maintaining the state in the callback. Do not use \fBgpio_read\fP.
+Remember the event that triggered the callback may have
+happened several milliseconds before and the GPIO may have
+changed level many times since then.
+
.IP "\fBint callback_ex(int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
.IP "" 4
This function initialises a new callback.
@@ -5595,9 +6188,27 @@ The function returns 1 if the edge occurred, otherwise 0.
.IP "\fBint bsc_xfer(int pi, bsc_xfer_t *bscxfer)\fP"
.IP "" 4
-This function provides a low-level interface to the
-SPI/I2C Slave peripheral. This peripheral allows the
-Pi to act as a slave device on an I2C or SPI bus.
+This function provides a low-level interface to the SPI/I2C Slave
+peripheral on the BCM chip.
+
+.br
+
+.br
+This peripheral allows the Pi to act as a hardware slave device
+on an I2C or SPI bus.
+
+.br
+
+.br
+This is not a bit bang version and as such is OS timing
+independent. The bus timing is handled directly by the chip.
+
+.br
+
+.br
+The output process is simple. You simply append data to the FIFO
+buffer on the chip. This works like a queue, you add data to the
+queue and the master removes it.
.br
@@ -5646,8 +6257,9 @@ typedef struct
.br
.br
-To start a transfer set control (see below) and copy the bytes to
-be sent (if any) to txBuf and set the byte count in txCnt.
+To start a transfer set control (see below), copy the bytes to
+be added to the transmit FIFO (if any) to txBuf and set txCnt to
+the number of copied bytes.
.br
@@ -5682,14 +6294,37 @@ that mode until a different control word is sent.
.br
.br
-The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
-and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
-need to swap MISO/MOSI between master and slave.
+GPIO used for models other than those based on the BCM2711.
.br
.br
-When a zero control word is received GPIO 18-21 will be reset
+ SDA SCL MOSI SCLK MISO CE
+.br
+I2C 18 19 - - - -
+.br
+SPI - - 18 19 20 21
+.br
+
+.br
+
+.br
+GPIO used for models based on the BCM2711 (e.g. the Pi4B).
+
+.br
+
+.br
+ SDA SCL MOSI SCLK MISO CE
+.br
+I2C 10 11 - - - -
+.br
+SPI - - 10 11 9 8
+.br
+
+.br
+
+.br
+When a zero control word is received the used GPIO will be reset
to INPUT mode.
.br
@@ -5845,6 +6480,12 @@ This function allows the Pi to act as a slave I2C device.
.br
.br
+This function is not available on the BCM2711 (e.g.as
+used in the Pi4B).
+
+.br
+
+.br
The data bytes (if any) are written to the BSC transmit
FIFO and the bytes in the BSC receive FIFO are returned.
@@ -5906,8 +6547,7 @@ If there was an error the status will be less than zero
.br
Note that an i2c_address of 0 may be used to close
-the BSC device and reassign the used GPIO (18/19)
-as inputs.
+the BSC device and reassign the used GPIO as inputs.
.IP "\fBint event_callback(int pi, unsigned event, evtCBFunc_t f)\fP"
.IP "" 4
@@ -6279,7 +6919,7 @@ A single character, an 8 bit quantity able to store 0-255.
.br
-.IP "\fBclkfreq\fP: 4689-250000000 (250M)" 0
+.IP "\fBclkfreq\fP: 4689-250M (13184-375M for the BCM2711)" 0
The hardware clock frequency.
.br
@@ -6856,6 +7496,13 @@ An array of script parameters.
.br
+.IP "\fBpercent\fP: 0-100" 0
+The size of waveform as percentage of maximum available.
+
+.br
+
+.br
+
.IP "\fBpi\fP" 0
An integer defining a connected Pi. The value is returned by
\fBpigpio_start\fP upon success.
@@ -6957,7 +7604,7 @@ The hardware PWM dutycycle.
.br
-.IP "\fBPWMfreq\fP: 1-125000000 (125M)" 0
+.IP "\fBPWMfreq\fP: 1-125M (1-187.5M for the BCM2711)" 0
The hardware PWM frequency.
.br
@@ -6969,6 +7616,8 @@ The hardware PWM frequency.
.br
#define PI_HW_PWM_MAX_FREQ 125000000
.br
+#define PI_HW_PWM_MAX_FREQ_2711 187500000
+.br
.EE
diff --git a/pigpiod_if2.c b/pigpiod_if2.c
index 85bc27c..ab2ef10 100644
--- a/pigpiod_if2.c
+++ b/pigpiod_if2.c
@@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
-/* PIGPIOD_IF2_VERSION 13 */
+/* PIGPIOD_IF2_VERSION 17 */
#include <stdio.h>
#include <stdlib.h>
@@ -234,33 +234,10 @@ static int pigpio_command_ext
return cmd.res;
}
-static int pigpioOpenSocket(char *addr, char *port)
+static int pigpioOpenSocket(char *addrStr, char *portStr)
{
int sock, err, opt;
struct addrinfo hints, *res, *rp;
- const char *addrStr, *portStr;
-
- if (!addr)
- {
- addrStr = getenv(PI_ENVADDR);
-
- if ((!addrStr) || (!strlen(addrStr)))
- {
- addrStr = PI_DEFAULT_SOCKET_ADDR_STR;
- }
- }
- else addrStr = addr;
-
- if (!port)
- {
- portStr = getenv(PI_ENVPORT);
-
- if ((!portStr) || (!strlen(portStr)))
- {
- portStr = PI_DEFAULT_SOCKET_PORT_STR;
- }
- }
- else portStr = port;
memset (&hints, 0, sizeof (hints));
@@ -713,11 +690,6 @@ int pigpio_start(char *addrStr, char *portStr)
int pi;
int *userdata;
- if ((!addrStr) || (strlen(addrStr) == 0))
- {
- addrStr = "localhost";
- }
-
for (pi=0; pi<MAX_PI; pi++)
{
if (!gPiInUse[pi]) break;
@@ -727,6 +699,26 @@ int pigpio_start(char *addrStr, char *portStr)
gPiInUse[pi] = 1;
+ if ((!addrStr) || (!strlen(addrStr)))
+ {
+ addrStr = getenv(PI_ENVADDR);
+
+ if ((!addrStr) || (!strlen(addrStr)))
+ {
+ addrStr = PI_DEFAULT_SOCKET_ADDR_STR;
+ }
+ }
+
+ if ((!portStr) || (!strlen(portStr)))
+ {
+ portStr = getenv(PI_ENVPORT);
+
+ if ((!portStr) || (!strlen(portStr)))
+ {
+ portStr = PI_DEFAULT_SOCKET_PORT_STR;
+ }
+ }
+
pthread_mutex_init(&gCmdMutex[pi], NULL);
gPigCommand[pi] = pigpioOpenSocket(addrStr, portStr);
@@ -961,6 +953,9 @@ int wave_add_serial(
int wave_create(int pi)
{return pigpio_command(pi, PI_CMD_WVCRE, 0, 0, 1);}
+int wave_create_and_pad(int pi, int percent)
+ {return pigpio_command(pi, PI_CMD_WVCAP, percent, 0, 1);}
+
int wave_delete(int pi, unsigned wave_id)
{return pigpio_command(pi, PI_CMD_WVDEL, wave_id, 0, 1);}
@@ -1293,7 +1288,7 @@ int i2c_process_call(int pi, unsigned handle, unsigned reg, uint32_t val)
ext[0].ptr = &val;
return pigpio_command_ext
- (pi, PI_CMD_I2CPK, handle, reg, 4, 1, ext, 1);
+ (pi, PI_CMD_I2CPC, handle, reg, 4, 1, ext, 1);
}
int i2c_write_block_data(
diff --git a/pigpiod_if2.h b/pigpiod_if2.h
index 062f71c..9700cc0 100644
--- a/pigpiod_if2.h
+++ b/pigpiod_if2.h
@@ -30,7 +30,7 @@ For more information, please refer to <http://unlicense.org/>
#include "pigpio.h"
-#define PIGPIOD_IF2_VERSION 13
+#define PIGPIOD_IF2_VERSION 17
/*TEXT
@@ -104,7 +104,7 @@ ESSENTIAL
pigpio_start Connects to a pigpio daemon
pigpio_stop Disconnects from a pigpio daemon
-BEGINNER
+BASIC
set_mode Set a GPIO mode
get_mode Get a GPIO mode
@@ -114,16 +114,23 @@ set_pull_up_down Set/clear GPIO pull up/down resistor
gpio_read Read a GPIO
gpio_write Write a GPIO
+PWM_(overrides_servo_commands_on_same_GPIO)
+
set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+set_PWM_frequency Configure PWM frequency for a GPIO
+set_PWM_range Configure PWM range for a GPIO
+
get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
+get_PWM_frequency Get configured PWM frequency for a GPIO
+get_PWM_range Get configured PWM range for a GPIO
+
+get_PWM_real_range Get underlying PWM range for a GPIO
+
+Servo_(overrides_PWM_commands_on_same_GPIO)
set_servo_pulsewidth Start/stop servo pulses on a GPIO
-get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
-callback Create GPIO level change callback
-callback_ex Create GPIO level change callback, extended
-callback_cancel Cancel a callback
-wait_for_edge Wait for GPIO level change
+get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
INTERMEDIATE
@@ -131,12 +138,6 @@ gpio_trigger Send a trigger pulse to a GPIO.
set_watchdog Set a watchdog on a GPIO.
-set_PWM_range Configure PWM range for a GPIO
-get_PWM_range Get configured PWM range for a GPIO
-
-set_PWM_frequency Configure PWM frequency for a GPIO
-get_PWM_frequency Get configured PWM frequency for a GPIO
-
read_bank_1 Read all GPIO in bank 1
read_bank_2 Read all GPIO in bank 2
@@ -146,75 +147,59 @@ clear_bank_2 Clear selected GPIO in bank 2
set_bank_1 Set selected GPIO in bank 1
set_bank_2 Set selected GPIO in bank 2
+callback Create GPIO level change callback
+callback_ex Create GPIO level change callback, extended
+
+callback_cancel Cancel a callback
+
+wait_for_edge Wait for GPIO level change
+
start_thread Start a new thread
stop_thread Stop a previously started thread
ADVANCED
-get_PWM_real_range Get underlying PWM range for a GPIO
-
notify_open Request a notification handle
notify_begin Start notifications for selected GPIO
notify_pause Pause notifications
notify_close Close a notification
-bb_serial_read_open Opens a GPIO for bit bang serial reads
-bb_serial_read Reads bit bang serial data from a GPIO
-bb_serial_read_close Closes a GPIO for bit bang serial reads
-bb_serial_invert Invert serial logic (1 invert, 0 normal)
-
hardware_clock Start hardware clock on supported GPIO
+
hardware_PWM Start hardware PWM on supported GPIO
set_glitch_filter Set a glitch filter on a GPIO
set_noise_filter Set a noise filter on a GPIO
-get_pad_strength Gets a pads drive strength
set_pad_strength Sets a pads drive strength
+get_pad_strength Gets a pads drive strength
shell_ Executes a shell command
-SCRIPTS
-
-store_script Store a script
-run_script Run a stored script
-update_script Set a scripts parameters
-script_status Get script status and parameters
-stop_script Stop a running script
-delete_script Delete a stored script
-
-WAVES
+Custom
-wave_clear Deletes all waveforms
-
-wave_add_new Starts a new waveform
-wave_add_generic Adds a series of pulses to the waveform
-wave_add_serial Adds serial data to the waveform
+custom_1 User custom function 1
+custom_2 User custom function 2
-wave_create Creates a waveform from added data
-wave_delete Deletes one or more waveforms
+Events
-wave_send_once Transmits a waveform once
-wave_send_repeat Transmits a waveform repeatedly
-wave_send_using_mode Transmits a waveform in the chosen mode
+event_callback Sets a callback for an event
+event_callback_ex Sets a callback for an event, extended
-wave_chain Transmits a chain of waveforms
+event_callback_cancel Cancel an event callback
-wave_tx_at Returns the current transmitting waveform
-wave_tx_busy Checks to see if the waveform has ended
-wave_tx_stop Aborts the current waveform
+event_trigger Triggers an event
-wave_get_micros Length in microseconds of the current waveform
-wave_get_high_micros Length of longest waveform so far
-wave_get_max_micros Absolute maximum allowed micros
+wait_for_event Wait for an event
-wave_get_pulses Length in pulses of the current waveform
-wave_get_high_pulses Length of longest waveform so far
-wave_get_max_pulses Absolute maximum allowed pulses
+Scripts
-wave_get_cbs Length in cbs of the current waveform
-wave_get_high_cbs Length of longest waveform so far
-wave_get_max_cbs Absolute maximum allowed cbs
+store_script Store a script
+run_script Run a stored script
+update_script Set a scripts parameters
+script_status Get script status and parameters
+stop_script Stop a running script
+delete_script Delete a stored script
I2C
@@ -222,41 +207,36 @@ i2c_open Opens an I2C device
i2c_close Closes an I2C device
i2c_write_quick smbus write quick
-i2c_write_byte smbus write byte
+
i2c_read_byte smbus read byte
-i2c_write_byte_data smbus write byte data
-i2c_write_word_data smbus write word data
+i2c_write_byte smbus write byte
+
i2c_read_byte_data smbus read byte data
+i2c_write_byte_data smbus write byte data
+
i2c_read_word_data smbus read word data
-i2c_process_call smbus process call
-i2c_write_block_data smbus write block data
+i2c_write_word_data smbus write word data
+
i2c_read_block_data smbus read block data
-i2c_block_process_call smbus block process call
+i2c_write_block_data smbus write block data
-i2c_write_i2c_block_data smbus write I2C block data
i2c_read_i2c_block_data smbus read I2C block data
+i2c_write_i2c_block_data smbus write I2C block data
i2c_read_device Reads the raw I2C device
i2c_write_device Writes the raw I2C device
+i2c_process_call smbus process call
+i2c_block_process_call smbus block process call
+
i2c_zip Performs multiple I2C transactions
+I2C_BIT_BANG
+
bb_i2c_open Opens GPIO for bit banging I2C
bb_i2c_close Closes GPIO for bit banging I2C
-bb_i2c_zip Performs multiple bit banged I2C transactions
-
-SPI
-
-spi_open Opens a SPI device
-spi_close Closes a SPI device
-spi_read Reads bytes from a SPI device
-spi_write Writes bytes to a SPI device
-spi_xfer Transfers bytes with a SPI device
-
-bb_spi_open Opens GPIO for bit banging SPI
-bb_spi_close Closes GPIO for bit banging SPI
-bb_spi_xfer Transfers bytes with bit banging SPI
+bb_i2c_zip Performs bit banged I2C transactions
I2C/SPI_SLAVE
@@ -268,34 +248,86 @@ SERIAL
serial_open Opens a serial device
serial_close Closes a serial device
-serial_write_byte Writes a byte to a serial device
serial_read_byte Reads a byte from a serial device
-serial_write Writes bytes to a serial device
+serial_write_byte Writes a byte to a serial device
+
serial_read Reads bytes from a serial device
+serial_write Writes bytes to a serial device
serial_data_available Returns number of bytes ready to be read
+SERIAL_BIT_BANG_(read_only)
+
+bb_serial_read_open Opens a GPIO for bit bang serial reads
+bb_serial_read_close Closes a GPIO for bit bang serial reads
+
+bb_serial_invert Invert serial logic (1 invert, 0 normal)
+
+bb_serial_read Reads bit bang serial data from a GPIO
+
+SPI
+
+spi_open Opens a SPI device
+spi_close Closes a SPI device
+
+spi_read Reads bytes from a SPI device
+spi_write Writes bytes to a SPI device
+spi_xfer Transfers bytes with a SPI device
+
+SPI_BIT_BANG
+
+bb_spi_open Opens GPIO for bit banging SPI
+bb_spi_close Closes GPIO for bit banging SPI
+
+bb_spi_xfer Transfers bytes with bit banging SPI
+
FILES
file_open Opens a file
file_close Closes a file
+
file_read Reads bytes from a file
file_write Writes bytes to a file
+
file_seek Seeks to a position within a file
+
file_list List files which match a pattern
-EVENTS
+WAVES
-event_callback Sets a callback for an event
-event_callback_ex Sets a callback for an event, extended
-event_callback_cancel Cancel an event callback
-event_trigger Triggers an event
-wait_for_event Wait for an event
+wave_clear Deletes all waveforms
-CUSTOM
+wave_add_new Starts a new waveform
+wave_add_generic Adds a series of pulses to the waveform
+wave_add_serial Adds serial data to the waveform
-custom_1 User custom function 1
-custom_2 User custom function 2
+wave_create Creates a waveform from added data
+wave_create_and_pad Creates a waveform of fixed size from added data
+wave_delete Deletes one or more waveforms
+
+wave_send_once Transmits a waveform once
+wave_send_repeat Transmits a waveform repeatedly
+wave_send_using_mode Transmits a waveform in the chosen mode
+
+wave_chain Transmits a chain of waveforms
+
+wave_tx_at Returns the current transmitting waveform
+
+wave_tx_busy Checks to see if the waveform has ended
+
+wave_tx_stop Aborts the current waveform
+
+wave_get_cbs Length in cbs of the current waveform
+wave_get_high_cbs Length of longest waveform so far
+wave_get_max_cbs Absolute maximum allowed cbs
+
+wave_get_micros Length in micros of the current waveform
+wave_get_high_micros Length of longest waveform so far
+wave_get_max_micros Absolute maximum allowed micros
+
+wave_get_pulses Length in pulses of the current waveform
+wave_get_high_pulses Length of longest waveform so far
+wave_get_max_pulses Absolute maximum allowed pulses
UTILITIES
@@ -1049,7 +1081,7 @@ Frequencies above 30MHz are unlikely to work.
. .
pi: >=0 (as returned by [*pigpio_start*]).
gpio: see description
-frequency: 0 (off) or 4689-250000000 (250M)
+frequency: 0 (off) or 4689-250M (13184-375M for the BCM2711)
. .
Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
@@ -1096,7 +1128,7 @@ daemon is started (option -t).
. .
pi: >=0 (as returned by [*pigpio_start*]).
gpio: see descripton
-PWMfreq: 0 (off) or 1-125000000 (125M)
+PWMfreq: 0 (off) or 1-125M (1-187.5M for the BCM2711)
PWMduty: 0 (off) to 1000000 (1M)(fully on)
. .
@@ -1124,12 +1156,12 @@ The GPIO must be one of the following.
. .
The actual number of steps beween off and fully on is the
-integral part of 250 million divided by PWMfreq.
+integral part of 250M/PWMfreq (375M/PWMfreq for the BCM2711).
-The actual frequency set is 250 million / steps.
+The actual frequency set is 250M/steps (375M/steps for the BCM2711).
-There will only be a million steps for a PWMfreq of 250.
-Lower frequencies will have more steps and higher
+There will only be a million steps for a PWMfreq of 250 (375 for
+the BCM2711). Lower frequencies will have more steps and higher
frequencies will have fewer steps. PWMduty is
automatically scaled to take this into account.
D*/
@@ -1342,6 +1374,49 @@ D*/
/*F*/
+int wave_create_and_pad(int pi, int percent);
+/*D
+This function creates a waveform like [*wave_create*] but pads the consumed
+resources. Where percent gives the percentage of the resources to use (in terms
+of the theoretical maximum, not the current amount free). This allows the reuse
+of deleted waves while a transmission is active.
+
+. .
+pi: >=0 (as returned by [*pigpio_start*]).
+percent: 0-100, size of waveform as percentage of maximum available.
+. .
+
+The data provided by the [*wave_add_**] functions are consumed by this
+function.
+
+As many waveforms may be created as there is space available. The
+wave id is passed to [*wave_send_**] to specify the waveform to transmit.
+
+A usage would be the creation of two waves where one is filled while the other
+is being transmitted. Each wave is assigned 50% of the resources.
+This buffer structure allows the transmission of infinite wave sequences.
+
+Normal usage:
+
+Step 1. [*wave_clear*] to clear all waveforms and added data.
+
+Step 2. [*wave_add_**] calls to supply the waveform data.
+
+Step 3. [*wave_create_and_pad*] to create a waveform of uniform size.
+
+Step 4. [*wave_send_**] with the id of the waveform to transmit.
+
+Repeat steps 2-4 as needed.
+
+Step 5. Any wave id can now be deleted and another wave of the same size
+ can be created in its place.
+
+Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
+PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
+D*/
+
+
+/*F*/
int wave_delete(int pi, unsigned wave_id);
/*D
This function deletes the waveform with id wave_id.
@@ -1534,7 +1609,7 @@ D*/
int wave_tx_at(int pi);
/*D
This function returns the id of the waveform currently being
-transmitted.
+transmitted by [*wave_send**]. Chained waves are not supported.
. .
pi: >=0 (as returned by [*pigpio_start*]).
@@ -3321,6 +3396,37 @@ tick 32 bit The number of microseconds since boot
WARNING: this wraps around from
4294967295 to 0 roughly every 72 minutes
. .
+
+The GPIO are sampled at a rate set when the pigpio daemon
+is started (default 5 us).
+
+The number of samples per second is given in the following table.
+
+. .
+ samples
+ per sec
+
+ 1 1,000,000
+ 2 500,000
+sample 4 250,000
+rate 5 200,000
+(us) 8 125,000
+ 10 100,000
+. .
+
+GPIO level changes shorter than the sample rate may be missed.
+
+The daemon software which generates the callbacks is triggered
+1000 times per second. The callbacks will be called once per
+level change since the last time they were called.
+i.e. The callbacks will get all level changes but there will
+be a latency.
+
+If you want to track the level of more than one GPIO do so by
+maintaining the state in the callback. Do not use [*gpio_read*].
+Remember the event that triggered the callback may have
+happened several milliseconds before and the GPIO may have
+changed level many times since then.
D*/
/*F*/
@@ -3398,9 +3504,18 @@ D*/
/*F*/
int bsc_xfer(int pi, bsc_xfer_t *bscxfer);
/*D
-This function provides a low-level interface to the
-SPI/I2C Slave peripheral. This peripheral allows the
-Pi to act as a slave device on an I2C or SPI bus.
+This function provides a low-level interface to the SPI/I2C Slave
+peripheral on the BCM chip.
+
+This peripheral allows the Pi to act as a hardware slave device
+on an I2C or SPI bus.
+
+This is not a bit bang version and as such is OS timing
+independent. The bus timing is handled directly by the chip.
+
+The output process is simple. You simply append data to the FIFO
+buffer on the chip. This works like a queue, you add data to the
+queue and the master removes it.
I can't get SPI to work properly. I tried with a
control word of 0x303 and swapped MISO and MOSI.
@@ -3424,8 +3539,9 @@ typedef struct
} bsc_xfer_t;
. .
-To start a transfer set control (see below) and copy the bytes to
-be sent (if any) to txBuf and set the byte count in txCnt.
+To start a transfer set control (see below), copy the bytes to
+be added to the transmit FIFO (if any) to txBuf and set txCnt to
+the number of copied bytes.
Upon return rxCnt will be set to the number of received bytes placed
in rxBuf.
@@ -3442,11 +3558,19 @@ less than requested if the FIFO already contained untransmitted data).
Note that the control word sets the BSC mode. The BSC will stay in
that mode until a different control word is sent.
-The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
-and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
-need to swap MISO/MOSI between master and slave.
+GPIO used for models other than those based on the BCM2711.
+
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+I2C @ 18 @ 19 @ - @ - @ - @ -
+SPI @ - @ - @ 18 @ 19 @ 20 @ 21
+
+GPIO used for models based on the BCM2711 (e.g. the Pi4B).
-When a zero control word is received GPIO 18-21 will be reset
+ @ SDA @ SCL @ MOSI @ SCLK @ MISO @ CE
+I2C @ 10 @ 11 @ - @ - @ - @ -
+SPI @ - @ - @ 10 @ 11 @ 9 @ 8
+
+When a zero control word is received the used GPIO will be reset
to INPUT mode.
control consists of the following bits.
@@ -3522,6 +3646,9 @@ int bsc_i2c(int pi, int i2c_addr, bsc_xfer_t *bscxfer);
/*D
This function allows the Pi to act as a slave I2C device.
+This function is not available on the BCM2711 (e.g.as
+used in the Pi4B).
+
The data bytes (if any) are written to the BSC transmit
FIFO and the bytes in the BSC receive FIFO are returned.
@@ -3551,8 +3678,7 @@ If there was an error the status will be less than zero
(and will contain the error code).
Note that an i2c_address of 0 may be used to close
-the BSC device and reassign the used GPIO (18/19)
-as inputs.
+the BSC device and reassign the used GPIO as inputs.
D*/
/*F*/
@@ -3743,7 +3869,7 @@ typedef void (*CBFuncEx_t)
char::
A single character, an 8 bit quantity able to store 0-255.
-clkfreq::4689-250000000 (250M)
+clkfreq::4689-250M (13184-375M for the BCM2711)
The hardware clock frequency.
count::
@@ -4001,6 +4127,9 @@ high and low levels.
*param::
An array of script parameters.
+percent:: 0-100
+The size of waveform as percentage of maximum available.
+
pi::
An integer defining a connected Pi. The value is returned by
[*pigpio_start*] upon success.
@@ -4047,12 +4176,13 @@ The hardware PWM dutycycle.
#define PI_HW_PWM_RANGE 1000000
. .
-PWMfreq::1-125000000 (125M)
+PWMfreq::1-125M (1-187.5M for the BCM2711)
The hardware PWM frequency.
. .
#define PI_HW_PWM_MIN_FREQ 1
#define PI_HW_PWM_MAX_FREQ 125000000
+#define PI_HW_PWM_MAX_FREQ_2711 187500000
. .
range::25-40000
diff --git a/pigs.1 b/pigs.1
index e10e0dd..5ecc076 100644
--- a/pigs.1
+++ b/pigs.1
@@ -1,5 +1,5 @@
-.TH pigs 1 2012-2018 Linux "pigpio archive"
+.TH pigs 1 2012-2020 Linux "pigpio archive"
.SH NAME
pigs - command line socket access to the pigpio daemon.
@@ -25,8 +25,8 @@ or
.br
-The socket and pipe interfaces allow control of the GPIO by passing
-messages to the running pigpio library.
+The socket and pipe interfaces allow control of the Pi's GPIO by
+passing messages to the running pigpio library.
.br
The normal way to start the pigpio library would be as a daemon during boot.
@@ -40,10 +40,6 @@ sudo pigpiod
.EE
.br
-pigs is a program and internally uses the socket interface to pigpio
-whereas /dev/pigpio uses the pipe interface.
-
-.br
.SS Features
.br
o hardware timed PWM on any of GPIO 0-31
@@ -77,7 +73,11 @@ ALL GPIO are identified by their Broadcom number.
.br
.SS Usage
.br
-pigs and the socket interface share the same commands and are invoked in
+pigs is a program and internally uses the socket interface to pigpio
+whereas /dev/pigpio uses the pipe interface.
+
+.br
+pigs and the pipe interface share the same commands and are invoked in
a similar fashion from the command line.
.br
@@ -239,6 +239,375 @@ $ pigs -x slr 4 100
.br
+.SH OVERVIEW
+.SS BASIC
+.B M/MODES g m
+Set GPIO mode
+.P
+.B MG/MODEG g
+Get GPIO mode
+.P
+.B PUD g p
+Set GPIO pull up/down
+.P
+.B R/READ g
+Read GPIO level
+.P
+.B W/WRITE g L
+Write GPIO level
+.P
+.SS PWM (overrides servo commands on same GPIO)
+.B P/PWM u v
+Set GPIO PWM value
+.P
+.B PFS u v
+Set GPIO PWM frequency
+.P
+.B PRS u v
+Set GPIO PWM range
+.P
+.B GDC u
+Get GPIO PWM dutycycle
+.P
+.B PFG u
+Get GPIO PWM frequency
+.P
+.B PRG u
+Get GPIO PWM range
+.P
+.B PRRG u
+Get GPIO PWM real range
+.P
+.SS Servo (overrides PWM commands on same GPIO)
+.B S/SERVO u v
+Set GPIO servo pulsewidth
+.P
+.B GPW u
+Get GPIO servo pulsewidth
+.P
+.SS INTERMEDIATE
+.B TRIG u pl L
+Send a trigger pulse
+.P
+.B WDOG u v
+Set GPIO watchdog
+.P
+.B BR1
+Read bank 1 GPIO
+.P
+.B BR2
+Read bank 2 GPIO
+.P
+.B BC1 bits
+Clear specified GPIO in bank 1
+.P
+.B BC2 bits
+Clear specified GPIO in bank 2
+.P
+.B BS1 bits
+Set specified GPIO in bank 1
+.P
+.B BS2 bits
+Set specified GPIO in bank 2
+.P
+.SS ADVANCED
+.B NO
+Request a notification
+.P
+.B NC h
+Close notification
+.P
+.B NB h bits
+Start notification
+.P
+.B NP h
+Pause notification
+.P
+.B HC g cf
+Set hardware clock frequency
+.P
+.B HP g pf pdc
+Set hardware PWM frequency and dutycycle
+.P
+.B FG u stdy
+Set a glitch filter on a GPIO
+.P
+.B FN u stdy actv
+Set a noise filter on a GPIO
+.P
+.B PADS pad padma
+Set pad drive strength
+.P
+.B PADG pad
+Get pad drive strength
+.P
+.B SHELL name str
+Execute a shell command
+.P
+.SS Custom
+.B CF1 uvs
+Custom function 1
+.P
+.B CF2 uvs
+Custom function 2
+.P
+.SS Events
+.B EVM h bits
+Set events to monitor
+.P
+.B EVT event
+Trigger event
+.P
+.SS Scripts
+.B PROC t
+Store script
+.P
+.B PROCR sid pars
+Run script
+.P
+.B PROCU sid pars
+Set script parameters
+.P
+.B PROCP sid
+Get script status and parameters
+.P
+.B PROCS sid
+Stop script
+.P
+.B PROCD sid
+Delete script
+.P
+.B PARSE t
+Validate script
+.P
+.SS I2C
+.B I2CO ib id if
+Open I2C bus and device with flags
+.P
+.B I2CC h
+Close I2C handle
+.P
+.B I2CWQ h bit
+smb Write Quick: write bit
+.P
+.B I2CRS h
+smb Read Byte: read byte
+.P
+.B I2CWS h bv
+smb Write Byte: write byte
+.P
+.B I2CRB h r
+smb Read Byte Data: read byte from register
+.P
+.B I2CWB h r bv
+smb Write Byte Data: write byte to register
+.P
+.B I2CRW h r
+smb Read Word Data: read word from register
+.P
+.B I2CWW h r wv
+smb Write Word Data: write word to register
+.P
+.B I2CRK h r
+smb Read Block Data: read data from register
+.P
+.B I2CWK h r bvs
+smb Write Block Data: write data to register
+.P
+.B I2CWI h r bvs
+smb Write I2C Block Data
+.P
+.B I2CRI h r num
+smb Read I2C Block Data: read bytes from register
+.P
+.B I2CRD h num
+i2c Read device
+.P
+.B I2CWD h bvs
+i2c Write device
+.P
+.B I2CPC h r wv
+smb Process Call: exchange register with word
+.P
+.B I2CPK h r bvs
+smb Block Process Call: exchange data bytes with register
+.P
+.B I2CZ h bvs
+Performs multiple I2C transactions
+.P
+.SS I2C BIT BANG
+.B BI2CO sda scl b
+Open bit bang I2C
+.P
+.B BI2CC sda
+Close bit bang I2C
+.P
+.B BI2CZ sda bvs
+I2C bit bang multiple transactions
+.P
+.SS I2C/SPI SLAVE
+.B BSCX bctl bvs
+BSC I2C/SPI transfer
+.P
+.SS SERIAL
+.B SERO dev b sef
+Open serial device dev at baud b with flags
+.P
+.B SERC h
+Close serial handle
+.P
+.B SERRB
+Read byte from serial handle
+.P
+.B SERWB h bv
+Write byte to serial handle
+.P
+.B SERR h num
+Read bytes from serial handle
+.P
+.B SERW h bvs
+Write bytes to serial handle
+.P
+.B SERDA h
+Check for serial data ready to read
+.P
+.SS SERIAL BIT BANG (read only)
+.B SLRO u b db
+Open GPIO for bit bang serial data
+.P
+.B SLRC u
+Close GPIO for bit bang serial data
+.P
+.B SLRI u v
+Sets bit bang serial data logic levels
+.P
+.B SLR u num
+Read bit bang serial data from GPIO
+.P
+.SS SPI
+.B SPIO c b spf
+SPI open channel at baud b with flags
+.P
+.B SPIC h
+SPI close handle
+.P
+.B SPIR h num
+SPI read bytes from handle
+.P
+.B SPIW h bvs
+SPI write bytes to handle
+.P
+.B SPIX h bvs
+SPI transfer bytes to handle
+.P
+.SS SPI BIT BANG
+.B BSPIO cs miso mosi sclk b spf
+Open bit bang SPI
+.P
+.B BSPIC cs
+Close bit bang SPI
+.P
+.B BSPIX cs bvs
+SPI bit bang transfer
+.P
+.SS FILES
+.B FO file mode
+Open a file in mode
+.P
+.B FC h
+Close file handle
+.P
+.B FR h num
+Read bytes from file handle
+.P
+.B FW h bvs
+Write bytes to file handle
+.P
+.B FS h num from
+Seek to file handle position
+.P
+.B FL pat num
+List files which match pattern
+.P
+.SS WAVES
+.B WVCLR
+Clear all waveforms
+.P
+.B WVNEW
+Initialise a new waveform
+.P
+.B WVAG trips
+Add generic pulses to waveform
+.P
+.B WVAS u b db sb o bvs
+Add serial data to waveform
+.P
+.B WVCRE
+Create a waveform
+.P
+.B WVCAP percent
+Create a waveform of fixed size
+.P
+.B WVDEL wid
+Delete selected waveform
+.P
+.B WVTX wid
+Transmits waveform once
+.P
+.B WVTXM wid wmde
+Transmits waveform using mode
+.P
+.B WVTXR wid
+Transmits waveform repeatedly
+.P
+.B WVCHA bvs
+Transmits a chain of waveforms
+.P
+.B WVTAT
+Returns the current transmitting waveform
+.P
+.B WVBSY
+Check if waveform is being transmitted
+.P
+.B WVHLT
+Stop waveform
+.P
+.B WVSC ws
+Get waveform DMA CB stats
+.P
+.B WVSM ws
+Get waveform time stats
+.P
+.B WVSP ws
+Get waveform pulse stats
+.P
+.SS UTILITIES
+.B H/HELP
+Display command help
+.P
+.B HWVER
+Get hardware version
+.P
+.B MICS v
+Microseconds delay
+.P
+.B MILS v
+Milliseconds delay
+.P
+.B PIGPV
+Get pigpio library version
+.P
+.B T/TICK
+Get current tick
+.P
+.SS CONFIGURATION
+.B CGI
+Configuration get internals
+.P
+.B CSI v
+Configuration set internals
+.P
+
.SH COMMANDS
.br
@@ -540,6 +909,23 @@ This command performs a BSC I2C/SPI slave transfer as defined by
\fBbctl\fP with data \fBbvs\fP.
.br
+This function provides a low-level interface to the SPI/I2C Slave
+peripheral on the BCM chip.
+
+.br
+This peripheral allows the Pi to act as a hardware slave device
+on an I2C or SPI bus.
+
+.br
+This is not a bit bang version and as such is OS timing
+independent. The bus timing is handled directly by the chip.
+
+.br
+The output process is simple. You simply append data to the FIFO
+buffer on the chip. This works like a queue, you add data to the
+queue and the master removes it.
+
+.br
I can't get SPI to work properly. I tried with a
control word of 0x303 and swapped MISO and MOSI.
@@ -560,12 +946,31 @@ For I2C use a control word of (I2C address << 16) + 0x305.
E.g. to talk as I2C slave with address 0x13 use 0x130305.
.br
-The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
-and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
-need to swap MISO/MOSI between master and slave.
+GPIO used for models other than those based on the BCM2711.
.br
-When a zero control word is received GPIO 18-21 will be reset
+
+.EX
+ SDA SCL MOSI SCLK MISO CE
+I2C 18 19 - - - -
+SPI - - 18 19 20 21
+
+.EE
+
+.br
+GPIO used for models based on the BCM2711 (e.g. the Pi4B).
+
+.br
+
+.EX
+ SDA SCL MOSI SCLK MISO CE
+I2C 10 11 - - - -
+SPI - - 10 11 9 8
+
+.EE
+
+.br
+When a zero control word is received the used GPIO will be reset
to INPUT mode.
.br
@@ -641,7 +1046,8 @@ TB transmit busy
.EE
.br
-This example assumes that GPIO 2/3 are connected to GPIO 18/19.
+This example assumes that GPIO 2/3 are connected to GPIO 18/19
+(GPIO 10/11 on the BCM2711).
.br
@@ -1698,11 +2104,11 @@ $ pigs hp 19 100 200000 # 20% dutycycle
.br
.br
-$ pigs hp 19 125000001 100000
+$ pigs hp 19 400000000 100000
.br
-96
.br
-ERROR: hardware PWM frequency not 1-125M
+ERROR: invalid hardware PWM frequency
.br
.EE
@@ -1738,14 +2144,14 @@ The GPIO must be one of the following.
.br
The actual number of steps beween off and fully on is the
-integral part of 250 million divided by \fBpf\fP.
+integral part of 250M/\fBpf\fP (375M/\fBpf\fP for the BCM2711).
.br
-The actual frequency set is 250 million / steps.
+The actual frequency set is 250M/steps (375M/steps for the BCM2711).
.br
-There will only be a million steps for a \fBpf\fP of 250.
-Lower frequencies will have more steps and higher
+There will only be a million steps for a \fBpf\fP of 250 (375 for
+the BCM2711). Lower frequencies will have more steps and higher
frequencies will have fewer steps. \fBpdc\fP is
automatically scaled to take this into account.
@@ -1967,7 +2373,7 @@ $ pigs i2crb 0 0
.br
-.IP "\fBI2CRD h num\fP - i2c Read bytes"
+.IP "\fBI2CRD h num\fP - i2c Read device"
.IP "" 4
.br
@@ -2139,7 +2545,7 @@ $ pigs i2cwb 0 10 0x54
.br
-.IP "\fBI2CWD h bvs\fP - i2c Write data"
+.IP "\fBI2CWD h bvs\fP - i2c Write device"
.IP "" 4
.br
@@ -4414,7 +4820,7 @@ $ pigs wvas 7 38400 8 2 0 0x41 0x42
.br
This command returns the id of the waveform currently
-being transmitted.
+being transmitted. Chained waves are not supported.
.br
Returns the waveform id or one of the following special
@@ -4733,6 +5139,72 @@ ERROR: attempt to create an empty waveform
.br
+.IP "\fBWVCAP percent\fP - Create a waveform of fixed size"
+.IP "" 4
+
+.br
+Create a waveform of fixed size. Similar to \fBWVCRE\fP, this command creates a waveform but pads the consumed resources to a fixed size, specified as a \fBpercent\fP of the total resources. Padded waves of equal size can be re-cycled efficiently allowing newly created waves to re-use the resources of deleted waves of the same dimension.
+
+.br
+Upon success a wave id (>=0) is returned. On error a negative status code will be returned.
+
+.br
+The data provided by the \fBWVAG\fP and \fBWVAS\fP commands are consumed by this command.
+
+.br
+As many waveforms may be created as there is space available. The wave id is passed to \fBWVTX\fP or \fBWVTXR\fP to specify the waveform to transmit.
+
+.br
+Normal usage would be
+
+.br
+Step 1. \fBWVCLR\fP to clear all waveforms and added data.
+
+.br
+Step 2. \fBWVAG\fP/\fBWVAS\fP calls to supply the waveform data.
+
+.br
+Step 3. \fBWVCAP\fP to create a waveform of a uniform size.
+
+.br
+Step 4. \fBWVTX\fP or \fBWVTXR\fP with the id of the waveform to transmit.
+
+.br
+Repeat steps 2 - 4 as needed.
+
+.br
+Step 5. Any wave id can now be deleted and another wave of the same size can be created in its place.
+
+.br
+Example
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+# Create a wave that consumes 50% of the total resource:
+.br
+
+.br
+$ pigs wvag 16 0 5000000 0 16 5000000
+.br
+2
+.br
+$ pigs wvcap 50
+.br
+0
+.br
+$ pigs wvtx 0
+.br
+11918
+.br
+
+.EE
+
+.br
+
.IP "\fBWVDEL wid\fP - Delete selected waveform"
.IP "" 4
@@ -5118,7 +5590,7 @@ The command expects a SPI channel.
.br
-.IP "\fBcf\fP - hardware clock frequency (4689-250M)" 0
+.IP "\fBcf\fP - hardware clock frequency (4689-250M, 13184-375M for the BCM2711)" 0
The command expects a frequency.
.br
@@ -5401,7 +5873,14 @@ The command expects a dutycycle.
.br
-.IP "\fBpf\fP - hardware PWM frequency (1-125M)" 0
+.IP "\fBpercent\fP - percent (1-100)" 0
+The percent of wave resources to allocate to a wave. It can be useful
+to create waves of fixed sizes to prevent wave fragmentation (where
+there are plenty of resources but not a large enough contiguous space).
+
+.br
+
+.IP "\fBpf\fP - hardware PWM frequency (1-125M, 1-187.5M for the BCM2711)" 0
The command expects a frequency.
.br
@@ -5748,11 +6227,36 @@ Each script has
.br
.SS Commands
.br
-All the normal pigs commands may be used within a script. However
-commands which return more than an integer will be of little use.
+Many pigpio commands may be used within a script. However
+some commands do not work within the script model as designed and
+are not permitted.
+
+.br
+The following commands are not permitted within a script:
+
+.br
+File - FL FO FR FW
+
+.br
+I2C - BI2CZ I2CPK I2CRD I2CRI I2CRK I2CWD I2CWI I2CWK I2CZ
+
+.br
+Misc - BSCX CF1 CF2 SHELL
+
+.br
+Script control - PARSE PROC PROCD PROCP PROCR PROCS PROCU
+
+.br
+Serial - SERO SERR SERW SLR
+
+.br
+SPI - BSPIO BSPIX SPIR SPIW SPIX
+
+.br
+Waves - WVAG WVAS WVCHA WVGO WVGOR
.br
-The following commands are only legal within a script.
+The following commands are only permitted within a script:
.br
diff --git a/pigs.c b/pigs.c
index 0d0f44e..928afa3 100644
--- a/pigs.c
+++ b/pigs.c
@@ -26,7 +26,7 @@ For more information, please refer to <http://unlicense.org/>
*/
/*
-This version is for pigpio version 67+
+This version is for pigpio version 69+
*/
#include <stdio.h>
@@ -233,8 +233,9 @@ void print_result(int sock, int rv, cmdCmd_t cmd)
*/
if (r < 0)
{
- printf("%d", r);
+ printf("%d\n", r);
report(PIGS_SCRIPT_ERR, "ERROR: %s", cmdErrStr(r));
+ break;
}
p = (uint32_t *)response_buf;
diff --git a/setup.py b/setup.py
index 9de06d2..4dbb8a9 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
from distutils.core import setup
setup(name='pigpio',
- version='1.42',
+ version='1.78',
author='joan',
author_email='joan@abyz.me.uk',
maintainer='joan',
diff --git a/util/pigpiod b/util/pigpiod
deleted file mode 100755
index 59ba142..0000000
--- a/util/pigpiod
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-### BEGIN INIT INFO
-# Provides: pigpiod
-# Required-Start:
-# Required-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: pigpio daemon
-# Description: pigpio daemon required to control GPIO pins via pigpio $
-### END INIT INFO
-
-# Actions
-case "$1" in
- start)
- pigpiod
- ;;
- stop)
- pkill pigpiod
- ;;
- restart)
- pkill pigpiod
- pigpiod
- ;;
- *)
- echo "Usage: $0 start" >&2
- exit 3
- ;;
-esac
-
-exit 0
-
diff --git a/util/pigpiod.service b/util/pigpiod.service
index b1d28a6..f040d38 100644
--- a/util/pigpiod.service
+++ b/util/pigpiod.service
@@ -2,7 +2,8 @@
Description=Pigpio daemon
[Service]
-Type=simple
+Type=forking
+PIDFile=pigpio.pid
ExecStart=/usr/bin/pigpiod
[Install]
diff --git a/x_pigpio.c b/x_pigpio.c
index c51732a..8119d73 100644
--- a/x_pigpio.c
+++ b/x_pigpio.c
@@ -63,10 +63,12 @@ void t1()
CHECK(1, 1, v, 0, 0, "set mode, get mode");
gpioSetPullUpDown(GPIO, PI_PUD_UP);
+ gpioDelay(1); /* 1 micro delay to let GPIO reach level reliably */
v = gpioRead(GPIO);
CHECK(1, 2, v, 1, 0, "set pull up down, read");
gpioSetPullUpDown(GPIO, PI_PUD_DOWN);
+ gpioDelay(1); /* 1 micro delay to let GPIO reach level reliably */
v = gpioRead(GPIO);
CHECK(1, 3, v, 0, 0, "set pull up down, read");
@@ -457,6 +459,51 @@ To the lascivious pleasing of a lute.\n\
c = gpioWaveGetMaxCbs();
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
+
+ /* waveCreatePad tests */
+ gpioWaveTxStop();
+ gpioWaveClear();
+ gpioSetAlertFunc(GPIO, t5cbf);
+
+ e = gpioWaveAddGeneric(2, (gpioPulse_t[])
+ { {1<<GPIO, 0, 10000},
+ {0, 1<<GPIO, 30000}
+ });
+ wid = gpioWaveCreatePad(50, 50, 0);
+ CHECK(5, 22, wid, 0, 0, "wave create pad, count==1, wid==");
+
+ e = gpioWaveAddGeneric(4, (gpioPulse_t[])
+ { {1<<GPIO, 0, 10000},
+ {0, 1<<GPIO, 30000},
+ {1<<GPIO, 0, 60000},
+ {0, 1<<GPIO, 100000}
+ });
+ wid = gpioWaveCreatePad(50, 50, 0);
+ CHECK(5, 23, wid, 1, 0, "wave create pad, count==2, wid==");
+
+ c = gpioWaveDelete(0);
+ CHECK(5, 24, c, 0, 0, "delete wid==0 success");
+
+ e = gpioWaveAddGeneric(6, (gpioPulse_t[])
+ { {1<<GPIO, 0, 10000},
+ {0, 1<<GPIO, 30000},
+ {1<<GPIO, 0, 60000},
+ {0, 1<<GPIO, 100000},
+ {1<<GPIO, 0, 60000},
+ {0, 1<<GPIO, 100000}
+ });
+ c = gpioWaveCreate();
+ CHECK(5, 25, c, -67, 0, "No more CBs using wave create");
+ wid = gpioWaveCreatePad(50, 50, 0);
+ CHECK(5, 26, wid, 0, 0, "wave create pad, count==3, wid==");
+
+ t5_count = 0;
+ e = gpioWaveChain((char[]) {1,0}, 2);
+ CHECK(5, 27, e, 0, 0, "wave chain [1,0]");
+ while (gpioWaveTxBusy()) time_sleep(0.1);
+ CHECK(5, 28, t5_count, 5, 1, "callback count==");
+
+ gpioSetAlertFunc(GPIO, NULL);
}
int t6_count;
diff --git a/x_pigpio.py b/x_pigpio.py
index 37459d3..e066e76 100755
--- a/x_pigpio.py
+++ b/x_pigpio.py
@@ -483,6 +483,47 @@ To the lascivious pleasing of a lute.
e = pi.wave_delete(0)
CHECK(5, 33, e, 0, 0, "wave delete")
+ # wave_create_and_pad tests
+ t5cb = pi.callback(GPIO, pigpio.FALLING_EDGE, t5cbf)
+ pi.wave_clear()
+
+ pi.wave_add_generic([pigpio.pulse(1<<GPIO, 0, 10000),
+ pigpio.pulse(0, 1<<GPIO, 30000)])
+ wid = pi.wave_create_and_pad(50)
+ CHECK(5, 34, wid, 0, 0, "wave create and pad, wid==")
+
+ pi.wave_add_generic([pigpio.pulse(1<<GPIO, 0, 10000),
+ pigpio.pulse(0, 1<<GPIO, 30000),
+ pigpio.pulse(1<<GPIO, 0, 60000),
+ pigpio.pulse(0, 1<<GPIO, 100000)])
+ wid = pi.wave_create_and_pad(50)
+ CHECK(5, 35, wid, 1, 0, "wave create and pad, wid==")
+
+ c = pi.wave_delete(0);
+ CHECK(5, 36, c, 0, 0, "delete wid==0 success");
+
+ pi.wave_add_generic([pigpio.pulse(1<<GPIO, 0, 10000),
+ pigpio.pulse(0, 1<<GPIO, 30000),
+ pigpio.pulse(1<<GPIO, 0, 60000),
+ pigpio.pulse(0, 1<<GPIO, 100000),
+ pigpio.pulse(1<<GPIO, 0, 60000),
+ pigpio.pulse(0, 1<<GPIO, 100000)])
+ pigpio.exceptions = False
+ c = pi.wave_create()
+ CHECK(5, 37, c, -67, 0, "No more CBs using wave create")
+ pigpio.exceptions = True
+
+ wid = pi.wave_create_and_pad(50)
+ CHECK(5, 38, wid, 0, 0, "wave create pad, count==3, wid==")
+
+ t5_count = 0;
+ e = pi.wave_chain([1,0])
+ CHECK(5, 39, e, 0, 0, "wave chain [1,0]")
+ while pi.wave_tx_busy():
+ time.sleep(0.2)
+ CHECK(5, 40, t5_count, 10, 1, "callback count==")
+
+
t5cb.cancel()
t6_count=0
diff --git a/x_pigpiod_if2.c b/x_pigpiod_if2.c
index 0494401..c9b2c27 100644
--- a/x_pigpiod_if2.c
+++ b/x_pigpiod_if2.c
@@ -434,6 +434,50 @@ To the lascivious pleasing of a lute.\n\
CHECK(5, 21, c, 25016, 0, "wave get max cbs");
callback_cancel(id);
+
+ /* wave create and pad tests */
+ id = callback(pi, GPIO, FALLING_EDGE, t5cbf);
+ e = wave_clear(pi);
+
+ e = wave_add_generic(pi, 2, (gpioPulse_t[])
+ { {1<<GPIO, 0, 10000},
+ {0, 1<<GPIO, 30000}
+ });
+ wid = wave_create_and_pad(pi, 50);
+ CHECK(5, 22, wid, 0, 0, "wave create pad, count==1, wid==");
+
+ e = wave_add_generic(pi, 4, (gpioPulse_t[])
+ { {1<<GPIO, 0, 10000},
+ {0, 1<<GPIO, 30000},
+ {1<<GPIO, 0, 60000},
+ {0, 1<<GPIO, 100000}
+ });
+ wid = wave_create_and_pad(pi, 50);
+ CHECK(5, 23, wid, 1, 0, "wave create pad, count==2, wid==");
+
+ c = wave_delete(pi, 0);
+ CHECK(5, 24, c, 0, 0, "delete wid==0 success");
+
+ e = wave_add_generic(pi, 6, (gpioPulse_t[])
+ { {1<<GPIO, 0, 10000},
+ {0, 1<<GPIO, 30000},
+ {1<<GPIO, 0, 60000},
+ {0, 1<<GPIO, 100000},
+ {1<<GPIO, 0, 60000},
+ {0, 1<<GPIO, 100000}
+ });
+ c = wave_create(pi);
+ CHECK(5, 25, c, -67, 0, "No more CBs using wave create");
+ wid = wave_create_and_pad(pi, 50);
+ CHECK(5, 26, wid, 0, 0, "wave create pad, count==3, wid==");
+
+ t5_count = 0;
+ e = wave_chain(pi, (char[]) {1,0}, 2);
+ CHECK(5, 27, e, 0, 0, "wave chain [1,0]");
+ while (wave_tx_busy(pi)) time_sleep(0.1);
+ CHECK(5, 28, t5_count, 5, 1, "callback count==");
+
+ callback_cancel(id);
}
int t6_count=0;
diff --git a/x_pigs b/x_pigs
index 125718e..508ea41 100755
--- a/x_pigs
+++ b/x_pigs
@@ -308,3 +308,23 @@ if [[ $s -ge 310 ]]; then echo "WVSP-b ok"; else echo "WVSP-b fail ($s)"; fi
s=$(pigs wvsp 2)
if [[ $s = 12000 ]]; then echo "WVSP-c ok"; else echo "WVSP-c fail ($s)"; fi
+s=$(pigs wvclr )
+s=$(pigs wvag 16 0 5000000 0 16 5000000)
+wid=$(pigs wvcap 50)
+if [[ $wid = 0 ]]; then echo "WVCAP-a ok"; else echo "WVCAP-a fail ($wid)"; fi
+
+s=$(pigs wvag 16 0 5000000 0 16 5000000 16 0 5000000 0 16 5000000)
+wid=$(pigs wvcap 50)
+if [[ $wid = 1 ]]; then echo "WVCAP-b ok"; else echo "WVCAP-b fail ($wid)"; fi
+
+s=$(pigs wvdel 0)
+if [[ $s == "" ]]; then echo "WVCAP-c ok"; else echo "WVCAP-c fail ($s)"; fi
+
+s=$(pigs wvag 16 0 5000000 0 16 5000000 16 0 5000000 0 16 5000000 16 0 5000000 0 16 5000000)
+# Show WVCRE fails
+wid=$(pigs wvcre)
+if [[ $wid = -67 ]]; then echo "WVCAP-d ok"; else echo "WVCAP-d fail ($wid)"; fi
+# but that WVCAP ok
+wid=$(pigs wvcap 50)
+if [[ $wid = 0 ]]; then echo "WVCAP-e ok"; else echo "WVCAP-e fail ($wid)"; fi
+