From 82414d93c33080b8a87514bb6bf8bb1ab7efbc62 Mon Sep 17 00:00:00 2001 From: Peter Michael Green Date: Thu, 28 Jan 2021 19:08:40 +0000 Subject: [PATCH] Import pigpio_1.78.orig.tar.gz [dgit import orig pigpio_1.78.orig.tar.gz] --- .gitignore | 23 + CMakeLists.txt | 127 + CONTRIBUTING.md | 58 + DOC/HTML/images/LDR-fritz.png | Bin 0 -> 42505 bytes DOC/HTML/images/LDR-gnup-1.png | Bin 0 -> 47487 bytes DOC/HTML/images/LDR-gnup-2.png | Bin 0 -> 31410 bytes DOC/HTML/images/LDR-photo.jpg | Bin 0 -> 109499 bytes DOC/HTML/images/LDR-wave-1.png | Bin 0 -> 4557 bytes DOC/HTML/images/LDR-wave-2.png | Bin 0 -> 4438 bytes DOC/HTML/images/LDR-wave-3.png | Bin 0 -> 4872 bytes DOC/HTML/images/breadboard.jpg | Bin 0 -> 46953 bytes DOC/HTML/images/caps.jpg | Bin 0 -> 35397 bytes DOC/HTML/images/driver.jpg | Bin 0 -> 41058 bytes DOC/HTML/images/faq-i2c-ss.png | Bin 0 -> 9006 bytes DOC/HTML/images/faq-i2c.jpg | Bin 0 -> 42782 bytes DOC/HTML/images/faq-serial.jpg | Bin 0 -> 40297 bytes DOC/HTML/images/faq-spi.jpg | Bin 0 -> 43222 bytes DOC/HTML/images/faq1.jpg | Bin 0 -> 14196 bytes DOC/HTML/images/faq2.jpg | Bin 0 -> 37418 bytes DOC/HTML/images/faq3.jpg | Bin 0 -> 6686 bytes DOC/HTML/images/imu-1.jpg | Bin 0 -> 44650 bytes DOC/HTML/images/imu-2.jpg | Bin 0 -> 42737 bytes DOC/HTML/images/imu-3.jpg | Bin 0 -> 42800 bytes DOC/HTML/images/ir-fritz.png | Bin 0 -> 40477 bytes DOC/HTML/images/ir-motion.jpg | Bin 0 -> 22139 bytes DOC/HTML/images/ir-photo.jpg | Bin 0 -> 90482 bytes DOC/HTML/images/ir-rx.jpg | Bin 0 -> 32358 bytes DOC/HTML/images/ir-wave-1.png | Bin 0 -> 4827 bytes DOC/HTML/images/ir-wave-2.png | Bin 0 -> 4237 bytes DOC/HTML/images/ir-wave-3.png | Bin 0 -> 5038 bytes DOC/HTML/images/keypad.jpg | Bin 0 -> 30294 bytes DOC/HTML/images/lcd.jpg | Bin 0 -> 29926 bytes DOC/HTML/images/ldr-cap.jpg | Bin 0 -> 34448 bytes DOC/HTML/images/ldr.jpg | Bin 0 -> 28458 bytes DOC/HTML/images/leds.jpg | Bin 0 -> 36146 bytes DOC/HTML/images/meter.jpg | Bin 0 -> 29610 bytes DOC/HTML/images/motor.jpg | Bin 0 -> 17593 bytes DOC/HTML/images/msp430.jpg | Bin 0 -> 43686 bytes DOC/HTML/images/nano.jpg | Bin 0 -> 40463 bytes DOC/HTML/images/oled-2.jpg | Bin 0 -> 40888 bytes DOC/HTML/images/oled.jpg | Bin 0 -> 31872 bytes DOC/HTML/images/pigpio-logo.gif | Bin 0 -> 375 bytes DOC/HTML/images/pins.jpg | Bin 0 -> 42788 bytes DOC/HTML/images/pisc-1.jpg | Bin 0 -> 20520 bytes DOC/HTML/images/pisc-2.jpg | Bin 0 -> 17527 bytes DOC/HTML/images/pisc-3.jpg | Bin 0 -> 15915 bytes DOC/HTML/images/pot.jpg | Bin 0 -> 26518 bytes DOC/HTML/images/pro-mini.jpg | Bin 0 -> 36398 bytes DOC/HTML/images/psu.jpg | Bin 0 -> 33988 bytes DOC/HTML/images/re-fritz.png | Bin 0 -> 39702 bytes DOC/HTML/images/re-photo.jpg | Bin 0 -> 50100 bytes DOC/HTML/images/re-wave-1.png | Bin 0 -> 5570 bytes DOC/HTML/images/re-wave-2.png | Bin 0 -> 5404 bytes DOC/HTML/images/remote-1.jpg | Bin 0 -> 27199 bytes DOC/HTML/images/remote-2.jpg | Bin 0 -> 28482 bytes DOC/HTML/images/reverse.jpg | Bin 0 -> 35860 bytes DOC/HTML/images/rf-rx-2.jpg | Bin 0 -> 34515 bytes DOC/HTML/images/rf-rx.jpg | Bin 0 -> 31082 bytes DOC/HTML/images/rf-tx.jpg | Bin 0 -> 40421 bytes DOC/HTML/images/rotary.jpg | Bin 0 -> 22765 bytes DOC/HTML/images/rpi.jpg | Bin 0 -> 37698 bytes DOC/HTML/images/serial.jpg | Bin 0 -> 29831 bytes DOC/HTML/images/servo.jpg | Bin 0 -> 28811 bytes DOC/HTML/images/sidebar.gif | Bin 0 -> 52 bytes DOC/HTML/images/son-fritz.png | Bin 0 -> 69915 bytes DOC/HTML/images/son-gnup-1.png | Bin 0 -> 15447 bytes DOC/HTML/images/son-gnup-2.png | Bin 0 -> 12101 bytes DOC/HTML/images/son-photo.jpg | Bin 0 -> 69827 bytes DOC/HTML/images/son-wave-1.png | Bin 0 -> 4410 bytes DOC/HTML/images/son-wave-2.png | Bin 0 -> 4293 bytes DOC/HTML/images/son-wave-3.png | Bin 0 -> 4757 bytes DOC/HTML/images/son-wave-4.png | Bin 0 -> 5270 bytes DOC/HTML/images/speaker.jpg | Bin 0 -> 34456 bytes DOC/HTML/images/spi-lnx-pi3b.png | Bin 0 -> 9134 bytes DOC/HTML/images/spi-lnx-pibr1.png | Bin 0 -> 7174 bytes DOC/HTML/images/spi-pig-pi3b.png | Bin 0 -> 8896 bytes DOC/HTML/images/spi-pig-pibr1.png | Bin 0 -> 8502 bytes DOC/HTML/images/srf02.jpg | Bin 0 -> 26595 bytes DOC/HTML/images/srf04.jpg | Bin 0 -> 33664 bytes DOC/HTML/images/stepper.jpg | Bin 0 -> 30634 bytes DOC/HTML/images/switches.jpg | Bin 0 -> 43275 bytes DOC/HTML/images/topbar.gif | Bin 0 -> 1015 bytes DOC/HTML/images/transistors.jpg | Bin 0 -> 43174 bytes DOC/HTML/images/ubec-2.jpg | Bin 0 -> 18920 bytes DOC/HTML/images/uln2003a.jpg | Bin 0 -> 26817 bytes DOC/HTML/images/wheel.jpg | Bin 0 -> 23241 bytes DOC/HTML/images/wires.jpg | Bin 0 -> 36804 bytes DOC/HTML/images/yl-40.jpg | Bin 0 -> 43771 bytes DOC/HTML/scripts/index.css | 52 + DOC/HTML/scripts/standard.css | 3 + DOC/MAN/README | 1 + DOC/README | 16 + DOC/bin/backup.sh | 5 + DOC/bin/body.py | 14 + DOC/bin/build_site.py | 21 + DOC/bin/cmakdoc.py | 563 + DOC/bin/examples.py | 123 + DOC/bin/html.py | 137 + DOC/bin/purge.sh | 14 + DOC/bin/pymakdoc.py | 270 + DOC/bin/smakdoc.py | 376 + DOC/bin/tidy.py | 28 + DOC/bin/updatesql.py | 21 + DOC/dbase/pigpio.sqlite | Bin 0 -> 1433600 bytes DOC/makedoc | 47 + DOC/src/defs/examples.def | 521 + DOC/src/defs/pig2vcd.def | 110 + DOC/src/defs/pigpiod.def | 101 + DOC/src/defs/pigs.def | 3482 ++++ DOC/src/html/download.html | 68 + DOC/src/html/ex_LDR.html | 150 + DOC/src/html/ex_ir_remote.html | 253 + DOC/src/html/ex_motor_shield.html | 254 + DOC/src/html/ex_rotary_encoder.html | 185 + DOC/src/html/ex_sonar_ranger.html | 164 + DOC/src/html/faq.html | 462 + DOC/src/html/index.html | 659 + DOC/src/html/misc.html | 33 + DOC/src/html/pif.html | 30 + DOC/src/html/piscope.html | 216 + DOC/src/html/sif.html | 2004 +++ EXAMPLES/C/COUNTER_1/README | 3 + EXAMPLES/C/COUNTER_1/freq_count_1.c | 238 + EXAMPLES/C/COUNTER_2/README | 6 + EXAMPLES/C/COUNTER_2/freq_count_2.c | 257 + EXAMPLES/C/HALL_EFFECT_SENSOR/README | 2 + EXAMPLES/C/HALL_EFFECT_SENSOR/hall.c | 51 + EXAMPLES/C/I2C_SNIFFER/README | 4 + EXAMPLES/C/I2C_SNIFFER/pig2i2c.c | 205 + EXAMPLES/C/IR_RECEIVER/README | 3 + EXAMPLES/C/IR_RECEIVER/ir_hasher.c | 136 + EXAMPLES/C/IR_RECEIVER/ir_hasher.h | 33 + EXAMPLES/C/IR_RECEIVER/test_ir_hasher.c | 47 + EXAMPLES/C/PCF8591_YL-40/PCF8591.c | 131 + EXAMPLES/C/PCF8591_YL-40/README | 1 + EXAMPLES/C/POT_CAP_RECHARGE/README | 3 + EXAMPLES/C/POT_CAP_RECHARGE/pot_cap_charge.c | 94 + EXAMPLES/C/ROTARY_ENCODER/README | 4 + EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.c | 94 + EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.h | 25 + .../C/ROTARY_ENCODER/test_rotary_encoder.c | 47 + EXAMPLES/C/WIEGAND_CODE/README | 4 + EXAMPLES/C/WIEGAND_CODE/test_wiegand.c | 42 + EXAMPLES/C/WIEGAND_CODE/wiegand.c | 137 + EXAMPLES/C/WIEGAND_CODE/wiegand.h | 32 + EXAMPLES/CPP/IR_RECEIVER/README | 4 + EXAMPLES/CPP/IR_RECEIVER/ir_hasher.cpp | 91 + EXAMPLES/CPP/IR_RECEIVER/ir_hasher.hpp | 44 + EXAMPLES/CPP/IR_RECEIVER/test_ir_hasher.cpp | 44 + EXAMPLES/CPP/ROTARY_ENCODER/README | 4 + .../CPP/ROTARY_ENCODER/rotary_encoder.cpp | 84 + .../CPP/ROTARY_ENCODER/rotary_encoder.hpp | 35 + .../ROTARY_ENCODER/test_rotary_encoder.cpp | 45 + EXAMPLES/CPP/WIEGAND_CODE/README | 3 + EXAMPLES/CPP/WIEGAND_CODE/test_wiegand.cpp | 40 + EXAMPLES/CPP/WIEGAND_CODE/wiegand.cpp | 116 + EXAMPLES/CPP/WIEGAND_CODE/wiegand.hpp | 43 + EXAMPLES/Python/DHT11_SENSOR/README | 2 + EXAMPLES/Python/DHT11_SENSOR/dht11.py | 163 + EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py | 283 + EXAMPLES/Python/DHT22_AM2302_SENSOR/README | 2 + EXAMPLES/Python/GPIO_STATUS/README | 2 + EXAMPLES/Python/GPIO_STATUS/gpio_status.py | 65 + EXAMPLES/Python/HALL_EFFECT_SENSOR/README | 2 + EXAMPLES/Python/HALL_EFFECT_SENSOR/hall.py | 32 + EXAMPLES/Python/I2C_SNIFFER/I2C_sniffer.py | 163 + EXAMPLES/Python/I2C_SNIFFER/README | 2 + EXAMPLES/Python/IR_RECEIVER/README | 2 + EXAMPLES/Python/IR_RECEIVER/ir_hasher.py | 165 + EXAMPLES/Python/MORSE_CODE/README | 2 + EXAMPLES/Python/MORSE_CODE/morse_code.py | 72 + EXAMPLES/Python/PCF8591_YL-40/PCF8591.py | 64 + EXAMPLES/Python/PCF8591_YL-40/README | 2 + EXAMPLES/Python/PIGPIO_BENCHMARK/README | 2 + EXAMPLES/Python/PIGPIO_BENCHMARK/bench_1.py | 91 + EXAMPLES/Python/ROTARY_ENCODER/README | 2 + .../Python/ROTARY_ENCODER/rotary_encoder.py | 135 + EXAMPLES/Python/SONAR_RANGER/README | 2 + .../Python/SONAR_RANGER/sonar_trigger_echo.py | 114 + EXAMPLES/Python/VIRTUAL_WIRE/README | 2 + EXAMPLES/Python/VIRTUAL_WIRE/vw.py | 372 + EXAMPLES/Python/WIEGAND_CODE/README | 2 + EXAMPLES/Python/WIEGAND_CODE/wiegand.py | 135 + EXAMPLES/Shell/GPIOTEST/README | 7 + EXAMPLES/Shell/GPIOTEST/gpiotest | 126 + MakeRemote | 101 + Makefile | 164 + README | 174 + README.md | 82 + SUPPORT.md | 8 + UNLICENCE | 25 + cmake/FindRT.cmake | 39 + cmake/pigpioConfig.cmake | 1 + cmake/setup.py.in | 24 + command.c | 1422 ++ command.h | 124 + custom.cext | 54 + pig2vcd.1 | 246 + pig2vcd.c | 121 + pigpio.3 | 11145 ++++++++++++ pigpio.c | 14018 ++++++++++++++++ pigpio.h | 6579 ++++++++ pigpio.py | 5783 +++++++ pigpiod.1 | 273 + pigpiod.c | 417 + pigpiod_if.3 | 5339 ++++++ pigpiod_if.c | 1572 ++ pigpiod_if.h | 2996 ++++ pigpiod_if2.3 | 8057 +++++++++ pigpiod_if2.c | 2126 +++ pigpiod_if2.h | 4379 +++++ pigs.1 | 6333 +++++++ pigs.c | 394 + pigs.h | 41 + setup.py | 23 + util/Findpigpio.cmake | 31 + util/pigpiod.service | 10 + util/readme.md | 31 + x_pigpio.c | 952 ++ x_pigpio.py | 1041 ++ x_pigpiod_if.c | 875 + x_pigpiod_if2.c | 931 + x_pigs | 330 + x_pipe | 425 + 224 files changed, 91442 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 CONTRIBUTING.md create mode 100644 DOC/HTML/images/LDR-fritz.png create mode 100644 DOC/HTML/images/LDR-gnup-1.png create mode 100644 DOC/HTML/images/LDR-gnup-2.png create mode 100644 DOC/HTML/images/LDR-photo.jpg create mode 100644 DOC/HTML/images/LDR-wave-1.png create mode 100644 DOC/HTML/images/LDR-wave-2.png create mode 100644 DOC/HTML/images/LDR-wave-3.png create mode 100644 DOC/HTML/images/breadboard.jpg create mode 100644 DOC/HTML/images/caps.jpg create mode 100644 DOC/HTML/images/driver.jpg create mode 100644 DOC/HTML/images/faq-i2c-ss.png create mode 100644 DOC/HTML/images/faq-i2c.jpg create mode 100644 DOC/HTML/images/faq-serial.jpg create mode 100644 DOC/HTML/images/faq-spi.jpg create mode 100644 DOC/HTML/images/faq1.jpg create mode 100644 DOC/HTML/images/faq2.jpg create mode 100644 DOC/HTML/images/faq3.jpg create mode 100644 DOC/HTML/images/imu-1.jpg create mode 100644 DOC/HTML/images/imu-2.jpg create mode 100644 DOC/HTML/images/imu-3.jpg create mode 100644 DOC/HTML/images/ir-fritz.png create mode 100644 DOC/HTML/images/ir-motion.jpg create mode 100644 DOC/HTML/images/ir-photo.jpg create mode 100644 DOC/HTML/images/ir-rx.jpg create mode 100644 DOC/HTML/images/ir-wave-1.png create mode 100644 DOC/HTML/images/ir-wave-2.png create mode 100644 DOC/HTML/images/ir-wave-3.png create mode 100644 DOC/HTML/images/keypad.jpg create mode 100644 DOC/HTML/images/lcd.jpg create mode 100644 DOC/HTML/images/ldr-cap.jpg create mode 100644 DOC/HTML/images/ldr.jpg create mode 100644 DOC/HTML/images/leds.jpg create mode 100644 DOC/HTML/images/meter.jpg create mode 100644 DOC/HTML/images/motor.jpg create mode 100644 DOC/HTML/images/msp430.jpg create mode 100644 DOC/HTML/images/nano.jpg create mode 100644 DOC/HTML/images/oled-2.jpg create mode 100644 DOC/HTML/images/oled.jpg create mode 100644 DOC/HTML/images/pigpio-logo.gif create mode 100644 DOC/HTML/images/pins.jpg create mode 100644 DOC/HTML/images/pisc-1.jpg create mode 100644 DOC/HTML/images/pisc-2.jpg create mode 100644 DOC/HTML/images/pisc-3.jpg create mode 100644 DOC/HTML/images/pot.jpg create mode 100644 DOC/HTML/images/pro-mini.jpg create mode 100644 DOC/HTML/images/psu.jpg create mode 100644 DOC/HTML/images/re-fritz.png create mode 100644 DOC/HTML/images/re-photo.jpg create mode 100644 DOC/HTML/images/re-wave-1.png create mode 100644 DOC/HTML/images/re-wave-2.png create mode 100644 DOC/HTML/images/remote-1.jpg create mode 100644 DOC/HTML/images/remote-2.jpg create mode 100644 DOC/HTML/images/reverse.jpg create mode 100644 DOC/HTML/images/rf-rx-2.jpg create mode 100644 DOC/HTML/images/rf-rx.jpg create mode 100644 DOC/HTML/images/rf-tx.jpg create mode 100644 DOC/HTML/images/rotary.jpg create mode 100644 DOC/HTML/images/rpi.jpg create mode 100644 DOC/HTML/images/serial.jpg create mode 100644 DOC/HTML/images/servo.jpg create mode 100644 DOC/HTML/images/sidebar.gif create mode 100644 DOC/HTML/images/son-fritz.png create mode 100644 DOC/HTML/images/son-gnup-1.png create mode 100644 DOC/HTML/images/son-gnup-2.png create mode 100644 DOC/HTML/images/son-photo.jpg create mode 100644 DOC/HTML/images/son-wave-1.png create mode 100644 DOC/HTML/images/son-wave-2.png create mode 100644 DOC/HTML/images/son-wave-3.png create mode 100644 DOC/HTML/images/son-wave-4.png create mode 100644 DOC/HTML/images/speaker.jpg create mode 100644 DOC/HTML/images/spi-lnx-pi3b.png create mode 100644 DOC/HTML/images/spi-lnx-pibr1.png create mode 100644 DOC/HTML/images/spi-pig-pi3b.png create mode 100644 DOC/HTML/images/spi-pig-pibr1.png create mode 100644 DOC/HTML/images/srf02.jpg create mode 100644 DOC/HTML/images/srf04.jpg create mode 100644 DOC/HTML/images/stepper.jpg create mode 100644 DOC/HTML/images/switches.jpg create mode 100644 DOC/HTML/images/topbar.gif create mode 100644 DOC/HTML/images/transistors.jpg create mode 100644 DOC/HTML/images/ubec-2.jpg create mode 100644 DOC/HTML/images/uln2003a.jpg create mode 100644 DOC/HTML/images/wheel.jpg create mode 100644 DOC/HTML/images/wires.jpg create mode 100644 DOC/HTML/images/yl-40.jpg create mode 100644 DOC/HTML/scripts/index.css create mode 100644 DOC/HTML/scripts/standard.css create mode 100644 DOC/MAN/README create mode 100644 DOC/README create mode 100755 DOC/bin/backup.sh create mode 100755 DOC/bin/body.py create mode 100755 DOC/bin/build_site.py create mode 100755 DOC/bin/cmakdoc.py create mode 100755 DOC/bin/examples.py create mode 100755 DOC/bin/html.py create mode 100755 DOC/bin/purge.sh create mode 100755 DOC/bin/pymakdoc.py create mode 100755 DOC/bin/smakdoc.py create mode 100755 DOC/bin/tidy.py create mode 100755 DOC/bin/updatesql.py create mode 100644 DOC/dbase/pigpio.sqlite create mode 100755 DOC/makedoc create mode 100644 DOC/src/defs/examples.def create mode 100644 DOC/src/defs/pig2vcd.def create mode 100644 DOC/src/defs/pigpiod.def create mode 100644 DOC/src/defs/pigs.def create mode 100644 DOC/src/html/download.html create mode 100644 DOC/src/html/ex_LDR.html create mode 100644 DOC/src/html/ex_ir_remote.html create mode 100644 DOC/src/html/ex_motor_shield.html create mode 100644 DOC/src/html/ex_rotary_encoder.html create mode 100644 DOC/src/html/ex_sonar_ranger.html create mode 100644 DOC/src/html/faq.html create mode 100644 DOC/src/html/index.html create mode 100644 DOC/src/html/misc.html create mode 100644 DOC/src/html/pif.html create mode 100644 DOC/src/html/piscope.html create mode 100644 DOC/src/html/sif.html create mode 100644 EXAMPLES/C/COUNTER_1/README create mode 100644 EXAMPLES/C/COUNTER_1/freq_count_1.c create mode 100644 EXAMPLES/C/COUNTER_2/README create mode 100644 EXAMPLES/C/COUNTER_2/freq_count_2.c create mode 100644 EXAMPLES/C/HALL_EFFECT_SENSOR/README create mode 100644 EXAMPLES/C/HALL_EFFECT_SENSOR/hall.c create mode 100644 EXAMPLES/C/I2C_SNIFFER/README create mode 100644 EXAMPLES/C/I2C_SNIFFER/pig2i2c.c create mode 100644 EXAMPLES/C/IR_RECEIVER/README create mode 100644 EXAMPLES/C/IR_RECEIVER/ir_hasher.c create mode 100644 EXAMPLES/C/IR_RECEIVER/ir_hasher.h create mode 100644 EXAMPLES/C/IR_RECEIVER/test_ir_hasher.c create mode 100644 EXAMPLES/C/PCF8591_YL-40/PCF8591.c create mode 100644 EXAMPLES/C/PCF8591_YL-40/README create mode 100644 EXAMPLES/C/POT_CAP_RECHARGE/README create mode 100644 EXAMPLES/C/POT_CAP_RECHARGE/pot_cap_charge.c create mode 100644 EXAMPLES/C/ROTARY_ENCODER/README create mode 100644 EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.c create mode 100644 EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.h create mode 100644 EXAMPLES/C/ROTARY_ENCODER/test_rotary_encoder.c create mode 100644 EXAMPLES/C/WIEGAND_CODE/README create mode 100644 EXAMPLES/C/WIEGAND_CODE/test_wiegand.c create mode 100644 EXAMPLES/C/WIEGAND_CODE/wiegand.c create mode 100644 EXAMPLES/C/WIEGAND_CODE/wiegand.h create mode 100644 EXAMPLES/CPP/IR_RECEIVER/README create mode 100644 EXAMPLES/CPP/IR_RECEIVER/ir_hasher.cpp create mode 100644 EXAMPLES/CPP/IR_RECEIVER/ir_hasher.hpp create mode 100644 EXAMPLES/CPP/IR_RECEIVER/test_ir_hasher.cpp create mode 100644 EXAMPLES/CPP/ROTARY_ENCODER/README create mode 100644 EXAMPLES/CPP/ROTARY_ENCODER/rotary_encoder.cpp create mode 100644 EXAMPLES/CPP/ROTARY_ENCODER/rotary_encoder.hpp create mode 100644 EXAMPLES/CPP/ROTARY_ENCODER/test_rotary_encoder.cpp create mode 100644 EXAMPLES/CPP/WIEGAND_CODE/README create mode 100644 EXAMPLES/CPP/WIEGAND_CODE/test_wiegand.cpp create mode 100644 EXAMPLES/CPP/WIEGAND_CODE/wiegand.cpp create mode 100644 EXAMPLES/CPP/WIEGAND_CODE/wiegand.hpp create mode 100644 EXAMPLES/Python/DHT11_SENSOR/README create mode 100644 EXAMPLES/Python/DHT11_SENSOR/dht11.py create mode 100755 EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py create mode 100644 EXAMPLES/Python/DHT22_AM2302_SENSOR/README create mode 100644 EXAMPLES/Python/GPIO_STATUS/README create mode 100755 EXAMPLES/Python/GPIO_STATUS/gpio_status.py create mode 100644 EXAMPLES/Python/HALL_EFFECT_SENSOR/README create mode 100755 EXAMPLES/Python/HALL_EFFECT_SENSOR/hall.py create mode 100755 EXAMPLES/Python/I2C_SNIFFER/I2C_sniffer.py create mode 100644 EXAMPLES/Python/I2C_SNIFFER/README create mode 100644 EXAMPLES/Python/IR_RECEIVER/README create mode 100755 EXAMPLES/Python/IR_RECEIVER/ir_hasher.py create mode 100644 EXAMPLES/Python/MORSE_CODE/README create mode 100755 EXAMPLES/Python/MORSE_CODE/morse_code.py create mode 100755 EXAMPLES/Python/PCF8591_YL-40/PCF8591.py create mode 100644 EXAMPLES/Python/PCF8591_YL-40/README create mode 100644 EXAMPLES/Python/PIGPIO_BENCHMARK/README create mode 100755 EXAMPLES/Python/PIGPIO_BENCHMARK/bench_1.py create mode 100644 EXAMPLES/Python/ROTARY_ENCODER/README create mode 100755 EXAMPLES/Python/ROTARY_ENCODER/rotary_encoder.py create mode 100644 EXAMPLES/Python/SONAR_RANGER/README create mode 100755 EXAMPLES/Python/SONAR_RANGER/sonar_trigger_echo.py create mode 100644 EXAMPLES/Python/VIRTUAL_WIRE/README create mode 100755 EXAMPLES/Python/VIRTUAL_WIRE/vw.py create mode 100644 EXAMPLES/Python/WIEGAND_CODE/README create mode 100755 EXAMPLES/Python/WIEGAND_CODE/wiegand.py create mode 100644 EXAMPLES/Shell/GPIOTEST/README create mode 100755 EXAMPLES/Shell/GPIOTEST/gpiotest create mode 100644 MakeRemote create mode 100644 Makefile create mode 100644 README create mode 100644 README.md create mode 100644 SUPPORT.md create mode 100644 UNLICENCE create mode 100644 cmake/FindRT.cmake create mode 100644 cmake/pigpioConfig.cmake create mode 100644 cmake/setup.py.in create mode 100644 command.c create mode 100644 command.h create mode 100644 custom.cext create mode 100644 pig2vcd.1 create mode 100644 pig2vcd.c create mode 100644 pigpio.3 create mode 100644 pigpio.c create mode 100644 pigpio.h create mode 100644 pigpio.py create mode 100644 pigpiod.1 create mode 100644 pigpiod.c create mode 100644 pigpiod_if.3 create mode 100644 pigpiod_if.c create mode 100644 pigpiod_if.h create mode 100644 pigpiod_if2.3 create mode 100644 pigpiod_if2.c create mode 100644 pigpiod_if2.h create mode 100644 pigs.1 create mode 100644 pigs.c create mode 100644 pigs.h create mode 100644 setup.py create mode 100644 util/Findpigpio.cmake create mode 100644 util/pigpiod.service create mode 100644 util/readme.md create mode 100644 x_pigpio.c create mode 100755 x_pigpio.py create mode 100644 x_pigpiod_if.c create mode 100644 x_pigpiod_if2.c create mode 100755 x_pigs create mode 100755 x_pipe diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fcdcc13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +*.o +*.so +*.so.* +*.pyc +pig2vcd +pigpiod +pigs +x_pigpio +x_pigpiod_if +x_pigpiod_if2 +__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 new file mode 100644 index 0000000..383c445 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,127 @@ +cmake_minimum_required(VERSION 3.0) + +project(pigpio LANGUAGES C VERSION 0.71) + +list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) + +find_package(Threads REQUIRED) +find_package(RT REQUIRED) + +option(BUILD_SHARED_LIBS "Create shared libraries" 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) +target_link_libraries(x_pigpio pigpio RT::RT Threads::Threads) + +# x_pigpiod_if +add_executable(x_pigpiod_if x_pigpiod_if.c) +target_link_libraries(x_pigpiod_if pigpiod_if RT::RT Threads::Threads) + +# x_pigpiod_if2 +add_executable(x_pigpiod_if2 x_pigpiod_if2.c) +target_link_libraries(x_pigpiod_if2 pigpiod_if2 RT::RT Threads::Threads) + +# pigpiod +add_executable(pigpiod pigpiod.c) +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) + +# Configure and install project + +include (GenerateExportHeader) +include (CMakePackageConfigHelpers) + +generate_export_header(${PROJECT_NAME}) + +install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs + 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 include + PERMISSIONS OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ +) + +file(GLOB man_1_SRC "*.1") +install(FILES ${man_1_SRC} + DESTINATION man/man1 + PERMISSIONS OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ +) + +file(GLOB man_3_SRC "*.3") +install(FILES ${man_3_SRC} + DESTINATION man/man3 + PERMISSIONS OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ +) + +# Install python modules. +find_package(Python COMPONENTS Interpreter QUIET) + +if(Python_FOUND) + configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/setup.py.in + ${CMAKE_CURRENT_BINARY_DIR}/setup.py + ) + + install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)") +endif() + +# package project + +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//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 +``` +- 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 +``` +- 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 0000000000000000000000000000000000000000..62655853dc5e85e94e128fb89191f05265dbbf58 GIT binary patch literal 42505 zcmXtg2RzmP_kW4ZByPyZCa$e)+4I_aZ$(!2p4r)4GPCzek*v%cl4K`@Bv~P|?Emro zJ^r^x@xJ#x?)&|Ez0Nt$af;DYSG++$MR4WHl^aSZIc@m);mVb(oOoF98-Awa8vM9! zt)eJ*<>K;BL3?@XlSSB)NDxk7(M zNlseVcjkAlU*_$}m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awQcd5#bTH3UBpk+sE#**Vi}5FU>!ge!x5HzdrsC&?GQ- Ty|O-`00000NkvXXu0mjfBij1Z literal 0 HcmV?d00001 diff --git a/DOC/HTML/images/LDR-gnup-1.png b/DOC/HTML/images/LDR-gnup-1.png new file mode 100644 index 0000000000000000000000000000000000000000..6ec61943d3f6a8ed1341fef77b34b035771c511a GIT binary patch literal 47487 zcmb5W1z1#V*fqL`p(O+*B~(HINhxVWy1PT^21&_5UO`D|rMo)>$x#HPTe?J~yZe7e z-}gKJf39<#>zwh@k#Y9kPu}-h>t2uVRFtIgaVc>j2*Q_@d8P(I7~rpHCD>@-?Kn$= z2E1Xuke7Z2U88=bH|52EPjH-MbX_3m#x2xu7?hYy4nD+kl~t6)n!&`m4dL3hUv@&! zT}bwsxQ6HC#*DR3?BT@Gu4(0i#}g97*!tM%mGs~5|7_P1e`KXktM4o!8Crcdy%ihM ztythzrdK0Ut@G`NR>?>Wb2&f!{zNr0+YxZG2;}TNP5(t{@Gpn5{K=lDauAi#@`3nR?wGwoWZ}F{IA0(9y>Ij{!UI#c5JzHA1&03SPUg& zH>$B2{ZXP{Yd2B(qAi3$KEB$Q3Uw)h;Q3mKG*Ok8~-n2`9X9+4$~*$NV2*eU^wAik0G+iAc3S%gF}@BVUobP$f<7 zftDX5JMsRHC4}gAdPQOo(`m-_@#5m*J{=u+*u~t%Z@$yhQ&tgMu8%)|{>)WQ^P5M) zx@7*YHf8hLsXLUE5wxOUF_lf(eIlZhq7w0`TeaMDKX3Lumx`czV*BG!7lV7ipVg_X zAeKktb1*1fRarUfv)@aa#>&pFEF)8{S7M|UKzkPvgM;cwBXYBLPQ-mC)bYmxE?8xvLK<>kAr?QyNb-bV&4e!lv~t2W^kQ*Lb=I zwo+MSH6J%Om5?U~1B3b0C;Pn4%#>?mZ4>-ITguZ2?d508lbwau?s!()-HDBjjSAC_ zt+^IaA))Cc<{dZ(8a}E;G(9#oTT`{$;e4~6$1@&dCHfv~)MrPV-kl5yjfX$T&-4@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DfJs2lr zTV?q~cqSQWMBk_~(&ejnV_979$jAWbm=3)%1S>fPWn);QFqzK3Q&9fe-vZf=lw") + t = snafu(t, "\n
", "\n") + t = snafu(t, "
", "") + t = snafu(t, "\n
", "\n") + t = snafu(t, "


", "

") + + 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 0000000000000000000000000000000000000000..f24fd30acb732b2cd3b9676e570ebb7a00e94642 GIT binary patch literal 1433600 zcmeFaOLJpMmL^u!(#)9Aq|T8^vYD1NGZ0Hv#Rvr=2)-gBD>FtQ2}V%KR})}HWp`K8 zKoTS|0Rm_|;!!>6-;0epzb^6ouNq5rgEW1Kmg@uNL z@p7fxpRCkszKzOmW3PU8(5kHZ)_R@yo!-4ghwYnA-0}LFZ&}(Kb}wswT(!;o&ug=P zUZ3&v#o+4Ga-}!u-%L6mCk`x2kN)0Q|MO42`s!Z;_kQ|MzWV>Z`hUOrf4=&^zxuzv z`ai$=Kfe0kzWQIk`d_~KpT7DxU;W#!{)eyrwG{fBf}?4i2?7ZM2?7ZM2?7ZM2?7ZM z2?7ZM2?7ZM2?Bq^A@I|G{2yZmpZ)`U{Ez<;KK{*rh>z(%#K+&mzn_f%7$1K{ll$P` z!^gWNe02W-K7RA}@$nZd^XIhWzxj9Y@%oSOk^V~%NDxR6NDxR6NDxR6NDxR6NDxR6 zNDxR6NDxR6NDxR6NDxR6NDx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ai+seb?f literal 0 HcmV?d00001 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 C and Python. + +?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. Video + +?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 gpioSetAlertFunc 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μs). + +?3|freq_count_2|2014-08-20|Frequency Counter 2 +A program showing how to use the gpioSetGetSamplesFunc 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μ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 μ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</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<=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<=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 @@ + + + + + +download + + +If the pigpio daemon is running it should be killed (sudo killall +pigpiod) before make install and restarted afterwards (sudo +pigpiod).
    +
    +The initial part of the make, the +compilation of pigpio.c, takes 100 seconds on early model +Pis.  Be patient.  The overall install takes just over 3 +minutes.
    +

    Download and install latest version

    + +wget https://github.com/joan2937/pigpio/archive/master.zip
    +unzip master.zip
    +cd pigpio-master
    +make
    +sudo make install
    +
    +
    +If the Python part of the install fails it may be because you need +the setup tools.
    +
    +sudo apt install python-setuptools +python3-setuptools

    +
    +

    To check the library

    +These tests make extensive use of GPIO 25 (pin 22).  Make sure +nothing, or only a LED, is connected to the GPIO before running the +tests.  Most tests are statistical in nature and so may on +occasion fail.  Repeated failures on the same test or many +failures in a group of tests indicate a problem.
    +
    +sudo ./x_pigpio # check C I/F
    +
    +sudo pigpiod    # start daemon
    +
    +./x_pigpiod_if2 # check C      I/F to +daemon
    +./x_pigpio.py   # check Python I/F to daemon
    +./x_pigs        # check +pigs   I/F to daemon
    +./x_pipe        # check +pipe   I/F to daemon
    +
    +
    +

    To compile, link, and run a C program

    +gcc -Wall -pthread -o foobar foobar.c -lpigpio -lrt
    +sudo ./foobar


    +

    To start the pigpio daemon

    +sudo pigpiod
    +

    To stop the pigpio daemon

    +sudo killall pigpiod

    +

    github

    +git clone https://github.com/joan2937/pigpio
    +

    Raspbian (raspberrypi.org image)

    +

    This may not be the most recent version.  You can check the +version with the command pigpiod -v.

    +sudo apt-get update
    +sudo apt-get install pigpio python-pigpio python3-pigpio

    +
    + + 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 @@ + + + + + +LDR example + + +

    The following code shows a method of reading analogue sensors on +the digital input only Pi.  A Light Dependent Resistor (LDR) +varies its resistance according to the incident light +intensisty.

    +

    SETUP

    +fritzing diagramThe LDR +used is a Cadmium Sulphide device with a 1MOhm dark resistance and +2-4KOhm at 100 lux.  The capacitor is a 104 +ceramic.
    +
    +One end of the capacitor is connected to Pi ground.
    +
    +One end of the LDR is connected to Pi 3V3.
    +
    +The other ends of the capacitor and LDR are connected to a spare +gpio.

    +

    Here P1-1 is used for 3V3, P1-20 is used for ground, and gpio 18 +(P1-12) is used for the gpio.

    +

    photo of set-up

    +

    CODE

    +#include <stdio.h>
    +
    +#include <pigpio.h>
    +
    +/* +-----------------------------------------------------------------------
    + +
    +   3V3 ----- Light Dependent Resistor --+-- Capacitor +----- Ground
    +                                        +|
    +                                        ++-- gpio
    +
    +
    +  cc -o LDR LDR.c -lpigpio -lpthread -lrt
    +  sudo ./LDR
    +
    +*/
    +
    +#define LDR 18
    +
    +/* forward declaration */
    +
    +void alert(int pin, int level, uint32_t tick);
    +
    +int main (int argc, char *argv[])
    +{
    +   if (gpioInitialise()<0) return 1;
    +
    +   gpioSetAlertFunc(LDR, alert); /* call alert when LDR +changes state */
    +    
    +   while (1)
    +   {
    +      gpioSetMode(LDR, PI_OUTPUT); /* +drain capacitor */
    +
    +      gpioWrite(LDR, PI_OFF);
    +
    +      gpioDelay(200); /* 50 micros is +enough, 200 is overkill */
    +
    +      gpioSetMode(LDR, PI_INPUT); /* start +capacitor recharge */
    +
    +      gpioDelay(10000); /* nominal 100 +readings per second */
    +   }
    +
    +   gpioTerminate();
    +}
    +
    +void alert(int pin, int level, uint32_t tick)
    +{
    +   static uint32_t inited = 0;
    +   static uint32_t lastTick, firstTick;
    +
    +   uint32_t diffTick;
    +
    +   if (inited)
    +   {
    +      diffTick = tick - lastTick;
    +      lastTick = tick;
    +
    +      if (level == 1) printf("%u %d\ ", +tick-firstTick, diffTick);
    +   }
    +   else
    +   {
    +      inited = 1;
    +      firstTick = tick;
    +      lastTick = firstTick;
    +   }
    +}
    +

    BUILD

    +cc -o LDR LDR.c -lpigpio -lrt -lpthread
    +

    RUN

    +sudo ./LDR >LDR.dat &
    +
    +While the program is running you can capture the waveform using the +notification feature built in to pigpio.  Issue the following +commands on the Pi.
    +
    +pigs no
    +pig2vcd  </dev/pigpio0 >LDR.vcd &
    +pigs nb 0 0x40000 # set bit for gpio 18
    +

    Change the light falling on the LDR for a few seconds (e.g. +shine a torch on it or shade it with your hands).

    +pigs nc 0
    +

    The file LDR.vcd will contain the captured waveform, which can +be viewed using GTKWave.

    +

    Overview

    +LDR waveform 1
    +

    Reading circa every 10ms

    +LDR waveform 2
    +

    One reading, circa 400us

    +LDR waveform 3
    +

    The file LDR.dat will contain pairs of timestamps and recharge +time (in us).  The following  script will convert the +timestamps into seconds.

    +

    awk '{print $1/1000000, $2}' LDR.dat +>LDR-secs.dat

    +

    Gnuplot is a useful tool to graph data.

    +plot [14:24] 'LDR-secs.dat' with lines title 'LDR' +

    Gnuplot readings 14-24 seconds

    +

    gnuplot 1

    +plot [18:21] 'LDR-secs.dat' with lines title 'LDR'
    +
    +Gnuplot readings 18-21 seconds +

    Gnuplot 2

    + + 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 @@ + + + + + +IR remote example + + +

    The following code shows one way to read an infrared remote +control device (the sort used in TVs and stereo systems).

    +

    SETUP

    +fritzing diagramThe device used +is a SFH5110 (IR Receiver for remote control, +carrier 38 kHz).
    +
    Pin 1 (left from front) may be connected to any spare +gpio.  Here it's connected via a 4K7 current limiting +resistor.  This isn't really needed as the device has an +internal 23K resistor in-line.  It does no harm though.
    +
    +Pin 2 should be connected to a Pi ground pin.
    +
    +Pin 3 should be connected to a Pi 5V pin.
    +

    Here pin 1 to gpio7 (P1-26) via a 4K7 resistor, pin 2 to ground +(P1-14), and pin 3 to 5V (P1-2).

    +

    photo of set-up

    +

    CODE

    +#include <stdio.h>
    +
    +#include <pigpio.h>
    +
    +#define IR_PIN 7
    +
    +#define OUTSIDE_CODE 0
    +#define INSIDE_CODE  1
    +
    +#define MIN_MESSAGE_GAP 3000
    +#define MAX_MESSAGE_END 3000
    +
    +#define MAX_TRANSITIONS 500
    +
    +/*
    +   using the FNV-1a +hash                
    + +   from +http://isthe.com/chongo/tech/comp/fnv/#FNV-param
    +*/
    +
    +#define FNV_PRIME_32 16777619
    +#define FNV_BASIS_32 2166136261U
    +
    +static volatile uint32_t ir_hash = 0;
    +
    +typedef struct
    +{
    +   int state;
    +   int count;
    +   int level;
    +   uint16_t micros[MAX_TRANSITIONS];
    +} decode_t;
    +
    +/* forward declarations */
    +
    +void     alert(int gpio, int level, uint32_t +tick);
    +uint32_t getHash(decode_t * decode);
    +void     updateState(decode_t * decode, int +level, uint32_t micros);
    +
    +int main(int argc, char * argv[])
    +{
    +   if (gpioInitialise()<0)
    +   {
    +      return 1 ;
    +   }
    +
    +   /* IR pin as input */
    +
    +   gpioSetMode(IR_PIN, PI_INPUT);
    +
    +   /* 5ms max gap after last pulse */
    +
    +   gpioSetWatchdog(IR_PIN, 5);
    +
    +   /* monitor IR level changes */
    +
    +   gpioSetAlertFunc(IR_PIN, alert);
    +
    +   while (1)
    +   {
    +      if (ir_hash)
    +      {
    +         /* non-zero means +new decode */
    +         printf("ir code is +%u\ ", ir_hash);
    +         ir_hash = 0;
    +      }
    +
    +      gpioDelay(100000); /* check remote +10 times per second */
    +   }
    +
    +   gpioTerminate();
    +}
    +
    +void alert(int gpio, int level, uint32_t tick)
    +{
    +   static int inited = 0;
    +
    +   static decode_t activeHigh, activeLow;
    +
    +   static uint32_t lastTick;
    +
    +   uint32_t diffTick;
    +
    +   if (!inited)
    +   {
    +      inited = 1;
    +
    +      activeHigh.state = OUTSIDE_CODE; +activeHigh.level = PI_LOW;
    +      activeLow.state  = +OUTSIDE_CODE; activeLow.level  = PI_HIGH;
    +
    +      lastTick = tick;
    +      return;
    +   }
    +
    +   diffTick = tick - lastTick;
    +
    +   if (level != PI_TIMEOUT) lastTick = tick;
    +
    +   updateState(&activeHigh, level, diffTick);
    +   updateState(&activeLow, level, diffTick);
    +}
    +
    +void updateState(decode_t * decode, int level, uint32_t micros)
    +{
    +   /*
    +      We are dealing with active high as +well as active low
    +      remotes.  Abstract the common +functionality.
    +   */
    +
    +   if (decode->state == OUTSIDE_CODE)
    +   {
    +      if (level == decode->level)
    +      {
    +         if (micros > +MIN_MESSAGE_GAP)
    +         {
    +            +decode->state = INSIDE_CODE;
    +            +decode->count = 0;
    +         }
    +      }
    +   }
    +   else
    +   {
    +      if (micros > MAX_MESSAGE_END)
    +      {
    +         /* end of message +*/
    +
    +         /* ignore if last +code not consumed */
    +
    +         if (!ir_hash) +ir_hash = getHash(decode);
    +
    +         decode->state = +OUTSIDE_CODE;
    +      }
    +      else
    +      {
    +         if +(decode->count < (MAX_TRANSITIONS-1))
    +         {
    +            +if (level != PI_TIMEOUT)
    +               +decode->micros[decode->count++] = micros;
    +         }
    +      }
    +   }
    +}
    +
    +int compare(unsigned int oldval, unsigned int newval)
    +{
    +   if      (newval < (oldval +* 0.75)) {return 1;}
    +   else if (oldval < (newval * 0.75)) {return 2;}
    +   +else                               +{return 4;}
    +}
    +
    +uint32_t getHash(decode_t * decode)
    +{
    +   /* use FNV-1a */
    +
    +   uint32_t hash;
    +   int i, value;
    +
    +   if (decode->count < 6) {return 0;}
    +
    +   hash = FNV_BASIS_32;
    +
    +   for (i=0; i<(decode->count-2); i++)
    +   {
    +      value = +compare(decode->micros[i], decode->micros[i+2]);
    +
    +      hash = hash ^ value;
    +      hash = (hash * FNV_PRIME_32);
    +   }
    +
    +   return hash;
    +}
    +

    BUILD

    +cc -o ir_remote ir_remote.c -lpigpio -lrt +-lpthread
    +

    RUN

    +sudo ./ir_remote
    +

    A hash code is formed from the level transitions detected during +a remote key press.  This is likely to be unique over multiple +remotes and keys.

    +

    While the program is running you can capture the waveform using +the notification feature built in to pigpio.  Issue the +following commands on the Pi.

    +pigs no
    +pig2vcd  </dev/pigpio0 >ir.vcd &
    +pigs nb 0 0x80 # set bits for gpios 7 (0x80)
    +

    Press a few different remotes and keys.  Then enter

    +pigs nc 0
    +

    The file ir.vcd will contain the captured waveform, which can be +viewed using GTKWave.

    +

    Overview

    +ir remote waveform 1
    +

    Remote A typical waveform

    +ir remote waveform 2
    +

    Remote B typical waveform

    ++"ir + + 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 @@ + + + + + +Arduino motor shield example + + +The following example demonstrates the use of an Arduino shield +from the Rasperry Pi.
    +
    +The shield used is a clone of the Adafruit motor shield.  See +shieldlist.org +for details.
    +
    +For the demonstration DC motors 3 and 4 are being driven forwards +and backwards with changing speeds (speeds are controlled via +PWM).
    +
    +Seven connections are made between the Pi and the shield.  +Four to latch the motor states (latch, enable, data, clock); Two to +control motor speed (PWM 3 and 4); and ground.
    +
    +The code used was ported from the Adafruit Arduino code and +converted to use the pigpio library.  Only the DC motor code +was ported.
    +
    +A video of the shield in use is available at youtube.com
    +
    +#include <stdio.h>

    +
    +#include <pigpio.h>
    +
    +/*
    +   This code may be used to drive the Adafruit (or +clones) Motor Shield.
    +
    +   The code as written only supports DC motors.
    +
    +   http://shieldlist.org/adafruit/motor
    +
    +   The shield pinouts are
    +
    +   D12 MOTORLATCH
    +   D11 PMW motor 1
    +   D10 Servo 1
    +   D9  Servo 2
    +   D8  MOTORDATA
    +
    +   D7  MOTORENABLE
    +   D6  PWM motor 4
    +   D5  PWM motor 3
    +   D4  MOTORCLK
    +   D3  PWM motor 2
    +
    +   The motor states (forward, backward, brake, release) +are encoded using the
    +   MOTOR_ latch pins.  This saves four gpios.
    +*/
    +
    +typedef unsigned char uint8_t;
    +
    +#define BIT(bit) (1 << (bit))
    +
    +/* assign gpios to drive the shield pins */
    +
    +/*      +Shield      Pi */
    +
    +#define MOTORLATCH  14
    +#define MOTORCLK    24
    +#define MOTORENABLE 25
    +#define MOTORDATA   15
    +
    +#define MOTOR_3_PWM  7
    +#define MOTOR_4_PWM  8
    +
    +/*
    +   The only other connection needed between the Pi and +the shield
    +   is ground to ground. I used Pi P1-6 to shield gnd +(next to D13).
    +*/
    +
    +/* assignment of motor states to latch */
    +
    +#define MOTOR1_A 2
    +#define MOTOR1_B 3
    +#define MOTOR2_A 1
    +#define MOTOR2_B 4
    +#define MOTOR4_A 0
    +#define MOTOR4_B 6
    +#define MOTOR3_A 5
    +#define MOTOR3_B 7
    +
    +#define FORWARD  1
    +#define BACKWARD 2
    +#define BRAKE    3
    +#define RELEASE  4
    +
    +static uint8_t latch_state;
    +
    +void latch_tx(void)
    +{
    +   unsigned char i;
    +
    +   gpioWrite(MOTORLATCH, PI_LOW);
    +
    +   gpioWrite(MOTORDATA, PI_LOW);
    +
    +   for (i=0; i<8; i++)
    +   {
    +      gpioDelay(10);  // 10 micros +delay
    +
    +      gpioWrite(MOTORCLK, PI_LOW);
    +
    +      if (latch_state & BIT(7-i)) +gpioWrite(MOTORDATA, PI_HIGH);
    +      +else                        +gpioWrite(MOTORDATA, PI_LOW);
    +
    +      gpioDelay(10);  // 10 micros +delay
    +
    +      gpioWrite(MOTORCLK, PI_HIGH);
    +   }
    +
    +   gpioWrite(MOTORLATCH, PI_HIGH);
    +}
    +
    +void init(void)
    +{
    +   latch_state = 0;
    +
    +   latch_tx();
    +
    +   gpioWrite(MOTORENABLE, PI_LOW);
    +}
    +
    +void DCMotorInit(uint8_t num)
    +{
    +   switch (num)
    +   {
    +      case 1: latch_state &= +~BIT(MOTOR1_A) & ~BIT(MOTOR1_B); break;
    +      case 2: latch_state &= +~BIT(MOTOR2_A) & ~BIT(MOTOR2_B); break;
    +      case 3: latch_state &= +~BIT(MOTOR3_A) & ~BIT(MOTOR3_B); break;
    +      case 4: latch_state &= +~BIT(MOTOR4_A) & ~BIT(MOTOR4_B); break;
    +      default: return;
    +   }
    +
    +   latch_tx();
    +
    +   printf("Latch=%08X\ ", latch_state);
    +}
    +
    +void DCMotorRun(uint8_t motornum, uint8_t cmd)
    +{
    +   uint8_t a, b;
    +
    +   switch (motornum)
    +   {
    +      case 1: a = MOTOR1_A; b = MOTOR1_B; +break;
    +      case 2: a = MOTOR2_A; b = MOTOR2_B; +break;
    +      case 3: a = MOTOR3_A; b = MOTOR3_B; +break;
    +      case 4: a = MOTOR4_A; b = MOTOR4_B; +break;
    +      default: return;
    +   }

    +   switch (cmd)
    +   {
    +      case FORWARD:  latch_state +|=  BIT(a); latch_state &= ~BIT(b); break;
    +      case BACKWARD: latch_state &= +~BIT(a); latch_state |=  BIT(b); break;
    +      case RELEASE:  latch_state +&= ~BIT(a); latch_state &= ~BIT(b); break;
    +      default: return;
    +   }
    +
    +   latch_tx();
    +
    +   printf("Latch=%08X\ ", latch_state);
    +}
    +
    +int main (int argc, char *argv[])
    +{
    +   int i;
    +
    +   if (gpioInitialise()<0) return 1;
    +
    +   gpioSetMode(MOTORLATCH,  PI_OUTPUT);
    +   gpioSetMode(MOTORENABLE, PI_OUTPUT);
    +   gpioSetMode(MOTORDATA,   PI_OUTPUT);
    +   gpioSetMode(MOTORCLK,    +PI_OUTPUT);
    +
    +   gpioSetMode(MOTOR_3_PWM, PI_OUTPUT);
    +   gpioSetMode(MOTOR_4_PWM, PI_OUTPUT);
    +
    +   gpioPWM(MOTOR_3_PWM, 0);
    +   gpioPWM(MOTOR_4_PWM, 0);
    +
    +   init();
    +
    +   for (i=60; i<160; i+=20)
    +   {
    +      gpioPWM(MOTOR_3_PWM, i);
    +      gpioPWM(MOTOR_4_PWM, 220-i);
    +
    +      DCMotorRun(3, FORWARD);
    +      DCMotorRun(4, BACKWARD);
    +
    +      sleep(2);
    +
    +      DCMotorRun(3, RELEASE);
    +      DCMotorRun(4, RELEASE);
    +
    +      sleep(2);
    +
    +      gpioPWM(MOTOR_4_PWM, i);
    +      gpioPWM(MOTOR_3_PWM, 220-i);
    +
    +      DCMotorRun(3, BACKWARD);
    +      DCMotorRun(4, FORWARD);
    +
    +      sleep(2);
    +
    +      DCMotorRun(3, RELEASE);
    +      DCMotorRun(4, RELEASE);
    +
    +      sleep(2);
    +   }
    +
    +   gpioPWM(MOTOR_4_PWM, 0);
    +   gpioPWM(MOTOR_3_PWM, 0);
    +
    +   DCMotorRun(3, RELEASE);
    +   DCMotorRun(4, RELEASE);
    +
    +   gpioTerminate();
    +}
    + + 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 @@ + + + + + +Rotary encoder sample + + +

    The following code shows one way to read an incremental +mechanical rotary enoder (the sort used for volume control in audio +systems).  These rotary encoders have two switches A and B +which return a quadrature output, i.e. they are 90 degrees out of +phase.

    +

    SETUP

    +fritzing diagramThe common +(centre) terminal should be connected to a Pi ground. +

    The A and B terminals may be connected to any spare gpios.

    +

    Here A to gpio18 (P1-12), common to ground (P1-20), B to gpio7 +(P1-26).

    +

    photo of set-up

    +

    CODE

    +#include <stdio.h>
    +
    +#include <pigpio.h>
    +
    +/*
    +   Rotary encoder connections:
    +
    +   Encoder A      - gpio +18   (pin P1-12)
    +   Encoder B      - gpio +7    (pin P1-26)
    +   Encoder Common - Pi ground (pin P1-20)
    +*/
    +
    +#define ENCODER_A 18
    +#define ENCODER_B  7
    +
    +static volatile int encoderPos;
    +
    +/* forward declaration */
    +
    +void encoderPulse(int gpio, int lev, uint32_t tick);
    +
    +int main(int argc, char * argv[])
    +{
    +   int pos=0;
    +
    +   if (gpioInitialise()<0) return 1;
    +
    +   gpioSetMode(ENCODER_A, PI_INPUT);
    +   gpioSetMode(ENCODER_B, PI_INPUT);
    +
    +   /* pull up is needed as encoder common is grounded +*/
    +
    +   gpioSetPullUpDown(ENCODER_A, PI_PUD_UP);
    +   gpioSetPullUpDown(ENCODER_B, PI_PUD_UP);
    +
    +   encoderPos = pos;
    +
    +   /* monitor encoder level changes */
    +
    +   gpioSetAlertFunc(ENCODER_A, encoderPulse);
    +   gpioSetAlertFunc(ENCODER_B, encoderPulse);
    +
    +   while (1)
    +   {
    +      if (pos != encoderPos)
    +      {
    +         pos = +encoderPos;
    +         printf("pos=%d\ ", +pos);
    +      }
    +      gpioDelay(20000); /* check pos 50 +times per second */
    +   }
    +
    +   gpioTerminate();
    +}
    +
    +void encoderPulse(int gpio, int level, uint32_t tick)
    +{
    +   /*
    +
    +             ++---------+         ++---------+      0
    +             +|         +|         +|         |
    +   A         +|         +|         +|         |
    +             +|         +|         +|         |
    +   ++---------+         ++---------+         +----- +1
    +
    +       ++---------+         ++---------+            +0
    +       +|         +|         +|         |
    +   B   +|         +|         +|         |
    +       +|         +|         +|         |
    +   ----+         ++---------+         ++---------+  1
    +
    +   */
    +
    +   static int levA=0, levB=0, lastGpio = -1;
    +
    +   if (gpio == ENCODER_A) levA = level; else levB = +level;
    +
    +   if (gpio != lastGpio) /* debounce */
    +   {
    +      lastGpio = gpio;
    +
    +      if ((gpio == ENCODER_A) && +(level == 0))
    +      {
    +         if (!levB) +++encoderPos;
    +      }
    +      else if ((gpio == ENCODER_B) +&& (level == 1))
    +      {
    +         if (levA) +--encoderPos;
    +      }
    +   }
    +}
    +

    BUILD

    +cc -o rotary_encoder rotary_encoder.c -lpigpio -lrt +-lpthread
    +

    RUN

    +sudo ./rotary_encoder
    +

    While the program is running you can capture the waveform using +the notification feature built in to pigpio.  Issue the +following commands on the Pi.

    +pigs no
    +pig2vcd  </dev/pigpio0 >re.vcd &
    +pigs nb 0 0x40080 # set bits for gpios 7 (0x80) and 18 +(0x40000)
    +

    Twiddle the rotary encoder forwards and backwards for a few +seconds.  Then enter

    +pigs nc 0
    +

    The file re.vcd will contain the captured waveform, which can be +viewed using GTKWave.

    +
    +Overview
    +
    ++"rotary
    +
    +Detail of switch bounce.  Contact A bounces for circa 700 us +before completing the level transition
    +
    ++"rotary
    + + 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 @@ + + + + + +Sonar ranger example + + +

    The following code shows a method of reading a class of sonar +rangers.  These rangers requires a trigger pulse.  +Shortly after receiving a trigger they transmit a noise pulse and +set the echo line high.  When the echo is received the echo +line is set low.

    +

    SETUP

    +fritzing diagram
    +
    +
    +
    +
    +The ranger used is a SRF05 (check the pinouts, there are many +variants).
    +
    +The fritzing diagram shows the back of the ranger, i.e. pin 1 is +the rightmost.
    +
    +Pin 1 is 5V.
    +Pin 2 is the trigger line.
    +Pin 3 is the echo line.
    +Pin 4 is out (unused).
    +Pin 5 is ground.
    +
    +

    photo of set-up

    +

    CODE

    +#include <stdio.h>
    +
    +#include <pigpio.h>
    +
    +/*
    +
    +P1  Name  gpio    used for
    +
    + 2  5V    ---     +5V
    + 6  GND   ---     +Ground
    +24  CE0   8       +Sonar echo
    +26  CE1   7       +Sonar trigger
    +
    +*/
    +
    +#define SONAR_TRIGGER 7
    +#define SONAR_ECHO    8
    +
    +/* forward prototypes */
    +
    +void sonarTrigger(void);
    +
    +void sonarEcho(int gpio, int level, uint32_t tick);
    +
    +int main(int argc, char *argv[])
    +{
    +   if (gpioInitialise()<0) return 1;
    +
    +   gpioSetMode(SONAR_TRIGGER, PI_OUTPUT);
    +   gpioWrite  (SONAR_TRIGGER, PI_OFF);
    +
    +   gpioSetMode(SONAR_ECHO,    +PI_INPUT);
    +
    +   /* update sonar 20 times a second, timer #0 */
    +
    +   gpioSetTimerFunc(0, 50, sonarTrigger); /* every 50ms +*/
    +
    +   /* monitor sonar echos */
    +
    +   gpioSetAlertFunc(SONAR_ECHO, sonarEcho);
    +
    +   while (1) sleep(1);
    +
    +   gpioTerminate();
    +
    +   return 0;
    +}
    +
    +void sonarTrigger(void)
    +{
    +   /* trigger a sonar reading */
    +
    +   gpioWrite(SONAR_TRIGGER, PI_ON);
    +
    +   gpioDelay(10); /* 10us trigger pulse */
    +
    +   gpioWrite(SONAR_TRIGGER, PI_OFF);
    +}
    +
    +void sonarEcho(int gpio, int level, uint32_t tick)
    +{
    +   static uint32_t startTick, firstTick=0;
    +
    +   int diffTick;
    +
    +   if (!firstTick) firstTick = tick;
    +
    +   if (level == PI_ON)
    +   {
    +      startTick = tick;
    +   }
    +   else if (level == PI_OFF)
    +   {
    +      diffTick = tick - startTick;
    +
    +      printf("%u %u\ ", tick-firstTick, +diffTick);
    +   }
    +}
    +

    BUILD

    +cc -o sonar sonar.c -lpigpio -lrt -lpthread
    +

    RUN

    +sudo ./sonar >sonar.dat &
    +
    +While the program is running you can capture the waveform using the +notification feature built in to pigpio.  Issue the following +commands on the Pi.
    +
    +pigs no
    +pig2vcd  </dev/pigpio0 >sonar.vcd &
    +pigs nb 0 0x180 # set bits for gpios 7 and 8
    +

    Move an object in front of the sonar ranger for a few +seconds.

    +pigs nc 0
    +

    The file sonar.vcd will contain the captured waveform, which can +be viewed using GTKWave.

    +

    Overview

    +LDR waveform 1
    +

    Reading circa every 10ms

    +Sonar waveform 2
    +

    One reading, circa 400us

    +Sonar waveform 3
    +

    another

    +Sonar waveform 4
    +

    The file sonar.dat will contain pairs of timestamps and echo +length (in us).  The following  script will convert the +timestamps into seconds.

    +

    awk '{print $1/1000000, $2}' sonar.dat +>sonar-secs.dat

    +

    Gnuplot is a useful tool to graph data.

    +plot 'sonar-secs.dat' title 'Sonar'
    +

    gnuplot 1
    + plot [10:25] 'sonar-secs.dat' title 'Sonar'

    +

    gnuplot 1

    + + 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 @@ + + + + + +faq + + +Are my GPIO broken?
    +
    +Audio is broken
    +
    +Can´t initialise pigpio +library
    +
    +Can´t lock +var/run/pigpio.pid
    +
    +Hello World!
    +
    +Clock skew, make fails
    +
    +Have I fried my GPIO?
    +
    +How do I debounce +inputs?
    +
    +How fast is SPI?
    +
    +Library update didn't work
    +
    +make fails with clock skew
    +
    +Porting pigpio to another CPU/SoC
    +
    +Sound isn't working
    +
    +Symbol not found
    +
    +What is I2C?
    +
    +What is Serial?
    +
    +What is SPI?
    +
    +Which library should I use?
    +
    +

    Are my +GPIO broken?

    +

    See Have I fried my +GPIO?

    +

    Audio is +broken

    +

    See Sound isn't +working

    +

    Can´t lock +/var/run/pigpio.pid

    +

    See Can´t_initialise_pigpio_library
    +

    +

    Can´t initialise pigpio +library

    +

    This message means the pigpio daemon is already running.

    +

    The default daemon is called pigpiod and may be removed as +follows.

    +Check that it is running with the command +

    ps aux | grep pigpiod

    +

    Kill the daemon with

    +

    sudo killall pigpiod

    +

    If your own program is acting as the daemon it may be removed as +follows.

    +

    Find its process id (pid).

    +

    cat /var/run/pigpio.pid

    +

    Kill the program with

    +

    sudo kill -9 pid

    +If the above doesn't work do the following and try starting the +daemon again +

    sudo rm /var/run/pigpio.pid

    +

    To start the daemon do

    +

    sudo pigpiod

    +

    Have I fried my GPIO?

    +

    If you think you have damaged one or more GPIO you can carry out +a diagnostic test.

    +

    The test is a command line script called gpiotest

    +For the duration of the test nothing must be connected to the GPIO +(no LEDs, wires, ribbon cables etc.). +

    The test checks that each GPIO may be read and written and that +the internal resistor pull-ups and pull-downs are functional.

    +

    A video +showing what happens to the GPIO during a test.

    +

    A test with all GPIO okay.

    +
    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
    19 20 21 22 23 24 25 26 27 +Failed user gpios: None +
    +

    A test showing failed GPIO.

    +
    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
    19 20 21 22 23 24 25 26 27 +Failed user gpios: 17 18 23 24 27 +
    +

    How do I debounce inputs?

    +

    Some devices like mechanical switches can generate multiple +interrupts as they bounce between on and off.  It is possible +to debounce the inputs in hardware by the correct use of resistors +and capacitors.

    +

    In software use the glitch filter which ignores all events +shorter than a set number of microseconds.  C gpioGlitchFilter, Python set_glitch_filter.

    +

    How fast is +SPI?

    +The SPI throughput in samples per second depends on a number of +factors.
    +
    +
      +
    • The SPI bit rate (transfer rate in bits per second)
    • +
    +
      +
    • The number of bytes transferred per sample (a 12 bit ADC sample +may require 3 bytes to transfer)
    • +
    +
      +
    • The driver used
    • +
    +

    Two of those factors are fixed, the variable is the driver +used.

    +

    The pigpio driver is considerably faster than the Linux SPI +driver as is demonstrated by the following graphs.

    +

    Each graph shows the SPI bit rate in bits per second along the +horizontal axis.  The samples per second achieved is shown on +the vertical axis.  Each graph contains plots assuming 1 to 5 +bytes per transfer.

    +

    The source code used for the tests is spi-driver-speed.c and spi-pigpio-speed.c

    +

    spi-lnx-pibr1.png

    +
    +

    spi-pig-pibr1.png

    +
    +

    spi-lnx-pi3b.png

    +
    +

    spi-pig-pi3b.png

    +

    Library update didn't work

    +

    pigpio places files in the following locations

    +

    /usr/local/include (pigpio.h, pigpiod_if.h, pigpiod_if2.h)
    +/usr/local/lib (libpigpio.so, libpigpiod_if.so, +libpigpiod_if2.so)
    +/usr/local/bin (pig2vcd, pigpiod, pigs)
    +/usr/local/man (man pages)

    +The raspberrypi.org image containing pigpio uses different +locations.
    +

    /usr/include (pigpio.h, pigpiod_if.h, pigpiod_if2.h)
    +/usr/lib (libpigpio.so, libpigpiod_if.so, libpigpiod_if2.so)
    +/usr/bin (pig2vcd, pigpiod, pigs)
    +/usr/man (man pages)

    +

    Mostly this doesn't matter as the /usr/local directories will +generally be earlier in the search path.  The pigpio built +includes, binaries, and manuals are normally found first.

    +

    However the wrong libraries may be linked during the +compilation.  If this is the case remove the /usr/lib entries +for libpigpio.so , libpigpiod_if.so, and libpigpiod_if2.so

    +

    Hello World!

    +

    The following examples show how to use the various components of +the pigpio library.

    +

    Each example shows how to read the level of a GPIO.

    +

    C

    +read_cif.c +
    +#include <stdio.h>
    +#include <pigpio.h>
    +
    +int main(int argc, char *argv[])
    +{
    +   int GPIO=4;
    +   int level;
    +
    +   if (gpioInitialise() < 0) return 1;
    +
    +   level = gpioRead(GPIO);
    +
    +   printf("GPIO %d is %d\n", GPIO, level);
    +
    +   gpioTerminate();
    +}
    +    
    +

    Build

    +gcc -pthread -o read_cif read_cif.c -lpigpio +

    Run

    +sudo ./read_cif +

    C via pigpio daemon

    +read_pdif.c +
    +#include <stdio.h>
    +#include <pigpiod_if2.h>
    +
    +int main(int argc, char *argv[])
    +{
    +   int pi;
    +   int GPIO=4;
    +   int level;
    +
    +   pi = pigpio_start(0, 0); /* Connect to local Pi. */
    +
    +   if (pi < 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;
    +}
    +
    +

    Build

    +gcc -pthread -o read_pdif read_pdif.c -lpigpiod_if2 +

    Run

    +./read_pdif +

    Python

    +read_gpio.py +
    +#!/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()
    +    
    +

    Run

    +python read_gpio.py +

    pigs

    +
    +pigs r 4
    +    
    +

    pipe I/F

    +
    +echo "r 4" >/dev/pigpio
    +cat /dev/pigout
    +    
    +

    make fails with clock +skew

    +

    If make fails with one of the following messages it is probably +because the Pi's clock is wrong.

    +

    make: Warning: File 'xxx' has modification time x s in the +future
    +make: warning: Clock skew detected. Your build may be +incomplete.

    +

    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).

    +

    The solution is to make sure the system clock is correct.  +If the Pi is networked this will not normally be a problem.

    +

    To set the date and time use the date command as in the +following example.

    +

    sudo date -d "2017-03-01 18:47:00"

    +

    Porting pigpio +to another CPU/SoC

    +

    Sound +isn't working

    +

    The Pi contains two pieces of hardware, a PWM peripheral and a +PCM peripheral, to generate sound.  The PWM peripheral is +normally used and generates medium quality audio out of the +headphone jack.  The PCM peripheral may be used by add-ons +such as HATs and generates high quality audio.

    +

    pigpio uses at least one of these peripherals during normal +operation (for timing DMA transfers).  pigpio will use both +peripherals if waves or the hardware PWM function is used.

    +

    By default pigpio uses the PCM peripheral leaving the PWM +peripheral free for medium quality audio.

    +

    You can change the default with a configuration option.  +For C use gpioCfgClock, for the +pigpio daemon use the -t option.

    +

    What is I2C?

    +

    I2C is a data link between the Pi (master) and one or more +slaves.

    +

    Data may be sent and received but the Pi initiates all +transfers.

    +

    I2C is a medium speed link.  On the Pi the default speed is +100 kbps, but 400 kbps also works.

    +

    I2C is implemented as a bus with two lines called

    +
      +
    • SDA - for data
    • +
    • SCL - for a clock
    • +
    +On the Pi bus 1 is used which uses GPIO 2 (pin 3) for SDA and GPIO +3 (pin 5) for SCL.
    +
    +Only one slave device may be communicated with at a time.  +Each message from the Pi includes the slave to be addressed and +whether a read or write is to be performed.
    +
    +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.
    +
    +I2C start and stop sequences
    +
    +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.
    +
    +

    I2C waveform

    +

    What is +Serial?

    +

    Serial is a data link between the Pi and one other +device.

    +

    Data may be sent and received.  Either the Pi or the device +can initiate a transfer.

    +

    Serial is a low to medium speed link.  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.

    +

    Serial is implemented with one line for transmit called TXD and +one line for receive called RXD.

    +

    If only receive or transmit are required the other line need not +be connected.

    +

    The Pi uses GPIO 14 (pin 8) for TXD and GPIO 15 (pin 10) for +RXD.

    +

    Data is normally transmitted in 8-bit bytes with a start bit, +eight data bits, no parity, and one stop bit.  This is +represented as 8N1.  The number of transmitted bits per second +(bps) is called the baud rate.   The time for each bit, +1 / baud rate seconds, is +referred to as the bit period.

    +

    The lines are in the high state when no data is being +transmitted.  The start of a byte is signalled by the line +going low for one bit period (the start bit).  The data bits +are then sent least significant bit firsts (low if the bit is 0, +high if the bit is 1).  The data bits are followed by the +optional parity bit.  Finally the line is set high for at +least the number of stop bit periods.  The line will stay high +if there are no more bytes to be transmitted.

    +

    Serial waveform

    +

    What is SPI?

    +

    SPI is a data link between the Pi (master) and one or more +slaves.

    +

    Data may be sent and received but the Pi initiates all +transfers.

    +

    SPI is a medium to high speed link.  On the Pi speeds of 32 +kbps to 8 Mbps may be used.

    +

    SPI is implemented as a bus with three lines called

    +
      +
    • MOSI - for data from the Pi to the slave
    • +
    • MISO - for data from the slave to the Pi
    • +
    • SCLK - for a clock
    • +
    +Only one slave device may be communicated with at a time.  An +additional line per slave called slave select is used to identify +the slave to be addressed. +

    The Pi has two SPI buses

    +
      +
    1. the main SPI bus +
        +
      • MOSI GPIO 10 (pin 19)
      • +
      • MISO GPIO 9 (pin 21)
      • +
      • SCLK GPIO 11 (pin 23)
      • +
      • Slave selects
      • +
      • +
          +
        • CE0 GPIO 8 (pin 24)
        • +
        • CE1 GPIO 7 (pin 26)
        • +
        +
      • +
      +
    2. +
    3. the auxiliary SPI bus +
        +
      • MOSI GPIO 20 (pin 38)
      • +
      • MISO GPIO 19 (pin 35)
      • +
      • SCLK GPIO 21 (pin 40)
      • +
      • Slave selects
      • +
      • +
          +
        • CE0 GPIO 18 (pin 12)
        • +
        • CE1 GPIO 17 (pin 11)
        • +
        • CE2 GPIO 16 (pin 36)
        • +
        +
      • +
      +
    4. +
    +

    SPI waveform

    +


    +

    Which library +should I use?

    +


    + + 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 @@ + + + + + +pigpio + + +pigpio is a library for the Raspberry which allows control of the +General Purpose Input Outputs (GPIO).  pigpio works on all +versions of the Pi. +

    Download

    +

    Features

    +
      +
    • +

      hardware timed sampling and time-stamping of GPIO 0-31 every 5 +us

      +
    • +
    • +

      hardware timed PWM on all of GPIO 0-31

      +
    • +
    • +

      hardware timed servo pulses on all of GPIO 0-31

      +
    • +
    • +

      callbacks on GPIO 0-31 level change (time accurate to a few +us)

      +
    • +
    • +

      notifications via pipe on GPIO 0-31 level change

      +
    • +
    • +

      callbacks at timed intervals

      +
    • +
    • +

      reading/writing all of the GPIO in a bank (0-31, 32-53) as a +single operation

      +
    • +
    • +

      GPIO reading, writing, modes, and internal pulls

      +
    • +
    • +

      socket and pipe interfaces for the bulk of the functionality

      +
    • +
    • +

      waveforms to generate GPIO level changes (time accurate to a few +us)

      +
    • +
    • +

      software serial links using any user GPIO

      +
    • +
    • +

      rudimentary permission control through the socket and pipe +interfaces

      +
    • +
    • creating and running scripts on the pigpio daemon
    • +
    +

    General

    +The pigpio library is written in the C +programming language.
    +
    +The pigpio daemon offers a socket and pipe interface to +the underlying C library.
    +
    +A C library and a Python module allow control of the GPIO via the +pigpio daemon.
    +
    +There is third party support for a number of other languages.  +

    piscope

    +

    piscope is a logic analyser (digital +waveform viewer).

    +piscope is a GTK+3 application and uses pigpio to provide raw GPIO +level data.  piscope may be run on a Pi or on any machine +capable of compiling a GTK+3 application. +

    GPIO

    +

    ALL GPIO are identified +by their Broadcom +number.  See +elinux.org

    +There are 54 GPIO in total, arranged in two banks.
    +

    Bank 1 contains GPIO 0-31.  Bank 2 contains GPIO +32-53.

    +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.
    +
    +There are several types of board, each with different expansion +headers, giving physical access to different GPIO.  + +

    Type 1 - Model B (original +model)

    +
      +
    • 26 pin header (P1).
    • +
    +
      +
    • Hardware revision numbers of 2 and 3.
    • +
    +
      +
    • User GPIO 0-1, 4, 7-11, 14-15, 17-18, 21-25.
    • +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +GPIOpinpin +GPIO
    3V3-12-5V
    SDA0
    34-5V
    SCL1
    56-Ground

    47814TXD
    Ground-91015RXD
    ce117111218ce0

    211314-Ground

    22151623
    3V3-
    171824
    MOSI101920-Ground
    MISO9212225
    SCLK1123248CE0
    Ground-25267CE1
    +
    +

    Type 2 - Model A, B (revision +2)

    +26 pin header (P1) and an additional 8 pin header (P5). +
      +
    • Hardware revision numbers of 4, 5, 6 (B), 7, 8, 9 (A), and 13, +14, 15 (B).
    • +
    +
      +
    • User GPIO 2-4, 7-11, 14-15, 17-18, 22-25, 27-31.
    • +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +GPIOpinpin +GPIO
    3V3-12-5V
    SDA234-5V
    SCL356-Ground

    47814TXD
    Ground-91015RXD
    ce117111218ce0

    271314-Ground

    22151623
    3V3-
    171824
    MOSI101920-Ground
    MISO9212225
    SCLK1123248CE0
    Ground-25267CE1
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +GPIOpinpin +GPIO
    5V
    -12-3V3
    SDA
    283429SCL

    305631
    Ground
    -
    78-
    Ground
    +
    +

    Type 3 - Model A+, B+, Pi +Zero, Pi Zero W, Pi2B, Pi3B, Pi4B

    +
      +
    • 40 pin expansion header (J8).
    • +
    +
      +
    • Hardware revision numbers of 16 or greater.
    • +
    +
      +
    • User GPIO 2-27 (0 and 1 are reserved).
    • +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +GPIOpinpin +GPIO
    3V3-12-5V
    SDA234-5V
    SCL356-Ground

    47814TXD
    Ground-91015RXD
    ce117111218ce0

    271314-Ground

    22151623
    3V3-
    171824
    MOSI101920-Ground
    MISO9212225
    SCLK1123248CE0
    Ground-25267CE1
    ID_SD027281ID_SC

    52930-Ground

    6313212

    133334-Ground
    miso19353616ce2

    26373820mosi
    Ground-394021sclk
    +
    +

    Compute Module

    +

    All 54 GPIO may be physically accessed.  Some are reserved +for system use - refer to the Compute Module documentation.

    +

    Only GPIO 0-31 are supported for hardware timed sampling, PWM, +servo pulses, alert callbacks, waves, and software serial +links.

    +

    Other +Languages

    +

    There are several third party projects which provide wrappers +for pigpio.

    +

    Some are listed here:

    +
      +
    • Erlang +(skvamme)
    • +
    • Java JNI +wrapper around the pigpio C library (mattlewis)
    • +
    • Java via +diozero, a high level wrapper around pigpio, Pi4J, wiringPi etc +(mattlewis)
    • +
    • Java +(nkolban)
    • +
    • .NET/mono +(unosquare)
    • +
    • Node.js +A wrapper for the pigpio C library (fivdi)
    • +
    • Node.js +A client for pigpio socket interface (guymcswain)
    • +
    • Perl (Gligan +Calin Horea)
    • +
    • Ruby +(Nak)
    • +
    • Smalltalk(Instantiations)
    • +
    • Xojo(UBogun)
    • +
    • Xojo(Eugene Dakin)
    • +
    +
    +

    The PWM and servo pulses are timed using the DMA +and PWM/PCM peripherals.  This use was inspired by Richard +Hirst's servoblaster kernel module.

    + + 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 @@ + + + + + +Miscellaneous + + +There are two C libraries which provide a socket interface to the +pigpio daemon.  They provide an interface very similar to the +pigpio Python module.
    +
      +
    • The original pigpiod_if library is +now deprecated and will no longer be updated.  This library is +limited to controlling one Pi at a time.
    • +
    +
      +
    • The new pigpiod_if2 library which +should be used for new code.  This library allows multiple Pis +to be controlled at one time.
    • +
    +Additional details of the pigpio socket +interface.
    +
    +Additional details of the pigpio pipe +interface.
    +
    +pig2vcd is a utility which converts +pigpio notifications into the VCD (Value Change Dump) format.  +VCD can be read by many programs, in particular GTKWave. + + 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 @@ + + + + + +Pipe interface + + +pigpio provides a pipe interface to many of its functions.
    +
    +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.  The pipe interface can be disabled +by the program which initialises the library.  pigpiod offers +the -f option to disable the pipe interface.  User programs +should call gpioCfgInterfaces +if they wish to disable the pipe interface.
    +
    +pigpio listens for commands on pipe /dev/pigpio.  The commands +consist of a command identifier with, depending on the command, +zero, one, or two parameters.  The result, if any, may be read +from pipe /dev/pigout.  If any errors are detected a message +will be written to pipe /dev/pigerr.
    +
    +
    +The format of the commands is identical to those used by pigs. + + 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 @@ + + + + + +piscope + + +

    Introduction

    +piscope is a logic analyser (digital +waveform viewer) for the Raspberry.  It shows the state (high +or low) of selected GPIO in real-time.
    +
    +See video.
    +
    +piscope uses the services of the pigpio library.  pigpio needs to be running on +the Pi whose GPIO are to be monitored.
    +
    +The pigpio library may be started as a daemon (background process) +by the following command.
    +
    +sudo pigpiod

    +piscope may be invoked in several different ways
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    Pi
    pi_host ~ $ piscope +&
    Pi captures +data
    +Pi processes data
    +Pi displays data
    Pi plus Linux PC
    +
    +(with the
    +display on a remote
    +  Linux PC)
    remote_host ~ $ ssh -X pi_host
    pi_host ~ $ piscope +&
    Pi captures data
    +Pi processes data
    +Remote Linux PC displays data
    Pi plus Windows PC
    +
    +(with the
    +display on a remote
    +  Windows PC)
    You need to install an SSH +client (putty suggested) and a X11 server (xming suggested).
    +
    +Run Program Files -> Xming -> XLaunch and accept the +defaults.
    +
    +Run putty and enter the Pi's host name or IP address.  Click +on SSH X11 and tick Enable X11 forwarding and then select +Open.

    +
    pi_host ~ $ piscope +&
    Pi captures data
    +Pi processes data
    +Remote Windows PC displays data
    Pi plus Linux PC
    +
    +(with the display and processing on a remote Linux +PC)
    remote_host ~ $ export +PIGPIO_ADDR=pi_host
    +remote_host ~ $ piscope +&
    Pi captures data
    +Remote processes data
    +Remote displays data
    +
    +piscope operates in one of three modes
    +
    + + + + + + + + + + + + + + + + + + +
    Live
    The latest GPIO samples are +displayed.
    +
    +The mode will automatically change to Pause if a sampling trigger +is detected.
    +
    +There are four triggers.  Each trigger is made up of a +combination of GPIO states (one of don't care, low, high, edge, +falling, or rising per GPIO).  Triggers are always +counted.  In addition a trigger may be sample to, sample +around, or sample from, a so called sampling trigger.
    New samples are added to the +sample buffer.
    +
    +Once the sample buffer is full the oldest samples are discarded.
    Play
    Recorded GPIO samples are +displayed.
    +
    +The play speed may be varied between 64 times real-time to 1/32768 +of real-time.
    +
    +The page up key increases the play speed by a factor of 2.  +The page down key decreases the play speed by a factor of 2.  +The home key sets the play speed to 1X.
    New samples are added to the +sample buffer.
    +
    +Once the sample buffer is full new samples are discarded.
    Pause
    Recorded GPIO samples are +displayed.
    +
    +The left and right cursor keys move the blue marker to the previous +or next edge.  By default all GPIO edges are considered.  +Clicking on a GPIO name will limit edge searches to the highlighted +GPIO only.
    +
    +The left and right square bracket keys move the blue marker to the +previous or next trigger.
    +
    +The time between the blue and gold markers is displayed.  The +gold marker is set to the blue marker by a press of the 'g' +key.
    New samples are added to the +sample buffer.
    +
    +Once the sample buffer is full new samples are discarded.
    +
    +In all modes the down and up cursor keys zoom the time scale in and +out.
    +
    +Samples can be saved with File Save All Samples or File Save +Selected Samples. +

    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).

    +

    The samples may be saved in the native piscope format or in VCD +format.

    +

    Data saved in VCD format may be viewed and further processed +with GTKWave.

    +

    Data saved in the native piscope format may be restored later +with File Restore Saved Data.

    +

    Installation

    +

    To download and install piscope.

    +

    Pi (pre-built image)

    +wget abyz.me.uk/rpi/pigpio/piscope.tar
    +tar xvf piscope.tar
    +cd PISCOPE
    +make hf
    +make install

    +

    Linux 64 bit X86/AMD (pre-built image)

    +wget abyz.me.uk/rpi/pigpio/piscope.tar
    +tar xvf piscope.tar
    +cd PISCOPE
    +make x86_64
    +make install
    +

    All machines (building from source)

    +You only need to perform this step if you want to build the +executable from the source files.  This is not needed if you +use a pre-built image.
    +
    +WARNING
    : Installing gtk+-3.0 uses a lot of SD card +space.
    +
    +Most of the space used by gtk+-3.0 is taken up by unneeded *-dbg +packages.
    +
    +With *-dbg packages an additional 3753MB SD space is required.
    +
    +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).
    +
    +#
    # *** This may take a lot of time and use +a lot of SD card space ***
    #
    +sudo apt-get install gtk+-3.0
    #
    +wget abyz.me.uk/rpi/pigpio/piscope.tar
    +tar xvf piscope.tar
    +cd PISCOPE
    +make
    +make install

    + + 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 @@ + + + + + +Socket interface + + +pigpio provides a socket interface to many of its functions.
    +
    +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.
    +
    +The socket interface can be disabled by the program which +initialises the library.  pigpiod offers the -k option to +disable the socket interface.  User programs should call +gpioCfgInterfaces if they +wish to disable the socket interface.
    +
    +pigpio listens for connections on port 8888 by default.  This +default may be overridden when pigpio starts by the gpioCfgSocketPort function +call.  The pigpio daemon uses this function to provide an +option to change the port number.
    +
    +The pigs utility is an example of using the socket interface from +C.
    +

    Request

    +

    pigpio expects messages of type cmdCmd_t immediately followed with an +extension for a few commands.
    +
    +The caller should fill in cmd, p1, p2, p3/res, and any extension as +needed.  p3 will always be zero unless the command requires an +extension in which case p3 will be the length in bytes of the +extension.
    +
    +The cmdCmd_t is echoed back with +the result, if any, in p3/res, and an extension immediately +afterwards for a few commands.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    COMMANDcmd
    p1p2p3Extension
    MODES0gpiomode0-
    MODEG1gpio00-
    PUD2gpiopud0-
    READ3gpio00-
    WRITE4gpiolevel0-
    PWM5gpiodutycycle0-
    PRS6gpiorange0-
    PFS7gpiofrequency0-
    SERVO8gpiopulsewidth0-
    WDOG9gpiotimeout0-
    BR110000-
    BR211000-
    BC112bits00-
    BC213bits00-
    BS114bits00-
    BS215bits00-
    TICK16000-
    HWVER17000-
    NO18000-
    NB19handlebits0-
    NP20handle00-
    NC21handle00-
    PRG22gpio00-
    PFG23gpio00-
    PRRG24gpio00-
    HELP
    25N/A
    N/A
    N/A
    N/A
    PIGPV26000-
    WVCLR27000-
    WVAG280012*XgpioPulse_t pulse[X]
    WVAS29gpiobaud12+Xuint32_t databits
    +uint32_t stophalfbits
    +uint32_t offset
    +uint8_t data[X]
    N/A
    30000-
    N/A
    31000-
    WVBSY32000-
    WVHLT33000-
    WVSM34subcmd00-
    WVSP35subcmd00-
    WVSC36subcmd00-
    TRIG37gpiopulselen4uint32_t level
    PROC3800Xuint8_t text[X]
    PROCD39script_id00-
    PROCR40script_id04*X
    uint32_t pars[X]
    PROCS41script_id00-
    SLRO42gpiobaud4uint32_t databits
    SLR43gpiocount0-
    SLRC44gpio00-
    PROCP45script_id00-
    MICS46micros00-
    MILS47millis00-
    PARSE48N/AN/A
    N/A
    N/A
    WVCRE49000-
    WVDEL50wave_id00-
    WVTX51wave_id00-
    WVTXR52wave_id00-
    WVNEW53000-
    I2CO54busdevice4uint32_t flags
    I2CC55handle00-
    I2CRD56handlecount0-
    I2CWD57handle0Xuint8_t data[X]
    I2CWQ58handlebit0-
    I2CRS59handle00-
    I2CWS60handlebyte0-
    I2CRB61handleregister0-
    I2CWB62handleregister4uint32_t byte
    I2CRW63handleregister0-
    I2CWW64handleregister4uint32_t word
    I2CRK65handleregister
    0-
    I2CWK66handleregister
    Xuint8_t bvs[X]
    I2CRI67handleregister
    4uint32_t num
    I2CWI68handleregister
    X
    uint8_t bvs[X]
    I2CPC69handleregister
    4uint32_t word
    I2CPK70handleregister
    X
    uint8_t data[X]
    SPIO
    71channelbaud4uint32_t flags
    SPIC72handle00-
    SPIR73handlecount0-
    SPIW74handle0Xuint8_t data[X]
    SPIX75handle0Xuint8_t data[X]
    SERO76baudflagsXuint8_t device[X]
    SERC77handle00-
    SERRB78handle00-
    SERWB79handlebyte0-
    SERR80handlecount0-
    SERW81handle0Xuint8_t data[X]
    SERDA82handle00-
    GDC
    83
    gpio
    0
    0
    -
    GPW
    84
    gpio
    0
    0
    -
    HC
    85
    gpio
    frequency
    0
    -
    HP
    86
    gpio
    frequency
    4
    uint32_t dutycycle
    CF1
    87
    arg1
    arg2
    X
    uint8_t argx[X]
    CF2
    88
    arg1
    retMax
    X
    uint8_t argx[X]
    BI2CC
    89
    sda
    0
    0
    -
    BI2CO
    90
    sda
    scl
    4
    uint32_t baud
    BI2CZ
    91
    sda
    0
    X
    uint8_t data[X]
    I2CZ
    92
    handle
    0
    X
    uint8_t data[X]
    WVCHA
    93
    0
    0
    X
    uint8_t data[X]
    SLRI
    94
    gpio
    invert
    0
    -
    CGI
    95
    0
    0
    0
    -
    CSI
    96
    config
    0
    0
    -
    FG
    97
    gpio
    steady
    0
    -
    FN
    98
    gpio
    steady
    4
    uint32_t active
    NOIB99000-
    WVTXM
    100
    wave_id
    mode
    0
    -
    WVTAT
    101
    0
    0
    0
    -
    PADS
    102
    pad
    strength
    0
    -
    PADG
    103
    pad
    0
    0
    -
    FO
    104
    mode
    0
    X
    uint8_t file[X]
    FC
    105
    handle
    0
    0
    -
    FR
    106
    handle
    count
    0
    -
    FW
    107
    handle
    0
    X
    uint8_t data[X]
    FS
    108
    handle
    offset
    4
    uint32_t from
    FL
    109
    count
    0
    X
    uint8_t pattern[X]
    SHELL
    110
    len(name)
    0
    len(name)+
    +1+
    +len(string)
    uint8_t name[len(name)]
    +uint8_t null (0)
    +uint8_t string[len(string)]
    BSPIC
    111
    CS
    0
    0
    -
    BSPIO
    112
    CS
    0
    20
    uint32_t MISO
    +uint32_t MOSI
    +uint32_t SCLK
    +uint32_t baud
    +uint32_t spi_flags
    BSPIX
    113
    CS
    0
    X
    uint8_t data[X]
    BSCX
    114
    control
    0
    X
    uint8_t data[X]
    EVM
    115
    handle
    bits
    0
    -
    EVT
    116
    event
    0
    0
    -
    PROCU
    117
    script_id
    0
    4*X
    uint32_t pars[X]
    +

    Response

    +

    The response has cmd/p1/p2 as in the request.  p3/res holds +the return value.  If the command returns additional values +they will be in the immediately following extension.

    +Normally res should be treated as a 32 bit signed value and will be +greater than or equal to zero.  Upon failure res will be less +than 0 and contains an error code.
    +

    There are a few commands where the returned value should be +treated as a 32 bit unsigned value.  These commands can not +fail.  They are indicated with a * after the command +name.

    +

    Commands with an extension have the size of the extension in +bytes returned in res (or <0 on error as above).

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    COMMANDcmd
    p1
    p2
    res
    Extension
    MODES0-
    -
    0-
    MODEG1-
    -
    mode
    -
    PUD2-
    -
    0-
    READ3-
    -
    level
    -
    WRITE4-
    -
    0-
    PWM5-
    -
    0-
    PRS6-
    -
    0-
    PFS7-
    -
    0-
    SERVO8-
    -
    0-
    WDOG9-
    -
    0-
    BR1 *10-
    -
    bits
    -
    BR2 *11-
    -
    bits
    -
    BC112-
    -
    0-
    BC213-
    -
    0-
    BS114-
    -
    0-
    BS215-
    -
    0-
    TICK *
    16-
    -
    tick
    -
    HWVER *
    17-
    -
    version
    -
    NO18-
    -
    handle
    -
    NB19-
    -
    0-
    NP20-
    -
    0-
    NC21-
    -
    0-
    PRG22-
    -
    range
    -
    PFG23-
    -
    frequency
    -
    PRRG24-
    -
    real range
    -
    HELP25-
    -
    N/A
    N/A
    PIGPV *
    26-
    -
    version
    -
    WVCLR27-
    -
    0-
    WVAG28-
    -
    wave pulses
    -
    WVAS29-
    -
    wave pulses
    -
    N/A
    30-
    -
    -
    -
    N/A
    31-
    -
    -
    -
    WVBSY32-
    -
    busy (1) or not busy (0)
    -
    WVHLT33-
    -
    0-
    WVSM34-
    -
    wave micros
    +wave micros - high
    +wave micros - max
    -
    WVSP35-
    -
    wave pulses
    +wave pulses - high
    +wave pulses - max
    -
    WVSC36-
    -
    wave DMA CBs
    +wave DMA CBs - high
    +wave DMA CBs - max
    -
    TRIG37-
    -
    0
    -
    PROC38-
    -
    script id
    -
    PROCD39-
    -
    0-
    PROCR40-
    -
    script status
    -
    PROCS41-
    -
    0-
    SLRO42-
    -
    0
    -
    SLR43-
    -
    X
    uint8_t data[X]
    SLRC44-
    -
    0-
    PROCP45-
    -
    44uint32_t script_status
    +uint32_t pars[10]
    MICS46-
    -
    0-
    MILS47-
    -
    0-
    PARSE48-
    -
    N/A
    -
    WVCRE49-
    -
    wave id
    -
    WVDEL50-
    -
    0-
    WVTX51-
    -
    wave DMA CBs
    -
    WVTXR52-
    -
    wave DMA CBs
    -
    WVNEW53-
    -
    0-
    I2CO54-
    -
    handle-
    I2CC55-
    -
    0-
    I2CRD56-
    -
    X
    uint8_t data[X]
    I2CWD57-
    -
    0
    -
    I2CWQ58-
    -
    0-
    I2CRS59-
    -
    byte value
    -
    I2CWS60-
    -
    0-
    I2CRB61-
    -
    byte value
    -
    I2CWB62-
    -
    0
    -
    I2CRW63-
    -
    word value
    -
    I2CWW64-
    -
    0
    -
    I2CRK65-
    -
    0-
    I2CWK66-
    -
    0
    -
    I2CRI67-
    -
    X
    uint8_t data[X]
    I2CWI68-
    -
    0
    -
    I2CPC69-
    -
    word value
    -
    I2CPK70-
    -
    X
    uint8_t data[X]
    SPIO
    71-
    -
    handle
    -
    SPIC72-
    -
    0-
    SPIR73-
    -
    X
    uint8_t data[X]
    SPIW74-
    -
    0
    -
    SPIX75-
    -
    Xuint8_t data[X]
    SERO76-
    -
    handle
    -
    SERC77-
    -
    0-
    SERRB78-
    -
    byte value
    -
    SERWB79-
    -
    0-
    SERR80-
    -
    X
    uint8_t data[X]
    SERW81-
    -
    0
    -
    SERDA82-
    -
    data ready count
    -
    GDC
    83
    -
    -
    dutycycle
    -
    GPW
    84
    -
    -
    pulsewidth
    -
    HC
    85
    -
    -
    0
    -
    HP
    86
    -
    -
    0
    -
    CF1
    87
    -
    -
    value
    -
    CF2
    88
    -
    -
    X
    uint8_t retBuf[X]
    BI2CC
    89
    -
    -
    0
    -
    BI2CO
    90
    -
    -
    handle
    -
    BI2CZ
    91
    -
    -
    X
    uint8_t data[X]
    I2CZ
    92
    -
    -
    X
    uint8_t data[X]
    WVCHA
    93
    -
    -
    0
    -
    SLRI
    94
    -
    -
    0
    -
    CGI
    95
    -
    -
    config
    -
    CSI
    96
    -
    -
    0
    -
    FG
    97
    -
    -
    0
    -
    FN
    98
    -
    -
    0
    -
    NOIB99-
    -
    0-
    WVTXM
    100
    -
    -
    wave DMA CBs
    -
    WVTAT
    101
    -
    -
    wave id
    -
    PADS
    102
    -
    -
    0
    -
    PADG
    103
    -
    -
    strength
    -
    FO
    104
    -
    -
    handle
    -
    FC
    105
    -
    -
    0
    -
    FR
    106
    -
    -
    X
    uint8_t data[X]
    FW
    107
    -
    -
    0
    -
    FS
    108
    -
    -
    position
    -
    FL
    109
    -
    -
    X
    uint8_t filenames[X]
    SHELL
    110
    -
    -
    exit status
    -
    BSPIC
    111
    -
    -
    0
    -
    BSPIO
    112
    -
    -
    0
    -
    BSPIX
    113
    -
    -
    X
    uint8_t data[X]
    BSCX
    114
    -
    -
    X+4
    uint32_t status
    +uint8_t data[X]
    EVM
    115
    -
    -
    0
    -
    EVT
    116
    -
    -
    0
    -
    PROCU
    117
    -
    -
    0
    -
    +
    +

    cmdCmd_t

    +typedef struct
    +{
    +   uint32_t cmd;
    +   uint32_t p1;
    +   uint32_t p2;
    +   union
    +   {
    +      uint32_t p3;
    +      uint32_t ext_len;
    +      uint32_t res;
    +   };
    +} cmdCmd_t;

    + + diff --git a/EXAMPLES/C/COUNTER_1/README b/EXAMPLES/C/COUNTER_1/README new file mode 100644 index 0000000..5eec110 --- /dev/null +++ b/EXAMPLES/C/COUNTER_1/README @@ -0,0 +1,3 @@ +A program showing how to use the gpioSetAlertFunc function to set a callback for gpio state changes. + +A frequency count is generated for each monitored gpio (frequencies up to 500KHz and beyond). diff --git a/EXAMPLES/C/COUNTER_1/freq_count_1.c b/EXAMPLES/C/COUNTER_1/freq_count_1.c new file mode 100644 index 0000000..31b5d38 --- /dev/null +++ b/EXAMPLES/C/COUNTER_1/freq_count_1.c @@ -0,0 +1,238 @@ +#include +#include +#include +#include + +#include + +/* +2014-08-20 + +gcc -o freq_count_1 freq_count_1.c -lpigpio -lpthread +$ sudo ./freq_count_1 4 7 8 + +This program uses the gpioSetAlertFunc function to request +a callback (the same one) for each gpio to be monitored. + +EXAMPLES + +Monitor gpio 4 (default settings) +sudo ./freq_count_1 4 + +Monitor gpios 4 and 8 (default settings) +sudo ./freq_count_1 4 8 + +Monitor gpios 4 and 8, sample rate 2 microseconds +sudo ./freq_count_1 4 8 -s2 + +Monitor gpios 7 and 8, sample rate 4 microseconds, report every second +sudo ./freq_count_1 7 8 -s4 -r10 + +Monitor gpios 4,7, 8, 9, 10, 23 24, report five times a second +sudo ./freq_count_1 4 7 8 9 10 23 24 -r2 + +Monitor gpios 4, 7, 8, and 9, report once a second, sample rate 1us, +generate 2us edges (4us square wave, 250000 highs per second). +sudo ./freq_count_1 4 7 8 9 -r 10 -s 1 -p 2 +*/ + +#define MAX_GPIOS 32 + +#define OPT_P_MIN 1 +#define OPT_P_MAX 1000 +#define OPT_P_DEF 20 + +#define OPT_R_MIN 1 +#define OPT_R_MAX 10 +#define OPT_R_DEF 5 + +#define OPT_S_MIN 1 +#define OPT_S_MAX 10 +#define OPT_S_DEF 5 + +static volatile int g_pulse_count[MAX_GPIOS]; +static volatile int g_reset_counts; +static uint32_t g_mask; + +static int g_num_gpios; +static int g_gpio[MAX_GPIOS]; + +static int g_opt_p = OPT_P_DEF; +static int g_opt_r = OPT_R_DEF; +static int g_opt_s = OPT_S_DEF; +static int g_opt_t = 0; + +void usage() +{ + fprintf + (stderr, + "\n" \ + "Usage: sudo ./freq_count_1 gpio ... [OPTION] ...\n" \ + " -p value, sets pulses every p micros, %d-%d, TESTING only\n" \ + " -r value, sets refresh period in deciseconds, %d-%d, default %d\n" \ + " -s value, sets sampling rate in micros, %d-%d, default %d\n" \ + "\nEXAMPLE\n" \ + "sudo ./freq_count_1 4 7 -r2 -s2\n" \ + "Monitor gpios 4 and 7. Refresh every 0.2 seconds. Sample rate 2 micros.\n" \ + "\n", + OPT_P_MIN, OPT_P_MAX, + OPT_R_MIN, OPT_R_MAX, OPT_R_DEF, + OPT_S_MIN, OPT_S_MAX, OPT_S_DEF + ); +} + +void fatal(int show_usage, char *fmt, ...) +{ + char buf[128]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + fprintf(stderr, "%s\n", buf); + + if (show_usage) usage(); + + fflush(stderr); + + exit(EXIT_FAILURE); +} + +static int initOpts(int argc, char *argv[]) +{ + int i, opt; + + while ((opt = getopt(argc, argv, "p:r:s:")) != -1) + { + i = -1; + + switch (opt) + { + case 'p': + i = atoi(optarg); + if ((i >= OPT_P_MIN) && (i <= OPT_P_MAX)) + g_opt_p = i; + else fatal(1, "invalid -p option (%d)", i); + g_opt_t = 1; + break; + + case 'r': + i = atoi(optarg); + if ((i >= OPT_R_MIN) && (i <= OPT_R_MAX)) + g_opt_r = i; + else fatal(1, "invalid -r option (%d)", i); + break; + + case 's': + i = atoi(optarg); + if ((i >= OPT_S_MIN) && (i <= OPT_S_MAX)) + g_opt_s = i; + else fatal(1, "invalid -s option (%d)", i); + break; + + default: /* '?' */ + usage(); + exit(-1); + } + } + return optind; +} + +void edges(int gpio, int level, uint32_t tick) +{ + int g; + + if (g_reset_counts) + { + g_reset_counts = 0; + for (g=0; g=0) && (g<32)) + { + g_gpio[g_num_gpios++] = g; + g_mask |= (1< +#include +#include +#include + +#include + +/* +2014-08-20 + +gcc -o freq_count_2 freq_count_2.c -lpigpio -lpthread +$ sudo ./freq_count_2 4 7 8 + +This program uses the gpioSetGetSamplesFunc function to request +a callback once a millisecond for all accumulated gpio changes +in that millisecond. + +This tends to be more efficient then calling a callback for each +gpio change during the millisecond. + +EXAMPLES + +Monitor gpio 4 (default settings) +sudo ./freq_count_2 4 + +Monitor gpios 4 and 8 (default settings) +sudo ./freq_count_2 4 8 + +Monitor gpios 4 and 8, sample rate 2 microseconds +sudo ./freq_count_2 4 8 -s2 + +Monitor gpios 7 and 8, sample rate 4 microseconds, report every second +sudo ./freq_count_2 7 8 -s4 -r10 + +Monitor gpios 4,7, 8, 9, 10, 23 24, report five times a second +sudo ./freq_count_2 4 7 8 9 10 23 24 -r2 + +Monitor gpios 4, 7, 8, and 9, report once a second, sample rate 1us, +generate 2us edges (4us square wave, 250000 highs per second). +sudo ./freq_count_2 4 7 8 9 -r 10 -s 1 -p 2 + +*/ + +#define MAX_GPIOS 32 + +#define OPT_P_MIN 1 +#define OPT_P_MAX 1000 +#define OPT_P_DEF 20 + +#define OPT_R_MIN 1 +#define OPT_R_MAX 10 +#define OPT_R_DEF 5 + +#define OPT_S_MIN 1 +#define OPT_S_MAX 10 +#define OPT_S_DEF 5 + +static volatile int g_pulse_count[MAX_GPIOS]; +static volatile int g_reset_counts; +static uint32_t g_mask; + +static int g_num_gpios; +static int g_gpio[MAX_GPIOS]; + +static int g_opt_p = OPT_P_DEF; +static int g_opt_r = OPT_R_DEF; +static int g_opt_s = OPT_S_DEF; +static int g_opt_t = 0; + +void usage() +{ + fprintf + (stderr, + "\n" \ + "Usage: sudo ./freq_count_2 gpio ... [OPTION] ...\n" \ + " -p value, sets pulses every p micros, %d-%d, TESTING only\n" \ + " -r value, sets refresh period in deciseconds, %d-%d, default %d\n" \ + " -s value, sets sampling rate in micros, %d-%d, default %d\n" \ + "\nEXAMPLE\n" \ + "sudo ./freq_count_2 4 7 -r2 -s2\n" \ + "Monitor gpios 4 and 7. Refresh every 0.2 seconds. Sample rate 2 micros.\n" \ + "\n", + OPT_P_MIN, OPT_P_MAX, + OPT_R_MIN, OPT_R_MAX, OPT_R_DEF, + OPT_S_MIN, OPT_S_MAX, OPT_S_DEF + ); +} + +void fatal(int show_usage, char *fmt, ...) +{ + char buf[128]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + fprintf(stderr, "%s\n", buf); + + if (show_usage) usage(); + + fflush(stderr); + + exit(EXIT_FAILURE); +} + +static int initOpts(int argc, char *argv[]) +{ + int i, opt; + + while ((opt = getopt(argc, argv, "p:r:s:")) != -1) + { + i = -1; + + switch (opt) + { + case 'p': + i = atoi(optarg); + if ((i >= OPT_P_MIN) && (i <= OPT_P_MAX)) + g_opt_p = i; + else fatal(1, "invalid -p option (%d)", i); + g_opt_t = 1; + break; + + case 'r': + i = atoi(optarg); + if ((i >= OPT_R_MIN) && (i <= OPT_R_MAX)) + g_opt_r = i; + else fatal(1, "invalid -r option (%d)", i); + break; + + case 's': + i = atoi(optarg); + if ((i >= OPT_S_MIN) && (i <= OPT_S_MAX)) + g_opt_s = i; + else fatal(1, "invalid -s option (%d)", i); + break; + + default: /* '?' */ + usage(); + exit(-1); + } + } + return optind; +} + +void samples(const gpioSample_t *samples, int numSamples) +{ + static uint32_t state = 0; + uint32_t high, level; + int g, s; + + if (g_reset_counts) + { + g_reset_counts = 0; + for (g=0; g=0) && (g<32)) + { + g_gpio[g_num_gpios++] = g; + g_mask |= (1< + +#include + +/* +OH3144E or equivalent Hall effect sensor + +Pin 1 - 5V +Pin 2 - Ground +Pin 3 - gpio (here P1-8, gpio 14, TXD is used) + +The internal gpio pull-up is enabled so that the sensor +normally reads high. It reads low when a magnet is close. + +gcc -o hall hall.c -lpigpio -lrt -lpthread +sudo ./hall +*/ + +#define HALL 14 + +void alert(int gpio, int level, uint32_t tick) +{ + static uint32_t lastTick=0; + + if (lastTick) printf("%d %.2f\n", level, (float)(tick-lastTick)/1000000.0); + else printf("%d 0.00\n", level); + + lastTick = tick; +} + +int main(int argc, char *argv[]) +{ + int secs=60; + + if (argc>1) secs = atoi(argv[1]); /* program run seconds */ + + if ((secs<1) || (secs>3600)) secs = 3600; + + if (gpioInitialise()<0) return 1; + + gpioSetMode(HALL, PI_INPUT); + + gpioSetPullUpDown(HALL, PI_PUD_UP); + + gpioSetAlertFunc(HALL, alert); + + sleep(secs); + + gpioTerminate(); +} + diff --git a/EXAMPLES/C/I2C_SNIFFER/README b/EXAMPLES/C/I2C_SNIFFER/README new file mode 100644 index 0000000..23b5594 --- /dev/null +++ b/EXAMPLES/C/I2C_SNIFFER/README @@ -0,0 +1,4 @@ +A program to passively sniff I2C transactions (100kHz bus maximum) and display the results. + +This C program uses pigpio notifications. + diff --git a/EXAMPLES/C/I2C_SNIFFER/pig2i2c.c b/EXAMPLES/C/I2C_SNIFFER/pig2i2c.c new file mode 100644 index 0000000..bf9102c --- /dev/null +++ b/EXAMPLES/C/I2C_SNIFFER/pig2i2c.c @@ -0,0 +1,205 @@ +/* +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pigpio.h" + +/* +This software reads pigpio notification reports monitoring the I2C signals. + +Notifications are pipe based so this software must be run on the Pi +being monitored. + +It should be able to handle a 100kHz bus. You are unlikely to get any +usable results if the bus is running at 400kHz. + +gcc -o pig2i2c pig2i2c.c + +Do something like + +sudo pigpiod -s 2 + +# get a notification handle, assume handle 0 was returned + +pigs no + +# start notifications for SCL/SDA + +e.g. pigs nb 0 0x3 # Rev. 1 select gpios 0/1 +e.g. pigs nb 0 0xC # Rev. 2 select gpios 2/3 +e.g. pigs nb 0 0xA00 # select gpios 9/11 (1<<9|1<<11) + +# run the program, specifying SCL/SDA and notification pipe + +./pig2i2c SCL SDA 2) + { + gSCL = atoi(argv[1]); + gSDA = atoi(argv[2]); + + bSCL = 1< + +#include + +#include "ir_hasher.h" + +/* +This code forms a hash over the IR pulses generated by an +IR remote. + +The remote key press is not converted into a code in the manner of +the lirc module. No attempt is made to decode the type of protocol +used by the remote. The hash is likely to be unique for different +keys and different remotes but this is not guaranteed. + +This hashing process works for some remotes/protocols but not for +others. The only way to find out if it works for one or more of +your remotes is to try it and see. +*/ + +struct _Pi_Hasher_s +{ + int gpio; + Pi_Hasher_CB_t callback; + int timeout; + int in_code; + uint32_t hash_val; + int edges; + int t1; + int t2; + int t3; + int t4; +}; + + +static uint32_t _hash(uint32_t hv, int old_val, int new_val) +{ + int val; + + if (new_val < (old_val * 0.60)) val = 13; + else if (old_val < (new_val * 0.60)) val = 23; + else val = 2; + + hv ^= val; + hv *= 16777619; /* FNV_PRIME_32 */ + + return hv; +} + +static void _cb(int gpio, int level, uint32_t tick, void *user) +{ + Pi_Hasher_t * hasher; + + hasher = user; + + if (level != PI_TIMEOUT) + { + if (hasher->in_code == 0) + { + hasher->in_code = 1; + + gpioSetWatchdog(gpio, hasher->timeout); + + hasher->hash_val = 2166136261U; /* FNV_BASIS_32 */ + + hasher->edges = 1; + + hasher->t1 = 0; + hasher->t2 = 0; + hasher->t3 = 0; + hasher->t4 = tick; + } + else + { + hasher->edges++; + + hasher->t1 = hasher->t2; + hasher->t2 = hasher->t3; + hasher->t3 = hasher->t4; + hasher->t4 = tick; + + if (hasher->edges > 3) + { + hasher->hash_val = + _hash(hasher->hash_val, + (hasher->t2)-(hasher->t1), + (hasher->t4)-(hasher->t3)); + } + } + } + else + { + if (hasher->in_code) + { + hasher->in_code = 0; + + gpioSetWatchdog(gpio, 0); + + if (hasher->edges > 12) /* Anything less is probably noise. */ + { + (hasher->callback)(hasher->hash_val); + } + } + } +} + +Pi_Hasher_t *Pi_Hasher(int gpio, Pi_Hasher_CB_t callback, int timeout) +{ + Pi_Hasher_t *hasher; + + hasher = malloc(sizeof(Pi_Hasher_t)); + + hasher->gpio = gpio; + hasher->callback = callback; + hasher->timeout = 5; + + hasher->in_code = 0; + + gpioSetMode(gpio, PI_INPUT); + gpioSetAlertFuncEx(gpio, _cb, hasher); + + return hasher; +} + +void Pi_Hasher_cancel(Pi_Hasher_t *hasher) +{ + if (hasher) + { + gpioSetAlertFunc(hasher->gpio, 0); + + free(hasher); + + hasher = NULL; + } +} + diff --git a/EXAMPLES/C/IR_RECEIVER/ir_hasher.h b/EXAMPLES/C/IR_RECEIVER/ir_hasher.h new file mode 100644 index 0000000..ef2278f --- /dev/null +++ b/EXAMPLES/C/IR_RECEIVER/ir_hasher.h @@ -0,0 +1,33 @@ +#ifndef IR_HASHER_H +#define IR_HASHER_H + +#include + +typedef void (*Pi_Hasher_CB_t)(uint32_t); + +struct _Pi_Hasher_s; + +typedef struct _Pi_Hasher_s Pi_Hasher_t; + +Pi_Hasher_t * Pi_Hasher(int gpio, Pi_Hasher_CB_t callback, int timeout); + /* + This function establishes an IR hasher on the gpio. + + A gap of timeout milliseconds without a new bit indicates + the end of a code. + + When code end is detected the callback function is called + with the code hash. + + A pointer to a private data type is returned. This should be passed + to Pi_Hasher_cancel if the hasher is to be cancelled. + */ + + +void Pi_Hasher_cancel(Pi_Hasher_t *hasher); + /* + This function releases the resources used by the hasher. + */ + + +#endif diff --git a/EXAMPLES/C/IR_RECEIVER/test_ir_hasher.c b/EXAMPLES/C/IR_RECEIVER/test_ir_hasher.c new file mode 100644 index 0000000..28673b7 --- /dev/null +++ b/EXAMPLES/C/IR_RECEIVER/test_ir_hasher.c @@ -0,0 +1,47 @@ +#include + +#include + +#include "ir_hasher.h" + +/* + +REQUIRES + +An IR receiver output pin connected to a Pi gpio. + +TO BUILD + +gcc -o ir_hash_c test_ir_hasher.c ir_hasher.c -lpigpio -lrt -lpthread + +TO RUN + +sudo ./ir_hash_c + +*/ + +void callback(uint32_t hash) +{ + printf("hash=%u\n", hash); +} + +int main(int argc, char *argv[]) +{ + Pi_Hasher_t *hasher; + + if (gpioInitialise() < 0) return 1; + + /* + This assumes the output pin of an IR receiver is + connected to gpio 7. + */ + + hasher = Pi_Hasher(7, callback, 5); + + sleep(300); + + Pi_Hasher_cancel(hasher); + + gpioTerminate(); +} + diff --git a/EXAMPLES/C/PCF8591_YL-40/PCF8591.c b/EXAMPLES/C/PCF8591_YL-40/PCF8591.c new file mode 100644 index 0000000..5d9e185 --- /dev/null +++ b/EXAMPLES/C/PCF8591_YL-40/PCF8591.c @@ -0,0 +1,131 @@ +#include +#include +#include +#include +#include +#include /* libncurses5-dev */ + +/* +2014-08-26 PCF8591.c + +sudo apt-get install libncurses5-dev + +gcc -o PCF8591 PCF8591.c -lcurses -lpigpio -lpthread + +sudo ./PCF8591 +*/ + +/* +Connect Pi 3V3 - VCC, Ground - Ground, SDA - SDA, SCL - SCL. +*/ + +#define PCF8591_I2C_ADDR 0x48 + +/* + P4 The thermister voltage is provided at AIN 1. + P5 The photocell voltage is provided at AIN 0. + P6 The single turn 10K ohm trim pot voltage is provided at AIN 3. +*/ + +/* +7 6 5 4 3 2 1 0 +0 X X X 0 X X X + | | | | | | + A B B C D D + +0 1 0 0 0 1 0 0 + +A 0 D/A inactive + 1 D/A active + +B 00 single ended inputs + 01 differential inputs + 10 single ended and differential + 11 two differential inputs + +C 0 no auto inc + 1 auto inc + +D 00 select channel 0 + 01 select channel 1 + 10 select channel 2 + 11 select channel 3 + +*/ + +int main(int argc, char *argv[]) +{ + int i; + int r; + int handle; + char aout; + unsigned char command[2]; + unsigned char value[4]; + unsigned char str[8]; + + int j; + int key; + + if (gpioInitialise() < 0) return 1; + + initscr(); + noecho(); + cbreak(); + nodelay(stdscr, true); + curs_set(0); + + printw("PCF8591 + or - to change aout, any other key to quit."); + + mvaddstr(10, 0, "Brightness"); + mvaddstr(12, 0, "Temperature"); + mvaddstr(14, 0, "?"); + mvaddstr(16, 0, "Resistor"); + + refresh(); + + handle = i2cOpen(1, PCF8591_I2C_ADDR, 0); + + command[1] = 0; + aout = 128; + + while (1) + { + for (i=0; i<4; i++) + { + command[1] = aout; + command[0] = 0x40 | ((i + 1) & 0x03); // output enable | read input i + + i2cWriteDevice(handle, &command, 2); + + usleep(20000); + + // the read is always one step behind the selected input + value[i] = i2cReadByte(handle); + + sprintf(str, "%3d", value[i]); + mvaddstr(10+i+i, 12, str); + value[i] = value[i] / 4; + move(10 + i + i, 16); + + for(j = 0; j < 64; j++) + if(j < value[i]) addch('*'); else addch(' '); + } + + refresh(); + + key = getch(); + + if ((key == '+') || (key == '=')) aout++; + else if ((key == '-') || (key == '_')) aout--; + else if (key != -1) break; + } + + endwin(); + + i2cClose(handle); + + gpioTerminate(); + + return (0); +} + diff --git a/EXAMPLES/C/PCF8591_YL-40/README b/EXAMPLES/C/PCF8591_YL-40/README new file mode 100644 index 0000000..40428b1 --- /dev/null +++ b/EXAMPLES/C/PCF8591_YL-40/README @@ -0,0 +1 @@ +A program to display readings from the (I2C) PCF8591. diff --git a/EXAMPLES/C/POT_CAP_RECHARGE/README b/EXAMPLES/C/POT_CAP_RECHARGE/README new file mode 100644 index 0000000..530685c --- /dev/null +++ b/EXAMPLES/C/POT_CAP_RECHARGE/README @@ -0,0 +1,3 @@ +Function to time capacitor charging (through a resistance). + +The time can be used to estimate the resistance. diff --git a/EXAMPLES/C/POT_CAP_RECHARGE/pot_cap_charge.c b/EXAMPLES/C/POT_CAP_RECHARGE/pot_cap_charge.c new file mode 100644 index 0000000..811e3f7 --- /dev/null +++ b/EXAMPLES/C/POT_CAP_RECHARGE/pot_cap_charge.c @@ -0,0 +1,94 @@ +#include + +#include + +/* + Measure how long a capacitor takes to charge through a resistance. + + A potentimeter is used to vary the resistance. + + The time taken will be proportional to the resistance. + + 3V3 ----- Potentiometer --+-- Capacitor ----- Ground + | + +-- gpio + + + gcc -o pot_cap_charge pot_cap_charge.c -lpigpio -lpthread -lrt + sudo ./pot_cap_charge + +*/ + +#define GPIO 25 + +#define MAX_READING 1000 + +static uint32_t rechargeTick = 0; + +void callback(int gpio, int level, uint32_t tick) +{ + static uint32_t smooth = 0; + static int reading = 0; + + uint32_t raw; + + if (level == 1) /* measure recharge time */ + { + ++reading; + + if (rechargeTick) + { + raw = tick - rechargeTick; /* set in main */ + + if (raw < MAX_READING) /* ignore outliers */ + { + /* smooth using 0.8 * smooth + 0.2 * raw */ + + smooth = (raw + (4 * smooth)) / 5; + + printf("%d %d %d\n", reading, raw, smooth); + } + else + { + /* ignore outlier, set dot at fixed position */ + printf("%d %d %d\n", reading, 40, smooth); + } + } + else + { + /* ignore reschedule, set dot at fixed position */ + printf("%d %d %d\n", reading, 20, smooth); + } + } +} + +int main (int argc, char *argv[]) +{ + uint32_t t1, t2; + int tDiff; + + if (gpioInitialise()<0) return 1; + + gpioSetAlertFunc(GPIO, callback); /* callback when GPIO changes state */ + + while (1) + { + gpioWrite(GPIO, PI_OFF); /* drain capacitor */ + + gpioDelay(200); /* microseconds */ + + t1 = gpioTick(); + + gpioSetMode(GPIO, PI_INPUT); /* start capacitor recharge */ + + t2 = gpioTick(); + + /* dump reading if rechargeTick not accurate to 3 micros */ + + if ((t2 - t1) < 3) rechargeTick = t1; else rechargeTick = 0; + + gpioDelay(5000); /* microseconds, nominal 200 readings per second */ + } + + gpioTerminate(); +} diff --git a/EXAMPLES/C/ROTARY_ENCODER/README b/EXAMPLES/C/ROTARY_ENCODER/README new file mode 100644 index 0000000..d07037e --- /dev/null +++ b/EXAMPLES/C/ROTARY_ENCODER/README @@ -0,0 +1,4 @@ +Function to decode a mechanical rotary encoder. + +Follow the instructions in the test file to build and run. + diff --git a/EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.c b/EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.c new file mode 100644 index 0000000..5bccba7 --- /dev/null +++ b/EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.c @@ -0,0 +1,94 @@ +#include +#include + +#include + +#include "rotary_encoder.h" + +struct _Pi_Renc_s +{ + int gpioA; + int gpioB; + Pi_Renc_CB_t callback; + int levA; + int levB; + int lastGpio; +}; + +/* + + +---------+ +---------+ 0 + | | | | + A | | | | + | | | | + +---------+ +---------+ +----- 1 + + +---------+ +---------+ 0 + | | | | + B | | | | + | | | | + ----+ +---------+ +---------+ 1 + +*/ + +static void _cb(int gpio, int level, uint32_t tick, void *user) +{ + Pi_Renc_t *renc; + + renc = user; + + if (gpio == renc->gpioA) renc->levA = level; else renc->levB = level; + + if (gpio != renc->lastGpio) /* debounce */ + { + renc->lastGpio = gpio; + + if ((gpio == renc->gpioA) && (level == 1)) + { + if (renc->levB) (renc->callback)(1); + } + else if ((gpio == renc->gpioB) && (level == 1)) + { + if (renc->levA) (renc->callback)(-1); + } + } +} + +Pi_Renc_t * Pi_Renc(int gpioA, int gpioB, Pi_Renc_CB_t callback) +{ + Pi_Renc_t *renc; + + renc = malloc(sizeof(Pi_Renc_t)); + + renc->gpioA = gpioA; + renc->gpioB = gpioB; + renc->callback = callback; + renc->levA=0; + renc->levB=0; + renc->lastGpio = -1; + + gpioSetMode(gpioA, PI_INPUT); + gpioSetMode(gpioB, PI_INPUT); + + /* pull up is needed as encoder common is grounded */ + + gpioSetPullUpDown(gpioA, PI_PUD_UP); + gpioSetPullUpDown(gpioB, PI_PUD_UP); + + /* monitor encoder level changes */ + + gpioSetAlertFuncEx(gpioA, _cb, renc); + gpioSetAlertFuncEx(gpioB, _cb, renc); +} + +void Pi_Renc_cancel(Pi_Renc_t *renc) +{ + if (renc) + { + gpioSetAlertFunc(renc->gpioA, 0); + gpioSetAlertFunc(renc->gpioB, 0); + + free(renc); + } +} + diff --git a/EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.h b/EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.h new file mode 100644 index 0000000..73f7454 --- /dev/null +++ b/EXAMPLES/C/ROTARY_ENCODER/rotary_encoder.h @@ -0,0 +1,25 @@ +#ifndef ROTARY_ENCODER_H +#define ROTARY_ENCODER_H + +typedef void (*Pi_Renc_CB_t)(int); + +struct _Pi_Renc_s; + +typedef struct _Pi_Renc_s Pi_Renc_t; + +Pi_Renc_t * Pi_Renc(int gpioA, int gpioB, Pi_Renc_CB_t callback); +/* + This function establishes a rotary encoder on gpioA and gpioB. + + When the encoder is turned the callback function is called. + + A pointer to a private data type is returned. This should be passed + to Pi_Renc_cancel if the rotary encoder is to be cancelled. +*/ + +void Pi_Renc_cancel(Pi_Renc_t *renc); +/* + This function releases the resources used by the decoder. +*/ + +#endif diff --git a/EXAMPLES/C/ROTARY_ENCODER/test_rotary_encoder.c b/EXAMPLES/C/ROTARY_ENCODER/test_rotary_encoder.c new file mode 100644 index 0000000..9f512e0 --- /dev/null +++ b/EXAMPLES/C/ROTARY_ENCODER/test_rotary_encoder.c @@ -0,0 +1,47 @@ +#include + +#include + +#include "rotary_encoder.h" + +/* + +REQUIRES + +A rotary encoder contacts A and B connected to separate gpios and +the common contact connected to Pi ground. + +TO BUILD + +gcc -o rot_enc_c test_rotary_encoder.c rotary_encoder.c -lpigpio -lrt + +TO RUN + +sudo ./rot_enc_c + +*/ + +void callback(int way) +{ + static int pos = 0; + + pos += way; + + printf("pos=%d\n", pos); +} + +int main(int argc, char *argv[]) +{ + Pi_Renc_t * renc; + + if (gpioInitialise() < 0) return 1; + + renc = Pi_Renc(7, 8, callback); + + sleep(300); + + Pi_Renc_cancel(renc); + + gpioTerminate(); +} + diff --git a/EXAMPLES/C/WIEGAND_CODE/README b/EXAMPLES/C/WIEGAND_CODE/README new file mode 100644 index 0000000..38d5acb --- /dev/null +++ b/EXAMPLES/C/WIEGAND_CODE/README @@ -0,0 +1,4 @@ +Function to decode a Wiegand code. + +Follow the instructions in the test file to build and run. + diff --git a/EXAMPLES/C/WIEGAND_CODE/test_wiegand.c b/EXAMPLES/C/WIEGAND_CODE/test_wiegand.c new file mode 100644 index 0000000..8aef6d6 --- /dev/null +++ b/EXAMPLES/C/WIEGAND_CODE/test_wiegand.c @@ -0,0 +1,42 @@ +#include + +#include + +#include "wiegand.h" + +/* + +REQUIRES + +Wiegand contacts 0 and 1 connected to separate gpios. + +TO BUILD + +gcc -o wiegand_c test_wiegand.c wiegand.c -lpigpio -lrt + +TO RUN + +sudo ./wiegand_c + +*/ + +void callback(int bits, uint32_t value) +{ + printf("bits=%d value=%u\n", bits, value); +} + +int main(int argc, char *argv[]) +{ + Pi_Wieg_t * w; + + if (gpioInitialise() < 0) return 1; + + w = Pi_Wieg(14, 15, callback, 5); + + sleep(300); + + Pi_Wieg_cancel(w); + + gpioTerminate(); +} + diff --git a/EXAMPLES/C/WIEGAND_CODE/wiegand.c b/EXAMPLES/C/WIEGAND_CODE/wiegand.c new file mode 100644 index 0000000..5bfecd7 --- /dev/null +++ b/EXAMPLES/C/WIEGAND_CODE/wiegand.c @@ -0,0 +1,137 @@ +#include + +#include + +#include "wiegand.h" + +struct _Pi_Wieg_s +{ + int mygpio_0; + int mygpio_1; + int mytimeout; + int in_code; + int bits; + Pi_Wieg_CB_t mycallback; + uint32_t num; + uint32_t code_timeout; +}; + +void _cb(int gpio, int level, uint32_t tick, void *user) +{ + /* + Accumulate bits until both gpios 0 and 1 timeout. + */ + + Pi_Wieg_t *wieg; + + wieg = user; + + if (level == 0) /* a falling edge indicates a new bit */ + { + if (!wieg->in_code) + { + wieg->bits = 1; + wieg->num = 0; + + wieg->in_code = 1; + wieg->code_timeout = 0; + + gpioSetWatchdog(wieg->mygpio_0, wieg->mytimeout); + gpioSetWatchdog(wieg->mygpio_1, wieg->mytimeout); + } + else + { + wieg->bits++; + wieg->num <<= 1; + } + + if (gpio == wieg->mygpio_0) + { + wieg->code_timeout &= 2; /* clear gpio 0 timeout */ + } + else + { + wieg->code_timeout &= 1; /* clear gpio 1 timeout */ + wieg->num |= 1; + } + } + else if (level == PI_TIMEOUT) + { + if (wieg->in_code) + { + if (gpio == wieg->mygpio_0) + { + wieg->code_timeout |= 1; /* timeout gpio 0 */ + } + else + { + wieg->code_timeout |= 2; /* timeout gpio 1 */ + } + + if (wieg->code_timeout == 3) /* both gpios timed out */ + { + gpioSetWatchdog(wieg->mygpio_0, 0); + gpioSetWatchdog(wieg->mygpio_1, 0); + + wieg->in_code = 0; + + (wieg->mycallback)(wieg->bits, wieg->num); + } + } + } +} + +Pi_Wieg_t * Pi_Wieg( + int gpio_0, + int gpio_1, + Pi_Wieg_CB_t callback, + int timeout) +{ + /* + Instantiate with the gpio for 0 (green wire), the gpio for 1 + (white wire), the callback function, and the timeout in + milliseconds which indicates the end of a code. + + The callback is passed the code length in bits and the value. + */ + + Pi_Wieg_t *wieg; + + wieg = malloc(sizeof(Pi_Wieg_t)); + + wieg->mygpio_0 = gpio_0; + wieg->mygpio_1 = gpio_1; + + wieg->mycallback = callback; + + wieg->mytimeout = timeout; + + wieg->in_code = 0; + + gpioSetMode(gpio_0, PI_INPUT); + gpioSetMode(gpio_1, PI_INPUT); + + gpioSetPullUpDown(gpio_0, PI_PUD_UP); + gpioSetPullUpDown(gpio_1, PI_PUD_UP); + + gpioSetAlertFuncEx(gpio_0, _cb, wieg); + gpioSetAlertFuncEx(gpio_1, _cb, wieg); + + return wieg; +} + +void Pi_Wieg_cancel(Pi_Wieg_t *wieg) +{ + /* + Cancel the Wiegand decoder. + */ + + if (wieg) + { + gpioSetAlertFunc(wieg->mygpio_0, 0); + gpioSetAlertFunc(wieg->mygpio_1, 0); + + free(wieg); + } +} + diff --git a/EXAMPLES/C/WIEGAND_CODE/wiegand.h b/EXAMPLES/C/WIEGAND_CODE/wiegand.h new file mode 100644 index 0000000..8deaa3a --- /dev/null +++ b/EXAMPLES/C/WIEGAND_CODE/wiegand.h @@ -0,0 +1,32 @@ +#ifndef WIEGAND_H +#define WIEGAND_H + +#include + +typedef void (*Pi_Wieg_CB_t)(int, uint32_t); + +struct _Pi_Wieg_s; + +typedef struct _Pi_Wieg_s Pi_Wieg_t; + +Pi_Wieg_t *Pi_Wieg(int gpio_0, int gpio_1, Pi_Wieg_CB_t callback, int timeout); + /* + This function establishes a Wiegand decoder on gpio_0 and gpio_1. + + A gap of timeout milliseconds without a new bit indicates the + end of a code. + + When the code is ended the callback function is called with the code + bit length and value. + + A pointer to a private data type is returned. This should be passed + to Pi_Wieg_cancel if the decoder is to be cancelled. + */ + +void Pi_Wieg_cancel(Pi_Wieg_t *wieg); + /* + This function releases the resources used by the decoder. + */ + +#endif + diff --git a/EXAMPLES/CPP/IR_RECEIVER/README b/EXAMPLES/CPP/IR_RECEIVER/README new file mode 100644 index 0000000..ccb0165 --- /dev/null +++ b/EXAMPLES/CPP/IR_RECEIVER/README @@ -0,0 +1,4 @@ +Class to hash a code from an IR receiver (reading an IR remote control). + +Follow the instructions in the test file to build and run. + diff --git a/EXAMPLES/CPP/IR_RECEIVER/ir_hasher.cpp b/EXAMPLES/CPP/IR_RECEIVER/ir_hasher.cpp new file mode 100644 index 0000000..d2d01fd --- /dev/null +++ b/EXAMPLES/CPP/IR_RECEIVER/ir_hasher.cpp @@ -0,0 +1,91 @@ +#include + +#include "ir_hasher.hpp" + +void Hasher::_hash(int old_val, int new_val) +{ + int val; + + if (new_val < (old_val * 0.60)) val = 13; + else if (old_val < (new_val * 0.60)) val = 23; + else val = 2; + + hash_val ^= val; + hash_val *= 16777619; /* FNV_PRIME_32 */ +} + +void Hasher::_callback(int gpio, int level, uint32_t tick) +{ + if (level != PI_TIMEOUT) + { + if (in_code == 0) + { + in_code = 1; + + gpioSetWatchdog(mygpio, mytimeout); + + hash_val = 2166136261U; /* FNV_BASIS_32 */ + + edges = 1; + + t1 = 0; + t2 = 0; + t3 = 0; + t4 = tick; + } + else + { + edges++; + + t1 = t2; + t2 = t3; + t3 = t4; + t4 = tick; + + if (edges > 3) _hash(t2-t1, t4-t3); + } + } + else + { + if (in_code) + { + in_code = 0; + + gpioSetWatchdog(mygpio, 0); + + if (edges > 12) /* Anything less is probably noise. */ + { + (mycallback)(hash_val); + } + } + } +} + +void Hasher::_callbackExt(int gpio, int level, uint32_t tick, void *user) +{ + /* + Need a static callback to link with C. + */ + + Hasher *mySelf = (Hasher *) user; + + mySelf->_callback(gpio, level, tick); /* Call the instance callback. */ +} + +Hasher::Hasher(int gpio, HasherCB_t callback, int timeout) +{ + /* + Initialises an IR remote hasher on a gpio. A gap of timeout + milliseconds indicates the end of the remote key press. + */ + mygpio = gpio; + mycallback = callback; + mytimeout = timeout; + + in_code = 0; + + gpioSetMode(gpio, PI_INPUT); + + gpioSetAlertFuncEx(gpio, _callbackExt, (void *)this); +} + diff --git a/EXAMPLES/CPP/IR_RECEIVER/ir_hasher.hpp b/EXAMPLES/CPP/IR_RECEIVER/ir_hasher.hpp new file mode 100644 index 0000000..2e9322a --- /dev/null +++ b/EXAMPLES/CPP/IR_RECEIVER/ir_hasher.hpp @@ -0,0 +1,44 @@ +#ifndef IR_RX_HASHER_HPP +#define IR_RX_HASHER_HPP + +#include + +typedef void (*HasherCB_t)(uint32_t); + +class Hasher +{ + + /* + This class forms a hash over the IR pulses generated by an + IR remote. + + The remote key press is not converted into a code in the manner of + the lirc module. No attempt is made to decode the type of protocol + used by the remote. The hash is likely to be unique for different + keys and different remotes but this is not guaranteed. + + This hashing process works for some remotes/protocols but not for + others. The only way to find out if it works for one or more of + your remotes is to try it and see. + */ + + int mygpio, mytimeout; + HasherCB_t mycallback; + int in_code; + uint32_t hash_val; + int edges; + uint32_t t1, t2, t3, t4; + + void _hash(int old_val, int new_val); + void _callback(int gpio, int level, uint32_t tick); + + /* Need a static callback to link with C. */ + static void _callbackExt(int gpio, int level, uint32_t tick, void *user); + + public: + + Hasher(int gpio, HasherCB_t callback, int timeout=5); +}; + +#endif + diff --git a/EXAMPLES/CPP/IR_RECEIVER/test_ir_hasher.cpp b/EXAMPLES/CPP/IR_RECEIVER/test_ir_hasher.cpp new file mode 100644 index 0000000..40788cc --- /dev/null +++ b/EXAMPLES/CPP/IR_RECEIVER/test_ir_hasher.cpp @@ -0,0 +1,44 @@ +#include + +#include + +#include "ir_hasher.hpp" + +/* + +REQUIRES + +An IR receiver output pin connected to a Pi gpio. + +TO BUILD + +g++ -o ir_hash_cpp test_ir_hasher.cpp ir_hasher.cpp -lpigpio -lrt -lpthread + +TO RUN + +sudo ./ir_hash_cpp + +*/ + +void callback(uint32_t hash) +{ + std::cout << "hash=" << hash << std::endl; +} + +int main(int argc, char *argv[]) +{ + if (gpioInitialise() >= 0) + { + /* Can't instantiate a Hasher before pigpio is initialised. */ + + /* + This assumes the output pin of an IR receiver is + connected to gpio 7. + */ + + Hasher ir(7, callback); + + sleep(300); + } +} + diff --git a/EXAMPLES/CPP/ROTARY_ENCODER/README b/EXAMPLES/CPP/ROTARY_ENCODER/README new file mode 100644 index 0000000..f9e01cb --- /dev/null +++ b/EXAMPLES/CPP/ROTARY_ENCODER/README @@ -0,0 +1,4 @@ +Class to decode a mechanical rotary encoder. + +Follow the instructions in the test file to build and run. + diff --git a/EXAMPLES/CPP/ROTARY_ENCODER/rotary_encoder.cpp b/EXAMPLES/CPP/ROTARY_ENCODER/rotary_encoder.cpp new file mode 100644 index 0000000..f0b6fb7 --- /dev/null +++ b/EXAMPLES/CPP/ROTARY_ENCODER/rotary_encoder.cpp @@ -0,0 +1,84 @@ +#include + +#include + +#include "rotary_encoder.hpp" + +/* + + +---------+ +---------+ 0 + | | | | + A | | | | + | | | | + +---------+ +---------+ +----- 1 + + +---------+ +---------+ 0 + | | | | + B | | | | + | | | | + ----+ +---------+ +---------+ 1 + +*/ + +void re_decoder::_pulse(int gpio, int level, uint32_t tick) +{ + if (gpio == mygpioA) levA = level; else levB = level; + + if (gpio != lastGpio) /* debounce */ + { + lastGpio = gpio; + + if ((gpio == mygpioA) && (level == 1)) + { + if (levB) (mycallback)(1); + } + else if ((gpio == mygpioB) && (level == 1)) + { + if (levA) (mycallback)(-1); + } + } +} + +void re_decoder::_pulseEx(int gpio, int level, uint32_t tick, void *user) +{ + /* + Need a static callback to link with C. + */ + + re_decoder *mySelf = (re_decoder *) user; + + mySelf->_pulse(gpio, level, tick); /* Call the instance callback. */ +} + +re_decoder::re_decoder(int gpioA, int gpioB, re_decoderCB_t callback) +{ + mygpioA = gpioA; + mygpioB = gpioB; + + mycallback = callback; + + levA=0; + levB=0; + + lastGpio = -1; + + gpioSetMode(gpioA, PI_INPUT); + gpioSetMode(gpioB, PI_INPUT); + + /* pull up is needed as encoder common is grounded */ + + gpioSetPullUpDown(gpioA, PI_PUD_UP); + gpioSetPullUpDown(gpioB, PI_PUD_UP); + + /* monitor encoder level changes */ + + gpioSetAlertFuncEx(gpioA, _pulseEx, this); + gpioSetAlertFuncEx(gpioB, _pulseEx, this); +} + +void re_decoder::re_cancel(void) +{ + gpioSetAlertFuncEx(mygpioA, 0, this); + gpioSetAlertFuncEx(mygpioB, 0, this); +} + diff --git a/EXAMPLES/CPP/ROTARY_ENCODER/rotary_encoder.hpp b/EXAMPLES/CPP/ROTARY_ENCODER/rotary_encoder.hpp new file mode 100644 index 0000000..e2ef8c0 --- /dev/null +++ b/EXAMPLES/CPP/ROTARY_ENCODER/rotary_encoder.hpp @@ -0,0 +1,35 @@ +#ifndef ROTARY_ENCODER_HPP +#define ROTARY_ENCODER_HPP + +#include + +typedef void (*re_decoderCB_t)(int); + +class re_decoder +{ + int mygpioA, mygpioB, levA, levB, lastGpio; + + re_decoderCB_t mycallback; + + void _pulse(int gpio, int level, uint32_t tick); + + /* Need a static callback to link with C. */ + static void _pulseEx(int gpio, int level, uint32_t tick, void *user); + + + public: + + re_decoder(int gpioA, int gpioB, re_decoderCB_t callback); + /* + This function establishes a rotary encoder on gpioA and gpioB. + + When the encoder is turned the callback function is called. + */ + + void re_cancel(void); + /* + This function releases the resources used by the decoder. + */ +}; + +#endif diff --git a/EXAMPLES/CPP/ROTARY_ENCODER/test_rotary_encoder.cpp b/EXAMPLES/CPP/ROTARY_ENCODER/test_rotary_encoder.cpp new file mode 100644 index 0000000..f1d6a59 --- /dev/null +++ b/EXAMPLES/CPP/ROTARY_ENCODER/test_rotary_encoder.cpp @@ -0,0 +1,45 @@ +#include + +#include + +#include "rotary_encoder.hpp" + +/* + +REQUIRES + +A rotary encoder contacts A and B connected to separate gpios and +the common contact connected to Pi ground. + +TO BUILD + +g++ -o rot_enc_cpp test_rotary_encoder.cpp rotary_encoder.cpp -lpigpio -lrt + +TO RUN + +sudo ./rot_enc_cpp + +*/ + +void callback(int way) +{ + static int pos = 0; + + pos += way; + + std::cout << "pos=" << pos << std::endl; +} + +int main(int argc, char *argv[]) +{ + if (gpioInitialise() < 0) return 1; + + re_decoder dec(7, 8, callback); + + sleep(3000); + + dec.re_cancel(); + + gpioTerminate(); +} + diff --git a/EXAMPLES/CPP/WIEGAND_CODE/README b/EXAMPLES/CPP/WIEGAND_CODE/README new file mode 100644 index 0000000..28079b4 --- /dev/null +++ b/EXAMPLES/CPP/WIEGAND_CODE/README @@ -0,0 +1,3 @@ +Class to decode a Wiegand code. + +Follow the instructions in the test file to build and run. diff --git a/EXAMPLES/CPP/WIEGAND_CODE/test_wiegand.cpp b/EXAMPLES/CPP/WIEGAND_CODE/test_wiegand.cpp new file mode 100644 index 0000000..ca225a4 --- /dev/null +++ b/EXAMPLES/CPP/WIEGAND_CODE/test_wiegand.cpp @@ -0,0 +1,40 @@ +#include + +#include + +#include "wiegand.hpp" + +/* + +REQUIRES + +Wiegand contacts 0 and 1 connected to separate gpios. + +TO BUILD + +g++ -o wiegand_cpp test_wiegand.cpp wiegand.cpp -lpigpio -lrt + +TO RUN + +sudo ./wiegand_cpp + +*/ + +void callback(int bits, uint32_t value) +{ + std::cout << "bits=" << bits << " value=" << value << std::endl; +} + +int main(int argc, char *argv[]) +{ + if (gpioInitialise() < 0) return 1; + + Wiegand dec(14, 15, callback); + + sleep(300); + + dec.cancel(); + + gpioTerminate(); +} + diff --git a/EXAMPLES/CPP/WIEGAND_CODE/wiegand.cpp b/EXAMPLES/CPP/WIEGAND_CODE/wiegand.cpp new file mode 100644 index 0000000..598b76d --- /dev/null +++ b/EXAMPLES/CPP/WIEGAND_CODE/wiegand.cpp @@ -0,0 +1,116 @@ +#include + +#include "wiegand.hpp" + +Wiegand::Wiegand(int gpio_0, int gpio_1, WiegandCB_t callback, int timeout) +{ + /* + Instantiate with the gpio for 0 (green wire), the gpio for 1 + (white wire), the callback function, and the bit timeout in + milliseconds which indicates the end of a code. + + The callback is passed the code length in bits and the value. + */ + + mygpio_0 = gpio_0; + mygpio_1 = gpio_1; + + mycallback = callback; + + mytimeout = timeout; + + in_code = 0; + + gpioSetMode(gpio_0, PI_INPUT); + gpioSetMode(gpio_1, PI_INPUT); + + gpioSetPullUpDown(gpio_0, PI_PUD_UP); + gpioSetPullUpDown(gpio_1, PI_PUD_UP); + + gpioSetAlertFuncEx(gpio_0, _cbEx, this); + gpioSetAlertFuncEx(gpio_1, _cbEx, this); +} + +void Wiegand::_cb(int gpio, int level, uint32_t tick) +{ + /* + Accumulate bits until both gpios 0 and 1 timeout. + */ + + if (level == 0) /* a falling edge indicates a new bit */ + { + if (!in_code) + { + bits = 1; + num = 0; + + in_code = 1; + code_timeout = 0; + + gpioSetWatchdog(mygpio_0, mytimeout); + gpioSetWatchdog(mygpio_1, mytimeout); + } + else + { + bits++; + num <<= 1; + } + + if (gpio == mygpio_0) + { + code_timeout &= 2; /* clear gpio 0 timeout */ + } + else + { + code_timeout &= 1; /* clear gpio 1 timeout */ + num |= 1; + } + } + else if (level == PI_TIMEOUT) + { + if (in_code) + { + if (gpio == mygpio_0) + { + code_timeout |= 1; /* timeout gpio 0 */ + } + else + { + code_timeout |= 2; /* timeout gpio 1 */ + } + + if (code_timeout == 3) /* both gpios timed out */ + { + gpioSetWatchdog(mygpio_0, 0); + gpioSetWatchdog(mygpio_1, 0); + + in_code = 0; + + (mycallback)(bits, num); + } + } + } +} + +void Wiegand::_cbEx(int gpio, int level, uint32_t tick, void *user) +{ + /* + Need a static callback to link with C. + */ + + Wiegand *mySelf = (Wiegand *) user; + + mySelf->_cb(gpio, level, tick); /* Call the instance callback. */ +} + + +void Wiegand::cancel(void) +{ + /* + Cancel the Wiegand decoder. + */ + + gpioSetAlertFuncEx(mygpio_0, 0, this); + gpioSetAlertFuncEx(mygpio_1, 0, this); +} + diff --git a/EXAMPLES/CPP/WIEGAND_CODE/wiegand.hpp b/EXAMPLES/CPP/WIEGAND_CODE/wiegand.hpp new file mode 100644 index 0000000..4b5215c --- /dev/null +++ b/EXAMPLES/CPP/WIEGAND_CODE/wiegand.hpp @@ -0,0 +1,43 @@ +#ifndef WIEGAND_HPP +#define WIEGAND_HPP + +#include + +typedef void (*WiegandCB_t)(int, uint32_t); + +class Wiegand +{ + int mygpio_0, mygpio_1, mytimeout, in_code, bits; + + WiegandCB_t mycallback; + + uint32_t num; + + uint32_t code_timeout; + + void _cb(int gpio, int level, uint32_t tick); + + /* Need a static callback to link with C. */ + static void _cbEx(int gpio, int level, uint32_t tick, void *user); + + public: + + Wiegand(int gpio_0, int gpio_1, WiegandCB_t callback, int timeout=5); + /* + This function establishes a Wiegand decoder on gpio_0 and gpio_1. + + A gap of timeout milliseconds without a new bit indicates + the end of a code. + + When the code is ended the callback function is called with the code + bit length and value. + */ + + void cancel(void); + /* + This function releases the resources used by the decoder. + */ +}; + +#endif + diff --git a/EXAMPLES/Python/DHT11_SENSOR/README b/EXAMPLES/Python/DHT11_SENSOR/README new file mode 100644 index 0000000..6e3259c --- /dev/null +++ b/EXAMPLES/Python/DHT11_SENSOR/README @@ -0,0 +1,2 @@ +Class to read the relative humidity and temperature from a DHT11 sensor. +It implements the iterator python protocol. diff --git a/EXAMPLES/Python/DHT11_SENSOR/dht11.py b/EXAMPLES/Python/DHT11_SENSOR/dht11.py new file mode 100644 index 0000000..455ad2a --- /dev/null +++ b/EXAMPLES/Python/DHT11_SENSOR/dht11.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import absolute_import, division, print_function, unicode_literals + +import time +import pigpio + + +class DHT11(object): + """ + The DHT11 class is a stripped version of the DHT22 sensor code by joan2937. + You can find the initial implementation here: + - https://github.com/srounet/pigpio/tree/master/EXAMPLES/Python/DHT22_AM2302_SENSOR + + example code: + >>> pi = pigpio.pi() + >>> sensor = DHT11(pi, 4) # 4 is the data GPIO pin connected to your sensor + >>> for response in sensor: + .... print("Temperature: {}".format(response['temperature'])) + .... print("Humidity: {}".format(response['humidity'])) + """ + + def __init__(self, pi, gpio): + """ + pi (pigpio): an instance of pigpio + gpio (int): gpio pin number + """ + self.pi = pi + self.gpio = gpio + self.high_tick = 0 + self.bit = 40 + self.temperature = 0 + self.humidity = 0 + self.either_edge_cb = None + self.setup() + + def setup(self): + """ + Clears the internal gpio pull-up/down resistor. + Kills any watchdogs. + """ + self.pi.set_pull_up_down(self.gpio, pigpio.PUD_OFF) + self.pi.set_watchdog(self.gpio, 0) + self.register_callbacks() + + def register_callbacks(self): + """ + Monitors RISING_EDGE changes using callback. + """ + self.either_edge_cb = self.pi.callback( + self.gpio, + pigpio.EITHER_EDGE, + self.either_edge_callback + ) + + def either_edge_callback(self, gpio, level, tick): + """ + Either Edge callbacks, called each time the gpio edge changes. + Accumulate the 40 data bits from the dht11 sensor. + """ + level_handlers = { + pigpio.FALLING_EDGE: self._edge_FALL, + pigpio.RISING_EDGE: self._edge_RISE, + pigpio.EITHER_EDGE: self._edge_EITHER + } + handler = level_handlers[level] + diff = pigpio.tickDiff(self.high_tick, tick) + handler(tick, diff) + + def _edge_RISE(self, tick, diff): + """ + Handle Rise signal. + """ + val = 0 + if diff >= 50: + val = 1 + if diff >= 200: # Bad bit? + self.checksum = 256 # Force bad checksum + + if self.bit >= 40: # Message complete + self.bit = 40 + elif self.bit >= 32: # In checksum byte + self.checksum = (self.checksum << 1) + val + if self.bit == 39: + # 40th bit received + self.pi.set_watchdog(self.gpio, 0) + total = self.humidity + self.temperature + # is checksum ok ? + if not (total & 255) == self.checksum: + raise + elif 16 <= self.bit < 24: # in temperature byte + self.temperature = (self.temperature << 1) + val + elif 0 <= self.bit < 8: # in humidity byte + self.humidity = (self.humidity << 1) + val + else: # skip header bits + pass + self.bit += 1 + + def _edge_FALL(self, tick, diff): + """ + Handle Fall signal. + """ + self.high_tick = tick + if diff <= 250000: + return + self.bit = -2 + self.checksum = 0 + self.temperature = 0 + self.humidity = 0 + + def _edge_EITHER(self, tick, diff): + """ + Handle Either signal. + """ + self.pi.set_watchdog(self.gpio, 0) + + def read(self): + """ + Start reading over DHT11 sensor. + """ + self.pi.write(self.gpio, pigpio.LOW) + time.sleep(0.017) # 17 ms + self.pi.set_mode(self.gpio, pigpio.INPUT) + self.pi.set_watchdog(self.gpio, 200) + time.sleep(0.2) + + def close(self): + """ + Stop reading sensor, remove callbacks. + """ + self.pi.set_watchdog(self.gpio, 0) + if self.either_edge_cb: + self.either_edge_cb.cancel() + self.either_edge_cb = None + + def __iter__(self): + """ + Support the iterator protocol. + """ + return self + + def next(self): + """ + Call the read method and return temperature and humidity informations. + """ + self.read() + response = { + 'humidity': self.humidity, + 'temperature': self.temperature + } + return response + + +if __name__ == '__main__': + pi = pigpio.pi() + sensor = DHT11(pi, 4) + for d in sensor: + print("temperature: {}".format(d['temperature'])) + print("humidity: {}".format(d['humidity'])) + time.sleep(1) + sensor.close() + diff --git a/EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py b/EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py new file mode 100755 index 0000000..c9ce87e --- /dev/null +++ b/EXAMPLES/Python/DHT22_AM2302_SENSOR/DHT22.py @@ -0,0 +1,283 @@ +#!/usr/bin/env python + +# 2014-07-11 DHT22.py + +import time +import atexit + +import pigpio + +class sensor: + """ + A class to read relative humidity and temperature from the + DHT22 sensor. The sensor is also known as the AM2302. + + The sensor can be powered from the Pi 3V3 or the Pi 5V rail. + + Powering from the 3V3 rail is simpler and safer. You may need + to power from 5V if the sensor is connected via a long cable. + + For 3V3 operation connect pin 1 to 3V3 and pin 4 to ground. + + Connect pin 2 to a gpio. + + For 5V operation connect pin 1 to 5V and pin 4 to ground. + + The following pin 2 connection works for me. Use at YOUR OWN RISK. + + 5V--5K_resistor--+--10K_resistor--Ground + | + DHT22 pin 2 -----+ + | + gpio ------------+ + """ + + def __init__(self, pi, gpio, LED=None, power=None): + """ + Instantiate with the Pi and gpio to which the DHT22 output + pin is connected. + + Optionally a LED may be specified. This will be blinked for + each successful reading. + + Optionally a gpio used to power the sensor may be specified. + This gpio will be set high to power the sensor. If the sensor + locks it will be power cycled to restart the readings. + + Taking readings more often than about once every two seconds will + eventually cause the DHT22 to hang. A 3 second interval seems OK. + """ + + self.pi = pi + self.gpio = gpio + self.LED = LED + self.power = power + + if power is not None: + pi.write(power, 1) # Switch sensor on. + time.sleep(2) + + self.powered = True + + self.cb = None + + atexit.register(self.cancel) + + self.bad_CS = 0 # Bad checksum count. + self.bad_SM = 0 # Short message count. + self.bad_MM = 0 # Missing message count. + self.bad_SR = 0 # Sensor reset count. + + # Power cycle if timeout > MAX_TIMEOUTS. + self.no_response = 0 + self.MAX_NO_RESPONSE = 2 + + self.rhum = -999 + self.temp = -999 + + self.tov = None + + self.high_tick = 0 + self.bit = 40 + + pi.set_pull_up_down(gpio, pigpio.PUD_OFF) + + pi.set_watchdog(gpio, 0) # Kill any watchdogs. + + self.cb = pi.callback(gpio, pigpio.EITHER_EDGE, self._cb) + + def _cb(self, gpio, level, tick): + """ + Accumulate the 40 data bits. Format into 5 bytes, humidity high, + humidity low, temperature high, temperature low, checksum. + """ + diff = pigpio.tickDiff(self.high_tick, tick) + + if level == 0: + + # Edge length determines if bit is 1 or 0. + + if diff >= 50: + val = 1 + if diff >= 200: # Bad bit? + self.CS = 256 # Force bad checksum. + else: + val = 0 + + if self.bit >= 40: # Message complete. + self.bit = 40 + + elif self.bit >= 32: # In checksum byte. + self.CS = (self.CS << 1) + val + + if self.bit == 39: + + # 40th bit received. + + self.pi.set_watchdog(self.gpio, 0) + + self.no_response = 0 + + total = self.hH + self.hL + self.tH + self.tL + + if (total & 255) == self.CS: # Is checksum ok? + + self.rhum = ((self.hH << 8) + self.hL) * 0.1 + + if self.tH & 128: # Negative temperature. + mult = -0.1 + self.tH = self.tH & 127 + else: + mult = 0.1 + + self.temp = ((self.tH << 8) + self.tL) * mult + + self.tov = time.time() + + if self.LED is not None: + self.pi.write(self.LED, 0) + + else: + + self.bad_CS += 1 + + elif self.bit >= 24: # in temp low byte + self.tL = (self.tL << 1) + val + + elif self.bit >= 16: # in temp high byte + self.tH = (self.tH << 1) + val + + elif self.bit >= 8: # in humidity low byte + self.hL = (self.hL << 1) + val + + elif self.bit >= 0: # in humidity high byte + self.hH = (self.hH << 1) + val + + else: # header bits + pass + + self.bit += 1 + + elif level == 1: + self.high_tick = tick + if diff > 250000: + self.bit = -2 + self.hH = 0 + self.hL = 0 + self.tH = 0 + self.tL = 0 + self.CS = 0 + + else: # level == pigpio.TIMEOUT: + self.pi.set_watchdog(self.gpio, 0) + if self.bit < 8: # Too few data bits received. + self.bad_MM += 1 # Bump missing message count. + self.no_response += 1 + if self.no_response > self.MAX_NO_RESPONSE: + self.no_response = 0 + self.bad_SR += 1 # Bump sensor reset count. + if self.power is not None: + self.powered = False + self.pi.write(self.power, 0) + time.sleep(2) + self.pi.write(self.power, 1) + time.sleep(2) + self.powered = True + elif self.bit < 39: # Short message receieved. + self.bad_SM += 1 # Bump short message count. + self.no_response = 0 + + else: # Full message received. + self.no_response = 0 + + def temperature(self): + """Return current temperature.""" + return self.temp + + def humidity(self): + """Return current relative humidity.""" + return self.rhum + + def staleness(self): + """Return time since measurement made.""" + if self.tov is not None: + return time.time() - self.tov + else: + return -999 + + def bad_checksum(self): + """Return count of messages received with bad checksums.""" + return self.bad_CS + + def short_message(self): + """Return count of short messages.""" + return self.bad_SM + + def missing_message(self): + """Return count of missing messages.""" + return self.bad_MM + + def sensor_resets(self): + """Return count of power cycles because of sensor hangs.""" + return self.bad_SR + + def trigger(self): + """Trigger a new relative humidity and temperature reading.""" + if self.powered: + if self.LED is not None: + self.pi.write(self.LED, 1) + + self.pi.write(self.gpio, pigpio.LOW) + time.sleep(0.017) # 17 ms + self.pi.set_mode(self.gpio, pigpio.INPUT) + self.pi.set_watchdog(self.gpio, 200) + + def cancel(self): + """Cancel the DHT22 sensor.""" + + self.pi.set_watchdog(self.gpio, 0) + + if self.cb is not None: + self.cb.cancel() + self.cb = None + +if __name__ == "__main__": + + import time + + import pigpio + + import DHT22 + + # Intervals of about 2 seconds or less will eventually hang the DHT22. + INTERVAL = 3 + + pi = pigpio.pi() + + s = DHT22.sensor(pi, 22, LED=16, power=8) + + r = 0 + + next_reading = time.time() + + while True: + + r += 1 + + s.trigger() + + time.sleep(0.2) + + print("{} {} {} {:3.2f} {} {} {} {}".format( + r, s.humidity(), s.temperature(), s.staleness(), + s.bad_checksum(), s.short_message(), s.missing_message(), + s.sensor_resets())) + + next_reading += INTERVAL + + time.sleep(next_reading-time.time()) # Overall INTERVAL second polling. + + s.cancel() + + pi.stop() + diff --git a/EXAMPLES/Python/DHT22_AM2302_SENSOR/README b/EXAMPLES/Python/DHT22_AM2302_SENSOR/README new file mode 100644 index 0000000..328c023 --- /dev/null +++ b/EXAMPLES/Python/DHT22_AM2302_SENSOR/README @@ -0,0 +1,2 @@ +Class to read the relative humidity and temperature from a DHT22/AM2302 sensor. + diff --git a/EXAMPLES/Python/GPIO_STATUS/README b/EXAMPLES/Python/GPIO_STATUS/README new file mode 100644 index 0000000..4ee48d3 --- /dev/null +++ b/EXAMPLES/Python/GPIO_STATUS/README @@ -0,0 +1,2 @@ +Script to display the status of gpios 0-31. + diff --git a/EXAMPLES/Python/GPIO_STATUS/gpio_status.py b/EXAMPLES/Python/GPIO_STATUS/gpio_status.py new file mode 100755 index 0000000..9b3bf78 --- /dev/null +++ b/EXAMPLES/Python/GPIO_STATUS/gpio_status.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +import time +import curses +import atexit +import sys + +import pigpio + +GPIOS=32 + +MODES=["INPUT", "OUTPUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3"] + +def cleanup(): + curses.nocbreak() + curses.echo() + curses.endwin() + pi.stop() + +pi = pigpio.pi() +if not pi.connected: + sys.exit(1) + +stdscr = curses.initscr() +curses.noecho() +curses.cbreak() + +atexit.register(cleanup) + +cb = [] + +for g in range(GPIOS): + cb.append(pi.callback(g, pigpio.EITHER_EDGE)) + +# disable gpio 28 as the PCM clock is swamping the system + +cb[28].cancel() + +stdscr.nodelay(1) + +stdscr.addstr(0, 23, "Status of gpios 0-31", curses.A_REVERSE) + +while True: + + for g in range(GPIOS): + tally = cb[g].tally() + mode = pi.get_mode(g) + + col = (g // 11) * 25 + row = (g % 11) + 2 + + stdscr.addstr(row, col, "{:2}".format(g), curses.A_BOLD) + + stdscr.addstr( + "={} {:>6}: {:<10}".format(pi.read(g), MODES[mode], tally)) + + stdscr.refresh() + + time.sleep(0.1) + + c = stdscr.getch() + + if c != curses.ERR: + break + diff --git a/EXAMPLES/Python/HALL_EFFECT_SENSOR/README b/EXAMPLES/Python/HALL_EFFECT_SENSOR/README new file mode 100644 index 0000000..57f9143 --- /dev/null +++ b/EXAMPLES/Python/HALL_EFFECT_SENSOR/README @@ -0,0 +1,2 @@ +Program to show status changes for a Hall effect sensor. + diff --git a/EXAMPLES/Python/HALL_EFFECT_SENSOR/hall.py b/EXAMPLES/Python/HALL_EFFECT_SENSOR/hall.py new file mode 100755 index 0000000..a3a19bb --- /dev/null +++ b/EXAMPLES/Python/HALL_EFFECT_SENSOR/hall.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import time + +import pigpio + +# +# OH3144E or equivalent Hall effect sensor +# +# Pin 1 - 5V +# Pin 2 - Ground +# Pin 3 - gpio (here P1-8, gpio 14, TXD is used) +# +# The internal gpio pull-up is enabled so that the sensor +# normally reads high. It reads low when a magnet is close. +# + +HALL=14 + +pi = pigpio.pi() # connect to local Pi + +pi.set_mode(HALL, pigpio.INPUT) +pi.set_pull_up_down(HALL, pigpio.PUD_UP) + +start = time.time() + +while (time.time() - start) < 60: + print("Hall = {}".format(pi.read(HALL))) + time.sleep(0.2) + +pi.stop() + diff --git a/EXAMPLES/Python/I2C_SNIFFER/I2C_sniffer.py b/EXAMPLES/Python/I2C_SNIFFER/I2C_sniffer.py new file mode 100755 index 0000000..e45fa21 --- /dev/null +++ b/EXAMPLES/Python/I2C_SNIFFER/I2C_sniffer.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python + +import time + +import pigpio + +class sniffer: + """ + A class to passively monitor activity on an I2C bus. This should + work for an I2C bus running at 100kbps or less. You are unlikely + to get any usable results for a bus running any faster. + """ + + def __init__(self, pi, SCL, SDA, set_as_inputs=True): + """ + Instantiate with the Pi and the gpios for the I2C clock + and data lines. + + If you are monitoring one of the Raspberry Pi buses you + must set set_as_inputs to False so that they remain in + I2C mode. + + The pigpio daemon should have been started with a higher + than default sample rate. + + For an I2C bus rate of 100Kbps sudo pigpiod -s 2 should work. + + A message is printed for each I2C transaction formatted with + "[" for the START + "XX" two hex characters for each data byte + "+" if the data is ACKd, "-" if the data is NACKd + "]" for the STOP + + E.g. Reading the X, Y, Z values from an ADXL345 gives: + + [A6+32+] + [A7+01+FF+F2+FF+06+00-] + """ + + self.pi = pi + self.gSCL = SCL + self.gSDA = SDA + + self.FALLING = 0 + self.RISING = 1 + self.STEADY = 2 + + self.in_data = False + self.byte = 0 + self.bit = 0 + self.oldSCL = 1 + self.oldSDA = 1 + + self.transact = "" + + if set_as_inputs: + self.pi.set_mode(SCL, pigpio.INPUT) + self.pi.set_mode(SDA, pigpio.INPUT) + + self.cbA = self.pi.callback(SCL, pigpio.EITHER_EDGE, self._cb) + self.cbB = self.pi.callback(SDA, pigpio.EITHER_EDGE, self._cb) + + def _parse(self, SCL, SDA): + """ + Accumulate all the data between START and STOP conditions + into a string and output when STOP is detected. + """ + + if SCL != self.oldSCL: + self.oldSCL = SCL + if SCL: + xSCL = self.RISING + else: + xSCL = self.FALLING + else: + xSCL = self.STEADY + + if SDA != self.oldSDA: + self.oldSDA = SDA + if SDA: + xSDA = self.RISING + else: + xSDA = self.FALLING + else: + xSDA = self.STEADY + + if xSCL == self.RISING: + if self.in_data: + if self.bit < 8: + self.byte = (self.byte << 1) | SDA + self.bit += 1 + else: + self.transact += '{:02X}'.format(self.byte) + if SDA: + self.transact += '-' + else: + self.transact += '+' + self.bit = 0 + self.byte = 0 + + elif xSCL == self.STEADY: + + if xSDA == self.RISING: + if SCL: + self.in_data = False + self.byte = 0 + self.bit = 0 + self.transact += ']' # STOP + print (self.transact) + self.transact = "" + + if xSDA == self.FALLING: + if SCL: + self.in_data = True + self.byte = 0 + self.bit = 0 + self.transact += '[' # START + + def _cb(self, gpio, level, tick): + """ + Check which line has altered state (ignoring watchdogs) and + call the parser with the new state. + """ + SCL = self.oldSCL + SDA = self.oldSDA + + if gpio == self.gSCL: + if level == 0: + SCL = 0 + elif level == 1: + SCL = 1 + + if gpio == self.gSDA: + if level == 0: + SDA = 0 + elif level == 1: + SDA = 1 + + self._parse(SCL, SDA) + + def cancel(self): + """Cancel the I2C callbacks.""" + self.cbA.cancel() + self.cbB.cancel() + +if __name__ == "__main__": + + import time + + import pigpio + + import I2C_sniffer + + pi = pigpio.pi() + + s = I2C_sniffer.sniffer(pi, 1, 0, False) # leave gpios 1/0 in I2C mode + + time.sleep(60000) + + s.cancel() + + pi.stop() + diff --git a/EXAMPLES/Python/I2C_SNIFFER/README b/EXAMPLES/Python/I2C_SNIFFER/README new file mode 100644 index 0000000..68aa6a7 --- /dev/null +++ b/EXAMPLES/Python/I2C_SNIFFER/README @@ -0,0 +1,2 @@ +A program to passively sniff I2C transactions (100kHz bus maximum) and display the results. + diff --git a/EXAMPLES/Python/IR_RECEIVER/README b/EXAMPLES/Python/IR_RECEIVER/README new file mode 100644 index 0000000..7b3cf33 --- /dev/null +++ b/EXAMPLES/Python/IR_RECEIVER/README @@ -0,0 +1,2 @@ +Class to hash a code from an IR receiver (reading an IR remote control). + diff --git a/EXAMPLES/Python/IR_RECEIVER/ir_hasher.py b/EXAMPLES/Python/IR_RECEIVER/ir_hasher.py new file mode 100755 index 0000000..61a443f --- /dev/null +++ b/EXAMPLES/Python/IR_RECEIVER/ir_hasher.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python + +import pigpio + +class hasher: + + """ + This class forms a hash over the IR pulses generated by an + IR remote. + + The remote key press is not converted into a code in the manner of + the lirc module. No attempt is made to decode the type of protocol + used by the remote. The hash is likely to be unique for different + keys and different remotes but this is not guaranteed. + + This hashing process works for some remotes/protocols but not for + others. The only way to find out if it works for one or more of + your remotes is to try it and see. + + EXAMPLE CODE + + #!/usr/bin/env python + + import time + import pigpio + import ir_hasher + + def callback(hash): + print("hash={}".format(hash)); + + pi = pigpio.pi() + + ir = ir_hasher.hasher(pi, 7, callback, 5) + + print("ctrl c to exit"); + + time.sleep(300) + + pi.stop() + """ + + def __init__(self, pi, gpio, callback, timeout=5): + + """ + Initialises an IR remote hasher on a pi's gpio. A gap of timeout + milliseconds indicates the end of the remote key press. + """ + + self.pi = pi + self.gpio = gpio + self.code_timeout = timeout + self.callback = callback + + self.in_code = False + + pi.set_mode(gpio, pigpio.INPUT) + + self.cb = pi.callback(gpio, pigpio.EITHER_EDGE, self._cb) + + def _hash(self, old_val, new_val): + + if new_val < (old_val * 0.60): + val = 13 + elif old_val < (new_val * 0.60): + val = 23 + else: + val = 2 + + self.hash_val = self.hash_val ^ val + self.hash_val *= 16777619 # FNV_PRIME_32 + self.hash_val = self.hash_val & ((1<<32)-1) + + def _cb(self, gpio, level, tick): + + if level != pigpio.TIMEOUT: + + if self.in_code == False: + + self.in_code = True + + self.pi.set_watchdog(self.gpio, self.code_timeout) + + self.hash_val = 2166136261 # FNV_BASIS_32 + + self.edges = 1 + + self.t1 = None + self.t2 = None + self.t3 = None + self.t4 = tick + + else: + + self.edges += 1 + + self.t1 = self.t2 + self.t2 = self.t3 + self.t3 = self.t4 + self.t4 = tick + + if self.t1 is not None: + + d1 = pigpio.tickDiff(self.t1,self.t2) + d2 = pigpio.tickDiff(self.t3,self.t4) + + self._hash(d1, d2) + + else: + + if self.in_code: + + self.in_code = False + + self.pi.set_watchdog(self.gpio, 0) + + if self.edges > 12: + + self.callback(self.hash_val) + +if __name__ == "__main__": + + import time + import pigpio + import ir_hasher + + hashes = { + 142650387: '2', 244341844: 'menu', 262513468: 'vol-', + 272048826: '5', 345069212: '6', 363685443: 'prev.ch', + 434191356: '1', 492745084: 'OK', 549497027: 'mute', + 603729091: 'text', 646476378: 'chan-', 832916949: 'home', + 923778138: 'power', 938165610: 'power', 953243510: 'forward', + 1009731980:'1', 1018231875:'TV', 1142888517:'c-up', + 1151589683:'chan+', 1344018636:'OK', 1348032067:'chan+', + 1367109971:'prev.ch', 1370712102:'c-left', 1438405361:'rewind', + 1452589043:'pause', 1518578730:'chan-', 1554432645:'8', + 1583569525:'0', 1629745313:'rewind', 1666513749:'record', + 1677653754:'c-down', 1825951717:'c-right', 1852412236:'6', + 1894279468:'9', 1904895749:'vol+', 1941947509:'ff', + 2076573637:'0', 2104823531:'back', 2141641957:'home', + 2160787557:'record', 2398525299:'7', 2468117013:'8', + 2476712746:'play', 2574308838:'forward', 2577952149:'4', + 2706654902:'stop', 2829002741:'c-up', 2956097083:'back', + 3112717386:'5', 3263244773:'ff', 3286088195:'pause', + 3363767978:'c-down', 3468076364:'vol-', 3491068358:'stop', + 3593710134:'c-left', 3708232515:'3', 3734134565:'back', + 3766109107:'TV', 3798010010:'play', 3869937700:'menu', + 3872715523:'7', 3885097091:'2', 3895301587:'text', + 3931058739:'mute', 3983900853:'c-right', 4032250885:'4', + 4041913909:'vol+', 4207017660:'9', 4227138677:'back', + 4294027955:'3'} + + def callback(hash): + if hash in hashes: + print("key={} hash={}".format(hashes[hash], hash)); + + pi = pigpio.pi() + + ir = ir_hasher.hasher(pi, 7, callback, 5) + + print("ctrl c to exit"); + + time.sleep(300) + + pi.stop() + diff --git a/EXAMPLES/Python/MORSE_CODE/README b/EXAMPLES/Python/MORSE_CODE/README new file mode 100644 index 0000000..2ceb79c --- /dev/null +++ b/EXAMPLES/Python/MORSE_CODE/README @@ -0,0 +1,2 @@ +Script to transmit the morse code corresponding to a text string. + diff --git a/EXAMPLES/Python/MORSE_CODE/morse_code.py b/EXAMPLES/Python/MORSE_CODE/morse_code.py new file mode 100755 index 0000000..a452747 --- /dev/null +++ b/EXAMPLES/Python/MORSE_CODE/morse_code.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +import pigpio + +morse={ +'a':'.-' , 'b':'-...' , 'c':'-.-.' , 'd':'-..' , 'e':'.' , +'f':'..-.' , 'g':'--.' , 'h':'....' , 'i':'..' , 'j':'.---' , +'k':'-.-' , 'l':'.-..' , 'm':'--' , 'n':'-.' , 'o':'---' , +'p':'.--.' , 'q':'--.-' , 'r':'.-.' , 's':'...' , 't':'-' , +'u':'..-' , 'v':'...-' , 'w':'.--' , 'x':'-..-' , 'y':'-.--' , +'z':'--..' , '1':'.----', '2':'..---', '3':'...--', '4':'....-', +'5':'.....', '6':'-....', '7':'--...', '8':'---..', '9':'----.', +'0':'-----'} + +GPIO=22 + +MICROS=100000 + +NONE=0 + +DASH=3 +DOT=1 + +GAP=1 +LETTER_GAP=3-GAP +WORD_GAP=7-LETTER_GAP + +def transmit_string(pi, gpio, str): + + pi.wave_clear() # start a new waveform + + wf=[] + + for C in str: + c=C.lower() + print(c) + if c in morse: + k = morse[c] + for x in k: + + if x == '.': + wf.append(pigpio.pulse(1<AIN2") +stdscr.addstr(16, 0, "Resistor") + +stdscr.nodelay(1) + +try: + while True: + + for a in range(0,4): + aout = aout + 1 + pi.i2c_write_byte_data(handle, 0x40 | ((a+1) & 0x03), aout&0xFF) + v = pi.i2c_read_byte(handle) + hashes = v / 4 + spaces = 64 - hashes + stdscr.addstr(10+a*2, 12, str(v) + ' ') + stdscr.addstr(10+a*2, 16, '#' * hashes + ' ' * spaces ) + + stdscr.refresh() + time.sleep(0.04) + + c = stdscr.getch() + + if c != curses.ERR: + break + +except: + pass + +curses.nocbreak() +curses.echo() +curses.endwin() + +pi.i2c_close(handle) +pi.stop() + diff --git a/EXAMPLES/Python/PCF8591_YL-40/README b/EXAMPLES/Python/PCF8591_YL-40/README new file mode 100644 index 0000000..cdd9374 --- /dev/null +++ b/EXAMPLES/Python/PCF8591_YL-40/README @@ -0,0 +1,2 @@ +Script to display readings from the (I2C) PCF8591. + diff --git a/EXAMPLES/Python/PIGPIO_BENCHMARK/README b/EXAMPLES/Python/PIGPIO_BENCHMARK/README new file mode 100644 index 0000000..4c6e46b --- /dev/null +++ b/EXAMPLES/Python/PIGPIO_BENCHMARK/README @@ -0,0 +1,2 @@ +Script to benchmark the pigpio Python module's performance. + diff --git a/EXAMPLES/Python/PIGPIO_BENCHMARK/bench_1.py b/EXAMPLES/Python/PIGPIO_BENCHMARK/bench_1.py new file mode 100755 index 0000000..0a66bdc --- /dev/null +++ b/EXAMPLES/Python/PIGPIO_BENCHMARK/bench_1.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +# +# WARNING! +# + +############################################################################## +# # +# Unless you know what you are doing don't run this script with anything # +# connected to the gpios. You will CAUSE damage. # +# # +############################################################################## + +# +# WARNING! +# + +import time + +import pigpio + +delay = 30 + +class gpioTest: + + def __init__(self, pi, gpio, edge, freq, duty): + self.pi = pi + self.gpio = gpio + self.edge = edge + self.freq = freq + self.duty = duty + self.calls = 0 + + def cb(self, g, t, l): + self.calls = self.calls + 1 + # print g,t,l + + def num(self): + return self.calls + + def start(self): + self.pi.set_PWM_frequency(self.gpio, self.freq) + self.pi.set_PWM_range(self.gpio, 25) + self.pi.set_PWM_dutycycle(self.gpio, self.duty) + self.n = self.pi.callback(self.gpio, self.edge, self.cb) + + def stop(self): + self.pi.set_PWM_dutycycle(self.gpio, 0) + self.n.cancel() + +pi = pigpio.pi() + +t1 = gpioTest(pi, 4, pigpio.EITHER_EDGE, 4000, 1) +t2 = gpioTest(pi, 7, pigpio.RISING_EDGE, 8000, 2) +t3 = gpioTest(pi, 8, pigpio.FALLING_EDGE, 8000, 3) +t4 = gpioTest(pi, 9, pigpio.EITHER_EDGE, 4000, 4) +t5 = gpioTest(pi,10, pigpio.RISING_EDGE, 8000, 5) +t6 = gpioTest(pi,11, pigpio.FALLING_EDGE, 8000, 6) +t7 = gpioTest(pi,14, pigpio.EITHER_EDGE, 4000, 7) +t8 = gpioTest(pi,15, pigpio.RISING_EDGE, 8000, 8) +t9 = gpioTest(pi,17, pigpio.FALLING_EDGE, 8000, 9) +t10 = gpioTest(pi,18, pigpio.EITHER_EDGE, 4000, 10) +t11 = gpioTest(pi,22, pigpio.RISING_EDGE, 8000, 11) +t12 = gpioTest(pi,23, pigpio.FALLING_EDGE, 8000, 12) +t13 = gpioTest(pi,24, pigpio.EITHER_EDGE, 4000, 13) +t14 = gpioTest(pi,25, pigpio.RISING_EDGE, 8000, 14) + +# R1: 0 1 4 7 8 9 10 11 14 15 17 18 21 22 23 24 25 +# R2: 2 3 4 7 8 9 10 11 14 15 17 18 22 23 24 25 27 28 29 30 31 + +tests = [t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14] + +for i in tests: i.start() + +time.sleep(delay) + +for i in tests: i.stop() + +pi.stop() + +tot = 0 +msg = "" + +for i in tests: + tot += i.num() + msg += str(i.num()) + " " + +print(msg) + +print("eps={} ({}/{})".format(tot/delay, tot, delay)) + diff --git a/EXAMPLES/Python/ROTARY_ENCODER/README b/EXAMPLES/Python/ROTARY_ENCODER/README new file mode 100644 index 0000000..8dbe585 --- /dev/null +++ b/EXAMPLES/Python/ROTARY_ENCODER/README @@ -0,0 +1,2 @@ +Class to decode a mechanical rotary encoder. + diff --git a/EXAMPLES/Python/ROTARY_ENCODER/rotary_encoder.py b/EXAMPLES/Python/ROTARY_ENCODER/rotary_encoder.py new file mode 100755 index 0000000..884ff61 --- /dev/null +++ b/EXAMPLES/Python/ROTARY_ENCODER/rotary_encoder.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python + +import pigpio + +class decoder: + + """Class to decode mechanical rotary encoder pulses.""" + + def __init__(self, pi, gpioA, gpioB, callback): + + """ + Instantiate the class with the pi and gpios connected to + rotary encoder contacts A and B. The common contact + should be connected to ground. The callback is + called when the rotary encoder is turned. It takes + one parameter which is +1 for clockwise and -1 for + counterclockwise. + + EXAMPLE + + import time + import pigpio + + import rotary_encoder + + pos = 0 + + def callback(way): + + global pos + + pos += way + + print("pos={}".format(pos)) + + pi = pigpio.pi() + + decoder = rotary_encoder.decoder(pi, 7, 8, callback) + + time.sleep(300) + + decoder.cancel() + + pi.stop() + + """ + + self.pi = pi + self.gpioA = gpioA + self.gpioB = gpioB + self.callback = callback + + self.levA = 0 + self.levB = 0 + + self.lastGpio = None + + self.pi.set_mode(gpioA, pigpio.INPUT) + self.pi.set_mode(gpioB, pigpio.INPUT) + + self.pi.set_pull_up_down(gpioA, pigpio.PUD_UP) + self.pi.set_pull_up_down(gpioB, pigpio.PUD_UP) + + self.cbA = self.pi.callback(gpioA, pigpio.EITHER_EDGE, self._pulse) + self.cbB = self.pi.callback(gpioB, pigpio.EITHER_EDGE, self._pulse) + + def _pulse(self, gpio, level, tick): + + """ + Decode the rotary encoder pulse. + + +---------+ +---------+ 0 + | | | | + A | | | | + | | | | + +---------+ +---------+ +----- 1 + + +---------+ +---------+ 0 + | | | | + B | | | | + | | | | + ----+ +---------+ +---------+ 1 + """ + + if gpio == self.gpioA: + self.levA = level + else: + self.levB = level; + + if gpio != self.lastGpio: # debounce + self.lastGpio = gpio + + if gpio == self.gpioA and level == 1: + if self.levB == 1: + self.callback(1) + elif gpio == self.gpioB and level == 1: + if self.levA == 1: + self.callback(-1) + + def cancel(self): + + """ + Cancel the rotary encoder decoder. + """ + + self.cbA.cancel() + self.cbB.cancel() + +if __name__ == "__main__": + + import time + import pigpio + + import rotary_encoder + + pos = 0 + + def callback(way): + + global pos + + pos += way + + print("pos={}".format(pos)) + + pi = pigpio.pi() + + decoder = rotary_encoder.decoder(pi, 7, 8, callback) + + time.sleep(300) + + decoder.cancel() + + pi.stop() + diff --git a/EXAMPLES/Python/SONAR_RANGER/README b/EXAMPLES/Python/SONAR_RANGER/README new file mode 100644 index 0000000..effc9e6 --- /dev/null +++ b/EXAMPLES/Python/SONAR_RANGER/README @@ -0,0 +1,2 @@ +Class to read sonar rangers with separate trigger and echo pins. + diff --git a/EXAMPLES/Python/SONAR_RANGER/sonar_trigger_echo.py b/EXAMPLES/Python/SONAR_RANGER/sonar_trigger_echo.py new file mode 100755 index 0000000..9485ef4 --- /dev/null +++ b/EXAMPLES/Python/SONAR_RANGER/sonar_trigger_echo.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python + +import time + +import pigpio + +class ranger: + """ + This class encapsulates a type of acoustic ranger. In particular + the type of ranger with separate trigger and echo pins. + + A pulse on the trigger initiates the sonar ping and shortly + afterwards a sonar pulse is transmitted and the echo pin + goes high. The echo pins stays high until a sonar echo is + received (or the response times-out). The time between + the high and low edges indicates the sonar round trip time. + """ + + def __init__(self, pi, trigger, echo): + """ + The class is instantiated with the Pi to use and the + gpios connected to the trigger and echo pins. + """ + self.pi = pi + self._trig = trigger + self._echo = echo + + self._ping = False + self._high = None + self._time = None + + self._triggered = False + + self._trig_mode = pi.get_mode(self._trig) + self._echo_mode = pi.get_mode(self._echo) + + pi.set_mode(self._trig, pigpio.OUTPUT) + pi.set_mode(self._echo, pigpio.INPUT) + + self._cb = pi.callback(self._trig, pigpio.EITHER_EDGE, self._cbf) + self._cb = pi.callback(self._echo, pigpio.EITHER_EDGE, self._cbf) + + self._inited = True + + def _cbf(self, gpio, level, tick): + if gpio == self._trig: + if level == 0: # trigger sent + self._triggered = True + self._high = None + else: + if self._triggered: + if level == 1: + self._high = tick + else: + if self._high is not None: + self._time = tick - self._high + self._high = None + self._ping = True + + def read(self): + """ + Triggers a reading. The returned reading is the number + of microseconds for the sonar round-trip. + + round trip cms = round trip time / 1000000.0 * 34030 + """ + if self._inited: + self._ping = False + self.pi.gpio_trigger(self._trig) + start = time.time() + while not self._ping: + if (time.time()-start) > 5.0: + return 20000 + time.sleep(0.001) + return self._time + else: + return None + + def cancel(self): + """ + Cancels the ranger and returns the gpios to their + original mode. + """ + if self._inited: + self._inited = False + self._cb.cancel() + self.pi.set_mode(self._trig, self._trig_mode) + self.pi.set_mode(self._echo, self._echo_mode) + +if __name__ == "__main__": + + import time + + import pigpio + + import sonar_trigger_echo + + pi = pigpio.pi() + + sonar = sonar_trigger_echo.ranger(pi, 23, 18) + + end = time.time() + 600.0 + + r = 1 + while time.time() < end: + + print("{} {}".format(r, sonar.read())) + r += 1 + time.sleep(0.03) + + sonar.cancel() + + pi.stop() + diff --git a/EXAMPLES/Python/VIRTUAL_WIRE/README b/EXAMPLES/Python/VIRTUAL_WIRE/README new file mode 100644 index 0000000..106c186 --- /dev/null +++ b/EXAMPLES/Python/VIRTUAL_WIRE/README @@ -0,0 +1,2 @@ +Class to send and receive radio messages compatible with the Virtual Wire library for Arduinos. + diff --git a/EXAMPLES/Python/VIRTUAL_WIRE/vw.py b/EXAMPLES/Python/VIRTUAL_WIRE/vw.py new file mode 100755 index 0000000..e871f4f --- /dev/null +++ b/EXAMPLES/Python/VIRTUAL_WIRE/vw.py @@ -0,0 +1,372 @@ +#!/usr/bin/env python +""" +This module provides a 313MHz/434MHz radio interface compatible +with the Virtual Wire library used on Arduinos. + +It has been tested between a Pi, TI Launchpad, and Arduino Pro Mini. +""" +# 2014-08-14 +# vw.py + +import time + +import pigpio + +MAX_MESSAGE_BYTES=77 + +MIN_BPS=50 +MAX_BPS=10000 + +_HEADER=[0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x38, 0x2c] + +_CTL=3 + +_SYMBOL=[ + 0x0d, 0x0e, 0x13, 0x15, 0x16, 0x19, 0x1a, 0x1c, + 0x23, 0x25, 0x26, 0x29, 0x2a, 0x2c, 0x32, 0x34] + + +def _sym2nibble(symbol): + for nibble in range(16): + if symbol == _SYMBOL[nibble]: + return nibble + return 0 + +def _crc_ccitt_update(crc, data): + + data = data ^ (crc & 0xFF); + + data = (data ^ (data << 4)) & 0xFF; + + return ( + (((data << 8) & 0xFFFF) | (crc >> 8)) ^ + ((data >> 4) & 0x00FF) ^ ((data << 3) & 0xFFFF) + ) + +class tx(): + + def __init__(self, pi, txgpio, bps=2000): + """ + Instantiate a transmitter with the Pi, the transmit gpio, + and the bits per second (bps). The bps defaults to 2000. + The bps is constrained to be within MIN_BPS to MAX_BPS. + """ + self.pi = pi + + self.txbit = (1< MAX_BPS: + bps = MAX_BPS + + self.mics = int(1000000 / bps) + + self.wave_id = None + + pi.wave_add_new() + + pi.set_mode(txgpio, pigpio.OUTPUT) + + + def _nibble(self, nibble): + + for i in range(6): + if nibble & (1<>4]) + self._nibble(_SYMBOL[byte&0x0F]) + return _crc_ccitt_update(crc, byte) + + def put(self, data): + """ + Transmit a message. If the message is more than + MAX_MESSAGE_BYTES in size it is discarded. If a message + is currently being transmitted it is aborted and replaced + with the new message. True is returned if message + transmission has successfully started. False indicates + an error. + """ + if len(data) > MAX_MESSAGE_BYTES: + return False + + self.wf = [] + + self.cancel() + + for i in _HEADER: + self._nibble(i) + + crc = self._byte(0xFFFF, len(data)+_CTL) + + for i in data: + + if type(i) == type(""): + v = ord(i) + else: + v = i + + crc = self._byte(crc, v) + + crc = ~crc + + self._byte(0, crc&0xFF) + self._byte(0, crc>>8) + + self.pi.wave_add_generic(self.wf) + + self.wave_id = self.pi.wave_create() + + if self.wave_id >= 0: + self.pi.wave_send_once(self.wave_id) + return True + else: + return False + + + def ready(self): + """ + Returns True if a new message may be transmitted. + """ + return not self.pi.wave_tx_busy() + + def cancel(self): + """ + Cancels the wireless transmitter, aborting any message + in progress. + """ + if self.wave_id is not None: + self.pi.wave_tx_stop() + self.pi.wave_delete(self.wave_id) + self.pi.wave_add_new() + + self.wave_id = None + +class rx(): + + def __init__(self, pi, rxgpio, bps=2000): + """ + Instantiate a receiver with the Pi, the receive gpio, and + the bits per second (bps). The bps defaults to 2000. + The bps is constrained to be within MIN_BPS to MAX_BPS. + """ + self.pi = pi + self.rxgpio = rxgpio + + self.messages = [] + self.bad_CRC = 0 + + if bps < MIN_BPS: + bps = MIN_BPS + elif bps > MAX_BPS: + bps = MAX_BPS + + slack = 0.20 + self.mics = int(1000000 / bps) + slack_mics = int(slack * self.mics) + self.min_mics = self.mics - slack_mics # Shortest legal edge. + self.max_mics = (self.mics + slack_mics) * 4 # Longest legal edge. + + self.timeout = 8 * self.mics / 1000 # 8 bits time in ms. + if self.timeout < 8: + self.timeout = 8 + + self.last_tick = None + self.good = 0 + self.bits = 0 + self.token = 0 + self.in_message = False + self.message = [0]*(MAX_MESSAGE_BYTES+_CTL) + self.message_len = 0 + self.byte = 0 + + pi.set_mode(rxgpio, pigpio.INPUT) + + self.cb = pi.callback(rxgpio, pigpio.EITHER_EDGE, self._cb) + + def _calc_crc(self): + + crc = 0xFFFF + for i in range(self.message_length): + crc = _crc_ccitt_update(crc, self.message[i]) + return crc + + def _insert(self, bits, level): + + for i in range(bits): + + self.token >>= 1 + + if level == 0: + self.token |= 0x800 + + if self.in_message: + + self.bits += 1 + + if self.bits >= 12: # Complete token. + + byte = ( + _sym2nibble(self.token & 0x3f) << 4 | + _sym2nibble(self.token >> 6)) + + if self.byte == 0: + self.message_length = byte + + if byte > (MAX_MESSAGE_BYTES+_CTL): + self.in_message = False # Abort message. + return + + self.message[self.byte] = byte + + self.byte += 1 + self.bits = 0 + + if self.byte >= self.message_length: + self.in_message = False + self.pi.set_watchdog(self.rxgpio, 0) + + crc = self._calc_crc() + + if crc == 0xF0B8: # Valid CRC. + self.messages.append( + self.message[1:self.message_length-2]) + else: + self.bad_CRC += 1 + + else: + if self.token == 0xB38: # Start message token. + self.in_message = True + self.pi.set_watchdog(self.rxgpio, self.timeout) + self.bits = 0 + self.byte = 0 + + def _cb(self, gpio, level, tick): + + if self.last_tick is not None: + + if level == pigpio.TIMEOUT: + + self.pi.set_watchdog(self.rxgpio, 0) # Switch watchdog off. + + if self.in_message: + self._insert(4, not self.last_level) + + self.good = 0 + self.in_message = False + + else: + + edge = pigpio.tickDiff(self.last_tick, tick) + + if edge < self.min_mics: + + self.good = 0 + self.in_message = False + + elif edge > self.max_mics: + + if self.in_message: + self._insert(4, level) + + self.good = 0 + self.in_message = False + + else: + + self.good += 1 + + if self.good > 8: + + bitlen = (100 * edge) / self.mics + + if bitlen < 140: + bits = 1 + elif bitlen < 240: + bits = 2 + elif bitlen < 340: + bits = 3 + else: + bits = 4 + + self._insert(bits, level) + + self.last_tick = tick + self.last_level = level + + def get(self): + """ + Returns the next unread message, or None if none is avaiable. + """ + if len(self.messages): + return self.messages.pop(0) + else: + return None + + def ready(self): + """ + Returns True if there is a message available to be read. + """ + return len(self.messages) + + def cancel(self): + """ + Cancels the wireless receiver. + """ + if self.cb is not None: + self.cb.cancel() + self.pi.set_watchdog(self.rxgpio, 0) + self.cb = None + +if __name__ == "__main__": + + import time + + import pigpio + + import vw + + RX=11 + TX=25 + + BPS=2000 + + pi = pigpio.pi() # Connect to local Pi. + + rx = vw.rx(pi, RX, BPS) # Specify Pi, rx gpio, and baud. + tx = vw.tx(pi, TX, BPS) # Specify Pi, tx gpio, and baud. + + msg = 0 + + start = time.time() + + while (time.time()-start) < 300: + + msg += 1 + + while not tx.ready(): + time.sleep(0.1) + + time.sleep(0.2) + + tx.put([48, 49, 65, ((msg>>6)&0x3F)+32, (msg&0x3F)+32]) + + while not tx.ready(): + time.sleep(0.1) + + time.sleep(0.2) + + tx.put("Hello World #{}!".format(msg)) + + while rx.ready(): + print("".join(chr (c) for c in rx.get())) + + rx.cancel() + tx.cancel() + + pi.stop() + diff --git a/EXAMPLES/Python/WIEGAND_CODE/README b/EXAMPLES/Python/WIEGAND_CODE/README new file mode 100644 index 0000000..e19bc7c --- /dev/null +++ b/EXAMPLES/Python/WIEGAND_CODE/README @@ -0,0 +1,2 @@ +Class to decode a Wiegand code. + diff --git a/EXAMPLES/Python/WIEGAND_CODE/wiegand.py b/EXAMPLES/Python/WIEGAND_CODE/wiegand.py new file mode 100755 index 0000000..f7c4610 --- /dev/null +++ b/EXAMPLES/Python/WIEGAND_CODE/wiegand.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python + +import pigpio + +class decoder: + + """ + A class to read Wiegand codes of an arbitrary length. + + The code length and value are returned. + + EXAMPLE + + #!/usr/bin/env python + + import time + + import pigpio + + import wiegand + + def callback(bits, code): + print("bits={} code={}".format(bits, code)) + + pi = pigpio.pi() + + w = wiegand.decoder(pi, 14, 15, callback) + + time.sleep(300) + + w.cancel() + + pi.stop() + """ + + def __init__(self, pi, gpio_0, gpio_1, callback, bit_timeout=5): + + """ + Instantiate with the pi, gpio for 0 (green wire), the gpio for 1 + (white wire), the callback function, and the bit timeout in + milliseconds which indicates the end of a code. + + The callback is passed the code length in bits and the value. + """ + + self.pi = pi + self.gpio_0 = gpio_0 + self.gpio_1 = gpio_1 + + self.callback = callback + + self.bit_timeout = bit_timeout + + self.in_code = False + + self.pi.set_mode(gpio_0, pigpio.INPUT) + self.pi.set_mode(gpio_1, pigpio.INPUT) + + self.pi.set_pull_up_down(gpio_0, pigpio.PUD_UP) + self.pi.set_pull_up_down(gpio_1, pigpio.PUD_UP) + + self.cb_0 = self.pi.callback(gpio_0, pigpio.FALLING_EDGE, self._cb) + self.cb_1 = self.pi.callback(gpio_1, pigpio.FALLING_EDGE, self._cb) + + def _cb(self, gpio, level, tick): + + """ + Accumulate bits until both gpios 0 and 1 timeout. + """ + + if level < pigpio.TIMEOUT: + + if self.in_code == False: + self.bits = 1 + self.num = 0 + + self.in_code = True + self.code_timeout = 0 + self.pi.set_watchdog(self.gpio_0, self.bit_timeout) + self.pi.set_watchdog(self.gpio_1, self.bit_timeout) + else: + self.bits += 1 + self.num = self.num << 1 + + if gpio == self.gpio_0: + self.code_timeout = self.code_timeout & 2 # clear gpio 0 timeout + else: + self.code_timeout = self.code_timeout & 1 # clear gpio 1 timeout + self.num = self.num | 1 + + else: + + if self.in_code: + + if gpio == self.gpio_0: + self.code_timeout = self.code_timeout | 1 # timeout gpio 0 + else: + self.code_timeout = self.code_timeout | 2 # timeout gpio 1 + + if self.code_timeout == 3: # both gpios timed out + self.pi.set_watchdog(self.gpio_0, 0) + self.pi.set_watchdog(self.gpio_1, 0) + self.in_code = False + self.callback(self.bits, self.num) + + def cancel(self): + + """ + Cancel the Wiegand decoder. + """ + + self.cb_0.cancel() + self.cb_1.cancel() + +if __name__ == "__main__": + + import time + + import pigpio + + import wiegand + + def callback(bits, value): + print("bits={} value={}".format(bits, value)) + + pi = pigpio.pi() + + w = wiegand.decoder(pi, 14, 15, callback) + + time.sleep(300) + + w.cancel() + + pi.stop() + diff --git a/EXAMPLES/Shell/GPIOTEST/README b/EXAMPLES/Shell/GPIOTEST/README new file mode 100644 index 0000000..981e62e --- /dev/null +++ b/EXAMPLES/Shell/GPIOTEST/README @@ -0,0 +1,7 @@ +This bash script tests the user gpios. + +Everything should be disconnected from the gpios. + +The pigpio daemon must be running (sudo pigpiod). + +Video at http://youtu.be/sCJFLKWaxHo diff --git a/EXAMPLES/Shell/GPIOTEST/gpiotest b/EXAMPLES/Shell/GPIOTEST/gpiotest new file mode 100755 index 0000000..b04b622 --- /dev/null +++ b/EXAMPLES/Shell/GPIOTEST/gpiotest @@ -0,0 +1,126 @@ +#!/bin/bash + +skipped="" +tested="" +failed="" + +usage() +{ + cat </dev/null + +usage + +v=$(pigs hwver) + +if [[ $v < 0 ]] +then + echo "The pigpio daemon wasn't found. Did you sudo pigpiod?" + exit +fi + +echo "Testing..." + +for ((i=0; i<4; i++)) do check_gpio $i 1; done +for ((i=4; i<16; i++)) do check_gpio $i 0; done + +if [[ $v -ge 16 ]]; +then + check_gpio 16 0 +else + skipped+="16 " +fi + +for ((i=17; i<28; i++)) do check_gpio $i 0; done +for ((i=28; i<30; i++)) do check_gpio $i 1; done +for ((i=30; i<32; i++)) do check_gpio $i 0; done + +if [[ $failed = "" ]]; then failed="None"; fi + +echo "Skipped non-user gpios: $skipped" +echo "Tested user gpios: $tested" +echo "Failed user gpios: $failed" + diff --git a/MakeRemote b/MakeRemote new file mode 100644 index 0000000..250d40e --- /dev/null +++ b/MakeRemote @@ -0,0 +1,101 @@ +# +CC = gcc +SIZE = size +SHLIB = gcc -shared +STRIPLIB = strip --strip-unneeded + +CFLAGS += -O3 -Wall -pthread + +ALL = libpigpiod_if.so libpigpiod_if2.so pigs x_pigpiod_if x_pigpiod_if2 + +prefix = /usr/local +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +includedir = $(prefix)/include +libdir = $(prefix)/lib +mandir = $(prefix)/man + +all: $(ALL) pigpio.py setup.py + +pigpiod_if.o: pigpiod_if.c pigpio.h command.h pigpiod_if.h + $(CC) $(CFLAGS) -fpic -c -o pigpiod_if.o pigpiod_if.c + +pigpiod_if2.o: pigpiod_if2.c pigpio.h command.h pigpiod_if2.h + $(CC) $(CFLAGS) -fpic -c -o pigpiod_if2.o pigpiod_if2.c + +command.o: command.c pigpio.h command.h + $(CC) $(CFLAGS) -fpic -c -o command.o command.c + +pigs: command.o pigs.o + $(CC) $(CFLAGS) -fpic -o pigs pigs.c command.c + +x_pigpiod_if: x_pigpiod_if.o $(LIB1) + $(CC) -o x_pigpiod_if x_pigpiod_if.o $(LL1) + +x_pigpiod_if2: x_pigpiod_if2.o $(LIB2) + $(CC) -o x_pigpiod_if2 x_pigpiod_if2.o $(LL2) + +clean: + rm -f *.o *.i *.s *~ $(ALL) + +install: $(LIB1) $(LIB2) + install -m 0755 -d $(DESTDIR)$(includedir) + install -m 0644 pigpio.h $(DESTDIR)$(includedir) + install -m 0644 pigpiod_if.h $(DESTDIR)$(includedir) + install -m 0644 pigpiod_if2.h $(DESTDIR)$(includedir) + install -m 0755 -d $(DESTDIR)$(libdir) + install -m 0644 libpigpiod_if.so $(DESTDIR)$(libdir) + install -m 0644 libpigpiod_if2.so $(DESTDIR)$(libdir) + install -m 0755 -d $(DESTDIR)$(bindir) + install -m 0755 pigs $(DESTDIR)$(bindir) + python2 setup.py install + python3 setup.py install + install -m 0755 -d $(DESTDIR)$(mandir)/man1 + install -m 0644 *.1 $(DESTDIR)$(mandir)/man1 + install -m 0755 -d $(DESTDIR)$(mandir)/man3 + install -m 0644 *.3 $(DESTDIR)$(mandir)/man3 + +uninstall: + rm -f $(DESTDIR)$(includedir)/pigpio.h + rm -f $(DESTDIR)$(includedir)/pigpiod_if.h + rm -f $(DESTDIR)$(includedir)/pigpiod_if2.h + rm -f $(DESTDIR)$(libdir)/libpigpiod_if.so + rm -f $(DESTDIR)$(libdir)/libpigpiod_if2.so + echo removing python2 files + python2 setup.py install --record /tmp/pigpio >/dev/null + xargs rm -f < /tmp/pigpio >/dev/null + echo removing python3 files + python3 setup.py install --record /tmp/pigpio >/dev/null + xargs rm -f < /tmp/pigpio >/dev/null + rm -f $(DESTDIR)$(bindir)/pigs + rm -f $(DESTDIR)$(mandir)/man1/pig*.1 + rm -f $(DESTDIR)$(mandir)/man3/pig*.3 + +LL1 = -L. -lpigpiod_if -pthread -lrt +LL2 = -L. -lpigpiod_if2 -pthread -lrt + +LIB1 = libpigpiod_if.so +OBJ1 = pigpiod_if.o command.o + +LIB2 = libpigpiod_if2.so +OBJ2 = pigpiod_if2.o command.o + +$(LIB1): $(OBJ1) + $(SHLIB) -o $(LIB1) $(OBJ1) + $(STRIPLIB) $(LIB1) + $(SIZE) $(LIB1) + +$(LIB2): $(OBJ2) + $(SHLIB) -o $(LIB2) $(OBJ2) + $(STRIPLIB) $(LIB2) + $(SIZE) $(LIB2) + +# generated using gcc -MM *.c + +command.o: command.c pigpio.h command.h +pigpiod.o: pigpiod.c pigpio.h +pigpiod_if.o: pigpiod_if.c pigpio.h pigpiod_if.h command.h +pigpiod_if2.o: pigpiod_if2.c pigpio.h pigpiod_if2.h command.h +pigs.o: pigs.c pigpio.h command.h pigs.h + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0aa14fe --- /dev/null +++ b/Makefile @@ -0,0 +1,164 @@ +# +# Set CROSS_PREFIX to prepend to all compiler tools at once for easier +# cross-compilation. +CROSS_PREFIX = +CC = $(CROSS_PREFIX)gcc +AR = $(CROSS_PREFIX)ar +RANLIB = $(CROSS_PREFIX)ranlib +SIZE = $(CROSS_PREFIX)size +STRIP = $(CROSS_PREFIX)strip +SHLIB = $(CC) -shared +STRIPLIB = $(STRIP) --strip-unneeded + +SOVERSION = 1 + +CFLAGS += -O3 -Wall -pthread + +LIB1 = libpigpio.so +OBJ1 = pigpio.o command.o + +LIB2 = libpigpiod_if.so +OBJ2 = pigpiod_if.o command.o + +LIB3 = libpigpiod_if2.so +OBJ3 = pigpiod_if2.o command.o + +LIB = $(LIB1) $(LIB2) $(LIB3) + +ALL = $(LIB) x_pigpio x_pigpiod_if x_pigpiod_if2 pig2vcd pigpiod pigs + +LL1 = -L. -lpigpio -pthread -lrt + +LL2 = -L. -lpigpiod_if -pthread -lrt + +LL3 = -L. -lpigpiod_if2 -pthread -lrt + +prefix = /usr/local +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +includedir = $(prefix)/include +libdir = $(prefix)/lib +mandir = $(prefix)/man + +all: $(ALL) + +lib: $(LIB) + +pigpio.o: pigpio.c pigpio.h command.h custom.cext + $(CC) $(CFLAGS) -fpic -c -o pigpio.o pigpio.c + +pigpiod_if.o: pigpiod_if.c pigpio.h command.h pigpiod_if.h + $(CC) $(CFLAGS) -fpic -c -o pigpiod_if.o pigpiod_if.c + +pigpiod_if2.o: pigpiod_if2.c pigpio.h command.h pigpiod_if2.h + $(CC) $(CFLAGS) -fpic -c -o pigpiod_if2.o pigpiod_if2.c + +command.o: command.c pigpio.h command.h + $(CC) $(CFLAGS) -fpic -c -o command.o command.c + +x_pigpio: x_pigpio.o $(LIB1) + $(CC) -o x_pigpio x_pigpio.o $(LL1) + +x_pigpiod_if: x_pigpiod_if.o $(LIB2) + $(CC) -o x_pigpiod_if x_pigpiod_if.o $(LL2) + +x_pigpiod_if2: x_pigpiod_if2.o $(LIB3) + $(CC) -o x_pigpiod_if2 x_pigpiod_if2.o $(LL3) + +pigpiod: pigpiod.o $(LIB1) + $(CC) -o pigpiod pigpiod.o $(LL1) + $(STRIP) pigpiod + +pigs: pigs.o command.o + $(CC) -o pigs pigs.o command.o + $(STRIP) pigs + +pig2vcd: pig2vcd.o + $(CC) -o pig2vcd pig2vcd.o + $(STRIP) pig2vcd + +clean: + rm -f *.o *.i *.s *~ $(ALL) *.so.$(SOVERSION) + +ifeq ($(DESTDIR),) + PYINSTALLARGS = +else + PYINSTALLARGS = --root=$(DESTDIR) +endif + +install: $(ALL) + install -m 0755 -d $(DESTDIR)/opt/pigpio/cgi + install -m 0755 -d $(DESTDIR)$(includedir) + install -m 0644 pigpio.h $(DESTDIR)$(includedir) + install -m 0644 pigpiod_if.h $(DESTDIR)$(includedir) + install -m 0644 pigpiod_if2.h $(DESTDIR)$(includedir) + install -m 0755 -d $(DESTDIR)$(libdir) + install -m 0755 libpigpio.so.$(SOVERSION) $(DESTDIR)$(libdir) + install -m 0755 libpigpiod_if.so.$(SOVERSION) $(DESTDIR)$(libdir) + install -m 0755 libpigpiod_if2.so.$(SOVERSION) $(DESTDIR)$(libdir) + cd $(DESTDIR)$(libdir) && ln -fs libpigpio.so.$(SOVERSION) libpigpio.so + cd $(DESTDIR)$(libdir) && ln -fs libpigpiod_if.so.$(SOVERSION) libpigpiod_if.so + cd $(DESTDIR)$(libdir) && ln -fs libpigpiod_if2.so.$(SOVERSION) libpigpiod_if2.so + install -m 0755 -d $(DESTDIR)$(bindir) + install -m 0755 pig2vcd $(DESTDIR)$(bindir) + install -m 0755 pigpiod $(DESTDIR)$(bindir) + install -m 0755 pigs $(DESTDIR)$(bindir) + if which python2; then python2 setup.py install $(PYINSTALLARGS); fi + if which python3; then python3 setup.py install $(PYINSTALLARGS); fi + install -m 0755 -d $(DESTDIR)$(mandir)/man1 + install -m 0644 p*.1 $(DESTDIR)$(mandir)/man1 + install -m 0755 -d $(DESTDIR)$(mandir)/man3 + install -m 0644 p*.3 $(DESTDIR)$(mandir)/man3 +ifeq ($(DESTDIR),) + ldconfig +endif + +uninstall: + rm -f $(DESTDIR)$(includedir)/pigpio.h + rm -f $(DESTDIR)$(includedir)/pigpiod_if.h + rm -f $(DESTDIR)$(includedir)/pigpiod_if2.h + rm -f $(DESTDIR)$(libdir)/libpigpio.so + rm -f $(DESTDIR)$(libdir)/libpigpiod_if.so + rm -f $(DESTDIR)$(libdir)/libpigpiod_if2.so + rm -f $(DESTDIR)$(libdir)/libpigpio.so.$(SOVERSION) + rm -f $(DESTDIR)$(libdir)/libpigpiod_if.so.$(SOVERSION) + rm -f $(DESTDIR)$(libdir)/libpigpiod_if2.so.$(SOVERSION) + rm -f $(DESTDIR)$(bindir)/pig2vcd + rm -f $(DESTDIR)$(bindir)/pigpiod + rm -f $(DESTDIR)$(bindir)/pigs + if which python2; then python2 setup.py install $(PYINSTALLARGS) --record /tmp/pigpio >/dev/null; sed 's!^!$(DESTDIR)!' < /tmp/pigpio | xargs rm -f >/dev/null; fi + if which python3; then python3 setup.py install $(PYINSTALLARGS) --record /tmp/pigpio >/dev/null; sed 's!^!$(DESTDIR)!' < /tmp/pigpio | xargs rm -f >/dev/null; fi + rm -f $(DESTDIR)$(mandir)/man1/pig*.1 + rm -f $(DESTDIR)$(mandir)/man1/libpigpio*.1 + rm -f $(DESTDIR)$(mandir)/man3/pig*.3 +ifeq ($(DESTDIR),) + ldconfig +endif + +$(LIB1): $(OBJ1) + $(SHLIB) -pthread -Wl,-soname,$(LIB1).$(SOVERSION) -o $(LIB1).$(SOVERSION) $(OBJ1) + ln -fs $(LIB1).$(SOVERSION) $(LIB1) + $(STRIPLIB) $(LIB1) + $(SIZE) $(LIB1) + +$(LIB2): $(OBJ2) + $(SHLIB) -pthread -Wl,-soname,$(LIB2).$(SOVERSION) -o $(LIB2).$(SOVERSION) $(OBJ2) + ln -fs $(LIB2).$(SOVERSION) $(LIB2) + $(STRIPLIB) $(LIB2) + $(SIZE) $(LIB2) + +$(LIB3): $(OBJ3) + $(SHLIB) -pthread -Wl,-soname,$(LIB3).$(SOVERSION) -o $(LIB3).$(SOVERSION) $(OBJ3) + ln -fs $(LIB3).$(SOVERSION) $(LIB3) + $(STRIPLIB) $(LIB3) + $(SIZE) $(LIB3) + +# generated using gcc -MM *.c + +pig2vcd.o: pig2vcd.c pigpio.h +pigpiod.o: pigpiod.c pigpio.h +pigs.o: pigs.c pigpio.h command.h pigs.h +x_pigpio.o: x_pigpio.c pigpio.h +x_pigpiod_if.o: x_pigpiod_if.c pigpiod_if.h pigpio.h +x_pigpiod_if2.o: x_pigpiod_if2.c pigpiod_if2.h pigpio.h + diff --git a/README b/README new file mode 100644 index 0000000..ed453a9 --- /dev/null +++ b/README @@ -0,0 +1,174 @@ +NOTE + +The initial part of the make, the compilation of pigpio.c, +takes 100 seconds on early model Pis. Be patient. The overall +install takes just over 3 minutes. + +INSTALL + +Extract the archive to a directory. + +IN THAT DIRECTORY + +Enter the following two commands (in this order) + +make +sudo make install + +This will install + +o the library (libpigpio.so) in /usr/local/lib +o the library (libpigpiod_if.so) in /usr/local/lib +o the library (libpigpiod_if2.so) in /usr/local/lib +o the header file (pigpio.h) in /usr/local/include +o the header file (pigpiod_if.h) in /usr/local/include +o the header file (pigpiod_if2.h) in /usr/local/include +o the header file (pigs.h) in /usr/local/include +o the daemon (pigpiod) in /usr/local/bin +o the socket interface (pigs) in /usr/local/bin +o the utility pig2vcd in /usr/local/bin +o man pages in /usr/local/man/man1 and /usr/local/man/man3 +o the Python module pigpio.py for Python 2 and 3 + +TEST (optional) + +*** WARNING ************************************************ +* * +* All the tests make extensive use of gpio 25 (pin 22). * +* Ensure that either nothing or just a LED is connected to * +* gpio 25 before running any of the tests. * +* * +* Some tests are statistical in nature and so may on * +* occasion fail. Repeated failures on the same test or * +* many failures in a group of tests indicate a problem. * +************************************************************ + +To test the library do + +sudo ./x_pigpio + +To test the pigpio daemon do + +sudo pigpiod + +./x_pigpiod_if # test the C I/F to the pigpio daemon +./x_pigpiod_if2 # test the C I/F to the pigpio daemon +./x_pigpio.py # test the Python I/F to the pigpio daemon +./x_pigs # test the socket I/F to the pigpio daemon +./x_pipe # test the pipe I/F to the pigpio daemon + +EXAMPLE CODE + +x_pigpio.c, pig2vcd.c, and pigpiod.c show examples of interfacing +with the pigpio library. + +pigs.c, pigpio.py, x_pigpiod_if, x_pigpiod_if2.c, x_pigpio.py, +x_pigs, and x_pipe show examples of interfacing with the pigpio +daemon. x_pipe uses the pipe interface, the others use the +socket interface. + +DAEMON + +To launch the daemon do + +sudo pigpiod (pigpiod -? for options) + +Once the daemon is launched the socket and pipe interfaces will be +available. + +When the library starts it locks + +/var/run/pigpio.pid + +The file should be automatically deleted when the library terminates. + +SOCKET INTERFACE + +Use pigs for the socket interface (pigs help for help). + +PIPE INTERFACE + +The pipe interface accepts commands written to /dev/pigpio. + +Results are read from /dev/pigout. + +Errors are output on /dev/pigerr. + +To test the pipe interface perhaps do + +cat /dev/pigout & +cat /dev/pigerr & + +echo "help" >/dev/pigpio + +PYTHON MODULE + +The Python pigpio module is installed to the default Python location +for Python 2 and Python 3. + +You can install it for additional Python versions by + +pythonx.y setup.py install + +where x.y is the Python version. + +STOP DAEMON + +To stop the pigpiod daemon + +sudo killall pigpiod + +RUNNING ON NON Pi's + +You can access the pigpiod daemon running on the Pi from any machine which +is connected to it over the network. This access is via the socket interface. + +In particular this allows you to use the following on non-Pi's. + +o pigs +o the pigpio Python module +o the C socket I/F using libpigpiod_if (header file pigpiod_if.h) +o the C socket I/F using libpigpiod_if2 (header file pigpiod_if2.h) + +On a Linux machine + +make -f MakeRemote clean +make -f MakeRemote +make -f MakeRemote install + +This will install + +o the library (libpigpiod_if.so) in /usr/local/lib +o the library (libpigpiod_if2.so) in /usr/local/lib +o the header file (pigpio.h) in /usr/local/include +o the header file (pigpiod_if.h) in /usr/local/include +o the header file (pigpiod_if2.h) in /usr/local/include +o the socket interface (pigs) in /usr/local/bin +o man pages in /usr/local/man/man1 and /usr/local/man/man3 +o the Python module pigpio.py + +On Windows machines (and possibly Macs) + +The Python module should install with + +python setup.py install + +pigs, pigpiod_if, and pigpiod_if2 will need minor mods to +reflect the Windows/Mac socket interface. + +DOCUMENTATION + +The most up to date should be http://abyz.me.uk/rpi/pigpio/ + +On the Pi try + +man pigs +man pigpiod +man pig2vcd + +man pigpio +man pigpiod_if +man pigpiod_if2 + +pydoc pigpio + diff --git a/README.md b/README.md new file mode 100644 index 0000000..8727e74 --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# pigpio + +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. + sudo pigpiod -d 5 -e 8 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 +* Provision of PWM on any number of the user GPIO simultaneously +* Provision of servo pulses on any number of the user GPIO simultaneously +* Callbacks when any of GPIO 0-31 change state (callbacks receive the time of the event + accurate to a few microseconds) +* Notifications via pipe when any of GPIO 0-31 change state +* Callbacks at timed intervals +* Reading/writing all of the GPIO in a bank (0-31, 32-53) as a single operation +* Individually setting GPIO modes, reading and writing +* Socket and pipe interfaces for the bulk of the functionality in addition to the + underlying C library calls +* Construction of arbitrary waveforms to give precise timing of output GPIO + level changes (accurate to a few microseconds) +* Software serial links, I2C, and SPI using any user GPIO +* Rudimentary permission control through the socket and pipe interfaces so users + can be prevented from "updating" inappropriate GPIO +* Creating and running scripts on the pigpio daemon + +## Interfaces + +The library provides a number of control interfaces +* the C function interface, +* the /dev/pigpio pipe interface, +* the socket interface (used by the pigs utility and the Python module). + +## Utilities + +A number of utility programs are provided: +* the pigpiod daemon, +* the Python module, +* the piscope digital waveform viewer, +* the pigs command line utility, +* the pig2vcd utility which converts notifications into the value change dump (VCD) + format (useful for viewing digital waveforms with GTKWave). + +## Documentation + +See http://abyz.me.uk/rpi/pigpio/ + +## Example programs + +See http://abyz.me.uk/rpi/pigpio/examples.html + +## GPIO + +ALL GPIO are identified by their Broadcom number. See http://elinux.org. + +There are 54 GPIO in total, arranged in two banks. + +Bank 1 contains GPIO 0-31. Bank 2 contains GPIO 32-54. + +A user should only manipulate GPIO in bank 1. + +There are at least three types of board: +* Type 1 + * 26 pin header (P1) + * Hardware revision numbers of 2 and 3 + * User GPIO 0-1, 4, 7-11, 14-15, 17-18, 21-25 +* Type 2 + * 26 pin header (P1) and an additional 8 pin header (P5) + * Hardware revision numbers of 4, 5, 6, and 15 + * User GPIO 2-4, 7-11, 14-15, 17-18, 22-25, 27-31 +* Type 3 + * 40 pin expansion header (J8) + * Hardware revision numbers of 16 or greater + * User GPIO 2-27 (0 and 1 are reserved) + +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. 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/UNLICENCE b/UNLICENCE new file mode 100644 index 0000000..471f09f --- /dev/null +++ b/UNLICENCE @@ -0,0 +1,25 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to + 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 new file mode 100644 index 0000000..ffc3463 --- /dev/null +++ b/command.c @@ -0,0 +1,1422 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +/* +This version is for pigpio version 70+ +*/ + +#include +#include +#include +#include +#include +#include + +#include "pigpio.h" +#include "command.h" + +cmdInfo_t cmdInfo[]= +{ + /* num str vfyt retv script*/ + + {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, 1}, // bbI2CClose + {PI_CMD_BI2CO, "BI2CO", 131, 0, 1}, // bbI2COpen + {PI_CMD_BI2CZ, "BI2CZ", 193, 6, 0}, // bbI2CZip + + {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, 1}, // gpioWrite_Bits_0_31_Set + {PI_CMD_BS2, "BS2", 111, 1, 1}, // gpioWrite_Bits_32_53_Set + + {PI_CMD_BSCX, "BSCX", 193, 8, 0}, // bscXfer + + {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, 0}, // gpioCustom1 + {PI_CMD_CF2, "CF2", 195, 6, 0}, // gpioCustom2 + + {PI_CMD_CGI, "CGI", 101, 4, 1}, // gpioCfgGetInternals + {PI_CMD_CSI, "CSI", 111, 1, 1}, // gpioCfgSetInternals + + {PI_CMD_EVM, "EVM", 122, 1, 1}, // eventMonitor + {PI_CMD_EVT, "EVT", 112, 0, 1}, // eventTrigger + + {PI_CMD_FC, "FC", 112, 0, 1}, // fileClose + + {PI_CMD_FG, "FG", 121, 0, 1}, // gpioGlitchFilter + + {PI_CMD_FL, "FL", 127, 6, 0}, // fileList + + {PI_CMD_FN, "FN", 131, 0, 1}, // gpioNoiseFilter + + {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, 1}, // gpioGetPWMdutycycle + {PI_CMD_GPW, "GPW", 112, 2, 1}, // gpioGetServoPulsewidth + + {PI_CMD_HELP, "H", 101, 5, 0}, // cmdUsage + {PI_CMD_HELP, "HELP", 101, 5, 0}, // cmdUsage + + {PI_CMD_HC, "HC", 121, 0, 1}, // gpioHardwareClock + {PI_CMD_HP, "HP", 131, 0, 1}, // gpioHardwarePWM + + {PI_CMD_HWVER, "HWVER", 101, 4, 1}, // gpioHardwareRevision + + {PI_CMD_I2CC, "I2CC", 112, 0, 1}, // i2cClose + {PI_CMD_I2CO, "I2CO", 131, 2, 1}, // i2cOpen + + {PI_CMD_I2CPC, "I2CPC", 131, 2, 1}, // i2cProcessCall + {PI_CMD_I2CPK, "I2CPK", 194, 6, 0}, // i2cBlockProcessCall + + {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, 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, 0}, // i2cZip + + {PI_CMD_MICS, "MICS", 112, 0, 1}, // gpioDelay + {PI_CMD_MILS, "MILS", 112, 0, 1}, // gpioDelay + + {PI_CMD_MODEG, "MG" , 112, 2, 1}, // gpioGetMode + {PI_CMD_MODEG, "MODEG", 112, 2, 1}, // gpioGetMode + + {PI_CMD_MODES, "M", 125, 0, 1}, // gpioSetMode + {PI_CMD_MODES, "MODES", 125, 0, 1}, // gpioSetMode + + {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, 1}, // gpioGetPad + {PI_CMD_PADS, "PADS", 121, 0, 1}, // gpioSetPad + + {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}, + +}; + + +char * cmdUsage = "\n\ +BC1 bits Clear GPIO in bank 1\n\ +BC2 bits Clear GPIO in bank 2\n\ +BI2CC sda Close bit bang I2C\n\ +BI2CO sda scl baud | Open bit bang I2C\n\ +BI2CZ sda ... I2C bit bang multiple transactions\n\ +\n\ +BSPIC cs Close bit bang SPI\n\ +BSPIO cs miso mosi sclk baud flag | Open bit bang SPI\n\ +BSPIX cs ... SPI bit bang transfer\n\ +\n\ +BR1 Read bank 1 GPIO\n\ +BR2 Read bank 2 GPIO\n\ +\n\ +BS1 bits Set GPIO in bank 1\n\ +BS2 bits Set GPIO in bank 2\n\ +\n\ +BSCX bctl bvs BSC I2C/SPI transfer\n\ +\n\ +CF1 ... Custom function 1\n\ +CF2 ... Custom function 2\n\ +\n\ +CGI Configuration get internals\n\ +CSI v Configuration set internals\n\ +\n\ +EVM h bits Set events to monitor\n\ +EVT n Trigger event\n\ +\n\ +FC h Close file handle\n\ +FG g steady Set glitch filter on GPIO\n\ +FL pat n List files which match pattern\n\ +FN g steady active | Set noise filter on GPIO\n\ +FO file mode Open a file in mode\n\ +FR h n Read bytes from file handle\n\ +FS h n from Seek to file handle position\n\ +FW h ... Write bytes to file handle\n\ +\n\ +GDC g Get PWM dutycycle for GPIO\n\ +GPW g Get servo pulsewidth for GPIO\n\ +\n\ +H/HELP Display command help\n\ +HC g f Set hardware clock frequency\n\ +HP g f dc Set hardware PWM frequency and dutycycle\n\ +HWVER Get hardware version\n\ +\n\ +I2CC h Close I2C handle\n\ +I2CO bus device flags | Open I2C bus and device with flags\n\ +I2CPC h r word SMBus Process Call: exchange register with word\n\ +I2CPK h r ... SMBus Block Process Call: exchange data bytes with register\n\ +I2CRB h r SMBus Read Byte Data: read byte from register\n\ +I2CRD h n I2C Read bytes\n\ +I2CRI h r n SMBus Read I2C Block Data: read bytes from register\n\ +I2CRK h r SMBus Read Block Data: read data from register\n\ +I2CRS h SMBus Read Byte: read byte\n\ +I2CRW h r SMBus Read Word Data: read word from register\n\ +I2CWB h r byte SMBus Write Byte Data: write byte to register\n\ +I2CWD h ... I2C Write data\n\ +I2CWI h r ... SMBus Write I2C Block Data\n\ +I2CWK h r ... SMBus Write Block Data: write data to register\n\ +I2CWQ h b SMBus Write Quick: write bit\n\ +I2CWS h b SMBus Write Byte: write byte\n\ +I2CWW h r word SMBus Write Word Data: write word to register\n\ +I2CZ h ... I2C multiple transactions\n\ +\n\ +M/MODES g mode Set GPIO mode\n\ +MG/MODEG g Get GPIO mode\n\ +MICS n Delay for microseconds\n\ +MILS n Delay for milliseconds\n\ +\n\ +NB h bits Start notification\n\ +NC h Close notification\n\ +NO Request a notification\n\ +NP h Pause notification\n\ +\n\ +P/PWM g v Set GPIO PWM value\n\ +PADG pad Get pad drive strength\n\ +PADS pad v Set pad drive strength\n\ +PARSE text Validate script\n\ +PFG g Get GPIO PWM frequency\n\ +PFS g v Set GPIO PWM frequency\n\ +PIGPV Get pigpio library version\n\ +PRG g Get GPIO PWM range\n\ +PROC text Store script\n\ +PROCD sid Delete script\n\ +PROCP sid Get script status and parameters\n\ +PROCR sid ... Run script\n\ +PROCS sid Stop script\n\ +PROCU sid ... Set script parameters\n\ +PRRG g Get GPIO PWM real range\n\ +PRS g v Set GPIO PWM range\n\ +PUD g pud Set GPIO pull up/down\n\ +\n\ +R/READ g Read GPIO level\n\ +\n\ +S/SERVO g v Set GPIO servo pulsewidth\n\ +SERC h Close serial handle\n\ +SERDA h Check for serial data ready to read\n\ +SERO text baud flags | Open serial device at baud with flags\n\ +SERR h n Read bytes from serial handle\n\ +SERRB h Read byte from serial handle\n\ +SERW h ... Write bytes to serial handle\n\ +SERWB h byte Write byte to serial handle\n\ +SHELL name str Execute a shell command\n\ +SLR g v Read bit bang serial data from GPIO\n\ +SLRC g Close GPIO for bit bang serial data\n\ +SLRO g baud bitlen | Open GPIO for bit bang serial data\n\ +SLRI g invert Invert serial logic (1 invert, 0 normal)\n\ +SPIC h SPI close handle\n\ +SPIO channel baud flags | SPI open channel at baud with flags\n\ +SPIR h v SPI read bytes from handle\n\ +SPIW h ... SPI write bytes to handle\n\ +SPIX h ... SPI transfer bytes to handle\n\ +\n\ +T/TICK Get current tick\n\ +TRIG g micros l Trigger level for micros on GPIO\n\ +\n\ +W/WRITE g l Write level to GPIO\n\ +WDOG g millis Set millisecond watchdog on GPIO\n\ +WVAG triplets Wave add generic pulses\n\ +WVAS g baud bitlen stopbits offset ... | Wave add serial data\n\ +WVBSY Check if wave busy\n\ +WVCHA Transmit a chain of waves\n\ +WVCLR Wave clear\n\ +WVCRE Create wave from added pulses\n\ +WVDEL wid Delete waves w and higher\n\ +WVGO Wave transmit (DEPRECATED)\n\ +WVGOR Wave transmit repeatedly (DEPRECATED)\n\ +WVHLT Wave stop\n\ +WVNEW Start a new empty wave\n\ +WVSC 0,1,2 Wave get DMA control block stats\n\ +WVSM 0,1,2 Wave get micros stats\n\ +WVSP 0,1,2 Wave get pulses stats\n\ +WVTAT Returns the current transmitting wave\n\ +WVTX wid Transmit wave as one-shot\n\ +WVTXM wid wmde Transmit wave using mode\n\ +WVTXR wid Transmit wave repeatedly\n\ +\n\ +Numbers may be entered as hex (prefix 0x), octal (prefix 0),\n\ +otherwise they are assumed to be decimal.\n\ +\n\ +Examples\n\ +\n\ +pigs w 4 1 # set GPIO 4 high\n\ +pigs r 5 # read GPIO 5\n\ +pigs t # get current tick\n\ +pigs i2co 1 0x20 0 # get handle to device 0x20 on I2C bus 1\n\ +\n\ +man pigs for full details.\n\ +\n"; + +typedef struct +{ + int error; + char * str; +} errInfo_t; + +static errInfo_t errInfo[]= +{ + {PI_INIT_FAILED , "pigpio initialisation failed"}, + {PI_BAD_USER_GPIO , "GPIO not 0-31"}, + {PI_BAD_GPIO , "GPIO not 0-53"}, + {PI_BAD_MODE , "mode not 0-7"}, + {PI_BAD_LEVEL , "level not 0-1"}, + {PI_BAD_PUD , "pud not 0-2"}, + {PI_BAD_PULSEWIDTH , "pulsewidth not 0 or 500-2500"}, + {PI_BAD_DUTYCYCLE , "dutycycle not 0-range (default 255)"}, + {PI_BAD_TIMER , "timer not 0-9"}, + {PI_BAD_MS , "ms not 10-60000"}, + {PI_BAD_TIMETYPE , "timetype not 0-1"}, + {PI_BAD_SECONDS , "seconds < 0"}, + {PI_BAD_MICROS , "micros not 0-999999"}, + {PI_TIMER_FAILED , "gpioSetTimerFunc failed"}, + {PI_BAD_WDOG_TIMEOUT , "timeout not 0-60000"}, + {PI_NO_ALERT_FUNC , "DEPRECATED"}, + {PI_BAD_CLK_PERIPH , "clock peripheral not 0-1"}, + {PI_BAD_CLK_SOURCE , "DEPRECATED"}, + {PI_BAD_CLK_MICROS , "clock micros not 1, 2, 4, 5, 8, or 10"}, + {PI_BAD_BUF_MILLIS , "buf millis not 100-10000"}, + {PI_BAD_DUTYRANGE , "dutycycle range not 25-40000"}, + {PI_BAD_SIGNUM , "signum not 0-63"}, + {PI_BAD_PATHNAME , "can't open pathname"}, + {PI_NO_HANDLE , "no handle available"}, + {PI_BAD_HANDLE , "unknown handle"}, + {PI_BAD_IF_FLAGS , "ifFlags > 4"}, + {PI_BAD_CHANNEL , "DMA channel not 0-14"}, + {PI_BAD_SOCKET_PORT , "socket port not 1024-30000"}, + {PI_BAD_FIFO_COMMAND , "unknown fifo command"}, + {PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-14"}, + {PI_NOT_INITIALISED , "function called before gpioInitialise"}, + {PI_INITIALISED , "function called after gpioInitialise"}, + {PI_BAD_WAVE_MODE , "waveform mode not 0-1"}, + {PI_BAD_CFG_INTERNAL , "bad parameter in gpioCfgInternals call"}, + {PI_BAD_WAVE_BAUD , "baud rate not 50-250K(RX)/50-1M(TX)"}, + {PI_TOO_MANY_PULSES , "waveform has too many pulses"}, + {PI_TOO_MANY_CHARS , "waveform has too many chars"}, + {PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on GPIO"}, + {PI_BAD_SERIAL_STRUC , "bad (null) serial structure parameter"}, + {PI_BAD_SERIAL_BUF , "bad (null) serial buf parameter"}, + {PI_NOT_PERMITTED , "no permission to update GPIO"}, + {PI_SOME_PERMITTED , "no permission to update one or more GPIO"}, + {PI_BAD_WVSC_COMMND , "bad WVSC subcommand"}, + {PI_BAD_WVSM_COMMND , "bad WVSM subcommand"}, + {PI_BAD_WVSP_COMMND , "bad WVSP subcommand"}, + {PI_BAD_PULSELEN , "trigger pulse length not 1-100"}, + {PI_BAD_SCRIPT , "invalid script"}, + {PI_BAD_SCRIPT_ID , "unknown script id"}, + {PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"}, + {PI_GPIO_IN_USE , "GPIO already in use"}, + {PI_BAD_SERIAL_COUNT , "must read at least a byte at a time"}, + {PI_BAD_PARAM_NUM , "script parameter id not 0-9"}, + {PI_DUP_TAG , "script has duplicate tag"}, + {PI_TOO_MANY_TAGS , "script has too many tags"}, + {PI_BAD_SCRIPT_CMD , "illegal script command"}, + {PI_BAD_VAR_NUM , "script variable id not 0-149"}, + {PI_NO_SCRIPT_ROOM , "no more room for scripts"}, + {PI_NO_MEMORY , "can't allocate temporary memory"}, + {PI_SOCK_READ_FAILED , "socket read failed"}, + {PI_SOCK_WRIT_FAILED , "socket write failed"}, + {PI_TOO_MANY_PARAM , "too many script parameters (> 10)"}, + {PI_SCRIPT_NOT_READY , "script initialising"}, + {PI_BAD_TAG , "script has unresolved tag"}, + {PI_BAD_MICS_DELAY , "bad MICS delay (too large)"}, + {PI_BAD_MILS_DELAY , "bad MILS delay (too large)"}, + {PI_BAD_WAVE_ID , "non existent wave id"}, + {PI_TOO_MANY_CBS , "No more CBs for waveform"}, + {PI_TOO_MANY_OOL , "No more OOL for waveform"}, + {PI_EMPTY_WAVEFORM , "attempt to create an empty waveform"}, + {PI_NO_WAVEFORM_ID , "no more waveform ids"}, + {PI_I2C_OPEN_FAILED , "can't open I2C device"}, + {PI_SER_OPEN_FAILED , "can't open serial device"}, + {PI_SPI_OPEN_FAILED , "can't open SPI device"}, + {PI_BAD_I2C_BUS , "bad I2C bus"}, + {PI_BAD_I2C_ADDR , "bad I2C address"}, + {PI_BAD_SPI_CHANNEL , "bad SPI channel"}, + {PI_BAD_FLAGS , "bad i2c/spi/ser open flags"}, + {PI_BAD_SPI_SPEED , "bad SPI speed"}, + {PI_BAD_SER_DEVICE , "bad serial device name"}, + {PI_BAD_SER_SPEED , "bad serial baud rate"}, + {PI_BAD_PARAM , "bad i2c/spi/ser parameter"}, + {PI_I2C_WRITE_FAILED , "I2C write failed"}, + {PI_I2C_READ_FAILED , "I2C read failed"}, + {PI_BAD_SPI_COUNT , "bad SPI count"}, + {PI_SER_WRITE_FAILED , "ser write failed"}, + {PI_SER_READ_FAILED , "ser read failed"}, + {PI_SER_READ_NO_DATA , "ser read no data available"}, + {PI_UNKNOWN_COMMAND , "unknown command"}, + {PI_SPI_XFER_FAILED , "spi xfer/read/write failed"}, + {PI_BAD_POINTER , "bad (NULL) pointer"}, + {PI_NO_AUX_SPI , "no auxiliary SPI on Pi A or B"}, + {PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"}, + {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 , "invalid hardware PWM frequency"}, + {PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"}, + {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"}, + {PI_BAD_STOPBITS , "serial (half) stop bits not 2-8"}, + {PI_MSG_TOOBIG , "socket/pipe message too big"}, + {PI_BAD_MALLOC_MODE , "bad memory allocation mode"}, + {PI_TOO_MANY_SEGS , "too many I2C transaction segments"}, + {PI_BAD_I2C_SEG , "an I2C transaction segment failed"}, + {PI_BAD_SMBUS_CMD , "SMBus command not supported by driver"}, + {PI_NOT_I2C_GPIO , "no bit bang I2C in progress on GPIO"}, + {PI_BAD_I2C_WLEN , "bad I2C write length"}, + {PI_BAD_I2C_RLEN , "bad I2C read length"}, + {PI_BAD_I2C_CMD , "bad I2C command"}, + {PI_BAD_I2C_BAUD , "bad I2C baud rate, not 50-500k"}, + {PI_CHAIN_LOOP_CNT , "bad chain loop count"}, + {PI_BAD_CHAIN_LOOP , "empty chain loop"}, + {PI_CHAIN_COUNTER , "too many chain counters"}, + {PI_BAD_CHAIN_CMD , "bad chain command"}, + {PI_BAD_CHAIN_DELAY , "bad chain delay micros"}, + {PI_CHAIN_NESTING , "chain counters nested too deeply"}, + {PI_CHAIN_TOO_BIG , "chain is too long"}, + {PI_DEPRECATED , "deprecated function removed"}, + {PI_BAD_SER_INVERT , "bit bang serial invert not 0 or 1"}, + {PI_BAD_EDGE , "bad ISR edge, not 1, 1, or 2"}, + {PI_BAD_ISR_INIT , "bad ISR initialisation"}, + {PI_BAD_FOREVER , "loop forever must be last chain command"}, + {PI_BAD_FILTER , "bad filter parameter"}, + {PI_BAD_PAD , "bad pad number"}, + {PI_BAD_STRENGTH , "bad pad drive strength"}, + {PI_FIL_OPEN_FAILED , "file open failed"}, + {PI_BAD_FILE_MODE , "bad file mode"}, + {PI_BAD_FILE_FLAG , "bad file flag"}, + {PI_BAD_FILE_READ , "bad file read"}, + {PI_BAD_FILE_WRITE , "bad file write"}, + {PI_FILE_NOT_ROPEN , "file not open for read"}, + {PI_FILE_NOT_WOPEN , "file not open for write"}, + {PI_BAD_FILE_SEEK , "bad file seek"}, + {PI_NO_FILE_MATCH , "no files match pattern"}, + {PI_NO_FILE_ACCESS , "no permission to access file"}, + {PI_FILE_IS_A_DIR , "file is a directory"}, + {PI_BAD_SHELL_STATUS , "bad shell return status"}, + {PI_BAD_SCRIPT_NAME , "bad script name"}, + {PI_BAD_SPI_BAUD , "bad SPI baud rate, not 50-500k"}, + {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"}, + +}; + +static char * fmtMdeStr="RW540123"; +static char * fmtPudStr="ODU"; + +static int cmdMatch(char *str) +{ + int i; + + for (i=0; i<(sizeof(cmdInfo)/sizeof(cmdInfo_t)); i++) + { + if (strcasecmp(str, cmdInfo[i].name) == 0) return i; + } + return CMD_UNKNOWN_CMD; +} + +static int getNum(char *str, uintptr_t *val, int8_t *opt) +{ + int f, n; + intmax_t v; + + *opt = 0; + + f = sscanf(str, " %ji %n", &v, &n); + + if (f == 1) + { + *val = v; + *opt = CMD_NUMERIC; + return n; + } + + f = sscanf(str, " v%ji %n", &v, &n); + + if (f == 1) + { + *val = v; + if (v < PI_MAX_SCRIPT_VARS) *opt = CMD_VAR; + else *opt = -CMD_VAR; + return n; + } + + f = sscanf(str, " p%ji %n", &v, &n); + + if (f == 1) + { + *val = v; + if (v < PI_MAX_SCRIPT_PARAMS) *opt = CMD_PAR; + else *opt = -CMD_PAR; + return n; + } + + return 0; +} + +static char intCmdStr[32]; +static int intCmdIdx; + +char *cmdStr(void) +{ + return intCmdStr; +} + +int cmdParse( + char *buf, uintptr_t *p, unsigned ext_len, char *ext, cmdCtlParse_t *ctl) +{ + int f, valid, idx, val, pp, pars, n, n2; + char *p8; + int32_t *p32; + char c; + uintptr_t tp1=0, tp2=0, tp3=0, tp4=0, tp5=0; + int8_t to1, to2, to3, to4, to5; + int eaten; + + /* Check that ext is big enough for the largest message. */ + if (ext_len < (4 * CMD_MAX_PARAM)) return CMD_EXT_TOO_SMALL; + + bzero(&ctl->opt, sizeof(ctl->opt)); + + sscanf(buf+ctl->eaten, " %31s %n", intCmdStr, &pp); + + ctl->eaten += pp; + + p[0] = -1; + + idx = cmdMatch(intCmdStr); + + intCmdIdx = idx; + + if (idx < 0) return idx; + + valid = 0; + + p[0] = cmdInfo[idx].cmd; + p[1] = 0; + p[2] = 0; + p[3] = 0; + + switch (cmdInfo[idx].vt) + { + case 101: /* BR1 BR2 CGI H HELP HWVER + DCRA HALT INRA NO + PIGPV POPA PUSHA RET T TICK WVBSY WVCLR + WVCRE WVGO WVGOR WVHLT WVNEW + + No parameters, always valid. + */ + valid = 1; + + break; + + case 111: /* ADD AND BC1 BC2 BS1 BS2 + CMP CSI DIV LDA LDAB MLT + MOD OR RLA RRA STAB SUB WAIT XOR + + One parameter, any value. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + if (ctl->opt[1] > 0) valid = 1; + + break; + + 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 + WVCAP WVDEL WVSC WVSM WVSP WVTX WVTXR BSPIC + + One positive parameter. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0)) valid = 1; + + break; + + case 113: /* DCR INR POP PUSH STA XA + + One register parameter. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + if ((ctl->opt[1] > 0) && (p[1] < PI_MAX_SCRIPT_VARS)) valid = 1; + + break; + + case 114: /* CALL JM JMP JNZ JP JZ TAG + + One numeric parameter, any value. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + if (ctl->opt[1] == CMD_NUMERIC) valid = 1; + + break; + + case 115: /* PARSE PROC + + One parameter, string (rest of input). + */ + p[3] = strlen(buf+ctl->eaten); + memcpy(ext, buf+ctl->eaten, p[3]); + ctl->eaten += p[3]; + valid = 1; + + break; + + case 116: /* SYS + + One parameter, a string. + */ + f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2); + if ((f >= 0) && n) + { + p[3] = n; + ctl->opt[3] = CMD_NUMERIC; + memcpy(ext, buf+ctl->eaten, n); + ctl->eaten += n2; + valid = 1; + } + + break; + + case 121: /* HC FR I2CRD I2CRR I2CRW I2CWB I2CWQ P + PADS PFS PRS PWM S SERVO SLR SLRI W + WDOG WRITE WVTXM + + Two positive parameters. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && + (ctl->opt[2] > 0) && ((int)p[2] >= 0)) valid = 1; + + break; + + case 122: /* NB + + Two parameters, first positive, second any value. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && + (ctl->opt[2] > 0)) valid = 1; + + break; + + case 123: /* LD RL RR + + Two parameters, first register, second any value. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + + if ((ctl->opt[1] > 0) && + (p[1] < PI_MAX_SCRIPT_VARS) && + (ctl->opt[2] > 0)) valid = 1; + + break; + + case 124: /* X + + Two register parameters. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + + if ((ctl->opt[1] > 0) && (p[1] < PI_MAX_SCRIPT_VARS) && + (ctl->opt[2] > 0) && (p[2] < PI_MAX_SCRIPT_VARS)) valid = 1; + + break; + + case 125: /* M MODES + + Two parameters, first positive, second in 'RW540123'. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + f = sscanf(buf+ctl->eaten, " %c %n", &c, &n); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && (f >= 1)) + { + ctl->eaten += n; + val = toupper(c); + p8 = strchr(fmtMdeStr, val); + + if (p8 != NULL) + { + val = p8 - fmtMdeStr; + p[2] = val; + valid = 1; + } + } + + break; + + case 126: /* PUD + + Two parameters, first positive, second in 'ODU'. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + f = sscanf(buf+ctl->eaten, " %c %n", &c, &n); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && (f >= 1)) + { + ctl->eaten += n; + val = toupper(c); + p8 = strchr(fmtPudStr, val); + if (p8 != NULL) + { + val = p8 - fmtPudStr; + p[2] = val; + valid = 1; + } + } + + break; + + case 127: /* FL FO + + Two parameters, first a string, other positive. + */ + f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2); + if ((f >= 0) && n) + { + p[3] = n; + ctl->opt[2] = CMD_NUMERIC; + memcpy(ext, buf+ctl->eaten, n); + ctl->eaten += n2; + + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0)) + valid = 1; + } + + break; + + case 128: /* SHELL + + Two string parameters, the first space teminated. + The second arbitrary. + */ + f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2); + + if ((f >= 0) && n) + { + valid = 1; + + p[1] = n; + memcpy(ext, buf+ctl->eaten, n); + ctl->eaten += n; + ext[n] = 0; /* terminate first string */ + + n2 = strlen(buf+ctl->eaten+1); + memcpy(ext+n+1, buf+ctl->eaten+1, n2); + ctl->eaten += n2; + ctl->eaten ++; + p[3] = p[1] + n2 + 1; + } + + break; + + case 131: /* BI2CO HP I2CO I2CPC I2CRI I2CWB I2CWW + SLRO SPIO TRIG + + Three positive parameters. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + ctl->eaten += getNum(buf+ctl->eaten, &tp1, &ctl->opt[3]); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && + (ctl->opt[2] > 0) && ((int)p[2] >= 0) && + (ctl->opt[3] > 0) && ((int)tp1 >= 0)) + { + p[3] = 4; + memcpy(ext, &tp1, 4); + valid = 1; + } + + break; + + case 132: /* SERO + + Three parameters, first a string, rest >=0 + */ + f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2); + if ((f >= 0) && n) + { + p[3] = n; + ctl->opt[2] = CMD_NUMERIC; + memcpy(ext, buf+ctl->eaten, n); + ctl->eaten += n2; + + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && + (ctl->opt[2] > 0) && ((int)p[2] >= 0)) + valid = 1; + } + + break; + + case 133: /* FS + + Three parameters. First and third positive. + Second may be negative when interpreted as an int. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && + (ctl->opt[2] > 0) && + (to1 == CMD_NUMERIC) && ((int)tp1 >= 0)) + { + p[3] = 4; + memcpy(ext, &tp1, 4); + valid = 1; + } + + break; + + case 134: /* BSPIO + + Six parameters. First to Fifth positive. + Sixth may be negative when interpreted as an int. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1); + ctl->eaten += getNum(buf+ctl->eaten, &tp2, &to2); + ctl->eaten += getNum(buf+ctl->eaten, &tp3, &to3); + ctl->eaten += getNum(buf+ctl->eaten, &tp4, &to4); + ctl->eaten += getNum(buf+ctl->eaten, &tp5, &to5); + + if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && + (to1 == CMD_NUMERIC) && ((int)tp1 >= 0) && + (to2 == CMD_NUMERIC) && ((int)tp2 >= 0) && + (to3 == CMD_NUMERIC) && ((int)tp3 >= 0) && + (to4 == CMD_NUMERIC) && ((int)tp4 >= 0) && + (to5 == CMD_NUMERIC)) + { + p[3] = 5 * 4; + memcpy(ext+ 0, &tp1, 4); + memcpy(ext+ 4, &tp2, 4); + memcpy(ext+ 8, &tp3, 4); + memcpy(ext+12, &tp4, 4); + memcpy(ext+16, &tp5, 4); + valid = 1; + } + + break; + + case 191: /* PROCR PROCU + + One to 11 parameters, first positive, + optional remainder, any value. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + if ((ctl->opt[1] == CMD_NUMERIC) && ((int)p[1] >= 0)) + { + pars = 0; + p32 = (int32_t *)ext; + + while (pars < PI_MAX_SCRIPT_PARAMS) + { + ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1); + if (to1 == CMD_NUMERIC) + { + pars++; + *p32++ = tp1; + } + else break; + } + + p[3] = pars * 4; + + valid = 1; + } + + break; + + case 192: /* WVAG + + One or more triplets (gpios on, gpios off, delay), + any value. + */ + + pars = 0; + p32 = (int32_t *)ext; + + while (pars < CMD_MAX_PARAM) + { + ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1); + if (to1 == CMD_NUMERIC) + { + pars++; + *p32++ = tp1; + } + else break; + } + + p[3] = pars * 4; + + if (pars && ((pars % 3) == 0)) valid = 1; + + break; + + case 193: /* BI2CZ BSCX BSPIX FW I2CWD I2CZ SERW + SPIW SPIX + + Two or more parameters, first >=0, rest 0-255. + + BSCX is special case one or more. + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + if ((ctl->opt[1] == CMD_NUMERIC) && ((int)p[1] >= 0)) + { + pars = 0; + p8 = ext; + + while (pars < CMD_MAX_PARAM) + { + eaten = getNum(buf+ctl->eaten, &tp1, &to1); + if (to1 == CMD_NUMERIC) + { + if (((int)tp1>=0) && ((int)tp1<=255)) + { + pars++; + *p8++ = tp1; + ctl->eaten += eaten; + } + else break; /* invalid number, end of command */ + } + else break; + } + + p[3] = pars; + + if (pars || (p[0]==PI_CMD_BSCX)) valid = 1; + } + + break; + + case 194: /* I2CPK I2CWI I2CWK + + Three to 34 parameters, all 0-255. + */ + + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + + if ((ctl->opt[1] == CMD_NUMERIC) && + (ctl->opt[2] == CMD_NUMERIC) && + ((int)p[1]>=0) && ((int)p[2]>=0) && ((int)p[2]<=255)) + { + pars = 0; + p8 = ext; + + while (pars < 32) + { + eaten = getNum(buf+ctl->eaten, &tp1, &to1); + if (to1 == CMD_NUMERIC) + { + if (((int)tp1>=0) && ((int)tp1<=255)) + { + pars++; + *p8++ = tp1; + ctl->eaten += eaten; + } + else break; /* invalid number, end of command */ + } + else break; + } + + p[3] = pars; + + if (pars > 0) valid = 1; + } + + break; + + case 195: /* CF1 CF2 + + Zero or more parameters, first two >=0, rest 0-255. + */ + valid = 1; + + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + + if (ctl->opt[1] == CMD_NUMERIC) + { + if ((int)p[1] >= 0) + { + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + + if (ctl->opt[2] == CMD_NUMERIC) + { + if ((int)p[2] >= 0) + { + pars = 0; + p8 = ext; + + while (pars < CMD_MAX_PARAM) + { + eaten = getNum(buf+ctl->eaten, &tp1, &to1); + if (to1 == CMD_NUMERIC) + { + if (((int)tp1>=0) && ((int)tp1<=255)) + { + pars++; + *p8++ = tp1; + ctl->eaten += eaten; + } + else break; + } + else break; + } + + p[3] = pars; + } + else valid = 0; + } + } + else valid = 0; + } + + break; + + case 196: /* WVAS + + gpio baud offset char... + + p1 gpio + p2 baud + p3 len + 4 + --------- + uint32_t databits + uint32_t stophalfbits + uint32_t offset + uint8_t[len] + */ + ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]); + ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]); + ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1); + ctl->eaten += getNum(buf+ctl->eaten, &tp2, &to2); + ctl->eaten += getNum(buf+ctl->eaten, &tp3, &to3); + + if ((ctl->opt[1] == CMD_NUMERIC) && ((int)p[1] >= 0) && + (ctl->opt[2] == CMD_NUMERIC) && ((int)p[2] > 0) && + (to1 == CMD_NUMERIC) && + (to2 == CMD_NUMERIC) && + (to3 == CMD_NUMERIC)) + { + pars = 0; + + memcpy(ext, &tp1, 4); + memcpy(ext+4, &tp2, 4); + memcpy(ext+8, &tp3, 4); + p8 = ext + 12; + while (pars < CMD_MAX_PARAM) + { + eaten = getNum(buf+ctl->eaten, &tp1, &to1); + if (to1 == CMD_NUMERIC) + { + if (((int)tp1>=0) && ((int)tp1<=255)) + { + *p8++ = tp1; + pars++; + ctl->eaten += eaten; + } + else break; /* invalid number, end of command */ + } + else break; + } + + p[3] = pars + 12; + + if (pars > 0) valid = 1; + } + + break; + + case 197: /* WVCHA + + One or more parameters, all 0-255. + */ + pars = 0; + p8 = ext; + + while (pars < CMD_MAX_PARAM) + { + eaten = getNum(buf+ctl->eaten, &tp1, &to1); + if (to1 == CMD_NUMERIC) + { + if (((int)tp1>=0) && ((int)tp1<=255)) + { + pars++; + *p8++ = tp1; + ctl->eaten += eaten; + } + else break; /* invalid number, end of command */ + } + else break; + } + + p[3] = pars; + + if (pars) valid = 1; + + break; + + + } + + if (valid) return idx; else return CMD_BAD_PARAMETER; +} + +char * cmdErrStr(int error) +{ + int i; + + for (i=0; i<(sizeof(errInfo)/sizeof(errInfo_t)); i++) + { + if (errInfo[i].error == error) return errInfo[i].str; + } + return "unknown error"; +} + +int cmdParseScript(char *script, cmdScript_t *s, int diags) +{ + int idx, len, b, i, j, tags, resolved; + int status; + uintptr_t p[10]; + cmdInstr_t instr; + cmdCtlParse_t ctl; + char v[CMD_MAX_EXTENSION]; + + ctl.eaten = 0; + + status = 0; + + cmdTagStep_t tag_step[PI_MAX_SCRIPT_TAGS]; + + len = strlen(script); + + /* calloc space for PARAMS, VARS, CMDS, and STRINGS */ + + b = (sizeof(int) * (PI_MAX_SCRIPT_PARAMS + PI_MAX_SCRIPT_VARS)) + + (sizeof(cmdInstr_t) * (len + 2) / 2) + len; + + s->par = calloc(1, b); + + if (s->par == NULL) return -1; + + s->var = s->par + PI_MAX_SCRIPT_PARAMS; + + s->instr = (cmdInstr_t *)(s->var + PI_MAX_SCRIPT_VARS); + + s->str_area = (char *)(s->instr + ((len + 2) / 2)); + + s->str_area_len = len; + s->str_area_pos = 0; + + s->instrs = 0; + + tags = 0; + + idx = 0; + + while (ctl.eaten= 0) || (idx != CMD_UNKNOWN_CMD)) + { + if (!cmdInfo[intCmdIdx].cvis) idx = CMD_NOT_IN_SCRIPT; + } + + if (idx >= 0) + { + if (p[3]) + { + memcpy(s->str_area + s->str_area_pos, v, p[3]); + s->str_area[s->str_area_pos + p[3]] = 0; + p[4] = (intptr_t) s->str_area + s->str_area_pos; + s->str_area_pos += (p[3] + 1); + } + + memcpy(&instr.p, p, sizeof(instr.p)); + + if (instr.p[0] == PI_CMD_TAG) + { + if (tags < PI_MAX_SCRIPT_TAGS) + { + /* check tag not already used */ + for (j=0; jinstrs; + tags++; + } + else + { + if (diags) + { + fprintf(stderr, "Too many tags: %"PRIdPTR"\n", instr.p[1]); + } + if (!status) status = PI_TOO_MANY_TAGS; + idx = -1; + } + } + } + else + { + if (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()); + } + if (!status) status = PI_BAD_SCRIPT_CMD; + } + + if (idx >= 0) + { + if (instr.p[0] != PI_CMD_TAG) + { + memcpy(instr.opt, &ctl.opt, sizeof(instr.opt)); + s->instr[s->instrs++] = instr; + } + } + } + + for (i=0; iinstrs; i++) + { + instr = s->instr[i]; + + /* resolve jumps */ + + if ((instr.p[0] == PI_CMD_JMP) || (instr.p[0] == PI_CMD_CALL) || + (instr.p[0] == PI_CMD_JZ) || (instr.p[0] == PI_CMD_JNZ) || + (instr.p[0] == PI_CMD_JM) || (instr.p[0] == PI_CMD_JP)) + { + resolved = 0; + + for (j=0; jinstr[i].p[1] = tag_step[j].step; + resolved = 1; + break; + } + } + + if (!resolved) + { + if (diags) + { + fprintf(stderr, "Can't resolve tag %"PRIdPTR"\n", instr.p[1]); + } + if (!status) status = PI_BAD_TAG; + } + } + } + return status; +} + diff --git a/command.h b/command.h new file mode 100644 index 0000000..3e5c336 --- /dev/null +++ b/command.h @@ -0,0 +1,124 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +/* +This version is for pigpio version 70+ +*/ + +#ifndef COMMAND_H +#define COMMAND_H + +#include +#include + +#include "pigpio.h" + +#define CMD_MAX_PARAM 512 +#define CMD_MAX_EXTENSION (1<<16) + +#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 + +#define CMD_NUMERIC 1 +#define CMD_VAR 2 +#define CMD_PAR 3 + +typedef struct +{ + uint32_t cmd; + uint32_t p1; + uint32_t p2; + union + { + uint32_t p3; + uint32_t ext_len; + uint32_t res; + }; +} cmdCmd_t; + +typedef struct +{ + int eaten; + int8_t opt[4]; +} cmdCtlParse_t; + +typedef struct +{ + int cmd; /* command number */ + 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 +{ + uint32_t tag; + int step; +} cmdTagStep_t; + +typedef struct +{ + uintptr_t p[5]; //these are sometimes converted to pointers, so presumablly they sometimes have pointers stored in them, I haven't figured out where though. --plugwash + int8_t opt[4]; +} cmdInstr_t; + +typedef struct +{ + /* + +-----------+---------+---------+----------------+ + | PARAMS... | VARS... | CMDS... | STRING AREA... | + +-----------+---------+---------+----------------+ + */ + int *par; + int *var; + cmdInstr_t *instr; + int instrs; + char *str_area; + int str_area_len; + int str_area_pos; +} cmdScript_t; + +extern cmdInfo_t cmdInfo[]; + +extern char *cmdUsage; + +int cmdParse(char *buf, uintptr_t *p, unsigned ext_len, char *ext, cmdCtlParse_t *ctl); + +int cmdParseScript(char *script, cmdScript_t *s, int diags); + +char *cmdErrStr(int error); + +char *cmdStr(void); + +#endif + diff --git a/custom.cext b/custom.cext new file mode 100644 index 0000000..905884d --- /dev/null +++ b/custom.cext @@ -0,0 +1,54 @@ +/* +This version is for pigpio version 26+ + +If you want customised functions replace this file with your own +definitions for gpioCustom1 and gpioCustom2. +*/ + +#include "pigpio.h" + +int gpioCustom1(unsigned arg1, unsigned arg2, char *argx, unsigned count) +{ + int i; + unsigned max; + + DBG(DBG_USER, "arg1=%d arg2=%d count=%d [%s]", + arg1, arg2, count, myBuf2Str(count, argx)); + + CHECK_INITED; + + /* for dummy just return max parameter */ + + if (arg1 > arg2) max = arg1; else max = arg2; + + for (i=0; i max) max = argx[i]; + + return max; +} + + +int gpioCustom2(unsigned arg1, char *argx, unsigned count, + char *retBuf, unsigned retMax) +{ + int i, j, t; + + DBG(DBG_USER, "arg1=%d count=%d [%s] retMax=%d", + arg1, count, myBuf2Str(count, argx), retMax); + + CHECK_INITED; + + /* for dummy just return argx reversed */ + + if (count > retMax) count = retMax; + + for (i=0, j=count-1; i<=j; i++, j--) + { + /* t used as argx and retBuf may be the same buffer */ + t = argx[i]; + retBuf[i] = argx[j]; + retBuf[j] = t; + } + + return count; +} + diff --git a/pig2vcd.1 b/pig2vcd.1 new file mode 100644 index 0000000..eacce19 --- /dev/null +++ b/pig2vcd.1 @@ -0,0 +1,246 @@ + +." 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. + +.SH SYNOPSIS + +pig2vcd file.VCD +.SH DESCRIPTION + + +.ad l + +.nh +pig2vcd is a utility which reads notifications on stdin and writes the +output as a Value Change Dump (VCD) file on stdout. + +.br + +.br +The VCD file can be viewed using GTKWave. + +.br + +.br +.SS Notifications +.br + +.br +Notifications consist of 12 bytes with the following binary format. + +.br + +.br + +.EX +typedef struct +.br +{ +.br + uint16_t seqno; +.br + uint16_t flags; +.br + uint32_t tick; +.br + uint32_t level; +.br +} gpioReport_t; +.br + +.EE + +.br + +.br +seqno: starts at 0 each time the handle is opened and then increments by one for each report. + +.br + +.br +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. + +.br + +.br +tick: the number of microseconds since system boot. It wraps around after 1h12m. + +.br + +.br +level: indicates the level of each gpio. If bit 1< +*/ + +/* +This version is for pigpio version 3+ +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pigpio.h" + +/* +This software converts pigpio notification reports +into a VCD format understood by GTKWave. +*/ + +#define RS (sizeof(gpioReport_t)) + +static char * timeStamp() +{ + static char buf[32]; + + struct timeval now; + struct tm tmp; + + gettimeofday(&now, NULL); + + localtime_r(&now.tv_sec, &tmp); + strftime(buf, sizeof(buf), "%F %T", &tmp); + + return buf; +} + +int symbol(int bit) +{ + if (bit < 26) return ('A' + bit); + else return ('a' + bit - 26); +} + +int main(int argc, char * argv[]) +{ + int b, r, v; + uint32_t t0; + uint32_t lastLevel, changed; + + gpioReport_t report; + + r=read(STDIN_FILENO, &report, RS); + + if (r != RS) exit(-1); + + printf("$date %s $end\n", timeStamp()); + printf("$version pig2vcd V1 $end\n"); + printf("$timescale 1 us $end\n"); + printf("$scope module top $end\n"); + + for (b=0; b<32; b++) + printf("$var wire 1 %c %d $end\n", symbol(b), b); + + printf("$upscope $end\n"); + printf("$enddefinitions $end\n"); + + t0 = report.tick; + lastLevel =0; + + while ((r=read(STDIN_FILENO, &report, RS)) == RS) + { + if (report.level != lastLevel) + { + printf("#%u\n", report.tick - t0); + + changed = report.level ^ lastLevel; + + lastLevel = report.level; + + for (b=0; b<32; b++) + { + if (changed & (1< + + +gcc -Wall -pthread -o prog prog.c -lpigpio -lrt + +sudo ./prog +.SH DESCRIPTION + + +.ad l + +.nh + +.br + +.br +pigpio is a C library for the Raspberry which allows control of the GPIO. + +.br + +.br +.SS Features +.br + +.br +o hardware timed PWM on any of GPIO 0-31 + +.br + +.br +o hardware timed servo pulses on any of GPIO 0-31 + +.br + +.br +o callbacks when any of GPIO 0-31 change state + +.br + +.br +o callbacks at timed intervals + +.br + +.br +o reading/writing all of the GPIO in a bank as one operation + +.br + +.br +o individually setting GPIO modes, reading and writing + +.br + +.br +o notifications when any of GPIO 0-31 change state + +.br + +.br +o the construction of output waveforms with microsecond timing + +.br + +.br +o rudimentary permission control over GPIO + +.br + +.br +o a simple interface to start and stop new threads + +.br + +.br +o I2C, SPI, and serial link wrappers + +.br + +.br +o creating and running scripts + +.br + +.br +.SS GPIO +.br + +.br +ALL GPIO are identified by their Broadcom number. + +.br + +.br +.SS Credits +.br + +.br +The PWM and servo pulses are timed using the DMA and PWM peripherals. + +.br + +.br +This use was inspired by Richard Hirst's servoblaster kernel module. + +.br + +.br +.SS Usage +.br + +.br +Include in your source files. + +.br + +.br +Assuming your source is in prog.c use the following command to build and +run the executable. + +.br + +.br + +.EX +gcc -Wall -pthread -o prog prog.c -lpigpio -lrt +.br +sudo ./prog +.br + +.EE + +.br + +.br +For examples of usage see the C programs within the pigpio archive file. + +.br + +.br +.SS Notes +.br + +.br +All the functions which return an int return < 0 on error. + +.br + +.br +\fBgpioInitialise\fP must be called before all other library functions +with the following exceptions: + +.br + +.br + +.EX +\fBgpioCfg*\fP +.br +\fBgpioVersion\fP +.br +\fBgpioHardwareRevision\fP +.br + +.EE + +.br + +.br +If the library is not initialised all but the \fBgpioCfg*\fP, +\fBgpioVersion\fP, and \fBgpioHardwareRevision\fP functions will +return error PI_NOT_INITIALISED. + +.br + +.br +If the library is initialised the \fBgpioCfg*\fP functions will return +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" +.IP "" 4 +Initialises the library. + +.br + +.br +Returns the pigpio version number if OK, otherwise PI_INIT_FAILED. + +.br + +.br +gpioInitialise must be called before using the other library functions +with the following exceptions: + +.br + +.br + +.EX +\fBgpioCfg*\fP +.br +\fBgpioVersion\fP +.br +\fBgpioHardwareRevision\fP +.br + +.EE + +.br + +.br +\fBExample\fP +.br + +.EX +if (gpioInitialise() < 0) +.br +{ +.br + // pigpio initialisation failed. +.br +} +.br +else +.br +{ +.br + // pigpio initialised okay. +.br +} +.br + +.EE + +.IP "\fBvoid gpioTerminate(void)\fP" +.IP "" 4 +Terminates the library. + +.br + +.br +Returns nothing. + +.br + +.br +Call before program exit. + +.br + +.br +This function resets the used DMA channels, releases memory, and +terminates any running threads. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioTerminate(); +.br + +.EE + +.IP "\fBint gpioSetMode(unsigned gpio, unsigned mode)\fP" +.IP "" 4 +Sets the GPIO mode, typically input or output. + +.br + +.br + +.EX +gpio: 0-53 +.br +mode: 0-7 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_MODE. + +.br + +.br +Arduino style: pinMode. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioSetMode(17, PI_INPUT); // Set GPIO17 as input. +.br + +.br +gpioSetMode(18, PI_OUTPUT); // Set GPIO18 as output. +.br + +.br +gpioSetMode(22,PI_ALT0); // Set GPIO22 to alternative mode 0. +.br + +.EE + +.br + +.br +See \fBhttp://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf\fP page 102 for an overview of the modes. + +.IP "\fBint gpioGetMode(unsigned gpio)\fP" +.IP "" 4 +Gets the GPIO mode. + +.br + +.br + +.EX +gpio: 0-53 +.br + +.EE + +.br + +.br +Returns the GPIO mode if OK, otherwise PI_BAD_GPIO. + +.br + +.br +\fBExample\fP +.br + +.EX +if (gpioGetMode(17) != PI_ALT0) +.br +{ +.br + gpioSetMode(17, PI_ALT0); // set GPIO17 to ALT0 +.br +} +.br + +.EE + +.IP "\fBint gpioSetPullUpDown(unsigned gpio, unsigned pud)\fP" +.IP "" 4 +Sets or clears resistor pull ups or downs on the GPIO. + +.br + +.br + +.EX +gpio: 0-53 +.br + pud: 0-2 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_PUD. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioSetPullUpDown(17, PI_PUD_UP); // Sets a pull-up. +.br + +.br +gpioSetPullUpDown(18, PI_PUD_DOWN); // Sets a pull-down. +.br + +.br +gpioSetPullUpDown(23, PI_PUD_OFF); // Clear any pull-ups/downs. +.br + +.EE + +.IP "\fBint gpioRead(unsigned gpio)\fP" +.IP "" 4 +Reads the GPIO level, on or off. + +.br + +.br + +.EX +gpio: 0-53 +.br + +.EE + +.br + +.br +Returns the GPIO level if OK, otherwise PI_BAD_GPIO. + +.br + +.br +Arduino style: digitalRead. + +.br + +.br +\fBExample\fP +.br + +.EX +printf("GPIO24 is level %d", gpioRead(24)); +.br + +.EE + +.IP "\fBint gpioWrite(unsigned gpio, unsigned level)\fP" +.IP "" 4 +Sets the GPIO level, on or off. + +.br + +.br + +.EX + gpio: 0-53 +.br +level: 0-1 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL. + +.br + +.br +If PWM or servo pulses are active on the GPIO they are switched off. + +.br + +.br +Arduino style: digitalWrite + +.br + +.br +\fBExample\fP +.br + +.EX +gpioWrite(24, 1); // Set GPIO24 high. +.br + +.EE + +.IP "\fBint gpioPWM(unsigned user_gpio, unsigned dutycycle)\fP" +.IP "" 4 +Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on). +Range defaults to 255. + +.br + +.br + +.EX +user_gpio: 0-31 +.br +dutycycle: 0-range +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYCYCLE. + +.br + +.br +Arduino style: analogWrite + +.br + +.br +This and the servo functionality use the DMA and PWM or PCM peripherals +to control and schedule the pulse lengths and dutycycles. + +.br + +.br +The \fBgpioSetPWMrange\fP function may be used to change the default +range of 255. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioPWM(17, 255); // Sets GPIO17 full on. +.br + +.br +gpioPWM(18, 128); // Sets GPIO18 half on. +.br + +.br +gpioPWM(23, 0); // Sets GPIO23 full off. +.br + +.EE + +.IP "\fBint gpioGetPWMdutycycle(unsigned user_gpio)\fP" +.IP "" 4 +Returns the PWM dutycycle setting for the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + +.EE + +.br + +.br +Returns between 0 (off) and range (fully on) if OK, otherwise +PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. + +.br + +.br +For normal PWM the dutycycle will be out of the defined range +for the GPIO (see \fBgpioGetPWMrange\fP). + +.br + +.br +If a hardware clock is active on the GPIO the reported dutycycle +will be 500000 (500k) out of 1000000 (1M). + +.br + +.br +If hardware PWM is active on the GPIO the reported dutycycle +will be out of a 1000000 (1M). + +.br + +.br +Normal PWM range defaults to 255. + +.IP "\fBint gpioSetPWMrange(unsigned user_gpio, unsigned range)\fP" +.IP "" 4 +Selects the dutycycle range to be used for the GPIO. Subsequent calls +to gpioPWM will use a dutycycle between 0 (off) and range (fully on). + +.br + +.br + +.EX +user_gpio: 0-31 +.br + range: 25-40000 +.br + +.EE + +.br + +.br +Returns the real range for the given GPIO's frequency if OK, +otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE. + +.br + +.br +If PWM is currently active on the GPIO its dutycycle will be scaled +to reflect the new range. + +.br + +.br +The real range, the number of steps between fully off and fully +on for each frequency, is given in the following table. + +.br + +.br + +.EX + 25, 50, 100, 125, 200, 250, 400, 500, 625, +.br + 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000 +.br + +.EE + +.br + +.br +The real value set by \fBgpioPWM\fP is (dutycycle * real range) / range. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioSetPWMrange(24, 2000); // Now 2000 is fully on +.br + // 1000 is half on +.br + // 500 is quarter on, etc. +.br + +.EE + +.IP "\fBint gpioGetPWMrange(unsigned user_gpio)\fP" +.IP "" 4 +Returns the dutycycle range used for the GPIO if OK, otherwise +PI_BAD_USER_GPIO. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + +.EE + +.br + +.br +If a hardware clock or hardware PWM is active on the GPIO +the reported range will be 1000000 (1M). + +.br + +.br +\fBExample\fP +.br + +.EX +r = gpioGetPWMrange(23); +.br + +.EE + +.IP "\fBint gpioGetPWMrealRange(unsigned user_gpio)\fP" +.IP "" 4 +Returns the real range used for the GPIO if OK, otherwise +PI_BAD_USER_GPIO. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + +.EE + +.br + +.br +If a hardware clock is active on the GPIO the reported real +range will be 1000000 (1M). + +.br + +.br +If hardware PWM is active on the GPIO the reported real range +will be approximately 250M divided by the set PWM frequency. + +.br + +.br +\fBExample\fP +.br + +.EX +rr = gpioGetPWMrealRange(17); +.br + +.EE + +.IP "\fBint gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency)\fP" +.IP "" 4 +Sets the frequency in hertz to be used for the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31 +.br +frequency: >=0 +.br + +.EE + +.br + +.br +Returns the numerically closest frequency if OK, otherwise +PI_BAD_USER_GPIO. + +.br + +.br +If PWM is currently active on the GPIO it will be +switched off and then back on at the new frequency. + +.br + +.br +Each GPIO can be independently set to one of 18 different PWM +frequencies. + +.br + +.br +The selectable frequencies depend upon the sample rate which +may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). + +.br + +.br +The frequencies for each sample rate are: + +.br + +.br + +.EX + Hertz +.br + +.br + 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600 +.br + 1250 1000 800 500 400 250 200 100 50 +.br + +.br + 2: 20000 10000 5000 4000 2500 2000 1250 1000 800 +.br + 625 500 400 250 200 125 100 50 25 +.br + +.br + 4: 10000 5000 2500 2000 1250 1000 625 500 400 +.br + 313 250 200 125 100 63 50 25 13 +.br +sample +.br + rate +.br + (us) 5: 8000 4000 2000 1600 1000 800 500 400 320 +.br + 250 200 160 100 80 50 40 20 10 +.br + +.br + 8: 5000 2500 1250 1000 625 500 313 250 200 +.br + 156 125 100 63 50 31 25 13 6 +.br + +.br + 10: 4000 2000 1000 800 500 400 250 200 160 +.br + 125 100 80 50 40 25 20 10 5 +.br + +.EE + +.br + +.br +\fBExample\fP +.br + +.EX +gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency. +.br + +.br +gpioSetPWMfrequency(24, 500); // Set GPIO24 to 500Hz. +.br + +.br +gpioSetPWMfrequency(25, 100000); // Set GPIO25 to highest frequency. +.br + +.EE + +.IP "\fBint gpioGetPWMfrequency(unsigned user_gpio)\fP" +.IP "" 4 +Returns the frequency (in hertz) used for the GPIO if OK, otherwise +PI_BAD_USER_GPIO. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + +.EE + +.br + +.br +For normal PWM the frequency will be that defined for the GPIO by +\fBgpioSetPWMfrequency\fP. + +.br + +.br +If a hardware clock is active on the GPIO the reported frequency +will be that set by \fBgpioHardwareClock\fP. + +.br + +.br +If hardware PWM is active on the GPIO the reported frequency +will be that set by \fBgpioHardwarePWM\fP. + +.br + +.br +\fBExample\fP +.br + +.EX +f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23. +.br + +.EE + +.IP "\fBint gpioServo(unsigned user_gpio, unsigned pulsewidth)\fP" +.IP "" 4 +Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to +2500 (most clockwise). + +.br + +.br + +.EX + user_gpio: 0-31 +.br +pulsewidth: 0, 500-2500 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_PULSEWIDTH. + +.br + +.br +The range supported by servos varies and should probably be determined +by experiment. 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. + +.br + +.br +The following 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. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioServo(17, 1000); // Move servo to safe position anti-clockwise. +.br + +.br +gpioServo(23, 1500); // Move servo to centre position. +.br + +.br +gpioServo(25, 2000); // Move servo to safe position clockwise. +.br + +.EE + +.br + +.br +OTHER UPDATE RATES: + +.br + +.br +This function updates servos at 50Hz. If you wish to use a different +update frequency you will have to use the PWM functions. + +.br + +.br + +.EX +PWM Hz 50 100 200 400 500 +.br +1E6/Hz 20000 10000 5000 2500 2000 +.br + +.EE + +.br + +.br +Firstly set the desired PWM frequency using \fBgpioSetPWMfrequency\fP. + +.br + +.br +Then set the PWM range using \fBgpioSetPWMrange\fP to 1E6/frequency. +Doing this allows you to use units of microseconds when setting +the servo pulsewidth. + +.br + +.br +E.g. If you want to update a servo connected to GPIO25 at 400Hz + +.br + +.br + +.EX +gpioSetPWMfrequency(25, 400); +.br + +.br +gpioSetPWMrange(25, 2500); +.br + +.EE + +.br + +.br +Thereafter use the PWM command to move the servo, +e.g. gpioPWM(25, 1500) will set a 1500 us pulse. + +.IP "\fBint gpioGetServoPulsewidth(unsigned user_gpio)\fP" +.IP "" 4 +Returns the servo pulsewidth setting for the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + +.EE + +.br + +.br +Returns 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise) +if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO. + +.IP "\fBint gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f)\fP" +.IP "" 4 +Registers a function to be called (a callback) when the specified +GPIO changes state. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + f: the callback function +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO. + +.br + +.br +One callback may be registered per GPIO. + +.br + +.br +The callback is passed the GPIO, the new level, and the tick. + +.br + +.br + +.EX +Parameter Value Meaning +.br + +.br +GPIO 0-31 The GPIO which has changed state +.br + +.br +level 0-2 0 = change to low (a falling edge) +.br + 1 = change to high (a rising edge) +.br + 2 = no level change (a watchdog timeout) +.br + +.br +tick 32 bit The number of microseconds since boot +.br + WARNING: this wraps around from +.br + 4294967295 to 0 roughly every 72 minutes +.br + +.EE + +.br + +.br +The alert may be cancelled by passing NULL as the function. + +.br + +.br +The GPIO are sampled at a rate set when the library is started. + +.br + +.br +If a value isn't specifically set the default of 5 us is used. + +.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 +Level changes shorter than the sample rate may be missed. + +.br + +.br +The thread which calls the alert functions is triggered nominally +1000 times per second. The active alert functions will be called +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. + +.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. + +.br + +.br +\fBExample\fP +.br + +.EX +void aFunction(int gpio, int level, uint32_t tick) +.br +{ +.br + printf("GPIO %d became %d at %d", gpio, level, tick); +.br +} +.br + +.br +// call aFunction whenever GPIO 4 changes state +.br + +.br +gpioSetAlertFunc(4, aFunction); +.br + +.EE + +.IP "\fBint gpioSetAlertFuncEx(unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata)\fP" +.IP "" 4 +Registers a function to be called (a callback) when the specified +GPIO changes state. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + f: the callback function +.br + userdata: pointer to arbitrary user data +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO. + +.br + +.br +One callback may be registered per GPIO. + +.br + +.br +The callback is passed the GPIO, the new level, the tick, and +the userdata pointer. + +.br + +.br + +.EX +Parameter Value Meaning +.br + +.br +GPIO 0-31 The GPIO which has changed state +.br + +.br +level 0-2 0 = change to low (a falling edge) +.br + 1 = change to high (a rising edge) +.br + 2 = no level change (a watchdog timeout) +.br + +.br +tick 32 bit The number of microseconds since boot +.br + WARNING: this wraps around from +.br + 4294967295 to 0 roughly every 72 minutes +.br + +.br +userdata pointer Pointer to an arbitrary object +.br + +.EE + +.br + +.br +See \fBgpioSetAlertFunc\fP for further details. + +.br + +.br +Only one of \fBgpioSetAlertFunc\fP or \fBgpioSetAlertFuncEx\fP can be +registered per GPIO. + +.IP "\fBint gpioSetISRFunc(unsigned gpio, unsigned edge, int timeout, gpioISRFunc_t f)\fP" +.IP "" 4 +Registers a function to be called (a callback) whenever the specified +GPIO interrupt occurs. + +.br + +.br + +.EX + gpio: 0-53 +.br + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE +.br +timeout: interrupt timeout in milliseconds (<=0 to cancel) +.br + f: the callback function +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_EDGE, +or PI_BAD_ISR_INIT. + +.br + +.br +One function may be registered per GPIO. + +.br + +.br +The function is passed the GPIO, the current level, and the +current tick. The level will be PI_TIMEOUT if the optional +interrupt timeout expires. + +.br + +.br + +.EX +Parameter Value Meaning +.br + +.br +GPIO 0-53 The GPIO which has changed state +.br + +.br +level 0-2 0 = change to low (a falling edge) +.br + 1 = change to high (a rising edge) +.br + 2 = no level change (interrupt timeout) +.br + +.br +tick 32 bit The number of microseconds since boot +.br + WARNING: this wraps around from +.br + 4294967295 to 0 roughly every 72 minutes +.br + +.EE + +.br + +.br +The underlying Linux sysfs GPIO interface is used to provide +the interrupt services. + +.br + +.br +The first time the function is called, with a non-NULL f, the +GPIO is exported, set to be an input, and set to interrupt +on the given edge and timeout. + +.br + +.br +Subsequent calls, with a non-NULL f, can vary one or more of the +edge, timeout, or function. + +.br + +.br +The ISR may be cancelled by passing a NULL f, in which case the +GPIO is unexported. + +.br + +.br +The tick is that read at the time the process was informed of +the interrupt. This will be a variable number of microseconds +after the interrupt occurred. Typically the latency will be of +the order of 50 microseconds. The latency is not guaranteed +and will vary with system load. + +.br + +.br +The level is that read at the time the process was informed of +the interrupt, or PI_TIMEOUT if the optional interrupt timeout +expired. It may not be the same as the expected edge as +interrupts happening in rapid succession may be missed by the +kernel (i.e. this mechanism can not be used to capture several +interrupts only a few microseconds apart). + +.IP "\fBint gpioSetISRFuncEx(unsigned gpio, unsigned edge, int timeout, gpioISRFuncEx_t f, void *userdata)\fP" +.IP "" 4 +Registers a function to be called (a callback) whenever the specified +GPIO interrupt occurs. + +.br + +.br + +.EX + gpio: 0-53 +.br + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE +.br + timeout: interrupt timeout in milliseconds (<=0 to cancel) +.br + f: the callback function +.br +userdata: pointer to arbitrary user data +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_EDGE, +or PI_BAD_ISR_INIT. + +.br + +.br +The function is passed the GPIO, the current level, the +current tick, and the userdata pointer. + +.br + +.br + +.EX +Parameter Value Meaning +.br + +.br +GPIO 0-53 The GPIO which has changed state +.br + +.br +level 0-2 0 = change to low (a falling edge) +.br + 1 = change to high (a rising edge) +.br + 2 = no level change (interrupt timeout) +.br + +.br +tick 32 bit The number of microseconds since boot +.br + WARNING: this wraps around from +.br + 4294967295 to 0 roughly every 72 minutes +.br + +.br +userdata pointer Pointer to an arbitrary object +.br + +.EE + +.br + +.br +Only one of \fBgpioSetISRFunc\fP or \fBgpioSetISRFuncEx\fP can be +registered per GPIO. + +.br + +.br +See \fBgpioSetISRFunc\fP for further details. + +.IP "\fBint gpioNotifyOpen(void)\fP" +.IP "" 4 +This function requests a free notification handle. + +.br + +.br +Returns a handle greater than or equal to zero if OK, +otherwise PI_NO_HANDLE. + +.br + +.br +A notification is a method for being notified of GPIO state changes +via a pipe or socket. + +.br + +.br +Pipe notifications for handle x will be available at the pipe +named /dev/pigpiox (where x is the handle number). E.g. if the +function returns 15 then the notifications must be read +from /dev/pigpio15. + +.br + +.br +Socket notifications are returned to the socket which requested the +handle. + +.br + +.br +\fBExample\fP +.br + +.EX +h = gpioNotifyOpen(); +.br + +.br +if (h >= 0) +.br +{ +.br + sprintf(str, "/dev/pigpio%d", h); +.br + +.br + fd = open(str, O_RDONLY); +.br + +.br + if (fd >= 0) +.br + { +.br + // Okay. +.br + } +.br + else +.br + { +.br + // Error. +.br + } +.br +} +.br +else +.br +{ +.br + // Error. +.br +} +.br + +.EE + +.IP "\fBint gpioNotifyOpenWithSize(int bufSize)\fP" +.IP "" 4 +This function requests a free notification handle. + +.br + +.br +It differs from \fBgpioNotifyOpen\fP in that the pipe size may be +specified, whereas \fBgpioNotifyOpen\fP uses the default pipe size. + +.br + +.br +See \fBgpioNotifyOpen\fP for further details. + +.IP "\fBint gpioNotifyBegin(unsigned handle, uint32_t bits)\fP" +.IP "" 4 +This function starts notifications on a previously opened handle. + +.br + +.br + +.EX +handle: >=0, as returned by \fBgpioNotifyOpen\fP +.br + bits: a bit mask indicating the GPIO of interest +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +The notification sends state changes for each GPIO whose corresponding +bit in bits is set. + +.br + +.br +Each notification occupies 12 bytes in the fifo and has the +following structure. + +.br + +.br + +.EX +typedef struct +.br +{ +.br + uint16_t seqno; +.br + uint16_t flags; +.br + uint32_t tick; +.br + uint32_t level; +.br +} gpioReport_t; +.br + +.EE + +.br + +.br +seqno: starts at 0 each time the handle is opened and then increments +by one for each report. + +.br + +.br +flags: three flags are defined, PI_NTFY_FLAGS_WDOG, +PI_NTFY_FLAGS_ALIVE, and PI_NTFY_FLAGS_EVENT. + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +If bit 7 is set (PI_NTFY_FLAGS_EVENT) then bits 0-4 of the flags +indicate an event which has been triggered. + +.br + +.br +tick: the number of microseconds since system boot. It wraps around +after 1h12m. + +.br + +.br +level: indicates the level of each GPIO. If bit 1<=0, as returned by \fBgpioNotifyOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +Notifications for the handle are suspended until \fBgpioNotifyBegin\fP +is called again. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioNotifyPause(h); +.br + +.EE + +.IP "\fBint gpioNotifyClose(unsigned handle)\fP" +.IP "" 4 +This function stops notifications on a previously opened handle +and releases the handle for reuse. + +.br + +.br + +.EX +handle: >=0, as returned by \fBgpioNotifyOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioNotifyClose(h); +.br + +.EE + +.IP "\fBint gpioWaveClear(void)\fP" +.IP "" 4 +This function clears all waveforms and any data added by calls to the +\fBgpioWaveAdd*\fP functions. + +.br + +.br +Returns 0 if OK. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioWaveClear(); +.br + +.EE + +.IP "\fBint gpioWaveAddNew(void)\fP" +.IP "" 4 +This function starts a new empty waveform. + +.br + +.br +You wouldn't normally need to call this function as it is automatically +called after a waveform is created with the \fBgpioWaveCreate\fP function. + +.br + +.br +Returns 0 if OK. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioWaveAddNew(); +.br + +.EE + +.IP "\fBint gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses)\fP" +.IP "" 4 +This function adds a number of pulses to the current waveform. + +.br + +.br + +.EX +numPulses: the number of pulses +.br + pulses: an array of pulses +.br + +.EE + +.br + +.br +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_TOO_MANY_PULSES. + +.br + +.br +The pulses are interleaved in time order within the existing waveform +(if any). + +.br + +.br +Merging allows the waveform to be built in parts, that is the settings +for GPIO#1 can be added, and then GPIO#2 etc. + +.br + +.br +If the added waveform is intended to start after or within the existing +waveform then the first pulse should consist of a delay. + +.br + +.br +\fBExample\fP +.br + +.EX +// Construct and send a 30 microsecond square wave. +.br + +.br +gpioSetMode(gpio, PI_OUTPUT); +.br + +.br +pulse[0].gpioOn = (1<= 0) +.br +{ +.br + gpioWaveTxSend(wave_id, PI_WAVE_MODE_REPEAT); +.br + +.br + // Transmit for 30 seconds. +.br + +.br + sleep(30); +.br + +.br + gpioWaveTxStop(); +.br +} +.br +else +.br +{ +.br + // Wave create failed. +.br +} +.br + +.EE + +.IP "\fBint gpioWaveAddSerial(unsigned user_gpio, unsigned baud, unsigned data_bits, unsigned stop_bits, unsigned offset, unsigned numBytes, char *str)\fP" +.IP "" 4 +This function adds a waveform representing serial data to the +existing waveform (if any). The serial data starts offset +microseconds from the start of the waveform. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + baud: 50-1000000 +.br +data_bits: 1-32 +.br +stop_bits: 2-8 +.br + offset: >=0 +.br + numBytes: >=1 +.br + str: an array of chars (which may contain nulls) +.br + +.EE + +.br + +.br +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS, +PI_BAD_STOPBITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET, +or PI_TOO_MANY_PULSES. + +.br + +.br +NOTES: + +.br + +.br +The serial data is formatted as one start bit, data_bits data bits, and +stop_bits/2 stop bits. + +.br + +.br +It is legal to add serial data streams with different baud rates to +the same waveform. + +.br + +.br +numBytes is the number of bytes of data in str. + +.br + +.br +The bytes required for each character depend upon data_bits. + +.br + +.br +For data_bits 1-8 there will be one byte per character. +.br +For data_bits 9-16 there will be two bytes per character. +.br +For data_bits 17-32 there will be four bytes per character. + +.br + +.br +\fBExample\fP +.br + +.EX +#define MSG_LEN 8 +.br + +.br +int i; +.br +char *str; +.br +char data[MSG_LEN]; +.br + +.br +str = "Hello world!"; +.br + +.br +gpioWaveAddSerial(4, 9600, 8, 2, 0, strlen(str), str); +.br + +.br +for (i=0; i=0, as returned by \fBgpioWaveCreate\fP +.br + +.EE + +.br + +.br +Wave ids are allocated in order, 0, 1, 2, etc. + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_WAVE_ID. + +.IP "\fBint gpioWaveTxSend(unsigned wave_id, unsigned wave_mode)\fP" +.IP "" 4 +This function transmits the waveform with id wave_id. The mode +determines whether the waveform is sent once or cycles endlessly. +The SYNC variants wait for the current waveform to reach the +end of a cycle or finish before starting the new waveform. + +.br + +.br +WARNING: bad things may happen if you delete the previous +waveform before it has been synced to the new waveform. + +.br + +.br +NOTE: Any hardware PWM started by \fBgpioHardwarePWM\fP will be cancelled. + +.br + +.br + +.EX + wave_id: >=0, as returned by \fBgpioWaveCreate\fP +.br +wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT, +.br + PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC +.br + +.EE + +.br + +.br +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. + +.IP "\fBint gpioWaveChain(char *buf, unsigned bufSize)\fP" +.IP "" 4 +This function transmits a chain of waveforms. + +.br + +.br +NOTE: Any hardware PWM started by \fBgpioHardwarePWM\fP will be cancelled. + +.br + +.br +The waves to be transmitted are specified by the contents of buf +which contains an ordered list of \fBwave_id\fPs and optional command +codes and related data. + +.br + +.br + +.EX + buf: pointer to the wave_ids and optional command codes +.br +bufSize: the number of bytes in buf +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER, +PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID. + +.br + +.br +Each wave is transmitted in the order specified. A wave may +occur multiple times per chain. + +.br + +.br +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. + +.br + +.br +Delays between waves may be added with the delay command. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +Loop Start 255 0 Identify start of a wave block +.br +Loop Repeat 255 1 x y loop x + y*256 times +.br +Delay 255 2 x y delay x + y*256 microseconds +.br +Loop Forever 255 3 loop forever +.br + +.br + +.br +If present Loop Forever must be the last entry in the chain. + +.br + +.br +The code is currently dimensioned to support a chain with roughly +600 entries and 20 loop counters. + +.br + +.br +\fBExample\fP +.br + +.EX +#include +.br +#include +.br + +.br +#define WAVES 5 +.br +#define GPIO 4 +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int i, wid[WAVES]; +.br + +.br + if (gpioInitialise()<0) return -1; +.br + +.br + gpioSetMode(GPIO, PI_OUTPUT); +.br + +.br + printf("start piscope, press return"); getchar(); +.br + +.br + for (i=0; i=0 +.br + +.EE + +.br + +.br +Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO +or PI_NOT_SERIAL_GPIO. + +.br + +.br +The bytes returned for each character depend upon the number of +data bits \fBdata_bits\fP specified in the \fBgpioSerialReadOpen\fP command. + +.br + +.br +For \fBdata_bits\fP 1-8 there will be one byte per character. +.br +For \fBdata_bits\fP 9-16 there will be two bytes per character. +.br +For \fBdata_bits\fP 17-32 there will be four bytes per character. + +.IP "\fBint gpioSerialReadClose(unsigned user_gpio)\fP" +.IP "" 4 +This function closes a GPIO for bit bang reading of serial data. + +.br + +.br + +.EX +user_gpio: 0-31, previously opened with \fBgpioSerialReadOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO. + +.IP "\fBint i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags)\fP" +.IP "" 4 +This returns a handle for the device at the address on the I2C bus. + +.br + +.br + +.EX + i2cBus: >=0 +.br + i2cAddr: 0-0x7F +.br +i2cFlags: 0 +.br + +.EE + +.br + +.br +No flags are currently defined. This parameter should be set to zero. + +.br + +.br +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. + +.br + +.br +The GPIO used are given in the following table. + +.br + +.br + SDA SCL +.br +I2C 0 0 1 +.br +I2C 1 2 3 +.br + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR, +PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED. + +.br + +.br +For the SMBus commands the low level transactions are shown at the end +of the function description. The following abbreviations are used. + +.br + +.br + +.EX +S (1 bit) : Start bit +.br +P (1 bit) : Stop bit +.br +Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. +.br +A, NA (1 bit) : Accept and not accept bit. +.br +.br +.br +Addr (7 bits): I2C 7 bit address. +.br +i2cReg (8 bits): Command byte, a byte which often selects a register. +.br +Data (8 bits): A data byte. +.br +Count (8 bits): A byte defining the length of a block operation. +.br + +.br +[..]: Data sent by the device. +.br + +.EE + +.IP "\fBint i2cClose(unsigned handle)\fP" +.IP "" 4 +This closes the I2C device associated with the handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint i2cWriteQuick(unsigned handle, unsigned bit)\fP" +.IP "" 4 +This sends a single bit (in the Rd/Wr bit) to the device associated +with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + bit: 0-1, the value to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Quick command. SMBus 2.0 5.5.1 + +.EX +S Addr bit [A] P +.br + +.EE + +.IP "\fBint i2cWriteByte(unsigned handle, unsigned bVal)\fP" +.IP "" 4 +This sends a single byte to the device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + bVal: 0-0xFF, the value to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Send byte. SMBus 2.0 5.5.2 + +.EX +S Addr Wr [A] bVal [A] P +.br + +.EE + +.IP "\fBint i2cReadByte(unsigned handle)\fP" +.IP "" 4 +This reads a single byte from the device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + +.EE + +.br + +.br +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +or PI_I2C_READ_FAILED. + +.br + +.br +Receive byte. SMBus 2.0 5.5.3 + +.EX +S Addr Rd [A] [Data] NA P +.br + +.EE + +.IP "\fBint i2cWriteByteData(unsigned handle, unsigned i2cReg, unsigned bVal)\fP" +.IP "" 4 +This writes a single byte to the specified register of the device +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to write +.br + bVal: 0-0xFF, the value to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Write byte. SMBus 2.0 5.5.4 + +.EX +S Addr Wr [A] i2cReg [A] bVal [A] P +.br + +.EE + +.IP "\fBint i2cWriteWordData(unsigned handle, unsigned i2cReg, unsigned wVal)\fP" +.IP "" 4 +This writes a single 16 bit word to the specified register of the device +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to write +.br + wVal: 0-0xFFFF, the value to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Write word. SMBus 2.0 5.5.4 + +.EX +S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A] P +.br + +.EE + +.IP "\fBint i2cReadByteData(unsigned handle, unsigned i2cReg)\fP" +.IP "" 4 +This reads a single byte from the specified register of the device +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to read +.br + +.EE + +.br + +.br +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Read byte. SMBus 2.0 5.5.5 + +.EX +S Addr Wr [A] i2cReg [A] S Addr Rd [A] [Data] NA P +.br + +.EE + +.IP "\fBint i2cReadWordData(unsigned handle, unsigned i2cReg)\fP" +.IP "" 4 +This reads a single 16 bit word from the specified register of the device +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to read +.br + +.EE + +.br + +.br +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Read word. SMBus 2.0 5.5.5 + +.EX +S Addr Wr [A] i2cReg [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P +.br + +.EE + +.IP "\fBint i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal)\fP" +.IP "" 4 +This writes 16 bits of data to the specified register of the device +associated with handle and reads 16 bits of data in return. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to write/read +.br + wVal: 0-0xFFFF, the value to write +.br + +.EE + +.br + +.br +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Process call. SMBus 2.0 5.5.6 + +.EX +S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A] +.br + S Addr Rd [A] [DataLow] A [DataHigh] NA P +.br + +.EE + +.IP "\fBint i2cWriteBlockData(unsigned handle, unsigned i2cReg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes up to 32 bytes to the specified register of the device +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to write +.br + buf: an array with the data to send +.br + count: 1-32, the number of bytes to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Block write. SMBus 2.0 5.5.7 + +.EX +S Addr Wr [A] i2cReg [A] count [A] +.br + buf0 [A] buf1 [A] ... [A] bufn [A] P +.br + +.EE + +.IP "\fBint i2cReadBlockData(unsigned handle, unsigned i2cReg, char *buf)\fP" +.IP "" 4 +This reads a block of up to 32 bytes from the specified register of +the device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to read +.br + buf: an array to receive the read data +.br + +.EE + +.br + +.br +The amount of returned data is set by the device. + +.br + +.br +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Block read. SMBus 2.0 5.5.7 + +.EX +S Addr Wr [A] i2cReg [A] +.br + S Addr Rd [A] [Count] A [buf0] A [buf1] A ... A [bufn] NA P +.br + +.EE + +.IP "\fBint i2cBlockProcessCall(unsigned handle, unsigned i2cReg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes data bytes to the specified register of the device +associated with handle and reads a device specified number +of bytes of data in return. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to write/read +.br + buf: an array with the data to send and to receive the read data +.br + count: 1-32, the number of bytes to write +.br + +.EE + +.br + +.br +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +The SMBus 2.0 documentation states that a minimum of 1 byte may be +sent and a minimum of 1 byte may be received. The total number of +bytes sent/received must be 32 or less. + +.br + +.br +Block write-block read. SMBus 2.0 5.5.8 + +.EX +S Addr Wr [A] i2cReg [A] count [A] buf0 [A] ... bufn [A] +.br + S Addr Rd [A] [Count] A [buf0] A ... [bufn] A P +.br + +.EE + +.IP "\fBint i2cReadI2CBlockData(unsigned handle, unsigned i2cReg, char *buf, unsigned count)\fP" +.IP "" 4 +This reads count bytes from the specified register of the device +associated with handle . The count may be 1-32. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to read +.br + buf: an array to receive the read data +.br + count: 1-32, the number of bytes to read +.br + +.EE + +.br + +.br +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br + +.EX +S Addr Wr [A] i2cReg [A] +.br + S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P +.br + +.EE + +.IP "\fBint i2cWriteI2CBlockData(unsigned handle, unsigned i2cReg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes 1 to 32 bytes to the specified register of the device +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br +i2cReg: 0-255, the register to write +.br + buf: the data to write +.br + count: 1-32, the number of bytes to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br + +.EX +S Addr Wr [A] i2cReg [A] buf0 [A] buf1 [A] ... [A] bufn [A] P +.br + +.EE + +.IP "\fBint i2cReadDevice(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This reads count bytes from the raw device into buf. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + buf: an array to receive the read data bytes +.br + count: >0, the number of bytes to read +.br + +.EE + +.br + +.br +Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_READ_FAILED. + +.br + +.br + +.EX +S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P +.br + +.EE + +.IP "\fBint i2cWriteDevice(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This writes count bytes from buf to the raw device. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + buf: an array containing the data bytes to write +.br + count: >0, the number of bytes to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br + +.EX +S Addr Wr [A] buf0 [A] buf1 [A] ... [A] bufn [A] P +.br + +.EE + +.IP "\fBvoid i2cSwitchCombined(int setting)\fP" +.IP "" 4 +This sets the I2C (i2c-bcm2708) module "use combined transactions" +parameter on or off. + +.br + +.br + +.EX +setting: 0 to set the parameter off, non-zero to set it on +.br + +.EE + +.br + +.br + +.br + +.br +NOTE: when the flag is on a write followed by a read to the same +slave address will use a repeated start (rather than a stop/start). + +.IP "\fBint i2cSegments(unsigned handle, pi_i2c_msg_t *segs, unsigned numSegs)\fP" +.IP "" 4 +This function executes multiple I2C segments in one transaction by +calling the I2C_RDWR ioctl. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + segs: an array of I2C segments +.br +numSegs: >0, the number of I2C segments +.br + +.EE + +.br + +.br +Returns the number of segments if OK, otherwise PI_BAD_I2C_SEG. + +.IP "\fBint i2cZip(unsigned handle, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP" +.IP "" 4 +This function executes a sequence of I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + inBuf: pointer to the concatenated I2C commands, see below +.br + inLen: size of command buffer +.br +outBuf: pointer to buffer to hold returned data +.br +outLen: size of output buffer +.br + +.EE + +.br + +.br +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN. +PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +End 0 No more commands +.br +Escape 1 Next P is two bytes +.br +On 2 Switch combined flag on +.br +Off 3 Switch combined flag off +.br +Address 4 P Set I2C address to P +.br +Flags 5 lsb msb Set I2C flags to lsb + (msb << 8) +.br +Read 6 P Read P bytes of data +.br +Write 7 P ... Write P bytes of data +.br + +.br + +.br +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). + +.br + +.br +The address defaults to that associated with the handle. +The flags default to 0. The address and flags maintain their +previous value until updated. + +.br + +.br +The returned I2C data is stored in consecutive locations of outBuf. + +.br + +.br +\fBExample\fP +.br + +.EX +Set address 0x53, write 0x32, read 6 bytes +.br +Set address 0x1E, write 0x03, read 6 bytes +.br +Set address 0x68, write 0x1B, read 8 bytes +.br +End +.br + +.br +0x04 0x53 0x07 0x01 0x32 0x06 0x06 +.br +0x04 0x1E 0x07 0x01 0x03 0x06 0x06 +.br +0x04 0x68 0x07 0x01 0x1B 0x06 0x08 +.br +0x00 +.br + +.EE + +.IP "\fBint bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud)\fP" +.IP "" 4 +This function selects a pair of GPIO for bit banging I2C at a +specified baud rate. + +.br + +.br +Bit banging I2C allows for certain operations which are not possible +with the standard I2C driver. + +.br + +.br +o baud rates as low as 50 +.br +o repeated starts +.br +o clock stretching +.br +o I2C on any pair of spare GPIO + +.br + +.br + +.EX + SDA: 0-31 +.br + SCL: 0-31 +.br +baud: 50-500000 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or +PI_GPIO_IN_USE. + +.br + +.br +NOTE: + +.br + +.br +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. + +.IP "\fBint bbI2CClose(unsigned SDA)\fP" +.IP "" 4 +This function stops bit banging I2C on a pair of GPIO previously +opened with \fBbbI2COpen\fP. + +.br + +.br + +.EX +SDA: 0-31, the SDA GPIO used in a prior call to \fBbbI2COpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO. + +.IP "\fBint bbI2CZip(unsigned SDA, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP" +.IP "" 4 +This function executes a sequence of bit banged I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +.br + +.br + +.EX + SDA: 0-31 (as used in a prior call to \fBbbI2COpen\fP) +.br + inBuf: pointer to the concatenated I2C commands, see below +.br + inLen: size of command buffer +.br +outBuf: pointer to buffer to hold returned data +.br +outLen: size of output buffer +.br + +.EE + +.br + +.br +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER, +PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN, +PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +End 0 No more commands +.br +Escape 1 Next P is two bytes +.br +Start 2 Start condition +.br +Stop 3 Stop condition +.br +Address 4 P Set I2C address to P +.br +Flags 5 lsb msb Set I2C flags to lsb + (msb << 8) +.br +Read 6 P Read P bytes of data +.br +Write 7 P ... Write P bytes of data +.br + +.br + +.br +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). + +.br + +.br +The address and flags default to 0. The address and flags maintain +their previous value until updated. + +.br + +.br +No flags are currently defined. + +.br + +.br +The returned I2C data is stored in consecutive locations of outBuf. + +.br + +.br +\fBExample\fP +.br + +.EX +Set address 0x53 +.br +start, write 0x32, (re)start, read 6 bytes, stop +.br +Set address 0x1E +.br +start, write 0x03, (re)start, read 6 bytes, stop +.br +Set address 0x68 +.br +start, write 0x1B, (re)start, read 8 bytes, stop +.br +End +.br + +.br +0x04 0x53 +.br +0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03 +.br + +.br +0x04 0x1E +.br +0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03 +.br + +.br +0x04 0x68 +.br +0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03 +.br + +.br +0x00 +.br + +.EE + +.IP "\fBint bscXfer(bsc_xfer_t *bsc_xfer)\fP" +.IP "" 4 +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 + +.br +I can't get SPI to work properly. I tried with a +control word of 0x303 and swapped MISO and MOSI. + +.br + +.br +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 +receive buffer. + +.br + +.br + +.EX +bsc_xfer:= a structure defining the transfer +.br + +.br +typedef struct +.br +{ +.br + uint32_t control; // Write +.br + int rxCnt; // Read only +.br + char rxBuf[BSC_FIFO_SIZE]; // Read only +.br + int txCnt; // Write +.br + char txBuf[BSC_FIFO_SIZE]; // Write +.br +} bsc_xfer_t; +.br + +.EE + +.br + +.br +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 + +.br +Upon return rxCnt will be set to the number of received bytes placed +in rxBuf. + +.br + +.br +Note that the control word sets the BSC mode. The BSC will stay in +that mode until a different control word is sent. + +.br + +.br +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 + 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 + +.br +The returned function value is the status of the transfer (see below). + +.br + +.br +If there was an error the status will be less than zero +(and will contain the error code). + +.br + +.br +The most significant word of the returned status contains the number +of bytes actually copied from txBuf to the BSC transmit FIFO (may be +less than requested if the FIFO already contained untransmitted data). + +.br + +.br +control consists of the following bits. + +.br + +.br + +.EX +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + a a a a a a a - - IT HC TF IR RE TE BK EC ES PL PH I2 SP EN +.br + +.EE + +.br + +.br +Bits 0-13 are copied unchanged to the BSC CR register. See +pages 163-165 of the Broadcom peripherals document for full +details. + +.br + +.br +aaaaaaa defines the I2C slave address (only relevant in I2C mode) +.br +IT invert transmit status flags +.br +HC enable host control +.br +TF enable test FIFO +.br +IR invert receive status flags +.br +RE enable receive +.br +TE enable transmit +.br +BK abort operation and clear FIFOs +.br +EC send control register as first I2C byte +.br +ES send status register as first I2C byte +.br +PL set SPI polarity high +.br +PH set SPI phase high +.br +I2 enable I2C mode +.br +SP enable SPI mode +.br +EN enable BSC peripheral +.br + +.br + +.br +The returned status has the following format + +.br + +.br + +.EX +20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + S S S S S R R R R R T T T T T RB TE RF TF RE TB +.br + +.EE + +.br + +.br +Bits 0-15 are copied unchanged from the BSC FR register. See +pages 165-166 of the Broadcom peripherals document for full +details. + +.br + +.br +SSSSS number of bytes successfully copied to transmit FIFO +.br +RRRRR number of bytes in receieve FIFO +.br +TTTTT number of bytes in transmit FIFO +.br +RB receive busy +.br +TE transmit FIFO empty +.br +RF receive FIFO full +.br +TF transmit FIFO full +.br +RE receive FIFO empty +.br +TB transmit busy +.br + +.br + +.br +The following example shows how to configure the BSC peripheral as +an I2C slave with address 0x13 and send four bytes. + +.br + +.br +\fBExample\fP +.br + +.EX +bsc_xfer_t xfer; +.br + +.br +xfer.control = (0x13<<16) | 0x305; +.br + +.br +memcpy(xfer.txBuf, "ABCD", 4); +.br +xfer.txCnt = 4; +.br + +.br +status = bscXfer(&xfer); +.br + +.br +if (status >= 0) +.br +{ +.br + // process transfer +.br +} +.br + +.EE + +.IP "\fBint bbSPIOpen(unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, unsigned baud, unsigned spiFlags)\fP" +.IP "" 4 +This function selects a set of GPIO for bit banging SPI with +a specified baud rate and mode. + +.br + +.br + +.EX + CS: 0-31 +.br + MISO: 0-31 +.br + MOSI: 0-31 +.br + SCLK: 0-31 +.br + baud: 50-250000 +.br +spiFlags: see below +.br + +.EE + +.br + +.br +spiFlags consists of the least significant 22 bits. + +.br + +.br + +.EX +21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m +.br + +.EE + +.br + +.br +mm defines the SPI mode, defaults to 0 + +.br + +.br + +.EX +Mode CPOL CPHA +.br + 0 0 0 +.br + 1 0 1 +.br + 2 1 0 +.br + 3 1 1 +.br + +.EE + +.br + +.br +p is 0 if CS is active low (default) and 1 for active high. + +.br + +.br +T is 1 if the least significant bit is transmitted on MOSI first, the +default (0) shifts the most significant bit out first. + +.br + +.br +R is 1 if the least significant bit is received on MISO first, the +default (0) receives the most significant bit first. + +.br + +.br +The other bits in flags should be set to zero. + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or +PI_GPIO_IN_USE. + +.br + +.br +If more than one device is connected to the SPI bus (defined by +SCLK, MOSI, and MISO) each must have its own CS. + +.br + +.br +\fBExample\fP +.br + +.EX +bbSPIOpen(10, MISO, MOSI, SCLK, 10000, 0); // device 1 +.br +bbSPIOpen(11, MISO, MOSI, SCLK, 20000, 3); // device 2 +.br + +.EE + +.IP "\fBint bbSPIClose(unsigned CS)\fP" +.IP "" 4 +This function stops bit banging SPI on a set of GPIO +opened with \fBbbSPIOpen\fP. + +.br + +.br + +.EX +CS: 0-31, the CS GPIO used in a prior call to \fBbbSPIOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO. + +.IP "\fBint bbSPIXfer(unsigned CS, char *inBuf, char *outBuf, unsigned count)\fP" +.IP "" 4 +This function executes a bit banged SPI transfer. + +.br + +.br + +.EX + CS: 0-31 (as used in a prior call to \fBbbSPIOpen\fP) +.br + inBuf: pointer to buffer to hold data to be sent +.br +outBuf: pointer to buffer to hold returned data +.br + count: size of data transfer +.br + +.EE + +.br + +.br +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_SPI_GPIO or PI_BAD_POINTER. + +.br + +.br +\fBExample\fP +.br + +.EX +// gcc -Wall -pthread -o bbSPIx_test bbSPIx_test.c -lpigpio +.br +// sudo ./bbSPIx_test +.br + +.br + +.br +#include +.br + +.br +#include "pigpio.h" +.br + +.br +#define CE0 5 +.br +#define CE1 6 +.br +#define MISO 13 +.br +#define MOSI 19 +.br +#define SCLK 12 +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int i, count, set_val, read_val; +.br + unsigned char inBuf[3]; +.br + char cmd1[] = {0, 0}; +.br + char cmd2[] = {12, 0}; +.br + char cmd3[] = {1, 128, 0}; +.br + +.br + if (gpioInitialise() < 0) +.br + { +.br + fprintf(stderr, "pigpio initialisation failed.\n"); +.br + return 1; +.br + } +.br + +.br + bbSPIOpen(CE0, MISO, MOSI, SCLK, 10000, 0); // MCP4251 DAC +.br + bbSPIOpen(CE1, MISO, MOSI, SCLK, 20000, 3); // MCP3008 ADC +.br + +.br + for (i=0; i<256; i++) +.br + { +.br + cmd1[1] = i; +.br + +.br + count = bbSPIXfer(CE0, cmd1, (char *)inBuf, 2); // > DAC +.br + +.br + if (count == 2) +.br + { +.br + count = bbSPIXfer(CE0, cmd2, (char *)inBuf, 2); // < DAC +.br + +.br + if (count == 2) +.br + { +.br + set_val = inBuf[1]; +.br + +.br + count = bbSPIXfer(CE1, cmd3, (char *)inBuf, 3); // < ADC +.br + +.br + if (count == 3) +.br + { +.br + read_val = ((inBuf[1]&3)<<8) | inBuf[2]; +.br + printf("%d %d\n", set_val, read_val); +.br + } +.br + } +.br + } +.br + } +.br + +.br + bbSPIClose(CE0); +.br + bbSPIClose(CE1); +.br + +.br + gpioTerminate(); +.br + +.br + return 0; +.br +} +.br + +.EE + +.IP "\fBint spiOpen(unsigned spiChan, unsigned baud, unsigned spiFlags)\fP" +.IP "" 4 +This function returns a handle for the SPI device on the channel. +Data will be transferred at baud bits per second. The flags may +be used to modify the default behaviour of 4-wire operation, mode 0, +active low chip select. + +.br + +.br +The Pi has two SPI peripherals: main and auxiliary. + +.br + +.br +The main SPI has two chip selects (channels), the auxiliary has +three. + +.br + +.br +The auxiliary SPI is available on all models but the A and B. + +.br + +.br +The GPIO used are given in the following table. + +.br + +.br + MISO MOSI SCLK CE0 CE1 CE2 +.br +Main SPI 9 10 11 8 7 - +.br +Aux SPI 19 20 21 18 17 16 +.br + +.br + +.br + +.EX + spiChan: 0-1 (0-2 for the auxiliary SPI) +.br + baud: 32K-125M (values above 30M are unlikely to work) +.br +spiFlags: see below +.br + +.EE + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL, +PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED. + +.br + +.br +spiFlags consists of the least significant 22 bits. + +.br + +.br + +.EX +21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m +.br + +.EE + +.br + +.br +mm defines the SPI mode. + +.br + +.br +Warning: modes 1 and 3 do not appear to work on the auxiliary SPI. + +.br + +.br + +.EX +Mode POL PHA +.br + 0 0 0 +.br + 1 0 1 +.br + 2 1 0 +.br + 3 1 1 +.br + +.EE + +.br + +.br +px is 0 if CEx is active low (default) and 1 for active high. + +.br + +.br +ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise. + +.br + +.br +A is 0 for the main SPI, 1 for the auxiliary SPI. + +.br + +.br +W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Main +SPI only. + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +bbbbbb defines the word size in bits (0-32). The default (0) +sets 8 bits per word. Auxiliary SPI only. + +.br + +.br +The \fBspiRead\fP, \fBspiWrite\fP, and \fBspiXfer\fP functions +transfer data packed into 1, 2, or 4 bytes according to +the word size in bits. + +.br + +.br +For bits 1-8 there will be one byte per word. +.br +For bits 9-16 there will be two bytes per word. +.br +For bits 17-32 there will be four bytes per word. + +.br + +.br +Multi-byte transfers are made in least significant byte first order. + +.br + +.br +E.g. to transfer 32 11-bit words buf should contain 64 bytes +and count should be 64. + +.br + +.br +E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed +by 0x1A. + +.br + +.br +The other bits in flags should be set to zero. + +.IP "\fBint spiClose(unsigned handle)\fP" +.IP "" 4 +This functions closes the SPI device identified by the handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBspiOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint spiRead(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function reads count bytes of data from the SPI +device associated with the handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBspiOpen\fP +.br + buf: an array to receive the read data bytes +.br + count: the number of bytes to read +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint spiWrite(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function writes count bytes of data from buf to the SPI +device associated with the handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBspiOpen\fP +.br + buf: the data bytes to write +.br + count: the number of bytes to write +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint spiXfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count)\fP" +.IP "" 4 +This function transfers count bytes of data from txBuf to the SPI +device associated with the handle. Simultaneously count bytes of +data are read from the device and placed in rxBuf. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBspiOpen\fP +.br + txBuf: the data bytes to write +.br + rxBuf: the received data bytes +.br + count: the number of bytes to transfer +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint serOpen(char *sertty, unsigned baud, unsigned serFlags)\fP" +.IP "" 4 +This function opens a serial device at a specified baud rate +and with specified flags. The device name must start with +/dev/tty or /dev/serial. + +.br + +.br + +.EX + sertty: the serial device to open +.br + baud: the baud rate in bits per second, see below +.br +serFlags: 0 +.br + +.EE + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or +PI_SER_OPEN_FAILED. + +.br + +.br +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. + +.br + +.br +No flags are currently defined. This parameter should be set to zero. + +.IP "\fBint serClose(unsigned handle)\fP" +.IP "" 4 +This function closes the serial device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint serWriteByte(unsigned handle, unsigned bVal)\fP" +.IP "" 4 +This function writes bVal to the serial port associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. + +.IP "\fBint serReadByte(unsigned handle)\fP" +.IP "" 4 +This function reads a byte from the serial port associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserOpen\fP +.br + +.EE + +.br + +.br +Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED. + +.br + +.br +If no data is ready PI_SER_READ_NO_DATA is returned. + +.IP "\fBint serWrite(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function writes count bytes from buf to the the serial port +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserOpen\fP +.br + buf: the array of bytes to write +.br + count: the number of bytes to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. + +.IP "\fBint serRead(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function reads up count bytes from the the serial port +associated with handle and writes them to buf. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserOpen\fP +.br + buf: an array to receive the read data +.br + count: the maximum number of bytes to read +.br + +.EE + +.br + +.br +Returns the number of bytes read (>0=) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_SER_READ_NO_DATA. + +.br + +.br +If no data is ready zero is returned. + +.IP "\fBint serDataAvailable(unsigned handle)\fP" +.IP "" 4 +This function returns the number of bytes available +to be read from the device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserOpen\fP +.br + +.EE + +.br + +.br +Returns the number of bytes of data available (>=0) if OK, +otherwise PI_BAD_HANDLE. + +.IP "\fBint gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level)\fP" +.IP "" 4 +This function sends a trigger pulse to a GPIO. The GPIO is set to +level for pulseLen microseconds and then reset to not level. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + pulseLen: 1-100 +.br + level: 0,1 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL, +or PI_BAD_PULSELEN. + +.IP "\fBint gpioSetWatchdog(unsigned user_gpio, unsigned timeout)\fP" +.IP "" 4 +Sets a watchdog for a GPIO. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + timeout: 0-60000 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_WDOG_TIMEOUT. + +.br + +.br +The watchdog is nominally in milliseconds. + +.br + +.br +One watchdog may be registered per GPIO. + +.br + +.br +The watchdog may be cancelled by setting timeout to 0. + +.br + +.br +Until cancelled a timeout will be reported every timeout milliseconds +after the last GPIO activity. + +.br + +.br +In particular: + +.br + +.br +1) any registered alert function for the GPIO will be called with + the level set to PI_TIMEOUT. + +.br + +.br +2) any notification for the GPIO will have a report written to the + fifo with the flags set to indicate a watchdog timeout. + +.br + +.br +\fBExample\fP +.br + +.EX +void aFunction(int gpio, int level, uint32_t tick) +.br +{ +.br + printf("GPIO %d became %d at %d", gpio, level, tick); +.br +} +.br + +.br +// call aFunction whenever GPIO 4 changes state +.br +gpioSetAlertFunc(4, aFunction); +.br + +.br +// or approximately every 5 millis +.br +gpioSetWatchdog(4, 5); +.br + +.EE + +.IP "\fBint gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active)\fP" +.IP "" 4 +Sets a noise filter on a GPIO. + +.br + +.br +Level changes on the GPIO are ignored until a level which has +been stable for \fBsteady\fP microseconds is detected. Level changes +on the GPIO are then reported for \fBactive\fP microseconds after +which the process repeats. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + steady: 0-300000 +.br + active: 0-1000000 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + +.br + +.br +This filter affects the GPIO samples returned to callbacks set up +with \fBgpioSetAlertFunc\fP, \fBgpioSetAlertFuncEx\fP, \fBgpioSetGetSamplesFunc\fP, +and \fBgpioSetGetSamplesFuncEx\fP. + +.br + +.br +It does not affect interrupts set up with \fBgpioSetISRFunc\fP, +\fBgpioSetISRFuncEx\fP, or levels read by \fBgpioRead\fP, +\fBgpioRead_Bits_0_31\fP, or \fBgpioRead_Bits_32_53\fP. + +.br + +.br +Level changes before and after the active period may +be reported. Your software must be designed to cope with +such reports. + +.IP "\fBint gpioGlitchFilter(unsigned user_gpio, unsigned steady)\fP" +.IP "" 4 +Sets a glitch filter on a GPIO. + +.br + +.br +Level changes on the GPIO are not reported unless the level +has been stable for at least \fBsteady\fP microseconds. The +level is then reported. Level changes of less than \fBsteady\fP +microseconds are ignored. + +.br + +.br + +.EX +user_gpio: 0-31 +.br + steady: 0-300000 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + +.br + +.br +This filter affects the GPIO samples returned to callbacks set up +with \fBgpioSetAlertFunc\fP, \fBgpioSetAlertFuncEx\fP, \fBgpioSetGetSamplesFunc\fP, +and \fBgpioSetGetSamplesFuncEx\fP. + +.br + +.br +It does not affect interrupts set up with \fBgpioSetISRFunc\fP, +\fBgpioSetISRFuncEx\fP, or levels read by \fBgpioRead\fP, +\fBgpioRead_Bits_0_31\fP, or \fBgpioRead_Bits_32_53\fP. + +.br + +.br +Each (stable) edge will be timestamped \fBsteady\fP microseconds +after it was first detected. + +.IP "\fBint gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits)\fP" +.IP "" 4 +Registers a function to be called (a callback) every millisecond +with the latest GPIO samples. + +.br + +.br + +.EX + f: the function to call +.br +bits: the GPIO of interest +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.br + +.br +The function is passed a pointer to the samples (an array of +\fBgpioSample_t\fP), and the number of samples. + +.br + +.br +Only one function can be registered. + +.br + +.br +The callback may be cancelled by passing NULL as the function. + +.br + +.br +The samples returned will be the union of bits, plus any active alerts, +plus any active notifications. + +.br + +.br +e.g. if there are alerts for GPIO 7, 8, and 9, notifications for GPIO +8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for GPIO +7, 8, 9, 10, 17, 23, and 24 will be reported. + +.IP "\fBint gpioSetGetSamplesFuncEx(gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata)\fP" +.IP "" 4 +Registers a function to be called (a callback) every millisecond +with the latest GPIO samples. + +.br + +.br + +.EX + f: the function to call +.br + bits: the GPIO of interest +.br +userdata: a pointer to arbitrary user data +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.br + +.br +The function is passed a pointer to the samples (an array of +\fBgpioSample_t\fP), the number of samples, and the userdata pointer. + +.br + +.br +Only one of \fBgpioGetSamplesFunc\fP or \fBgpioGetSamplesFuncEx\fP can be +registered. + +.br + +.br +See \fBgpioSetGetSamplesFunc\fP for further details. + +.IP "\fBint gpioSetTimerFunc(unsigned timer, unsigned millis, gpioTimerFunc_t f)\fP" +.IP "" 4 +Registers a function to be called (a callback) every millis milliseconds. + +.br + +.br + +.EX + timer: 0-9 +.br +millis: 10-60000 +.br + f: the function to call +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED. + +.br + +.br +10 timers are supported numbered 0 to 9. + +.br + +.br +One function may be registered per timer. + +.br + +.br +The timer may be cancelled by passing NULL as the function. + +.br + +.br +\fBExample\fP +.br + +.EX +void bFunction(void) +.br +{ +.br + printf("two seconds have elapsed"); +.br +} +.br + +.br +// call bFunction every 2000 milliseconds +.br +gpioSetTimerFunc(0, 2000, bFunction); +.br + +.EE + +.IP "\fBint gpioSetTimerFuncEx(unsigned timer, unsigned millis, gpioTimerFuncEx_t f, void *userdata)\fP" +.IP "" 4 +Registers a function to be called (a callback) every millis milliseconds. + +.br + +.br + +.EX + timer: 0-9. +.br + millis: 10-60000 +.br + f: the function to call +.br +userdata: a pointer to arbitrary user data +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED. + +.br + +.br +The function is passed the userdata pointer. + +.br + +.br +Only one of \fBgpioSetTimerFunc\fP or \fBgpioSetTimerFuncEx\fP can be +registered per timer. + +.br + +.br +See \fBgpioSetTimerFunc\fP for further details. + +.IP "\fBpthread_t *gpioStartThread(gpioThreadFunc_t f, void *userdata)\fP" +.IP "" 4 +Starts a new thread of execution with f as the main routine. + +.br + +.br + +.EX + f: the main function for the new thread +.br +userdata: a pointer to arbitrary user data +.br + +.EE + +.br + +.br +Returns a pointer to pthread_t if OK, otherwise NULL. + +.br + +.br +The function is passed the single argument arg. + +.br + +.br +The thread can be cancelled by passing the pointer to pthread_t to +\fBgpioStopThread\fP. + +.br + +.br +\fBExample\fP +.br + +.EX +#include +.br +#include +.br + +.br +void *myfunc(void *arg) +.br +{ +.br + while (1) +.br + { +.br + printf("%s", arg); +.br + sleep(1); +.br + } +.br +} +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + pthread_t *p1, *p2, *p3; +.br + +.br + if (gpioInitialise() < 0) return 1; +.br + +.br + p1 = gpioStartThread(myfunc, "thread 1"); sleep(3); +.br + +.br + p2 = gpioStartThread(myfunc, "thread 2"); sleep(3); +.br + +.br + p3 = gpioStartThread(myfunc, "thread 3"); sleep(3); +.br + +.br + gpioStopThread(p3); sleep(3); +.br + +.br + gpioStopThread(p2); sleep(3); +.br + +.br + gpioStopThread(p1); sleep(3); +.br + +.br + gpioTerminate(); +.br +} +.br + +.EE + +.IP "\fBvoid gpioStopThread(pthread_t *pth)\fP" +.IP "" 4 +Cancels the thread pointed at by pth. + +.br + +.br + +.EX +pth: a thread pointer returned by \fBgpioStartThread\fP +.br + +.EE + +.br + +.br +No value is returned. + +.br + +.br +The thread to be stopped should have been started with \fBgpioStartThread\fP. + +.IP "\fBint gpioStoreScript(char *script)\fP" +.IP "" 4 +This function stores a null terminated script for later execution. + +.br + +.br +See \fBhttp://abyz.me.uk/rpi/pigpio/pigs.html#Scripts\fP for details. + +.br + +.br + +.EX +script: the text of the script +.br + +.EE + +.br + +.br +The function returns a script id if the script is valid, +otherwise PI_BAD_SCRIPT. + +.IP "\fBint gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param)\fP" +.IP "" 4 +This function runs a stored script. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBgpioStoreScript\fP +.br + numPar: 0-10, the number of parameters +.br + param: an array of parameters +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM. + +.br + +.br +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. + +.IP "\fBint gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param)\fP" +.IP "" 4 +This function runs a stored script. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBgpioStoreScript\fP +.br + numPar: 0-10, the number of parameters +.br + param: an array of parameters +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM. + +.br + +.br +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. + +.IP "\fBint gpioUpdateScript(unsigned script_id, unsigned numPar, uint32_t *param)\fP" +.IP "" 4 +This function sets the parameters of a script. The script may or +may not be running. The first numPar parameters of the script are +overwritten with the new values. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBgpioStoreScript\fP +.br + numPar: 0-10, the number of parameters +.br + param: an array of parameters +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM. + +.br + +.br +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. + +.IP "\fBint gpioScriptStatus(unsigned script_id, uint32_t *param)\fP" +.IP "" 4 +This function returns the run status of a stored script as well as +the current values of parameters 0 to 9. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBgpioStoreScript\fP +.br + param: an array to hold the returned 10 parameters +.br + +.EE + +.br + +.br +The function returns greater than or equal to 0 if OK, +otherwise PI_BAD_SCRIPT_ID. + +.br + +.br +The run status may be + +.br + +.br + +.EX +PI_SCRIPT_INITING +.br +PI_SCRIPT_HALTED +.br +PI_SCRIPT_RUNNING +.br +PI_SCRIPT_WAITING +.br +PI_SCRIPT_FAILED +.br + +.EE + +.br + +.br +The current value of script parameters 0 to 9 are returned in param. + +.IP "\fBint gpioStopScript(unsigned script_id)\fP" +.IP "" 4 +This function stops a running script. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBgpioStoreScript\fP +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. + +.IP "\fBint gpioDeleteScript(unsigned script_id)\fP" +.IP "" 4 +This function deletes a stored script. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBgpioStoreScript\fP +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. + +.IP "\fBint gpioSetSignalFunc(unsigned signum, gpioSignalFunc_t f)\fP" +.IP "" 4 +Registers a function to be called (a callback) when a signal occurs. + +.br + +.br + +.EX +signum: 0-63 +.br + f: the callback function +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_SIGNUM. + +.br + +.br +The function is passed the signal number. + +.br + +.br +One function may be registered per signal. + +.br + +.br +The callback may be cancelled by passing NULL. + +.br + +.br +By default all signals are treated as fatal and cause the library +to call gpioTerminate and then exit. + +.IP "\fBint gpioSetSignalFuncEx(unsigned signum, gpioSignalFuncEx_t f, void *userdata)\fP" +.IP "" 4 +Registers a function to be called (a callback) when a signal occurs. + +.br + +.br + +.EX + signum: 0-63 +.br + f: the callback function +.br +userdata: a pointer to arbitrary user data +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_SIGNUM. + +.br + +.br +The function is passed the signal number and the userdata pointer. + +.br + +.br +Only one of gpioSetSignalFunc or gpioSetSignalFuncEx can be +registered per signal. + +.br + +.br +See gpioSetSignalFunc for further details. + +.IP "\fBuint32_t gpioRead_Bits_0_31(void)\fP" +.IP "" 4 +Returns the current level of GPIO 0-31. + +.IP "\fBuint32_t gpioRead_Bits_32_53(void)\fP" +.IP "" 4 +Returns the current level of GPIO 32-53. + +.IP "\fBint gpioWrite_Bits_0_31_Clear(uint32_t bits)\fP" +.IP "" 4 +Clears GPIO 0-31 if the corresponding bit in bits is set. + +.br + +.br + +.EX +bits: a bit mask of GPIO to clear +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.br + +.br +\fBExample\fP +.br + +.EX +// To clear (set to 0) GPIO 4, 7, and 15 +.br +gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) ); +.br + +.EE + +.IP "\fBint gpioWrite_Bits_32_53_Clear(uint32_t bits)\fP" +.IP "" 4 +Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set. + +.br + +.br + +.EX +bits: a bit mask of GPIO to clear +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.IP "\fBint gpioWrite_Bits_0_31_Set(uint32_t bits)\fP" +.IP "" 4 +Sets GPIO 0-31 if the corresponding bit in bits is set. + +.br + +.br + +.EX +bits: a bit mask of GPIO to set +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.IP "\fBint gpioWrite_Bits_32_53_Set(uint32_t bits)\fP" +.IP "" 4 +Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set. + +.br + +.br + +.EX +bits: a bit mask of GPIO to set +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.br + +.br +\fBExample\fP +.br + +.EX +// To set (set to 1) GPIO 32, 40, and 53 +.br +gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32))); +.br + +.EE + +.IP "\fBint gpioHardwareClock(unsigned gpio, unsigned clkfreq)\fP" +.IP "" 4 +Starts a hardware clock on a GPIO at the specified frequency. +Frequencies above 30MHz are unlikely to work. + +.br + +.br + +.EX + gpio: see description +.br +clkfreq: 0 (off) or 4689-250M (13184-375M for the BCM2711) +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HCLK_GPIO, +PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS. + +.br + +.br +The same clock is available on multiple GPIO. The latest +frequency setting will be used by all GPIO which share a clock. + +.br + +.br +The GPIO must be one of the following. + +.br + +.br + +.EX +4 clock 0 All models +.br +5 clock 1 All models but A and B (reserved for system use) +.br +6 clock 2 All models but A and B +.br +20 clock 0 All models but A and B +.br +21 clock 1 All models but A and Rev.2 B (reserved for system use) +.br + +.br +32 clock 0 Compute module only +.br +34 clock 0 Compute module only +.br +42 clock 1 Compute module only (reserved for system use) +.br +43 clock 2 Compute module only +.br +44 clock 1 Compute module only (reserved for system use) +.br + +.EE + +.br + +.br +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. + +.IP "\fBint gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty)\fP" +.IP "" 4 +Starts hardware PWM on a GPIO at the specified frequency and dutycycle. +Frequencies above 30MHz are unlikely to work. + +.br + +.br +NOTE: Any waveform started by \fBgpioWaveTxSend\fP, or +\fBgpioWaveChain\fP will be cancelled. + +.br + +.br +This function is only valid if the pigpio main clock is PCM. The +main clock defaults to PCM but may be overridden by a call to +\fBgpioCfgClock\fP. + +.br + +.br + +.EX + gpio: see description +.br +PWMfreq: 0 (off) or 1-125M (1-187.5M for the BCM2711) +.br +PWMduty: 0 (off) to 1000000 (1M)(fully on) +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HPWM_GPIO, +PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, or PI_HPWM_ILLEGAL. + +.br + +.br +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. + +.br + +.br +The GPIO must be one of the following. + +.br + +.br + +.EX +12 PWM channel 0 All models but A and B +.br +13 PWM channel 1 All models but A and B +.br +18 PWM channel 0 All models +.br +19 PWM channel 1 All models but A and B +.br + +.br +40 PWM channel 0 Compute module only +.br +41 PWM channel 1 Compute module only +.br +45 PWM channel 1 Compute module only +.br +52 PWM channel 0 Compute module only +.br +53 PWM channel 1 Compute module only +.br + +.EE + +.br + +.br +The actual number of steps beween off and fully on is the +integral part of 250M/PWMfreq (375M/PWMfreq for the BCM2711). + +.br + +.br +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 (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. + +.IP "\fBint gpioTime(unsigned timetype, int *seconds, int *micros)\fP" +.IP "" 4 +Updates the seconds and micros variables with the current time. + +.br + +.br + +.EX +timetype: 0 (relative), 1 (absolute) +.br + seconds: a pointer to an int to hold seconds +.br + micros: a pointer to an int to hold microseconds +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_TIMETYPE. + +.br + +.br +If timetype is PI_TIME_ABSOLUTE updates seconds and micros with the +number of seconds and microseconds since the epoch (1st January 1970). + +.br + +.br +If timetype is PI_TIME_RELATIVE updates seconds and micros with the +number of seconds and microseconds since the library was initialised. + +.br + +.br +\fBExample\fP +.br + +.EX +int secs, mics; +.br + +.br +// print the number of seconds since the library was started +.br +gpioTime(PI_TIME_RELATIVE, &secs, &mics); +.br +printf("library started %d.%03d seconds ago", secs, mics/1000); +.br + +.EE + +.IP "\fBint gpioSleep(unsigned timetype, int seconds, int micros)\fP" +.IP "" 4 +Sleeps for the number of seconds and microseconds specified by seconds +and micros. + +.br + +.br + +.EX +timetype: 0 (relative), 1 (absolute) +.br + seconds: seconds to sleep +.br + micros: microseconds to sleep +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_TIMETYPE, PI_BAD_SECONDS, +or PI_BAD_MICROS. + +.br + +.br +If timetype is PI_TIME_ABSOLUTE the sleep ends when the number of seconds +and microseconds since the epoch (1st January 1970) has elapsed. System +clock changes are taken into account. + +.br + +.br +If timetype is PI_TIME_RELATIVE the sleep is for the specified number +of seconds and microseconds. System clock changes do not effect the +sleep length. + +.br + +.br +For short delays (say, 50 microseonds or less) use \fBgpioDelay\fP. + +.br + +.br +\fBExample\fP +.br + +.EX +gpioSleep(PI_TIME_RELATIVE, 2, 500000); // sleep for 2.5 seconds +.br + +.br +gpioSleep(PI_TIME_RELATIVE, 0, 100000); // sleep for 0.1 seconds +.br + +.br +gpioSleep(PI_TIME_RELATIVE, 60, 0); // sleep for one minute +.br + +.EE + +.IP "\fBuint32_t gpioDelay(uint32_t micros)\fP" +.IP "" 4 +Delays for at least the number of microseconds specified by micros. + +.br + +.br + +.EX +micros: the number of microseconds to sleep +.br + +.EE + +.br + +.br +Returns the actual length of the delay in microseconds. + +.br + +.br +Delays of 100 microseconds or less use busy waits. + +.IP "\fBuint32_t gpioTick(void)\fP" +.IP "" 4 +Returns the current system tick. + +.br + +.br +Tick is the number of microseconds since system boot. + +.br + +.br +As tick is an unsigned 32 bit quantity it wraps around after +2^32 microseconds, which is approximately 1 hour 12 minutes. + +.br + +.br +You don't need to worry about the wrap around as long as you +take a tick (uint32_t) from another tick, i.e. the following +code will always provide the correct difference. + +.br + +.br +\fBExample\fP +.br + +.EX +uint32_t startTick, endTick; +.br +int diffTick; +.br + +.br +startTick = gpioTick(); +.br + +.br +// do some processing +.br + +.br +endTick = gpioTick(); +.br + +.br +diffTick = endTick - startTick; +.br + +.br +printf("some processing took %d microseconds", diffTick); +.br + +.EE + +.IP "\fBunsigned gpioHardwareRevision(void)\fP" +.IP "" 4 +Returns the hardware revision. + +.br + +.br +If the hardware revision can not be found or is not a valid hexadecimal +number the function returns 0. + +.br + +.br +The hardware revision is the last few characters on the Revision line of +/proc/cpuinfo. + +.br + +.br +The revision number can be used to determine the assignment of GPIO +to pins (see \fBgpio\fP). + +.br + +.br +There are at least three types of board. + +.br + +.br +Type 1 boards have hardware revision numbers of 2 and 3. + +.br + +.br +Type 2 boards have hardware revision numbers of 4, 5, 6, and 15. + +.br + +.br +Type 3 boards have hardware revision numbers of 16 or greater. + +.br + +.br +for "Revision : 0002" the function returns 2. +.br +for "Revision : 000f" the function returns 15. +.br +for "Revision : 000g" the function returns 0. + +.IP "\fBunsigned gpioVersion(void)\fP" +.IP "" 4 +Returns the pigpio version. + +.IP "\fBint gpioGetPad(unsigned pad)\fP" +.IP "" 4 +This function returns the pad drive strength in mA. + +.br + +.br + +.EX +pad: 0-2, the pad to get +.br + +.EE + +.br + +.br +Returns the pad drive strength if OK, otherwise PI_BAD_PAD. + +.br + +.br +Pad GPIO +.br +0 0-27 +.br +1 28-45 +.br +2 46-53 +.br + +.br + +.br +\fBExample\fP +.br + +.EX +strength = gpioGetPad(1); // get pad 1 strength +.br + +.EE + +.IP "\fBint gpioSetPad(unsigned pad, unsigned padStrength)\fP" +.IP "" 4 +This function sets the pad drive strength in mA. + +.br + +.br + +.EX + pad: 0-2, the pad to set +.br +padStrength: 1-16 mA +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH. + +.br + +.br +Pad GPIO +.br +0 0-27 +.br +1 28-45 +.br +2 46-53 +.br + +.br + +.br +\fBExample\fP +.br + +.EX +gpioSetPad(0, 16); // set pad 0 strength to 16 mA +.br + +.EE + +.IP "\fBint eventMonitor(unsigned handle, uint32_t bits)\fP" +.IP "" 4 +This function selects the events to be reported on a previously +opened handle. + +.br + +.br + +.EX +handle: >=0, as returned by \fBgpioNotifyOpen\fP +.br + bits: a bit mask indicating the events of interest +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +A report is sent each time an event is triggered providing the +corresponding bit in bits is set. + +.br + +.br +See \fBgpioNotifyBegin\fP for the notification format. + +.br + +.br +\fBExample\fP +.br + +.EX +// Start reporting events 3, 6, and 7. +.br + +.br +// bit 76543210 +.br +// (0xC8 = 0b11001000) +.br + +.br +eventMonitor(h, 0xC8); +.br + +.EE + +.br + +.br + +.IP "\fBint eventSetFunc(unsigned event, eventFunc_t f)\fP" +.IP "" 4 +Registers a function to be called (a callback) when the specified +event occurs. + +.br + +.br + +.EX +event: 0-31 +.br + f: the callback function +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + +.br + +.br +One function may be registered per event. + +.br + +.br +The function is passed the event, and the tick. + +.br + +.br +The callback may be cancelled by passing NULL as the function. + +.IP "\fBint eventSetFuncEx(unsigned event, eventFuncEx_t f, void *userdata)\fP" +.IP "" 4 +Registers a function to be called (a callback) when the specified +event occurs. + +.br + +.br + +.EX + event: 0-31 +.br + f: the callback function +.br +userdata: pointer to arbitrary user data +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + +.br + +.br +One function may be registered per event. + +.br + +.br +The function is passed the event, the tick, and the ueserdata pointer. + +.br + +.br +The callback may be cancelled by passing NULL as the function. + +.br + +.br +Only one of \fBeventSetFunc\fP or \fBeventSetFuncEx\fP can be +registered per event. + +.IP "\fBint eventTrigger(unsigned event)\fP" +.IP "" 4 +This function signals the occurrence of an event. + +.br + +.br + +.EX +event: 0-31, the event +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + +.br + +.br +An event is a signal used to inform one or more consumers +to start an action. Each consumer which has registered an interest +in the event (e.g. by calling \fBeventSetFunc\fP) will be informed by +a callback. + +.br + +.br +One event, PI_EVENT_BSC (31) is predefined. This event is +auto generated on BSC slave activity. + +.br + +.br +The meaning of other events is arbitrary. + +.br + +.br +Note that other than its id and its tick there is no data associated +with an event. + +.IP "\fBint shell(char *scriptName, char *scriptString)\fP" +.IP "" 4 +This function uses the system call to execute a shell script +with the given string as its parameter. + +.br + +.br + +.EX + scriptName: the name of the script, only alphanumeric characters, +.br + '-' and '_' are allowed in the name +.br +scriptString: the string to pass to the script +.br + +.EE + +.br + +.br +The exit status of the system call is returned if OK, otherwise +PI_BAD_SHELL_STATUS. + +.br + +.br +scriptName must exist in /opt/pigpio/cgi and must be executable. + +.br + +.br +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. + +.br + +.br +The following table gives some example returned statuses. + +.br + +.br +Script exit status Returned system call status +.br +1 256 +.br +5 1280 +.br +10 2560 +.br +200 51200 +.br +script not found 32512 +.br + +.br + +.br +\fBExample\fP +.br + +.EX +// pass two parameters, hello and world +.br +status = shell("scr1", "hello world"); +.br + +.br +// pass three parameters, hello, string with spaces, and world +.br +status = shell("scr1", "hello 'string with spaces' world"); +.br + +.br +// pass one parameter, hello string with spaces world +.br +status = shell("scr1", "\"hello string with spaces world\""); +.br + +.EE + +.IP "\fBint fileOpen(char *file, unsigned mode)\fP" +.IP "" 4 +This function returns a handle to a file opened in a specified mode. + +.br + +.br + +.EX +file: the file to open +.br +mode: the file open mode +.br + +.EE + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS, +PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR. + +.br + +.br +File + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +Where more than one entry matches a file the most specific rule +applies. If no entry matches a file then access is denied. + +.br + +.br +Suppose /opt/pigpio/access contains the following entries + +.br + +.br + +.EX +/home/* n +.br +/home/pi/shared/dir_1/* w +.br +/home/pi/shared/dir_2/* r +.br +/home/pi/shared/dir_3/* u +.br +/home/pi/shared/dir_1/file.txt n +.br + +.EE + +.br + +.br +Files may be written in directory dir_1 with the exception +of file.txt. + +.br + +.br +Files may be read in directory dir_2. + +.br + +.br +Files may be read and written in directory dir_3. + +.br + +.br +If a directory allows read, write, or read/write access then files may +be created in that directory. + +.br + +.br +In an attempt to prevent risky permissions the following paths are +ignored in /opt/pigpio/access. + +.br + +.br + +.EX +a path containing .. +.br +a path containing only wildcards (*?) +.br +a path containing less than two non-wildcard parts +.br + +.EE + +.br + +.br +Mode + +.br + +.br +The mode may have the following values. + +.br + +.br +Macro Value Meaning +.br +PI_FILE_READ 1 open file for reading +.br +PI_FILE_WRITE 2 open file for writing +.br +PI_FILE_RW 3 open file for reading and writing +.br + +.br + +.br +The following values may be or'd into the mode. + +.br + +.br +Macro Value Meaning +.br +PI_FILE_APPEND 4 Writes append data to the end of the file +.br +PI_FILE_CREATE 8 The file is created if it doesn't exist +.br +PI_FILE_TRUNC 16 The file is truncated +.br + +.br + +.br +Newly created files are owned by root with permissions owner read and write. + +.br + +.br +\fBExample\fP +.br + +.EX +#include +.br +#include +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int handle, c; +.br + char buf[60000]; +.br + +.br + if (gpioInitialise() < 0) return 1; +.br + +.br + // assumes /opt/pigpio/access contains the following line +.br + // /ram/*.c r +.br + +.br + handle = fileOpen("/ram/pigpio.c", PI_FILE_READ); +.br + +.br + if (handle >= 0) +.br + { +.br + while ((c=fileRead(handle, buf, sizeof(buf)-1))) +.br + { +.br + buf[c] = 0; +.br + printf("%s", buf); +.br + } +.br + +.br + fileClose(handle); +.br + } +.br + +.br + gpioTerminate(); +.br +} +.br + +.EE + +.IP "\fBint fileClose(unsigned handle)\fP" +.IP "" 4 +This function closes the file associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBfileOpen\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +\fBExample\fP +.br + +.EX +fileClose(h); +.br + +.EE + +.IP "\fBint fileWrite(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function writes count bytes from buf to the the file +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBfileOpen\fP +.br + buf: the array of bytes to write +.br + count: the number of bytes to write +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, +PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE. + +.br + +.br +\fBExample\fP +.br + +.EX +status = fileWrite(h, buf, count); +.br +if (status == 0) +.br +{ +.br + // okay +.br +} +.br +else +.br +{ +.br + // error +.br +} +.br + +.EE + +.IP "\fBint fileRead(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function reads up to count bytes from the the file +associated with handle and writes them to buf. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBfileOpen\fP +.br + buf: an array to receive the read data +.br + count: the maximum number of bytes to read +.br + +.EE + +.br + +.br +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE. + +.br + +.br +\fBExample\fP +.br + +.EX +if (fileRead(h, buf, sizeof(buf)) > 0) +.br +{ +.br + // process read data +.br +} +.br + +.EE + +.IP "\fBint fileSeek(unsigned handle, int32_t seekOffset, int seekFrom)\fP" +.IP "" 4 +This function seeks to a position within the file associated +with handle. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBfileOpen\fP +.br +seekOffset: the number of bytes to move. Positive offsets +.br + move forward, negative offsets backwards. +.br + seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1), +.br + or PI_FROM_END (2) +.br + +.EE + +.br + +.br +Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK. + +.br + +.br +\fBExample\fP +.br + +.EX +fileSeek(0, 20, PI_FROM_START); // Seek to start plus 20 +.br + +.br +size = fileSeek(0, 0, PI_FROM_END); // Seek to end, return size +.br + +.br +pos = fileSeek(0, 0, PI_FROM_CURRENT); // Return current position +.br + +.EE + +.IP "\fBint fileList(char *fpat, char *buf, unsigned count)\fP" +.IP "" 4 +This function returns a list of files which match a pattern. The +pattern may contain wildcards. + +.br + +.br + +.EX + fpat: file pattern to match +.br + buf: an array to receive the matching file names +.br +count: the maximum number of bytes to read +.br + +.EE + +.br + +.br +Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS, +or PI_NO_FILE_MATCH. + +.br + +.br +The pattern must match an entry in /opt/pigpio/access. The pattern +may contain wildcards. See \fBfileOpen\fP. + +.br + +.br +NOTE + +.br + +.br +The returned value is not the number of files, it is the number +of bytes in the buffer. The file names are separated by newline +characters. + +.br + +.br +\fBExample\fP +.br + +.EX +#include +.br +#include +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int c; +.br + char buf[1000]; +.br + +.br + if (gpioInitialise() < 0) return 1; +.br + +.br + // assumes /opt/pigpio/access contains the following line +.br + // /ram/*.c r +.br + +.br + c = fileList("/ram/p*.c", buf, sizeof(buf)); +.br + +.br + if (c >= 0) +.br + { +.br + // terminate string +.br + buf[c] = 0; +.br + printf("%s", buf); +.br + } +.br + +.br + gpioTerminate(); +.br +} +.br + +.EE + +.IP "\fBint gpioCfgBufferSize(unsigned cfgMillis)\fP" +.IP "" 4 +Configures pigpio to buffer cfgMillis milliseconds of GPIO samples. + +.br + +.br +This function is only effective if called before \fBgpioInitialise\fP. + +.br + +.br + +.EX +cfgMillis: 100-10000 +.br + +.EE + +.br + +.br +The default setting is 120 milliseconds. + +.br + +.br +The intention is to allow for bursts of data and protection against +other processes hogging cpu time. + +.br + +.br +I haven't seen a process locked out for more than 100 milliseconds. + +.br + +.br +Making the buffer bigger uses a LOT of memory at the more frequent +sampling rates as shown in the following table in MBs. + +.br + +.br + +.EX + buffer milliseconds +.br + 120 250 500 1sec 2sec 4sec 8sec +.br + +.br + 1 16 31 55 107 --- --- --- +.br + 2 10 18 31 55 107 --- --- +.br +sample 4 8 12 18 31 55 107 --- +.br + rate 5 8 10 14 24 45 87 --- +.br + (us) 8 6 8 12 18 31 55 107 +.br + 10 6 8 10 14 24 45 87 +.br + +.EE + +.IP "\fBint gpioCfgClock(unsigned cfgMicros, unsigned cfgPeripheral, unsigned cfgSource)\fP" +.IP "" 4 +Configures pigpio to use a particular sample rate timed by a specified +peripheral. + +.br + +.br +This function is only effective if called before \fBgpioInitialise\fP. + +.br + +.br + +.EX + cfgMicros: 1, 2, 4, 5, 8, 10 +.br +cfgPeripheral: 0 (PWM), 1 (PCM) +.br + cfgSource: deprecated, value is ignored +.br + +.EE + +.br + +.br +The timings are provided by the specified peripheral (PWM or PCM). + +.br + +.br +The default setting is 5 microseconds using the PCM peripheral. + +.br + +.br +The approximate CPU percentage used for each sample rate is: + +.br + +.br + +.EX +sample cpu +.br + rate % +.br + +.br + 1 25 +.br + 2 16 +.br + 4 11 +.br + 5 10 +.br + 8 15 +.br + 10 14 +.br + +.EE + +.br + +.br +A sample rate of 5 microseconds seeems to be the sweet spot. + +.IP "\fBint gpioCfgDMAchannel(unsigned DMAchannel)\fP" +.IP "" 4 +Configures pigpio to use the specified DMA channel. + +.br + +.br +This function is only effective if called before \fBgpioInitialise\fP. + +.br + +.br + +.EX +DMAchannel: 0-14 +.br + +.EE + +.br + +.br +The default setting is to use channel 14. + +.IP "\fBint gpioCfgDMAchannels(unsigned primaryChannel, unsigned secondaryChannel)\fP" +.IP "" 4 +Configures pigpio to use the specified DMA channels. + +.br + +.br +This function is only effective if called before \fBgpioInitialise\fP. + +.br + +.br + +.EX + primaryChannel: 0-14 +.br +secondaryChannel: 0-14 +.br + +.EE + +.br + +.br +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 + +.br +The secondary channel is only used for the transmission of waves. + +.br + +.br +If possible use one of channels 0 to 6 for the secondary channel +(a full channel). + +.br + +.br +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. + +.IP "\fBint gpioCfgPermissions(uint64_t updateMask)\fP" +.IP "" 4 +Configures pigpio to restrict GPIO updates via the socket or pipe +interfaces to the GPIO specified by the mask. Programs directly +calling the pigpio library (i.e. linked with -lpigpio are not +affected). A GPIO update is a write to a GPIO or a GPIO mode +change or any function which would force such an action. + +.br + +.br +This function is only effective if called before \fBgpioInitialise\fP. + +.br + +.br + +.EX +updateMask: bit (1<=0 +.br +arg2: >=0 +.br +argx: extra (byte) arguments +.br +argc: number of extra arguments +.br + +.EE + +.br + +.br +Returns >= 0 if OK, less than 0 indicates a user defined error. + +.IP "\fBint gpioCustom2(unsigned arg1, char *argx, unsigned argc, char *retBuf, unsigned retMax)\fP" +.IP "" 4 +This function is available for user customisation. + +.br + +.br +It differs from gpioCustom1 in that it returns an array of bytes +rather than just an integer. + +.br + +.br +The returned value is an integer indicating the number of returned bytes. + +.EX + arg1: >=0 +.br + argx: extra (byte) arguments +.br + argc: number of extra arguments +.br +retBuf: buffer for returned bytes +.br +retMax: maximum number of bytes to return +.br + +.EE + +.br + +.br +Returns >= 0 if OK, less than 0 indicates a user defined error. + +.br + +.br +The number of returned bytes must be retMax or less. + +.IP "\fBint rawWaveAddSPI(rawSPI_t *spi, unsigned offset, unsigned spiSS, char *buf, unsigned spiTxBits, unsigned spiBitFirst, unsigned spiBitLast, unsigned spiBits)\fP" +.IP "" 4 +This function adds a waveform representing SPI data to the +existing waveform (if any). + +.br + +.br + +.EX + spi: a pointer to a spi object +.br + offset: microseconds from the start of the waveform +.br + spiSS: the slave select GPIO +.br + buf: the bits to transmit, most significant bit first +.br + spiTxBits: the number of bits to write +.br +spiBitFirst: the first bit to read +.br + spiBitLast: the last bit to read +.br + spiBits: the number of bits to transfer +.br + +.EE + +.br + +.br +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_BAD_USER_GPIO, PI_BAD_SER_OFFSET, or PI_TOO_MANY_PULSES. + +.br + +.br +Not intended for general use. + +.IP "\fBint rawWaveAddGeneric(unsigned numPulses, rawWave_t *pulses)\fP" +.IP "" 4 +This function adds a number of pulses to the current waveform. + +.br + +.br + +.EX +numPulses: the number of pulses +.br + pulses: the array containing the pulses +.br + +.EE + +.br + +.br +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_TOO_MANY_PULSES. + +.br + +.br +The advantage of this function over gpioWaveAddGeneric is that it +allows the setting of the flags field. + +.br + +.br +The pulses are interleaved in time order within the existing waveform +(if any). + +.br + +.br +Merging allows the waveform to be built in parts, that is the settings +for GPIO#1 can be added, and then GPIO#2 etc. + +.br + +.br +If the added waveform is intended to start after or within the existing +waveform then the first pulse should consist of a delay. + +.br + +.br +Not intended for general use. + +.IP "\fBunsigned rawWaveCB(void)\fP" +.IP "" 4 +Returns the number of the cb being currently output. + +.br + +.br +Not intended for general use. + +.IP "\fBrawCbs_t *rawWaveCBAdr(int cbNum)\fP" +.IP "" 4 +Return the (Linux) address of contol block cbNum. + +.br + +.br + +.EX +cbNum: the cb of interest +.br + +.EE + +.br + +.br +Not intended for general use. + +.IP "\fBuint32_t rawWaveGetOOL(int pos)\fP" +.IP "" 4 +Gets the OOL parameter stored at pos. + +.br + +.br + +.EX +pos: the position of interest. +.br + +.EE + +.br + +.br +Not intended for general use. + +.IP "\fBvoid rawWaveSetOOL(int pos, uint32_t lVal)\fP" +.IP "" 4 +Sets the OOL parameter stored at pos to value. + +.br + +.br + +.EX + pos: the position of interest +.br +lVal: the value to write +.br + +.EE + +.br + +.br +Not intended for general use. + +.IP "\fBuint32_t rawWaveGetOut(int pos)\fP" +.IP "" 4 +Gets the wave output parameter stored at pos. + +.br + +.br +DEPRECATED: use rawWaveGetOOL instead. + +.br + +.br + +.EX +pos: the position of interest. +.br + +.EE + +.br + +.br +Not intended for general use. + +.IP "\fBvoid rawWaveSetOut(int pos, uint32_t lVal)\fP" +.IP "" 4 +Sets the wave output parameter stored at pos to value. + +.br + +.br +DEPRECATED: use rawWaveSetOOL instead. + +.br + +.br + +.EX + pos: the position of interest +.br +lVal: the value to write +.br + +.EE + +.br + +.br +Not intended for general use. + +.IP "\fBuint32_t rawWaveGetIn(int pos)\fP" +.IP "" 4 +Gets the wave input value parameter stored at pos. + +.br + +.br +DEPRECATED: use rawWaveGetOOL instead. + +.br + +.br + +.EX +pos: the position of interest +.br + +.EE + +.br + +.br +Not intended for general use. + +.IP "\fBvoid rawWaveSetIn(int pos, uint32_t lVal)\fP" +.IP "" 4 +Sets the wave input value stored at pos to value. + +.br + +.br +DEPRECATED: use rawWaveSetOOL instead. + +.br + +.br + +.EX + pos: the position of interest +.br +lVal: the value to write +.br + +.EE + +.br + +.br +Not intended for general use. + +.IP "\fBrawWaveInfo_t rawWaveInfo(int wave_id)\fP" +.IP "" 4 +Gets details about the wave with id wave_id. + +.br + +.br + +.EX +wave_id: the wave of interest +.br + +.EE + +.br + +.br +Not intended for general use. + +.IP "\fBint getBitInBytes(int bitPos, char *buf, int numBits)\fP" +.IP "" 4 +Returns the value of the bit bitPos bits from the start of buf. Returns +0 if bitPos is greater than or equal to numBits. + +.br + +.br + +.EX + bitPos: bit index from the start of buf +.br + buf: array of bits +.br +numBits: number of valid bits in buf +.br + +.EE + +.br + +.br + +.IP "\fBvoid putBitInBytes(int bitPos, char *buf, int bit)\fP" +.IP "" 4 +Sets the bit bitPos bits from the start of buf to bit. + +.br + +.br + +.EX +bitPos: bit index from the start of buf +.br + buf: array of bits +.br + bit: 0-1, value to set +.br + +.EE + +.br + +.br + +.IP "\fBdouble time_time(void)\fP" +.IP "" 4 +Return the current time in seconds since the Epoch. + +.IP "\fBvoid time_sleep(double seconds)\fP" +.IP "" 4 +Delay execution for a given number of seconds + +.br + +.br + +.EX +seconds: the number of seconds to sleep +.br + +.EE + +.IP "\fBvoid rawDumpWave(void)\fP" +.IP "" 4 +Used to print a readable version of the current waveform to stderr. + +.br + +.br +Not intended for general use. + +.IP "\fBvoid rawDumpScript(unsigned script_id)\fP" +.IP "" 4 +Used to print a readable version of a script to stderr. + +.br + +.br + +.EX +script_id: >=0, a script_id returned by \fBgpioStoreScript\fP +.br + +.EE + +.br + +.br +Not intended for general use. +.SH PARAMETERS + +.br + +.br + +.IP "\fBactive\fP: 0-1000000" 0 + +.br + +.br +The number of microseconds level changes are reported for once +a noise filter has been triggered (by \fBsteady\fP microseconds of +a stable level). + +.br + +.br + +.IP "\fBarg1\fP" 0 + +.br + +.br +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +.br + +.br + +.IP "\fBarg2\fP" 0 + +.br + +.br +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +.br + +.br + +.IP "\fBargc\fP" 0 +The count of bytes passed to a user customised function. + +.br + +.br + +.IP "\fB*argx\fP" 0 +A pointer to an array of bytes passed to a user customised function. +Its meaning and content is defined by the customiser. + +.br + +.br + +.IP "\fBbaud\fP" 0 +The speed of serial communication (I2C, SPI, serial link, waves) in +bits per second. + +.br + +.br + +.IP "\fBbit\fP" 0 +A value of 0 or 1. + +.br + +.br + +.IP "\fBbitPos\fP" 0 +A bit position within a byte or word. The least significant bit is +position 0. + +.br + +.br + +.IP "\fBbits\fP" 0 +A value used to select GPIO. If bit n of bits is set then GPIO n is +selected. + +.br + +.br +A convenient way to set bit n is to or in (1<=0" 0 + +.br + +.br +The number of times a GPIO is swiched on and off per second. This +can be set per GPIO and may be as little as 5Hz or as much as +40KHz. The GPIO will be on for a proportion of the time as defined +by its dutycycle. + +.br + +.br + +.IP "\fBgpio\fP" 0 + +.br + +.br +A Broadcom numbered GPIO, in the range 0-53. + +.br + +.br +There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through +GPIO53. + +.br + +.br +They are split into two banks. Bank 1 consists of GPIO0 through +GPIO31. Bank 2 consists of GPIO32 through GPIO53. + +.br + +.br +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. + +.br + +.br +See \fBgpioHardwareRevision\fP. + +.br + +.br +The user GPIO are marked with an X in the following table. + +.br + +.br + +.EX + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +.br +Type 1 X X - - X - - X X X X X - - X X +.br +Type 2 - - X X X - - X X X X X - - X X +.br +Type 3 X X X X X X X X X X X X X X +.br + +.br + 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +.br +Type 1 - X X - - X X X X X - - - - - - +.br +Type 2 - X X - - - X X X X - X X X X X +.br +Type 3 X X X X X X X X X X X X - - - - +.br + +.EE + +.br + +.br + +.IP "\fBgpioAlertFunc_t\fP" 0 + +.EX +typedef void (*gpioAlertFunc_t) (int gpio, int level, uint32_t tick); +.br + +.EE + +.br + +.br + +.IP "\fBgpioAlertFuncEx_t\fP" 0 + +.EX +typedef void (*eventFuncEx_t) +.br + (int event, int level, uint32_t tick, void *userdata); +.br + +.EE + +.br + +.br + +.IP "\fBgpioCfg*\fP" 0 + +.br + +.br +These functions are only effective if called before \fBgpioInitialise\fP. + +.br + +.br +\fBgpioCfgBufferSize\fP +.br +\fBgpioCfgClock\fP +.br +\fBgpioCfgDMAchannel\fP +.br +\fBgpioCfgDMAchannels\fP +.br +\fBgpioCfgPermissions\fP +.br +\fBgpioCfgInterfaces\fP +.br +\fBgpioCfgSocketPort\fP +.br +\fBgpioCfgMemAlloc\fP + +.br + +.br + +.IP "\fBgpioGetSamplesFunc_t\fP" 0 + +.EX +typedef void (*gpioGetSamplesFunc_t) +.br + (const gpioSample_t *samples, int numSamples); +.br + +.EE + +.br + +.br + +.IP "\fBgpioGetSamplesFuncEx_t\fP" 0 + +.EX +typedef void (*gpioGetSamplesFuncEx_t) +.br + (const gpioSample_t *samples, int numSamples, void *userdata); +.br + +.EE + +.br + +.br + +.IP "\fBgpioISRFunc_t\fP" 0 + +.EX +typedef void (*gpioISRFunc_t) +.br + (int gpio, int level, uint32_t tick); +.br + +.EE + +.br + +.br + +.IP "\fBgpioISRFuncEx_t\fP" 0 + +.EX +typedef void (*gpioISRFuncEx_t) +.br + (int gpio, int level, uint32_t tick, void *userdata); +.br + +.EE + +.br + +.br + +.IP "\fBgpioPulse_t\fP" 0 + +.EX +typedef struct +.br +{ +.br + uint32_t gpioOn; +.br + uint32_t gpioOff; +.br + uint32_t usDelay; +.br +} gpioPulse_t; +.br + +.EE + +.br + +.br + +.IP "\fBgpioSample_t\fP" 0 + +.EX +typedef struct +.br +{ +.br + uint32_t tick; +.br + uint32_t level; +.br +} gpioSample_t; +.br + +.EE + +.br + +.br + +.IP "\fBgpioSignalFunc_t\fP" 0 + +.EX +typedef void (*gpioSignalFunc_t) (int signum); +.br + +.EE + +.br + +.br + +.IP "\fBgpioSignalFuncEx_t\fP" 0 + +.EX +typedef void (*gpioSignalFuncEx_t) (int signum, void *userdata); +.br + +.EE + +.br + +.br + +.IP "\fBgpioThreadFunc_t\fP" 0 + +.EX +typedef void *(gpioThreadFunc_t) (void *); +.br + +.EE + +.br + +.br + +.IP "\fBgpioTimerFunc_t\fP" 0 + +.EX +typedef void (*gpioTimerFunc_t) (void); +.br + +.EE + +.br + +.br + +.IP "\fBgpioTimerFuncEx_t\fP" 0 + +.EX +typedef void (*gpioTimerFuncEx_t) (void *userdata); +.br + +.EE + +.br + +.br + +.IP "\fBgpioWaveAdd*\fP" 0 + +.br + +.br +One of + +.br + +.br +\fBgpioWaveAddNew\fP +.br +\fBgpioWaveAddGeneric\fP +.br +\fBgpioWaveAddSerial\fP + +.br + +.br + +.IP "\fBhandle\fP: >=0" 0 + +.br + +.br +A number referencing an object opened by one of + +.br + +.br +\fBfileOpen\fP +.br +\fBgpioNotifyOpen\fP +.br +\fBi2cOpen\fP +.br +\fBserOpen\fP +.br +\fBspiOpen\fP + +.br + +.br + +.IP "\fBi2cAddr\fP: 0-0x7F" 0 +The address of a device on the I2C bus. + +.br + +.br + +.IP "\fBi2cBus\fP: >=0" 0 + +.br + +.br +An I2C bus number. + +.br + +.br + +.IP "\fBi2cFlags\fP: 0" 0 + +.br + +.br +Flags which modify an I2C open command. None are currently defined. + +.br + +.br + +.IP "\fBi2cReg\fP: 0-255" 0 + +.br + +.br +A register of an I2C device. + +.br + +.br + +.IP "\fBifFlags\fP: 0-3" 0 + +.EX +PI_DISABLE_FIFO_IF 1 +.br +PI_DISABLE_SOCK_IF 2 +.br + +.EE + +.br + +.br + +.IP "\fB*inBuf\fP" 0 +A buffer used to pass data to a function. + +.br + +.br + +.IP "\fBinLen\fP" 0 +The number of bytes of data in a buffer. + +.br + +.br + +.IP "\fBint\fP" 0 +A whole number, negative or positive. + +.br + +.br + +.IP "\fBint32_t\fP" 0 +A 32-bit signed value. + +.br + +.br + +.IP "\fBinvert\fP" 0 +A flag used to set normal or inverted bit bang serial data level logic. + +.br + +.br + +.IP "\fBlevel\fP" 0 +The level of a GPIO. Low or High. + +.br + +.br + +.EX +PI_OFF 0 +.br +PI_ON 1 +.br + +.br +PI_CLEAR 0 +.br +PI_SET 1 +.br + +.br +PI_LOW 0 +.br +PI_HIGH 1 +.br + +.EE + +.br + +.br +There is one exception. If a watchdog expires on a GPIO the level will be +reported as PI_TIMEOUT. See \fBgpioSetWatchdog\fP. + +.br + +.br + +.EX +PI_TIMEOUT 2 +.br + +.EE + +.br + +.br + +.br + +.br + +.IP "\fBlVal\fP: 0-4294967295 (Hex 0x0-0xFFFFFFFF, Octal 0-37777777777)" 0 + +.br + +.br +A 32-bit word value. + +.br + +.br + +.IP "\fBmemAllocMode\fP: 0-2" 0 + +.br + +.br +The DMA memory allocation mode. + +.br + +.br + +.EX +PI_MEM_ALLOC_AUTO 0 +.br +PI_MEM_ALLOC_PAGEMAP 1 +.br +PI_MEM_ALLOC_MAILBOX 2 +.br + +.EE + +.br + +.br + +.IP "\fB*micros\fP" 0 + +.br + +.br +A value representing microseconds. + +.br + +.br + +.IP "\fBmicros\fP" 0 + +.br + +.br +A value representing microseconds. + +.br + +.br + +.IP "\fBmillis\fP" 0 + +.br + +.br +A value representing milliseconds. + +.br + +.br + +.IP "\fBMISO\fP" 0 +The GPIO used for the MISO signal when bit banging SPI. + +.br + +.br + +.IP "\fBmode\fP" 0 + +.br + +.br +1. The operational mode of a GPIO, normally INPUT or OUTPUT. + +.br + +.br + +.EX +PI_INPUT 0 +.br +PI_OUTPUT 1 +.br +PI_ALT0 4 +.br +PI_ALT1 5 +.br +PI_ALT2 6 +.br +PI_ALT3 7 +.br +PI_ALT4 3 +.br +PI_ALT5 2 +.br + +.EE + +.br + +.br +2. A file open mode. + +.br + +.br + +.EX +PI_FILE_READ 1 +.br +PI_FILE_WRITE 2 +.br +PI_FILE_RW 3 +.br + +.EE + +.br + +.br +The following values can be or'd into the mode. + +.br + +.br + +.EX +PI_FILE_APPEND 4 +.br +PI_FILE_CREATE 8 +.br +PI_FILE_TRUNC 16 +.br + +.EE + +.br + +.br + +.IP "\fBMOSI\fP" 0 +The GPIO used for the MOSI signal when bit banging SPI. + +.br + +.br + +.IP "\fBnumBits\fP" 0 + +.br + +.br +The number of bits stored in a buffer. + +.br + +.br + +.IP "\fBnumBytes\fP" 0 +The number of bytes used to store characters in a string. Depending +on the number of bits per character there may be 1, 2, or 4 bytes +per character. + +.br + +.br + +.IP "\fBnumPar\fP: 0-10" 0 +The number of parameters passed to a script. + +.br + +.br + +.IP "\fBnumPulses\fP" 0 +The number of pulses to be added to a waveform. + +.br + +.br + +.IP "\fBnumSegs\fP" 0 +The number of segments in a combined I2C transaction. + +.br + +.br + +.IP "\fBnumSockAddr\fP" 0 +The number of network addresses allowed to use the socket interface. + +.br + +.br +0 means all addresses allowed. + +.br + +.br + +.IP "\fBoffset\fP" 0 +The associated data starts this number of microseconds from the start of +the waveform. + +.br + +.br + +.IP "\fB*outBuf\fP" 0 +A buffer used to return data from a function. + +.br + +.br + +.IP "\fBoutLen\fP" 0 +The size in bytes of an output buffer. + +.br + +.br + +.IP "\fBpad\fP: 0-2" 0 +A set of GPIO which share common drivers. + +.br + +.br +Pad GPIO +.br +0 0-27 +.br +1 28-45 +.br +2 46-53 +.br + +.br + +.br + +.IP "\fBpadStrength\fP: 1-16" 0 +The mA which may be drawn from each GPIO whilst still guaranteeing the +high and low levels. + +.br + +.br + +.IP "\fB*param\fP" 0 +An array of script parameters. + +.br + +.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 +typedef struct +.br +{ +.br + uint16_t addr; // slave address +.br + uint16_t flags; +.br + uint16_t len; // msg length +.br + uint8_t *buf; // pointer to msg data +.br +} pi_i2c_msg_t; +.br + +.EE + +.br + +.br + +.IP "\fBport\fP: 1024-32000" 0 +The port used to bind to the pigpio socket. Defaults to 8888. + +.br + +.br + +.IP "\fBpos\fP" 0 +The position of an item. + +.br + +.br + +.IP "\fBprimaryChannel\fP: 0-15" 0 +The DMA channel used to time the sampling of GPIO and to time servo and +PWM pulses. + +.br + +.br + +.IP "\fB*pth\fP" 0 + +.br + +.br +A thread identifier, returned by \fBgpioStartThread\fP. + +.br + +.br + +.IP "\fBpthread_t\fP" 0 + +.br + +.br +A thread identifier. + +.br + +.br + +.IP "\fBpud\fP: 0-2" 0 + +.br + +.br +The setting of the pull up/down resistor for a GPIO, which may be off, +pull-up, or pull-down. + +.br + +.br + +.EX +PI_PUD_OFF 0 +.br +PI_PUD_DOWN 1 +.br +PI_PUD_UP 2 +.br + +.EE + +.br + +.br + +.IP "\fBpulseLen\fP" 0 + +.br + +.br +1-100, the length of a trigger pulse in microseconds. + +.br + +.br + +.IP "\fB*pulses\fP" 0 + +.br + +.br +An array of pulses to be added to a waveform. + +.br + +.br + +.IP "\fBpulsewidth\fP: 0, 500-2500" 0 + +.EX +PI_SERVO_OFF 0 +.br +PI_MIN_SERVO_PULSEWIDTH 500 +.br +PI_MAX_SERVO_PULSEWIDTH 2500 +.br + +.EE + +.br + +.br + +.IP "\fBPWMduty\fP: 0-1000000 (1M)" 0 +The hardware PWM dutycycle. + +.br + +.br + +.EX +PI_HW_PWM_RANGE 1000000 +.br + +.EE + +.br + +.br + +.IP "\fBPWMfreq\fP: 1-125M (1-187.5M for the BCM2711)" 0 +The hardware PWM frequency. + +.br + +.br + +.EX +PI_HW_PWM_MIN_FREQ 1 +.br +PI_HW_PWM_MAX_FREQ 125000000 +.br +PI_HW_PWM_MAX_FREQ_2711 187500000 +.br + +.EE + +.br + +.br + +.IP "\fBrange\fP: 25-40000" 0 + +.EX +PI_MIN_DUTYCYCLE_RANGE 25 +.br +PI_MAX_DUTYCYCLE_RANGE 40000 +.br + +.EE + +.br + +.br + +.IP "\fBrawCbs_t\fP" 0 + +.EX +typedef struct // linux/arch/arm/mach-bcm2708/include/mach/dma.h +.br +{ +.br + unsigned long info; +.br + unsigned long src; +.br + unsigned long dst; +.br + unsigned long length; +.br + unsigned long stride; +.br + unsigned long next; +.br + unsigned long pad[2]; +.br +} rawCbs_t; +.br + +.EE + +.br + +.br + +.IP "\fBrawSPI_t\fP" 0 + +.EX +typedef struct +.br +{ +.br + int clk; // GPIO for clock +.br + int mosi; // GPIO for MOSI +.br + int miso; // GPIO for MISO +.br + int ss_pol; // slave select off state +.br + int ss_us; // delay after slave select +.br + int clk_pol; // clock off state +.br + int clk_pha; // clock phase +.br + int clk_us; // clock micros +.br +} rawSPI_t; +.br + +.EE + +.br + +.br + +.IP "\fBrawWave_t\fP" 0 + +.EX +typedef struct +.br +{ +.br + uint32_t gpioOn; +.br + uint32_t gpioOff; +.br + uint32_t usDelay; +.br + uint32_t flags; +.br +} rawWave_t; +.br + +.EE + +.br + +.br + +.IP "\fBrawWaveInfo_t\fP" 0 + +.EX +typedef struct +.br +{ +.br + uint16_t botCB; // first CB used by wave +.br + uint16_t topCB; // last CB used by wave +.br + uint16_t botOOL; // last OOL used by wave +.br + uint16_t topOOL; // first OOL used by wave +.br + uint16_t deleted; +.br + uint16_t numCB; +.br + uint16_t numBOOL; +.br + uint16_t numTOOL; +.br +} rawWaveInfo_t; +.br + +.EE + +.br + +.br + +.IP "\fB*retBuf\fP" 0 + +.br + +.br +A buffer to hold a number of bytes returned to a used customised function, + +.br + +.br + +.IP "\fBretMax\fP" 0 + +.br + +.br +The maximum number of bytes a user customised function should return. + +.br + +.br + +.IP "\fB*rxBuf\fP" 0 + +.br + +.br +A pointer to a buffer to receive data. + +.br + +.br + +.IP "\fBSCL\fP" 0 +The user GPIO to use for the clock when bit banging I2C. + +.br + +.br + +.IP "\fBSCLK\fP" 0 +The GPIO used for the SCLK signal when bit banging SPI. + +.br + +.br + +.IP "\fB*script\fP" 0 +A pointer to the text of a script. + +.br + +.br + +.IP "\fBscript_id\fP" 0 +An id of a stored script as returned by \fBgpioStoreScript\fP. + +.br + +.br + +.IP "\fB*scriptName\fP" 0 +The name of a \fBshell\fP script to be executed. The script must be present in +/opt/pigpio/cgi and must have execute permission. + +.br + +.br + +.IP "\fB*scriptString\fP" 0 +The string to be passed to a \fBshell\fP script to be executed. + +.br + +.br + +.IP "\fBSDA\fP" 0 +The user GPIO to use for data when bit banging I2C. + +.br + +.br + +.IP "\fBsecondaryChannel\fP: 0-6" 0 + +.br + +.br +The DMA channel used to time output waveforms. + +.br + +.br + +.IP "\fB*seconds\fP" 0 + +.br + +.br +A pointer to a uint32_t to store the second component of +a returned time. + +.br + +.br + +.IP "\fBseconds\fP" 0 +The number of seconds. + +.br + +.br + +.IP "\fBseekFrom\fP" 0 + +.br + +.br + +.EX +PI_FROM_START 0 +.br +PI_FROM_CURRENT 1 +.br +PI_FROM_END 2 +.br + +.EE + +.br + +.br + +.IP "\fBseekOffset\fP" 0 +The number of bytes to move forward (positive) or backwards (negative) +from the seek position (start, current, or end of file). + +.br + +.br + +.IP "\fB*segs\fP" 0 +An array of segments which make up a combined I2C transaction. + +.br + +.br + +.IP "\fBserFlags\fP" 0 +Flags which modify a serial open command. None are currently defined. + +.br + +.br + +.IP "\fB*sertty\fP" 0 +The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1. + +.br + +.br + +.IP "\fBsetting\fP" 0 +A value used to set a flag, 0 for false, non-zero for true. + +.br + +.br + +.IP "\fBsignum\fP: 0-63" 0 + +.EX +PI_MIN_SIGNUM 0 +.br +PI_MAX_SIGNUM 63 +.br + +.EE + +.br + +.br + +.IP "\fBsize_t\fP" 0 + +.br + +.br +A standard type used to indicate the size of an object in bytes. + +.br + +.br + +.IP "\fB*sockAddr\fP" 0 +An array of network addresses allowed to use the socket interface encoded +as 32 bit numbers. + +.br + +.br +E.g. address 192.168.1.66 would be encoded as 0x4201a8c0. + +.br + +.br + +.IP "\fB*spi\fP" 0 +A pointer to a \fBrawSPI_t\fP structure. + +.br + +.br + +.IP "\fBspiBitFirst\fP" 0 +GPIO reads are made from spiBitFirst to spiBitLast. + +.br + +.br + +.IP "\fBspiBitLast\fP" 0 + +.br + +.br +GPIO reads are made from spiBitFirst to spiBitLast. + +.br + +.br + +.IP "\fBspiBits\fP" 0 +The number of bits to transfer in a raw SPI transaction. + +.br + +.br + +.IP "\fBspiChan\fP" 0 +A SPI channel, 0-2. + +.br + +.br + +.IP "\fBspiFlags\fP" 0 +See \fBspiOpen\fP and \fBbbSPIOpen\fP. + +.br + +.br + +.IP "\fBspiSS\fP" 0 +The SPI slave select GPIO in a raw SPI transaction. + +.br + +.br + +.IP "\fBspiTxBits\fP" 0 +The number of bits to transfer dring a raw SPI transaction + +.br + +.br + +.IP "\fBsteady\fP: 0-300000" 0 + +.br + +.br +The number of microseconds level changes must be stable for +before reporting the level changed (\fBgpioGlitchFilter\fP) or triggering +the active part of a noise filter (\fBgpioNoiseFilter\fP). + +.br + +.br + +.IP "\fBstop_bits\fP: 2-8" 0 +The number of (half) stop bits to be used when adding serial data +to a waveform. + +.br + +.br + +.EX +PI_MIN_WAVE_HALFSTOPBITS 2 +.br +PI_MAX_WAVE_HALFSTOPBITS 8 +.br + +.EE + +.br + +.br + +.IP "\fB*str\fP" 0 +An array of characters. + +.br + +.br + +.IP "\fBtimeout\fP" 0 +A GPIO level change timeout in milliseconds. + +.br + +.br +\fBgpioSetWatchdog\fP + +.EX +PI_MIN_WDOG_TIMEOUT 0 +.br +PI_MAX_WDOG_TIMEOUT 60000 +.br + +.EE + +.br + +.br +\fBgpioSetISRFunc\fP and \fBgpioSetISRFuncEx\fP + +.EX +<=0 cancel timeout +.br +>0 timeout after specified milliseconds +.br + +.EE + +.br + +.br + +.IP "\fBtimer\fP" 0 + +.EX +PI_MIN_TIMER 0 +.br +PI_MAX_TIMER 9 +.br + +.EE + +.br + +.br + +.IP "\fBtimetype\fP" 0 + +.EX +PI_TIME_RELATIVE 0 +.br +PI_TIME_ABSOLUTE 1 +.br + +.EE + +.br + +.br + +.IP "\fB*txBuf\fP" 0 + +.br + +.br +An array of bytes to transmit. + +.br + +.br + +.IP "\fBuint32_t\fP: 0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)" 0 + +.br + +.br +A 32-bit unsigned value. + +.br + +.br + +.IP "\fBuint64_t\fP: 0-(2^64)-1" 0 + +.br + +.br +A 64-bit unsigned value. + +.br + +.br + +.IP "\fBunsigned\fP" 0 + +.br + +.br +A whole number >= 0. + +.br + +.br + +.IP "\fBupdateMask\fP" 0 + +.br + +.br +A 64 bit mask indicating which GPIO may be written to by the user. + +.br + +.br +If GPIO#n may be written then bit (1< 4 +.br +#define PI_BAD_CHANNEL -27 // DMA channel not 0-15 +.br +#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-15 +.br +#define PI_NOT_INITIALISED -31 // function called before gpioInitialise +.br +#define PI_INITIALISED -32 // function called after gpioInitialise +.br +#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3 +.br +#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call +.br +#define PI_BAD_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX) +.br +#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses +.br +#define PI_TOO_MANY_CHARS -37 // waveform has too many chars +.br +#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read on GPIO +.br +#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter +.br +#define PI_BAD_SERIAL_BUF -40 // bad (null) serial buf parameter +.br +#define PI_NOT_PERMITTED -41 // GPIO operation not permitted +.br +#define PI_SOME_PERMITTED -42 // one or more GPIO not permitted +.br +#define PI_BAD_WVSC_COMMND -43 // bad WVSC subcommand +.br +#define PI_BAD_WVSM_COMMND -44 // bad WVSM subcommand +.br +#define PI_BAD_WVSP_COMMND -45 // bad WVSP subcommand +.br +#define PI_BAD_PULSELEN -46 // trigger pulse length not 1-100 +.br +#define PI_BAD_SCRIPT -47 // invalid script +.br +#define PI_BAD_SCRIPT_ID -48 // unknown script id +.br +#define PI_BAD_SER_OFFSET -49 // add serial data offset > 30 minutes +.br +#define PI_GPIO_IN_USE -50 // GPIO already in use +.br +#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time +.br +#define PI_BAD_PARAM_NUM -52 // script parameter id not 0-9 +.br +#define PI_DUP_TAG -53 // script has duplicate tag +.br +#define PI_TOO_MANY_TAGS -54 // script has too many tags +.br +#define PI_BAD_SCRIPT_CMD -55 // illegal script command +.br +#define PI_BAD_VAR_NUM -56 // script variable id not 0-149 +.br +#define PI_NO_SCRIPT_ROOM -57 // no more room for scripts +.br +#define PI_NO_MEMORY -58 // can't allocate temporary memory +.br +#define PI_SOCK_READ_FAILED -59 // socket read failed +.br +#define PI_SOCK_WRIT_FAILED -60 // socket write failed +.br +#define PI_TOO_MANY_PARAM -61 // too many script parameters (> 10) +.br +#define PI_NOT_HALTED -62 // DEPRECATED +.br +#define PI_SCRIPT_NOT_READY -62 // script initialising +.br +#define PI_BAD_TAG -63 // script has unresolved tag +.br +#define PI_BAD_MICS_DELAY -64 // bad MICS delay (too large) +.br +#define PI_BAD_MILS_DELAY -65 // bad MILS delay (too large) +.br +#define PI_BAD_WAVE_ID -66 // non existent wave id +.br +#define PI_TOO_MANY_CBS -67 // No more CBs for waveform +.br +#define PI_TOO_MANY_OOL -68 // No more OOL for waveform +.br +#define PI_EMPTY_WAVEFORM -69 // attempt to create an empty waveform +.br +#define PI_NO_WAVEFORM_ID -70 // no more waveforms +.br +#define PI_I2C_OPEN_FAILED -71 // can't open I2C device +.br +#define PI_SER_OPEN_FAILED -72 // can't open serial device +.br +#define PI_SPI_OPEN_FAILED -73 // can't open SPI device +.br +#define PI_BAD_I2C_BUS -74 // bad I2C bus +.br +#define PI_BAD_I2C_ADDR -75 // bad I2C address +.br +#define PI_BAD_SPI_CHANNEL -76 // bad SPI channel +.br +#define PI_BAD_FLAGS -77 // bad i2c/spi/ser open flags +.br +#define PI_BAD_SPI_SPEED -78 // bad SPI speed +.br +#define PI_BAD_SER_DEVICE -79 // bad serial device name +.br +#define PI_BAD_SER_SPEED -80 // bad serial baud rate +.br +#define PI_BAD_PARAM -81 // bad i2c/spi/ser parameter +.br +#define PI_I2C_WRITE_FAILED -82 // i2c write failed +.br +#define PI_I2C_READ_FAILED -83 // i2c read failed +.br +#define PI_BAD_SPI_COUNT -84 // bad SPI count +.br +#define PI_SER_WRITE_FAILED -85 // ser write failed +.br +#define PI_SER_READ_FAILED -86 // ser read failed +.br +#define PI_SER_READ_NO_DATA -87 // ser read no data available +.br +#define PI_UNKNOWN_COMMAND -88 // unknown command +.br +#define PI_SPI_XFER_FAILED -89 // spi xfer/read/write failed +.br +#define PI_BAD_POINTER -90 // bad (NULL) pointer +.br +#define PI_NO_AUX_SPI -91 // no auxiliary SPI on Pi A or B +.br +#define PI_NOT_PWM_GPIO -92 // GPIO is not in use for PWM +.br +#define PI_NOT_SERVO_GPIO -93 // GPIO is not in use for servo pulses +.br +#define PI_NOT_HCLK_GPIO -94 // GPIO has no hardware clock +.br +#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM +.br +#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 // invalid hardware clock frequency +.br +#define PI_BAD_HCLK_PASS -99 // need password to use hardware clock 1 +.br +#define PI_HPWM_ILLEGAL -100 // illegal, PWM in use for main clock +.br +#define PI_BAD_DATABITS -101 // serial data bits not 1-32 +.br +#define PI_BAD_STOPBITS -102 // serial (half) stop bits not 2-8 +.br +#define PI_MSG_TOOBIG -103 // socket/pipe message too big +.br +#define PI_BAD_MALLOC_MODE -104 // bad memory allocation mode +.br +#define PI_TOO_MANY_SEGS -105 // too many I2C transaction segments +.br +#define PI_BAD_I2C_SEG -106 // an I2C transaction segment failed +.br +#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver +.br +#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO +.br +#define PI_BAD_I2C_WLEN -109 // bad I2C write length +.br +#define PI_BAD_I2C_RLEN -110 // bad I2C read length +.br +#define PI_BAD_I2C_CMD -111 // bad I2C command +.br +#define PI_BAD_I2C_BAUD -112 // bad I2C baud rate, not 50-500k +.br +#define PI_CHAIN_LOOP_CNT -113 // bad chain loop count +.br +#define PI_BAD_CHAIN_LOOP -114 // empty chain loop +.br +#define PI_CHAIN_COUNTER -115 // too many chain counters +.br +#define PI_BAD_CHAIN_CMD -116 // bad chain command +.br +#define PI_BAD_CHAIN_DELAY -117 // bad chain delay micros +.br +#define PI_CHAIN_NESTING -118 // chain counters nested too deeply +.br +#define PI_CHAIN_TOO_BIG -119 // chain is too long +.br +#define PI_DEPRECATED -120 // deprecated function removed +.br +#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1 +.br +#define PI_BAD_EDGE -122 // bad ISR edge value, not 0-2 +.br +#define PI_BAD_ISR_INIT -123 // bad ISR initialisation +.br +#define PI_BAD_FOREVER -124 // loop forever must be last command +.br +#define PI_BAD_FILTER -125 // bad filter parameter +.br +#define PI_BAD_PAD -126 // bad pad number +.br +#define PI_BAD_STRENGTH -127 // bad pad drive strength +.br +#define PI_FIL_OPEN_FAILED -128 // file open failed +.br +#define PI_BAD_FILE_MODE -129 // bad file mode +.br +#define PI_BAD_FILE_FLAG -130 // bad file flag +.br +#define PI_BAD_FILE_READ -131 // bad file read +.br +#define PI_BAD_FILE_WRITE -132 // bad file write +.br +#define PI_FILE_NOT_ROPEN -133 // file not open for read +.br +#define PI_FILE_NOT_WOPEN -134 // file not open for write +.br +#define PI_BAD_FILE_SEEK -135 // bad file seek +.br +#define PI_NO_FILE_MATCH -136 // no files match pattern +.br +#define PI_NO_FILE_ACCESS -137 // no permission to access file +.br +#define PI_FILE_IS_A_DIR -138 // file is a directory +.br +#define PI_BAD_SHELL_STATUS -139 // bad shell return status +.br +#define PI_BAD_SCRIPT_NAME -140 // bad script name +.br +#define PI_BAD_SPI_BAUD -141 // bad SPI baud rate, not 50-500k +.br +#define PI_NOT_SPI_GPIO -142 // no bit bang SPI in progress on GPIO +.br +#define PI_BAD_EVENT_ID -143 // bad event id +.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 +.br +#define PI_PIGIF_ERR_99 -2099 +.br + +.br +#define PI_CUSTOM_ERR_0 -3000 +.br +#define PI_CUSTOM_ERR_999 -3999 +.br + +.br + +.EE +.SH Defaults + +.EX + +.br +#define PI_DEFAULT_BUFFER_MILLIS 120 +.br +#define PI_DEFAULT_CLK_MICROS 5 +.br +#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM +.br +#define PI_DEFAULT_IF_FLAGS 0 +.br +#define PI_DEFAULT_FOREGROUND 0 +.br +#define PI_DEFAULT_DMA_CHANNEL 14 +.br +#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14 +.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 "localhost" +.br +#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0x0000000FFFFFFCLL +.br +#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93 +.br +#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C +.br +#define PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS 0x0080480FFFFFFCLL +.br +#define PI_DEFAULT_UPDATE_MASK_ZERO 0x0080000FFFFFFCLL +.br +#define PI_DEFAULT_UPDATE_MASK_PI2B 0x0080480FFFFFFCLL +.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 +.br + +.br +#define PI_DEFAULT_CFG_INTERNALS 0 +.br + +.br + +.EE + +.SH SEE ALSO + +pigpiod(1), pig2vcd(1), pigs(1), pigpiod_if(3), pigpiod_if2(3) +.SH AUTHOR + +joan@abyz.me.uk diff --git a/pigpio.c b/pigpio.c new file mode 100644 index 0000000..92b9bf7 --- /dev/null +++ b/pigpio.c @@ -0,0 +1,14018 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +/* pigpio version 78 */ + +/* include ------------------------------------------------------- */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pigpio.h" + +#include "command.h" + + +/* --------------------------------------------------------------- */ + +/* + 0 GPFSEL0 GPIO Function Select 0 + 1 GPFSEL1 GPIO Function Select 1 + 2 GPFSEL2 GPIO Function Select 2 + 3 GPFSEL3 GPIO Function Select 3 + 4 GPFSEL4 GPIO Function Select 4 + 5 GPFSEL5 GPIO Function Select 5 + 6 - Reserved + 7 GPSET0 GPIO Pin Output Set 0 + 8 GPSET1 GPIO Pin Output Set 1 + 9 - Reserved +10 GPCLR0 GPIO Pin Output Clear 0 +11 GPCLR1 GPIO Pin Output Clear 1 +12 - Reserved +13 GPLEV0 GPIO Pin Level 0 +14 GPLEV1 GPIO Pin Level 1 +15 - Reserved +16 GPEDS0 GPIO Pin Event Detect Status 0 +17 GPEDS1 GPIO Pin Event Detect Status 1 +18 - Reserved +19 GPREN0 GPIO Pin Rising Edge Detect Enable 0 +20 GPREN1 GPIO Pin Rising Edge Detect Enable 1 +21 - Reserved +22 GPFEN0 GPIO Pin Falling Edge Detect Enable 0 +23 GPFEN1 GPIO Pin Falling Edge Detect Enable 1 +24 - Reserved +25 GPHEN0 GPIO Pin High Detect Enable 0 +26 GPHEN1 GPIO Pin High Detect Enable 1 +27 - Reserved +28 GPLEN0 GPIO Pin Low Detect Enable 0 +29 GPLEN1 GPIO Pin Low Detect Enable 1 +30 - Reserved +31 GPAREN0 GPIO Pin Async. Rising Edge Detect 0 +32 GPAREN1 GPIO Pin Async. Rising Edge Detect 1 +33 - Reserved +34 GPAFEN0 GPIO Pin Async. Falling Edge Detect 0 +35 GPAFEN1 GPIO Pin Async. Falling Edge Detect 1 +36 - Reserved +37 GPPUD GPIO Pin Pull-up/down Enable +38 GPPUDCLK0 GPIO Pin Pull-up/down Enable Clock 0 +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 +*/ + +/* +0 CS DMA Channel 0 Control and Status +1 CPI_ONBLK_AD DMA Channel 0 Control Block Address +2 TI DMA Channel 0 CB Word 0 (Transfer Information) +3 SOURCE_AD DMA Channel 0 CB Word 1 (Source Address) +4 DEST_AD DMA Channel 0 CB Word 2 (Destination Address) +5 TXFR_LEN DMA Channel 0 CB Word 3 (Transfer Length) +6 STRIDE DMA Channel 0 CB Word 4 (2D Stride) +7 NEXTCPI_ONBK DMA Channel 0 CB Word 5 (Next CB Address) +8 DEBUG DMA Channel 0 Debug +*/ + +/* +DEBUG register bits + +bit 2 READ_ERROR + + Slave Read Response Error RW 0x0 + + Set if the read operation returned an error value on + the read response bus. It can be cleared by writing + a 1. + +bit 1 FIFO_ERROR + + Fifo Error RW 0x0 + + Set if the optional read Fifo records an error + condition. It can be cleared by writing a 1. + +bit 0 READ_LAST_NOT_SET_ERROR + + Read Last Not Set Error RW 0x0 + + If the AXI read last signal was not set when + expected, then this error bit will be set. It can be + cleared by writing a 1. +*/ + +/* +0 CTL PWM Control +1 STA PWM Status +2 DMAC PWM DMA Configuration +4 RNG1 PWM Channel 1 Range +5 DAT1 PWM Channel 1 Data +6 FIF1 PWM FIFO Input +8 RNG2 PWM Channel 2 Range +9 DAT2 PWM Channel 2 Data +*/ + +/* +0 PCM_CS PCM Control and Status +1 PCM_FIFO PCM FIFO Data +2 PCM_MODE PCM Mode +3 PCM_RXC PCM Receive Configuration +4 PCM_TXC PCM Transmit Configuration +5 PCM_DREQ PCM DMA Request Level +6 PCM_INTEN PCM Interrupt Enables +7 PCM_INTSTC PCM Interrupt Status & Clear +8 PCM_GRAY PCM Gray Mode Control +*/ + +/* +0 CS System Timer Control/Status +1 CLO System Timer Counter Lower 32 bits +2 CHI System Timer Counter Higher 32 bits +3 C0 System Timer Compare 0 +4 C1 System Timer Compare 1 +5 C2 System Timer Compare 2 +6 C3 System Timer Compare 3 +*/ + +/* define -------------------------------------------------------- */ + +#define THOUSAND 1000 +#define MILLION 1000000 +#define BILLION 1000000000 + +#define BANK (gpio>>5) + +#define BIT (1<<(gpio&0x1F)) + +#ifndef EMBEDDED_IN_VM +#define DBG(level, format, arg...) DO_DBG(level, format, ## arg) +#else +#define DBG(level, format, arg...) +#endif + +#define DO_DBG(level, format, arg...) \ + { \ + if ((gpioCfg.dbgLevel >= level) && \ + (!(gpioCfg.internals & PI_CFG_NOSIGHANDLER))) \ + fprintf(stderr, "%s %s: " format "\n" , \ + myTimeStamp(), __FUNCTION__ , ## arg); \ + } + +#ifndef DISABLE_SER_CHECK_INITED +#define SER_CHECK_INITED CHECK_INITED +#else +#define SER_CHECK_INITED +#endif + +#define CHECK_INITED \ + do \ + { \ + if (!libInitialised) \ + { \ + DBG(DBG_ALWAYS, \ + "pigpio uninitialised, call gpioInitialise()"); \ + return PI_NOT_INITIALISED; \ + } \ + } \ + while (0) + +#define CHECK_INITED_RET_NULL_PTR \ + do \ + { \ + if (!libInitialised) \ + { \ + DBG(DBG_ALWAYS, \ + "pigpio uninitialised, call gpioInitialise()"); \ + return (NULL); \ + } \ + } \ + while (0) + +#define CHECK_INITED_RET_NIL \ + do \ + { \ + if (!libInitialised) \ + { \ + DBG(DBG_ALWAYS, \ + "pigpio uninitialised, call gpioInitialise()"); \ + } \ + } \ + while (0) + +#define CHECK_NOT_INITED \ + do \ + { \ + if (libInitialised) \ + { \ + DBG(DBG_ALWAYS, \ + "pigpio initialised, call gpioTerminate()"); \ + return PI_INITIALISED; \ + } \ + } \ + while (0) + +#define SOFT_ERROR(x, format, arg...) \ + do \ + { \ + DBG(DBG_ALWAYS, format, ## arg); \ + return x; \ + } \ + while (0) + +#define TIMER_ADD(a, b, result) \ + do \ + { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_nsec = (a)->tv_nsec + (b)->tv_nsec; \ + if ((result)->tv_nsec >= BILLION) \ + { \ + ++(result)->tv_sec; \ + (result)->tv_nsec -= BILLION; \ + } \ + } \ + while (0) + +#define TIMER_SUB(a, b, result) \ + do \ + { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \ + if ((result)->tv_nsec < 0) \ + { \ + --(result)->tv_sec; \ + (result)->tv_nsec += BILLION; \ + } \ + } \ + while (0) + +#define PI_PERI_BUS 0x7E000000 + +#define AUX_BASE (pi_peri_phys + 0x00215000) +#define BSCS_BASE (pi_peri_phys + 0x00214000) +#define CLK_BASE (pi_peri_phys + 0x00101000) +#define DMA_BASE (pi_peri_phys + 0x00007000) +#define DMA15_BASE (pi_peri_phys + 0x00E05000) +#define GPIO_BASE (pi_peri_phys + 0x00200000) +#define PADS_BASE (pi_peri_phys + 0x00100000) +#define PCM_BASE (pi_peri_phys + 0x00203000) +#define PWM_BASE (pi_peri_phys + 0x0020C000) +#define SPI_BASE (pi_peri_phys + 0x00204000) +#define SYST_BASE (pi_peri_phys + 0x00003000) + +#define AUX_LEN 0xD8 +#define BSCS_LEN 0x40 +#define CLK_LEN 0xA8 +#define DMA_LEN 0x1000 /* allow access to all channels */ +#define GPIO_LEN 0xF4 /* 2711 has more registers */ +#define PADS_LEN 0x38 +#define PCM_LEN 0x24 +#define PWM_LEN 0x28 +#define SPI_LEN 0x18 +#define SYST_LEN 0x1C + +#define DMA_ENABLE (0xFF0/4) + +#define GPFSEL0 0 + +#define GPSET0 7 +#define GPSET1 8 + +#define GPCLR0 10 +#define GPCLR1 11 + +#define GPLEV0 13 +#define GPLEV1 14 + +#define GPEDS0 16 +#define GPEDS1 17 + +#define GPREN0 19 +#define GPREN1 20 +#define GPFEN0 22 +#define GPFEN1 23 +#define GPHEN0 25 +#define GPHEN1 26 +#define GPLEN0 28 +#define GPLEN1 29 +#define GPAREN0 31 +#define GPAREN1 32 +#define GPAFEN0 34 +#define GPAFEN1 35 + +#define GPPUD 37 +#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_ACTIVE (1<< 0) + +/* DMA control block "info" field bits */ +#define DMA_NO_WIDE_BURSTS (1<<26) +#define DMA_PERIPHERAL_MAPPING(x) ((x)<<16) +#define DMA_BURST_LENGTH(x) ((x)<<12) +#define DMA_SRC_IGNORE (1<<11) +#define DMA_SRC_DREQ (1<<10) +#define DMA_SRC_WIDTH (1<< 9) +#define DMA_SRC_INC (1<< 8) +#define DMA_DEST_IGNORE (1<< 7) +#define DMA_DEST_DREQ (1<< 6) +#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) +#define DMA_DEBUG_RD_LST_NOT_SET_ERR (1<<0) + +#define DMA_LITE_FIRST 7 +#define DMA_LITE_MAX 0xfffc + +#define PWM_CTL 0 +#define PWM_STA 1 +#define PWM_DMAC 2 +#define PWM_RNG1 4 +#define PWM_DAT1 5 +#define PWM_FIFO 6 +#define PWM_RNG2 8 +#define PWM_DAT2 9 + +#define PWM_CTL_MSEN2 (1<<15) +#define PWM_CTL_PWEN2 (1<<8) +#define PWM_CTL_MSEN1 (1<<7) +#define PWM_CTL_CLRF1 (1<<6) +#define PWM_CTL_USEF1 (1<<5) +#define PWM_CTL_MODE1 (1<<1) +#define PWM_CTL_PWEN1 (1<<0) + +#define PWM_DMAC_ENAB (1 <<31) +#define PWM_DMAC_PANIC(x) ((x)<< 8) +#define PWM_DMAC_DREQ(x) (x) + +#define PCM_CS 0 +#define PCM_FIFO 1 +#define PCM_MODE 2 +#define PCM_RXC 3 +#define PCM_TXC 4 +#define PCM_DREQ 5 +#define PCM_INTEN 6 +#define PCM_INTSTC 7 +#define PCM_GRAY 8 + +#define PCM_CS_STBY (1 <<25) +#define PCM_CS_SYNC (1 <<24) +#define PCM_CS_RXSEX (1 <<23) +#define PCM_CS_RXERR (1 <<16) +#define PCM_CS_TXERR (1 <<15) +#define PCM_CS_DMAEN (1 <<9) +#define PCM_CS_RXTHR(x) ((x)<<7) +#define PCM_CS_TXTHR(x) ((x)<<5) +#define PCM_CS_RXCLR (1 <<4) +#define PCM_CS_TXCLR (1 <<3) +#define PCM_CS_TXON (1 <<2) +#define PCM_CS_RXON (1 <<1) +#define PCM_CS_EN (1 <<0) + +#define PCM_MODE_CLK_DIS (1 <<28) +#define PCM_MODE_PDMN (1 <<27) +#define PCM_MODE_PDME (1 <<26) +#define PCM_MODE_FRXP (1 <<25) +#define PCM_MODE_FTXP (1 <<24) +#define PCM_MODE_CLKM (1 <<23) +#define PCM_MODE_CLKI (1 <<22) +#define PCM_MODE_FSM (1 <<21) +#define PCM_MODE_FSI (1 <<20) +#define PCM_MODE_FLEN(x) ((x)<<10) +#define PCM_MODE_FSLEN(x) ((x)<< 0) + +#define PCM_RXC_CH1WEX (1 <<31) +#define PCM_RXC_CH1EN (1 <<30) +#define PCM_RXC_CH1POS(x) ((x)<<20) +#define PCM_RXC_CH1WID(x) ((x)<<16) +#define PCM_RXC_CH2WEX (1 <<15) +#define PCM_RXC_CH2EN (1 <<14) +#define PCM_RXC_CH2POS(x) ((x)<< 4) +#define PCM_RXC_CH2WID(x) ((x)<< 0) + +#define PCM_TXC_CH1WEX (1 <<31) +#define PCM_TXC_CH1EN (1 <<30) +#define PCM_TXC_CH1POS(x) ((x)<<20) +#define PCM_TXC_CH1WID(x) ((x)<<16) +#define PCM_TXC_CH2WEX (1 <<15) +#define PCM_TXC_CH2EN (1 <<14) +#define PCM_TXC_CH2POS(x) ((x)<< 4) +#define PCM_TXC_CH2WID(x) ((x)<< 0) + +#define PCM_DREQ_TX_PANIC(x) ((x)<<24) +#define PCM_DREQ_RX_PANIC(x) ((x)<<16) +#define PCM_DREQ_TX_REQ_L(x) ((x)<< 8) +#define PCM_DREQ_RX_REQ_L(x) ((x)<< 0) + +#define PCM_INTEN_RXERR (1<<3) +#define PCM_INTEN_TXERR (1<<2) +#define PCM_INTEN_RXR (1<<1) +#define PCM_INTEN_TXW (1<<0) + +#define PCM_INTSTC_RXERR (1<<3) +#define PCM_INTSTC_TXERR (1<<2) +#define PCM_INTSTC_RXR (1<<1) +#define PCM_INTSTC_TXW (1<<0) + +#define PCM_GRAY_FLUSH (1<<2) +#define PCM_GRAY_CLR (1<<1) +#define PCM_GRAY_EN (1<<0) + +#define BCM_PASSWD (0x5A<<24) + +#define CLK_CTL_MASH(x)((x)<<9) +#define CLK_CTL_BUSY (1 <<7) +#define CLK_CTL_KILL (1 <<5) +#define CLK_CTL_ENAB (1 <<4) +#define CLK_CTL_SRC(x) ((x)<<0) + +#define CLK_SRCS 2 + +#define CLK_CTL_SRC_OSC 1 +#define CLK_CTL_SRC_PLLD 6 + +#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) + +#define CLK_GP0_CTL 28 +#define CLK_GP0_DIV 29 +#define CLK_GP1_CTL 30 +#define CLK_GP1_DIV 31 +#define CLK_GP2_CTL 32 +#define CLK_GP2_DIV 33 + +#define CLK_PCMCTL 38 +#define CLK_PCMDIV 39 + +#define CLK_PWMCTL 40 +#define CLK_PWMDIV 41 + +#define SYST_CS 0 +#define SYST_CLO 1 +#define SYST_CHI 2 + +/* SPI */ + +#define SPI_CS 0 +#define SPI_FIFO 1 +#define SPI_CLK 2 +#define SPI_DLEN 3 +#define SPI_LTOH 4 +#define SPI_DC 5 + +#define SPI_CS_LEN_LONG (1<<25) +#define SPI_CS_DMA_LEN (1<<24) +#define SPI_CS_CSPOLS(x) ((x)<<21) +#define SPI_CS_RXF (1<<20) +#define SPI_CS_RXR (1<<19) +#define SPI_CS_TXD (1<<18) +#define SPI_CS_RXD (1<<17) +#define SPI_CS_DONE (1<<16) +#define SPI_CS_LEN (1<<13) +#define SPI_CS_REN (1<<12) +#define SPI_CS_ADCS (1<<11) +#define SPI_CS_INTR (1<<10) +#define SPI_CS_INTD (1<<9) +#define SPI_CS_DMAEN (1<<8) +#define SPI_CS_TA (1<<7) +#define SPI_CS_CSPOL(x) ((x)<<6) +#define SPI_CS_CLEAR(x) ((x)<<4) +#define SPI_CS_MODE(x) ((x)<<2) +#define SPI_CS_CS(x) ((x)<<0) + +#define SPI_DC_RPANIC(x) ((x)<<24) +#define SPI_DC_RDREQ(x) ((x)<<16) +#define SPI_DC_TPANIC(x) ((x)<<8) +#define SPI_DC_TDREQ(x) ((x)<<0) + +#define SPI_MODE0 0 +#define SPI_MODE1 1 +#define SPI_MODE2 2 +#define SPI_MODE3 3 + +#define SPI_CS0 0 +#define SPI_CS1 1 +#define SPI_CS2 2 + +/* standard SPI gpios (ALT0) */ + +#define PI_SPI_CE0 8 +#define PI_SPI_CE1 7 +#define PI_SPI_SCLK 11 +#define PI_SPI_MISO 9 +#define PI_SPI_MOSI 10 + +/* auxiliary SPI gpios (ALT4) */ + +#define PI_ASPI_CE0 18 +#define PI_ASPI_CE1 17 +#define PI_ASPI_CE2 16 +#define PI_ASPI_MISO 19 +#define PI_ASPI_MOSI 20 +#define PI_ASPI_SCLK 21 + +/* AUX */ + +#define AUX_IRQ 0 +#define AUX_ENABLES 1 + +#define AUX_MU_IO_REG 16 +#define AUX_MU_IER_REG 17 +#define AUX_MU_IIR_REG 18 +#define AUX_MU_LCR_REG 19 +#define AUX_MU_MCR_REG 20 +#define AUX_MU_LSR_REG 21 +#define AUX_MU_MSR_REG 22 +#define AUX_MU_SCRATCH 23 +#define AUX_MU_CNTL_REG 24 +#define AUX_MU_STAT_REG 25 +#define AUX_MU_BAUD_REG 26 + +#define AUX_SPI0_CNTL0_REG 32 +#define AUX_SPI0_CNTL1_REG 33 +#define AUX_SPI0_STAT_REG 34 +#define AUX_SPI0_PEEK_REG 35 + +#define AUX_SPI0_IO_REG 40 +#define AUX_SPI0_TX_HOLD 44 + +#define AUX_SPI1_CNTL0_REG 48 +#define AUX_SPI1_CNTL1_REG 49 +#define AUX_SPI1_STAT_REG 50 +#define AUX_SPI1_PEEK_REG 51 + +#define AUX_SPI1_IO_REG 56 +#define AUX_SPI1_TX_HOLD 60 + +#define AUXENB_SPI2 (1<<2) +#define AUXENB_SPI1 (1<<1) +#define AUXENB_UART (1<<0) + +#define AUXSPI_CNTL0_SPEED(x) ((x)<<20) +#define AUXSPI_CNTL0_CS(x) ((x)<<17) +#define AUXSPI_CNTL0_POSTINP (1<<16) +#define AUXSPI_CNTL0_VAR_CS (1<<15) +#define AUXSPI_CNTL0_VAR_WIDTH (1<<14) +#define AUXSPI_CNTL0_DOUT_HOLD(x) ((x)<<12) +#define AUXSPI_CNTL0_ENABLE (1<<11) +#define AUXSPI_CNTL0_IN_RISING(x) ((x)<<10) +#define AUXSPI_CNTL0_CLR_FIFOS (1<<9) +#define AUXSPI_CNTL0_OUT_RISING(x) ((x)<<8) +#define AUXSPI_CNTL0_INVERT_CLK(x) ((x)<<7) +#define AUXSPI_CNTL0_MSB_FIRST(x) ((x)<<6) +#define AUXSPI_CNTL0_SHIFT_LEN(x) ((x)<<0) + +#define AUXSPI_CNTL1_CS_HIGH(x) ((x)<<8) +#define AUXSPI_CNTL1_TX_IRQ (1<<7) +#define AUXSPI_CNTL1_DONE_IRQ (1<<6) +#define AUXSPI_CNTL1_MSB_FIRST(x)((x)<<1) +#define AUXSPI_CNTL1_KEEP_INPUT (1<<0) + +#define AUXSPI_STAT_TX_FIFO(x) ((x)<<28) +#define AUXSPI_STAT_RX_FIFO(x) ((x)<<20) +#define AUXSPI_STAT_TX_FULL (1<<10) +#define AUXSPI_STAT_TX_EMPTY (1<<9) +#define AUXSPI_STAT_RX_EMPTY (1<<7) +#define AUXSPI_STAT_BUSY (1<<6) +#define AUXSPI_STAT_BITS(x) ((x)<<0) + +/* --------------------------------------------------------------- */ + +#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)) + +#define PCM_TIMER (((PCM_BASE + PCM_FIFO*4) & 0x00ffffff) | PI_PERI_BUS) +#define PWM_TIMER (((PWM_BASE + PWM_FIFO*4) & 0x00ffffff) | PI_PERI_BUS) + +#define DBG_MIN_LEVEL 0 +#define DBG_ALWAYS 0 +#define DBG_STARTUP 1 +#define DBG_DMACBS 2 +#define DBG_SCRIPT 3 +#define DBG_USER 4 +#define DBG_INTERNAL 5 +#define DBG_SLOW_TICK 6 +#define DBG_FAST_TICK 7 +#define DBG_MAX_LEVEL 8 + +#define GPIO_UNDEFINED 0 +#define GPIO_WRITE 1 +#define GPIO_PWM 2 +#define GPIO_SERVO 3 +#define GPIO_HW_CLK 4 +#define GPIO_HW_PWM 5 +#define GPIO_SPI 6 +#define GPIO_I2C 7 + +#define STACK_SIZE (256*1024) + +#define PAGE_SIZE 4096 + +#define PWM_FREQS 18 + +#define CYCLES_PER_BLOCK 80 +#define PULSE_PER_CYCLE 25 + +#define PAGES_PER_BLOCK 53 + +#define CBS_PER_IPAGE 117 +#define LVS_PER_IPAGE 38 +#define OFF_PER_IPAGE 38 +#define TCK_PER_IPAGE 2 +#define ON_PER_IPAGE 2 +#define PAD_PER_IPAGE 7 + +#define CBS_PER_OPAGE 118 +#define OOL_PER_OPAGE 79 + +/* +Wave Count Block + +Assumes two counters per block. Each counter 4 * 16 (16^4=65536) + 0 CB [13] 13*8 104 CBs for counter 0 + 104 CB [13] 13*8 104 CBs for counter 1 + 208 CB [60] 60*8 480 CBs reserved to construct wave + 688 OOL [60] 60*1 60 OOL reserved to construct wave + 748 OOL[136] 136*1 136 OOL for counter 0 + 884 OOL[136] 136*1 136 OOL for counter 1 +1020 pad [4] 4*1 4 spare +*/ + +#define WCB_CNT_PER_PAGE 2 +#define WCB_COUNTERS (WCB_CNT_PER_PAGE * PI_WAVE_COUNT_PAGES) +#define WCB_CNT_CBS 13 +#define WCB_CNT_OOL 68 +#define WCB_COUNTER_OOL (WCB_CNT_PER_PAGE * WCB_CNT_OOL) +#define WCB_COUNTER_CBS (WCB_CNT_PER_PAGE * WCB_CNT_CBS) +#define WCB_CHAIN_CBS 60 +#define WCB_CHAIN_OOL 60 + +#define CBS_PER_CYCLE ((PULSE_PER_CYCLE*3)+2) + +#define NUM_CBS (CBS_PER_CYCLE * bufferCycles) + +#define SUPERCYCLE 800 +#define SUPERLEVEL 20000 + +#define BLOCK_SIZE (PAGES_PER_BLOCK*PAGE_SIZE) + +#define DMAI_PAGES (PAGES_PER_BLOCK * bufferBlocks) + +#define DMAO_PAGES (PAGES_PER_BLOCK * PI_WAVE_BLOCKS) + +#define NUM_WAVE_OOL (DMAO_PAGES * OOL_PER_OPAGE) +#define NUM_WAVE_CBS (DMAO_PAGES * CBS_PER_OPAGE) + +#define TICKSLOTS 50 + +#define PI_I2C_CLOSED 0 +#define PI_I2C_RESERVED 1 +#define PI_I2C_OPENED 2 + +#define PI_SPI_CLOSED 0 +#define PI_SPI_RESERVED 1 +#define PI_SPI_OPENED 2 + +#define PI_SER_CLOSED 0 +#define PI_SER_RESERVED 1 +#define PI_SER_OPENED 2 + +#define PI_FILE_CLOSED 0 +#define PI_FILE_RESERVED 1 +#define PI_FILE_OPENED 2 + +#define PI_NOTIFY_CLOSED 0 +#define PI_NOTIFY_RESERVED 1 +#define PI_NOTIFY_CLOSING 2 +#define PI_NOTIFY_OPENED 3 +#define PI_NOTIFY_RUNNING 4 +#define PI_NOTIFY_PAUSED 5 + +#define PI_WFRX_NONE 0 +#define PI_WFRX_SERIAL 1 +#define PI_WFRX_I2C_SDA 2 +#define PI_WFRX_I2C_SCL 3 +#define PI_WFRX_SPI_SCLK 4 +#define PI_WFRX_SPI_MISO 5 +#define PI_WFRX_SPI_MOSI 6 +#define PI_WFRX_SPI_CS 7 + +#define PI_WF_MICROS 1 + +#define BPD 4 + +#define MAX_REPORT 250 +#define MAX_SAMPLE 4000 + +#define DEFAULT_PWM_IDX 5 + +#define MAX_EMITS (PIPE_BUF / sizeof(gpioReport_t)) + +#define SRX_BUF_SIZE 8192 + +#define PI_I2C_RETRIES 0x0701 +#define PI_I2C_TIMEOUT 0x0702 +#define PI_I2C_SLAVE 0x0703 +#define PI_I2C_FUNCS 0x0705 +#define PI_I2C_RDWR 0x0707 +#define PI_I2C_SMBUS 0x0720 + +#define PI_I2C_SMBUS_READ 1 +#define PI_I2C_SMBUS_WRITE 0 + +#define PI_I2C_SMBUS_QUICK 0 +#define PI_I2C_SMBUS_BYTE 1 +#define PI_I2C_SMBUS_BYTE_DATA 2 +#define PI_I2C_SMBUS_WORD_DATA 3 +#define PI_I2C_SMBUS_PROC_CALL 4 +#define PI_I2C_SMBUS_BLOCK_DATA 5 +#define PI_I2C_SMBUS_I2C_BLOCK_BROKEN 6 +#define PI_I2C_SMBUS_BLOCK_PROC_CALL 7 +#define PI_I2C_SMBUS_I2C_BLOCK_DATA 8 + +#define PI_I2C_SMBUS_BLOCK_MAX 32 +#define PI_I2C_SMBUS_I2C_BLOCK_MAX 32 + +#define PI_I2C_FUNC_SMBUS_QUICK 0x00010000 +#define PI_I2C_FUNC_SMBUS_READ_BYTE 0x00020000 +#define PI_I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 +#define PI_I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 +#define PI_I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 +#define PI_I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 +#define PI_I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 +#define PI_I2C_FUNC_SMBUS_PROC_CALL 0x00800000 +#define PI_I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 +#define PI_I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 +#define PI_I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 +#define PI_I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 + +#define PI_MASH_MAX_FREQ 23800000 + +#define FLUSH_PAGES 1024 + +#define MB_DEV_MAJOR 100 + +#define MB_IOCTL _IOWR(MB_DEV_MAJOR, 0, char *) + +#define MB_DEV1 "/dev/vcio" +#define MB_DEV2 "/dev/pigpio-mb" + +#define BUS_TO_PHYS(x) ((x)&~0xC0000000) + +#define MB_END_TAG 0 +#define MB_PROCESS_REQUEST 0 + +#define MB_ALLOCATE_MEMORY_TAG 0x3000C +#define MB_LOCK_MEMORY_TAG 0x3000D +#define MB_UNLOCK_MEMORY_TAG 0x3000E +#define MB_RELEASE_MEMORY_TAG 0x3000F + +#define PI_SCRIPT_FREE 0 +#define PI_SCRIPT_RESERVED 1 +#define PI_SCRIPT_IN_USE 2 +#define PI_SCRIPT_DYING 3 + +#define PI_SCRIPT_HALT 0 +#define PI_SCRIPT_RUN 1 +#define PI_SCRIPT_DELETE 2 + +#define PI_SCRIPT_STACK_SIZE 256 + +#define PI_SPI_FLAGS_CHANNEL(x) ((x&7)<<29) + +#define PI_SPI_FLAGS_GET_CHANNEL(x) (((x)>>29)&7) +#define PI_SPI_FLAGS_GET_BITLEN(x) (((x)>>16)&63) +#define PI_SPI_FLAGS_GET_RX_LSB(x) (((x)>>15)&1) +#define PI_SPI_FLAGS_GET_TX_LSB(x) (((x)>>14)&1) +#define PI_SPI_FLAGS_GET_3WREN(x) (((x)>>10)&15) +#define PI_SPI_FLAGS_GET_3WIRE(x) (((x)>>9)&1) +#define PI_SPI_FLAGS_GET_AUX_SPI(x) (((x)>>8)&1) +#define PI_SPI_FLAGS_GET_RESVD(x) (((x)>>5)&7) +#define PI_SPI_FLAGS_GET_CSPOLS(x) (((x)>>2)&7) +#define PI_SPI_FLAGS_GET_MODE(x) ((x)&3) + +#define PI_SPI_FLAGS_GET_CPHA(x) ((x)&1) +#define PI_SPI_FLAGS_GET_CPOL(x) ((x)&2) +#define PI_SPI_FLAGS_GET_CSPOL(x) ((x)&4) + +#define PI_STARTING 0 +#define PI_RUNNING 1 +#define PI_ENDING 2 + +#define PI_THREAD_NONE 0 +#define PI_THREAD_STARTED 1 +#define PI_THREAD_RUNNING 2 + +#define PI_MAX_PATH 512 + +/* typedef ------------------------------------------------------- */ + +typedef void (*callbk_t) (); + +typedef struct +{ + rawCbs_t cb [128]; +} dmaPage_t; + +typedef struct +{ + rawCbs_t cb [CBS_PER_IPAGE]; + uint32_t level [LVS_PER_IPAGE]; + uint32_t gpioOff [OFF_PER_IPAGE]; + uint32_t tick [TCK_PER_IPAGE]; + uint32_t gpioOn [ON_PER_IPAGE]; + uint32_t periphData; + uint32_t pad [PAD_PER_IPAGE]; +} dmaIPage_t; + +typedef struct +{ + rawCbs_t cb [CBS_PER_OPAGE]; + uint32_t OOL [OOL_PER_OPAGE]; + uint32_t periphData; +} dmaOPage_t; + +typedef struct +{ + uint8_t is; + uint8_t pad; + uint16_t width; + uint16_t range; /* dutycycles specified by 0 .. range */ + uint16_t freqIdx; + uint16_t deferOff; + uint16_t deferRng; +} gpioInfo_t; + +typedef struct +{ + callbk_t func; + unsigned ex; + void *userdata; + + int wdSteadyUs; + uint32_t wdTick; + uint32_t wdLBitV; + + int nfSteadyUs; + int nfActiveUs; + int nfActive; + uint32_t nfTick1; + uint32_t nfTick2; + uint32_t nfLBitV; + uint32_t nfRBitV; + + uint32_t gfSteadyUs; + uint8_t gfInitialised; + uint32_t gfTick; + uint32_t gfLBitV; + uint32_t gfRBitV; + +} gpioAlert_t; + +typedef struct +{ + callbk_t func; + unsigned ex; + void *userdata; + int ignore; + int fired; +} eventAlert_t; + +typedef struct +{ + unsigned gpio; + pthread_t *pth; + callbk_t func; + unsigned edge; + int timeout; + unsigned ex; + void *userdata; + int fd; + int inited; +} gpioISR_t; + +typedef struct +{ + callbk_t func; + unsigned ex; + void *userdata; +} gpioSignal_t; + +typedef struct +{ + callbk_t func; + unsigned ex; + void *userdata; + uint32_t bits; +} gpioGetSamples_t; + +typedef struct +{ + callbk_t func; + unsigned ex; + void *userdata; + unsigned id; + unsigned running; + unsigned millis; + pthread_t pthId; +} gpioTimer_t; + +typedef struct +{ + unsigned id; + unsigned state; + unsigned request; + unsigned run_state; + uint32_t waitBits; + uint32_t eventBits; + uint32_t changedBits; + pthread_t *pthIdp; + pthread_mutex_t pthMutex; + pthread_cond_t pthCond; + cmdScript_t script; +} gpioScript_t; + + +typedef struct +{ + uint16_t valid; + uint16_t servoIdx; +} clkCfg_t; + +typedef struct +{ + uint16_t seqno; + uint16_t state; + uint32_t bits; + uint32_t eventBits; + uint32_t lastReportTick; + int fd; + int pipe; + int max_emits; +} gpioNotify_t; + +typedef struct +{ + uint16_t state; + int16_t fd; + uint32_t mode; +} fileInfo_t; + +typedef struct +{ + uint16_t state; + int16_t fd; + uint32_t addr; + uint32_t flags; + uint32_t funcs; +} i2cInfo_t; + +typedef struct +{ + uint16_t state; + int16_t fd; + uint32_t flags; +} serInfo_t; + +typedef struct +{ + uint16_t state; + unsigned speed; + uint32_t flags; +} spiInfo_t; + +typedef struct +{ + uint32_t alertTicks; + uint32_t lateTicks; + uint32_t moreToDo; + uint32_t diffTick[TICKSLOTS]; + uint32_t cbTicks; + uint32_t cbCalls; + uint32_t maxEmit; + uint32_t emitFrags; + uint32_t maxSamples; + uint32_t numSamples; + uint32_t DMARestarts; + uint32_t dmaInitCbsCount; + uint32_t goodPipeWrite; + uint32_t shortPipeWrite; + uint32_t wouldBlockPipeWrite; +} gpioStats_t; + +typedef struct +{ + unsigned bufferMilliseconds; + unsigned clockMicros; + unsigned clockPeriph; + unsigned DMAprimaryChannel; + unsigned DMAsecondaryChannel; + unsigned socketPort; + unsigned ifFlags; + unsigned memAllocMode; + unsigned dbgLevel; + unsigned alertFreq; + uint32_t internals; + /* + 0-3: dbgLevel + 4-7: alertFreq + */ +} gpioCfg_t; + +typedef struct +{ + uint32_t micros; + uint32_t highMicros; + uint32_t maxMicros; + uint32_t pulses; + uint32_t highPulses; + uint32_t maxPulses; + uint32_t cbs; + uint32_t highCbs; + uint32_t maxCbs; +} wfStats_t; + +typedef struct +{ + char *buf; + uint32_t bufSize; + int readPos; + int writePos; + uint32_t fullBit; /* nanoseconds */ + uint32_t halfBit; /* nanoseconds */ + int timeout; /* millisconds */ + uint32_t startBitTick; /* microseconds */ + uint32_t nextBitDiff; /* nanoseconds */ + int bit; + uint32_t data; + int bytes; /* 1, 2, 4 */ + int level; + int dataBits; /* 1-32 */ + int invert; /* 0, 1 */ +} wfRxSerial_t; + +typedef struct +{ + int SDA; + int SCL; + int delay; + int SDAMode; + int SCLMode; + int started; +} wfRxI2C_t; + +typedef struct +{ + int CS; + int MISO; + int MOSI; + int SCLK; + int usage; + int delay; + int spiFlags; + int MISOMode; + int MOSIMode; + int CSMode; + int SCLKMode; +} wfRxSPI_t; + +typedef struct +{ + int mode; + int gpio; + uint32_t baud; + pthread_mutex_t mutex; + union + { + wfRxSerial_t s; + wfRxI2C_t I; + wfRxSPI_t S; + }; +} wfRx_t; + +union my_smbus_data +{ + uint8_t byte; + uint16_t word; + uint8_t block[PI_I2C_SMBUS_BLOCK_MAX + 2]; +}; + +struct my_smbus_ioctl_data +{ + uint8_t read_write; + uint8_t command; + uint32_t size; + union my_smbus_data *data; +}; + +typedef struct +{ + pi_i2c_msg_t *msgs; /* pointers to pi_i2c_msgs */ + uint32_t nmsgs; /* number of pi_i2c_msgs */ +} my_i2c_rdwr_ioctl_data_t; + +typedef struct +{ + unsigned div; + unsigned frac; + unsigned clock; +} clkInf_t; + +typedef struct +{ + unsigned handle; /* mbAllocateMemory() */ + uintptr_t bus_addr; /* mbLockMemory() */ + uintptr_t *virtual_addr; /* mbMapMem() */ + unsigned size; /* in bytes */ +} DMAMem_t; + +/* global -------------------------------------------------------- */ + +/* initialise once then preserve */ + +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; + +/* initialise every gpioInitialise */ + +static struct timespec libStarted; + +static uint32_t sockNetAddr[MAX_CONNECT_ADDRESSES]; + +static int numSockNetAddr = 0; + +static uint32_t reportedLevel = 0; + +static int waveClockInited = 0; +static int PWMClockInited = 0; + +static volatile gpioStats_t gpioStats; + +static int gpioMaskSet = 0; + +/* initialise if not libInitialised */ + +static uint64_t gpioMask; + +static rawWave_t wf[3][PI_WAVE_MAX_PULSES]; + +static int wfc[3]={0, 0, 0}; + +static int wfcur=0; + +static wfStats_t wfStats= +{ + 0, 0, PI_WAVE_MAX_MICROS, + 0, 0, PI_WAVE_MAX_PULSES, + 0, 0, (DMAO_PAGES * CBS_PER_OPAGE) +}; + +static rawWaveInfo_t waveInfo[PI_MAX_WAVES]; + +static wfRx_t wfRx[PI_MAX_USER_GPIO+1]; + +static int waveOutBotCB = PI_WAVE_COUNT_PAGES*CBS_PER_OPAGE; +static int waveOutBotOOL = PI_WAVE_COUNT_PAGES*OOL_PER_OPAGE; +static int waveOutTopOOL = NUM_WAVE_OOL; +static int waveOutCount = 0; + +static uint32_t *waveEndPtr = NULL; + +static volatile uint32_t alertBits = 0; +static volatile uint32_t monitorBits = 0; +static volatile uint32_t notifyBits = 0; +static volatile uint32_t scriptBits = 0; +static volatile uint32_t gFilterBits = 0; +static volatile uint32_t nFilterBits = 0; +static volatile uint32_t wdogBits = 0; + +static volatile uint32_t scriptEventBits = 0; + +static volatile int runState = PI_STARTING; + +static int pthAlertRunning = PI_THREAD_NONE; +static int pthFifoRunning = PI_THREAD_NONE; +static int pthSocketRunning = PI_THREAD_NONE; + +static gpioAlert_t gpioAlert [PI_MAX_USER_GPIO+1]; + +static eventAlert_t eventAlert [PI_MAX_EVENT+1]; + +static gpioISR_t gpioISR [PI_MAX_GPIO+1]; + +static gpioGetSamples_t gpioGetSamples; + +static gpioInfo_t gpioInfo [PI_MAX_GPIO+1]; + +static gpioNotify_t gpioNotify [PI_NOTIFY_SLOTS]; + +static fileInfo_t fileInfo [PI_FILE_SLOTS]; +static i2cInfo_t i2cInfo [PI_I2C_SLOTS]; +static serInfo_t serInfo [PI_SER_SLOTS]; +static spiInfo_t spiInfo [PI_SPI_SLOTS]; + +static gpioScript_t gpioScript [PI_MAX_SCRIPTS]; + +static gpioSignal_t gpioSignal [PI_MAX_SIGNUM+1]; + +static gpioTimer_t gpioTimer [PI_MAX_TIMER+1]; + +static int pwmFreq[PWM_FREQS]; + +/* reset after gpioTerminated */ + +/* resources which must be released on gpioTerminate */ + +static FILE * inpFifo = NULL; +static FILE * outFifo = NULL; + +static int fdLock = -1; +static int fdMem = -1; +static int fdSock = -1; +static int fdPmap = -1; +static int fdMbox = -1; + +static DMAMem_t *dmaMboxBlk = MAP_FAILED; +static uintptr_t * * dmaPMapBlk = MAP_FAILED; +static dmaPage_t * * dmaVirt = MAP_FAILED; +static dmaPage_t * * dmaBus = MAP_FAILED; + +static dmaIPage_t * * dmaIVirt = MAP_FAILED; +static dmaIPage_t * * dmaIBus = MAP_FAILED; + +static dmaOPage_t * * dmaOVirt = MAP_FAILED; +static dmaOPage_t * * dmaOBus = MAP_FAILED; + +static volatile uint32_t * auxReg = MAP_FAILED; +static volatile uint32_t * bscsReg = MAP_FAILED; +static volatile uint32_t * clkReg = MAP_FAILED; +static volatile uint32_t * dmaReg = MAP_FAILED; +static volatile uint32_t * gpioReg = MAP_FAILED; +static volatile uint32_t * padsReg = MAP_FAILED; +static volatile uint32_t * pcmReg = MAP_FAILED; +static volatile uint32_t * pwmReg = MAP_FAILED; +static volatile uint32_t * spiReg = MAP_FAILED; +static volatile uint32_t * systReg = MAP_FAILED; + +static volatile uint32_t * dmaIn = MAP_FAILED; +static volatile uint32_t * dmaOut = MAP_FAILED; + +static uint32_t hw_clk_freq[3]; +static uint32_t hw_pwm_freq[2]; +static uint32_t hw_pwm_duty[2]; +static uint32_t hw_pwm_real_range[2]; + +static volatile gpioCfg_t gpioCfg = +{ + PI_DEFAULT_BUFFER_MILLIS, + PI_DEFAULT_CLK_MICROS, + PI_DEFAULT_CLK_PERIPHERAL, + 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, + 0, /* dbgLevel */ + 0, /* alertFreq */ + 0, /* internals */ +}; + +/* no initialisation required */ + +static unsigned bufferBlocks; /* number of blocks in buffer */ +static unsigned bufferCycles; /* number of cycles */ + +static pthread_t pthAlert; +static pthread_t pthFifo; +static pthread_t pthSocket; + +static uint32_t spi_dummy; + +static unsigned old_mode_ce0; +static unsigned old_mode_ce1; +static unsigned old_mode_sclk; +static unsigned old_mode_miso; +static unsigned old_mode_mosi; + +static uint32_t old_spi_cs; +static uint32_t old_spi_clk; + +static unsigned old_mode_ace0; +static unsigned old_mode_ace1; +static unsigned old_mode_ace2; +static unsigned old_mode_asclk; +static unsigned old_mode_amiso; +static unsigned old_mode_amosi; + +static uint32_t old_spi_cntl0; +static uint32_t old_spi_cntl1; + +static uint32_t bscFR; + +/* const --------------------------------------------------------- */ + +static const uint8_t clkDef[PI_MAX_GPIO + 1] = +{ + /* 0 1 2 3 4 5 6 7 8 9 */ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x84, 0x94, 0xA4, 0x00, 0x00, 0x00, + /* 1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 2 */ 0x82, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 3 */ 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 4 */ 0x00, 0x00, 0x94, 0xA4, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 5 */ 0x00, 0x00, 0x00, 0x00, +}; + +/* + 7 6 5 4 3 2 1 0 + V . C C . M M M + + V: 0 no clock, 1 has a clock +CC: 00 CLK0, 01 CLK1, 10 CLK2 + M: 100 ALT0, 010 ALT5 + + gpio4 GPCLK0 ALT0 + gpio5 GPCLK1 ALT0 B+ and compute module only (reserved for system use) + gpio6 GPCLK2 ALT0 B+ and compute module only + gpio20 GPCLK0 ALT5 B+ and compute module only + gpio21 GPCLK1 ALT5 Not available on Rev.2 B (reserved for system use) + + gpio32 GPCLK0 ALT0 Compute module only + gpio34 GPCLK0 ALT0 Compute module only + gpio42 GPCLK1 ALT0 Compute module only (reserved for system use) + gpio43 GPCLK2 ALT0 Compute module only + gpio44 GPCLK1 ALT0 Compute module only (reserved for system use) +*/ + +static const uint8_t PWMDef[PI_MAX_GPIO + 1] = +{ + /* 0 1 2 3 4 5 6 7 8 9 */ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 1 */ 0x00, 0x00, 0x84, 0x94, 0x00, 0x00, 0x00, 0x00, 0x82, 0x92, + /* 2 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 4 */ 0x84, 0x94, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x00, + /* 5 */ 0x00, 0x00, 0x85, 0x95, +}; + +/* + 7 6 5 4 3 2 1 0 + V . . P . M M M + + V: 0 no PWM, 1 has a PWM + P: 0 PWM0, 1 PWM1 + M: 010 ALT5, 100 ALT0, 101 ALT1 + + gpio12 pwm0 ALT0 + gpio13 pwm1 ALT0 + gpio18 pwm0 ALT5 + gpio19 pwm1 ALT5 + gpio40 pwm0 ALT0 + gpio41 pwm1 ALT0 + gpio45 pwm1 ALT0 + gpio52 pwm0 ALT1 + gpio53 pwm1 ALT1 +*/ + +static const clkCfg_t clkCfg[]= +{ + /* valid servo */ + { 0, 0}, /* 0 */ + { 1, 17}, /* 1 */ + { 1, 16}, /* 2 */ + { 0, 0}, /* 3 */ + { 1, 15}, /* 4 */ + { 1, 14}, /* 5 */ + { 0, 0}, /* 6 */ + { 0, 0}, /* 7 */ + { 1, 13}, /* 8 */ + { 0, 0}, /* 9 */ + { 1, 12}, /* 10 */ +}; + +static const uint16_t pwmCycles[PWM_FREQS]= + { 1, 2, 4, 5, 8, 10, 16, 20, 25, + 32, 40, 50, 80, 100, 160, 200, 400, 800}; + +static const uint16_t pwmRealRange[PWM_FREQS]= + { 25, 50, 100, 125, 200, 250, 400, 500, 625, + 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000}; + +/* prototype ----------------------------------------------------- */ + +static void intNotifyBits(void); + +static void intScriptBits(void); + +static void intScriptEventBits(void); + +static int gpioNotifyOpenInBand(int fd); + +static void initHWClk + (int clkCtl, int clkDiv, int clkSrc, int divI, int divF, int MASH); + +static void initDMAgo(volatile uint32_t *dmaAddr, uint32_t cbAddr); + +int gpioWaveTxStart(unsigned wave_mode); /* deprecated */ + +static void closeOrphanedNotifications(int slot, int fd); + + +/* ======================================================================= */ + +int myScriptNameValid(char *name) +{ + int i, c, len, valid; + + len = strlen(name); + + valid = 1; + + for (i=0; i 40) c = 40; else c = count; + + for (i=0; ibyte+1, (char*)data)); + + args.read_write = rw; + args.command = cmd; + args.size = size; + args.data = data; + + return ioctl(fd, PI_I2C_SMBUS, &args); +} + +/* ----------------------------------------------------------------------- */ + +static void myGpioSetMode(unsigned gpio, unsigned mode) +{ + int reg, shift; + + reg = gpio/10; + shift = (gpio%10) * 3; + + gpioReg[reg] = (gpioReg[reg] & ~(7<level[slot]; + + return level; +} + +/* ----------------------------------------------------------------------- */ + +static int myI2CGetPar(char *inBuf, int *inPos, int inLen, int *esc) +{ + int bytes; + + if (*esc) bytes = 2; else bytes = 1; + + *esc = 0; + + if (*inPos <= (inLen - bytes)) + { + if (bytes == 1) + { + return inBuf[(*inPos)++]; + } + else + { + (*inPos) += 2; + return inBuf[*inPos-2] + (inBuf[*inPos-1]<<8); + } + } + return -1; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t myGetTick(int pos) +{ + uint32_t tick; + int page, slot; + + myTckPageSlot(pos, &page, &slot); + + tick = dmaIVirt[page]->tick[slot]; + + return tick; +} + +static int myPermit(unsigned gpio) +{ + if (gpio <= PI_MAX_GPIO) + { + if (gpioMask & ((uint64_t)(1)<>32; + + res = gpioWrite_Bits_32_53_Clear(p[1]&mask); + + if ((mask | p[1]) != mask) + { + DBG(DBG_USER, + "gpioWrite_Bits_32_53_Clear: bad bits %08"PRIXPTR" (permissions %08X)", + p[1], mask); + res = PI_SOME_PERMITTED; + } + break; + + case PI_CMD_BI2CC: + res = bbI2CClose(p[1]); + break; + + case PI_CMD_BI2CO: + memcpy(&p[4], buf, 4); + res = bbI2COpen(p[1], p[2], p[4]); + break; + + case PI_CMD_BI2CZ: + /* use half buffer for write, half buffer for read */ + if (p[3] > (bufSize/2)) p[3] = bufSize/2; + res = bbI2CZip(p[1], buf, p[3], buf+(bufSize/2), bufSize/2); + if (res > 0) + { + memcpy(buf, buf+(bufSize/2), res); + } + break; + + case PI_CMD_BSCX: + xfer.control = p[1]; + if (p[3] > BSC_FIFO_SIZE) p[3] = BSC_FIFO_SIZE; + xfer.txCnt = p[3]; + if (p[3]) memcpy(&xfer.txBuf, buf, p[3]); + res = bscXfer(&xfer); + if (res >= 0) + { + memcpy(buf, &res, 4); + res = 4 + xfer.rxCnt; + if (res > 4) memcpy(buf+4, &xfer.rxBuf, res-4); + } + break; + + case PI_CMD_BSPIO: + + memcpy(&tmp1, buf+ 0, 4); // MISO + memcpy(&tmp2, buf+ 4, 4); // MOSI + memcpy(&tmp3, buf+ 8, 4); // SCLK + memcpy(&tmp4, buf+12, 4); // baud + memcpy(&tmp5, buf+16, 4); // flags + + if (!myPermit(p[1])) + { + DBG(DBG_USER, + "bbSPIOpen: gpio %"PRIdPTR", no permission to update CS", p[1]); + res = PI_NOT_PERMITTED; + } + + if (!myPermit(tmp1)) + { + DBG(DBG_USER, + "bbSPIOpen: gpio %d, no permission to update MISO", tmp1); + res = PI_NOT_PERMITTED; + } + + if (!myPermit(tmp2)) + { + DBG(DBG_USER, + "bbSPIOpen: gpio %d, no permission to update MOSI", tmp2); + res = PI_NOT_PERMITTED; + } + + if (!myPermit(tmp3)) + { + DBG(DBG_USER, + "bbSPIOpen: gpio %d, no permission to update SCLK", tmp3); + res = PI_NOT_PERMITTED; + } + + if (!res) res = bbSPIOpen(p[1], tmp1, tmp2, tmp3, tmp4, tmp5); + break; + + case PI_CMD_BSPIC: + res = bbSPIClose(p[1]); + break; + + case PI_CMD_BSPIX: + if (p[3] > bufSize) p[3] = bufSize; + res = bbSPIXfer(p[1], buf, buf, p[3]); + break; + + case PI_CMD_BR1: res = gpioRead_Bits_0_31(); break; + + case PI_CMD_BR2: res = gpioRead_Bits_32_53(); break; + + case PI_CMD_BS1: + mask = gpioMask; + + res = gpioWrite_Bits_0_31_Set(p[1]&mask); + + if ((mask | p[1]) != mask) + { + DBG(DBG_USER, + "gpioWrite_Bits_0_31_Set: bad bits %08"PRIXPTR" (permissions %08X)", + p[1], mask); + res = PI_SOME_PERMITTED; + } + break; + + case PI_CMD_BS2: + mask = gpioMask>>32; + + res = gpioWrite_Bits_32_53_Set(p[1]&mask); + + if ((mask | p[1]) != mask) + { + DBG(DBG_USER, + "gpioWrite_Bits_32_53_Set: bad bits %08"PRIXPTR" (permissions %08X)", + p[1], mask); + res = PI_SOME_PERMITTED; + } + break; + + case PI_CMD_CF1: + res = gpioCustom1(p[1], p[2], buf, p[3]); + break; + + case PI_CMD_CF2: + /* a couple of extra precautions for untrusted code */ + if (p[2] > bufSize) p[2] = bufSize; + res = gpioCustom2(p[1], buf, p[3], buf, p[2]); + if (res > p[2]) res = p[2]; + break; + + case PI_CMD_CGI: res = gpioCfgGetInternals(); break; + + case PI_CMD_CSI: res = gpioCfgSetInternals(p[1]); break; + + case PI_CMD_EVM: res = eventMonitor(p[1], p[2]); break; + + case PI_CMD_EVT: res = eventTrigger(p[1]); break; + + case PI_CMD_FC: res = fileClose(p[1]); break; + + case PI_CMD_FG: + res = gpioGlitchFilter(p[1], p[2]); + break; + + case PI_CMD_FL: + if (p[1] > bufSize) p[1] = bufSize; + res = fileList(buf, buf, p[1]); + break; + + case PI_CMD_FN: + memcpy(&p[4], buf, 4); + res = gpioNoiseFilter(p[1], p[2], p[4]); + break; + + case PI_CMD_FO: res = fileOpen(buf, p[1]); break; + + case PI_CMD_FR: + if (p[2] > bufSize) p[2] = bufSize; + res = fileRead(p[1], buf, p[2]); + break; + + case PI_CMD_FS: + memcpy(&p[4], buf, 4); + res = fileSeek(p[1], p[2], p[4]); + break; + + case PI_CMD_FW: res = fileWrite(p[1], buf, p[3]); break; + + case PI_CMD_GDC: res = gpioGetPWMdutycycle(p[1]); break; + + case PI_CMD_GPW: res = gpioGetServoPulsewidth(p[1]); break; + + case PI_CMD_HC: + /* special case to allow password in upper byte */ + if (myPermit(p[1]&0xFFFFFF)) res = gpioHardwareClock(p[1], p[2]); + else + { + DBG(DBG_USER, + "gpioHardwareClock: gpio %"PRIdPTR", no permission to update", + p[1] & 0xFFFFFF); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_HELP: break; + + case PI_CMD_HP: + if (myPermit(p[1])) + { + memcpy(&p[4], buf, 4); + res = gpioHardwarePWM(p[1], p[2], p[4]); + } + else + { + DBG(DBG_USER, + "gpioHardwarePWM: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_HWVER: res = gpioHardwareRevision(); break; + + + + case PI_CMD_I2CC: res = i2cClose(p[1]); break; + + case PI_CMD_I2CO: + memcpy(&p[4], buf, 4); + res = i2cOpen(p[1], p[2], p[4]); + break; + + case PI_CMD_I2CPC: + memcpy(&p[4], buf, 4); + res = i2cProcessCall(p[1], p[2], p[4]); + break; + + case PI_CMD_I2CPK: + res = i2cBlockProcessCall(p[1], p[2], buf, p[3]); + break; + + case PI_CMD_I2CRB: res = i2cReadByteData(p[1], p[2]); break; + + case PI_CMD_I2CRD: + if (p[2] > bufSize) p[2] = bufSize; + res = i2cReadDevice(p[1], buf, p[2]); + break; + + case PI_CMD_I2CRI: + memcpy(&p[4], buf, 4); + res = i2cReadI2CBlockData(p[1], p[2], buf, p[4]); + break; + + case PI_CMD_I2CRK: + res = i2cReadBlockData(p[1], p[2], buf); + break; + + case PI_CMD_I2CRS: res = i2cReadByte(p[1]); break; + + case PI_CMD_I2CRW: res = i2cReadWordData(p[1], p[2]); break; + + case PI_CMD_I2CWB: + memcpy(&p[4], buf, 4); + res = i2cWriteByteData(p[1], p[2], p[4]); + break; + + case PI_CMD_I2CWD: + res = i2cWriteDevice(p[1], buf, p[3]); + break; + + case PI_CMD_I2CWI: + res = i2cWriteI2CBlockData(p[1], p[2], buf, p[3]); + break; + + case PI_CMD_I2CWK: + res = i2cWriteBlockData(p[1], p[2], buf, p[3]); + break; + + case PI_CMD_I2CWQ: res = i2cWriteQuick(p[1], p[2]); break; + + case PI_CMD_I2CWS: res = i2cWriteByte(p[1], p[2]); break; + + case PI_CMD_I2CWW: + memcpy(&p[4], buf, 4); + res = i2cWriteWordData(p[1], p[2], p[4]); + break; + + case PI_CMD_I2CZ: + /* use half buffer for write, half buffer for read */ + if (p[3] > (bufSize/2)) p[3] = bufSize/2; + res = i2cZip(p[1], buf, p[3], buf+(bufSize/2), bufSize/2); + if (res > 0) + { + memcpy(buf, buf+(bufSize/2), res); + } + break; + + case PI_CMD_MICS: + if (p[1] <= PI_MAX_MICS_DELAY) myGpioDelay(p[1]); + else res = PI_BAD_MICS_DELAY; + break; + + case PI_CMD_MILS: + if (p[1] <= PI_MAX_MILS_DELAY) myGpioDelay(p[1] * 1000); + else res = PI_BAD_MILS_DELAY; + break; + + case PI_CMD_MODEG: res = gpioGetMode(p[1]); break; + + case PI_CMD_MODES: + if (myPermit(p[1])) res = gpioSetMode(p[1], p[2]); + else + { + DBG(DBG_USER, + "gpioSetMode: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_NB: res = gpioNotifyBegin(p[1], p[2]); break; + + case PI_CMD_NC: res = gpioNotifyClose(p[1]); break; + + case PI_CMD_NO: res = gpioNotifyOpen(); break; + + case PI_CMD_NP: res = gpioNotifyPause(p[1]); break; + + case PI_CMD_PADG: res = gpioGetPad(p[1]); break; + + case PI_CMD_PADS: res = gpioSetPad(p[1], p[2]); break; + + case PI_CMD_PFG: res = gpioGetPWMfrequency(p[1]); break; + + case PI_CMD_PFS: + if (myPermit(p[1])) res = gpioSetPWMfrequency(p[1], p[2]); + else + { + DBG(DBG_USER, + "gpioSetPWMfrequency: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_PIGPV: res = gpioVersion(); break; + + case PI_CMD_PRG: res = gpioGetPWMrange(p[1]); break; + + case PI_CMD_PROC: + res = gpioStoreScript(buf); + break; + + case PI_CMD_PROCD: res = gpioDeleteScript(p[1]); break; + + case PI_CMD_PROCP: + res = gpioScriptStatus(p[1], (uint32_t *)buf); + break; + + case PI_CMD_PROCR: + res = gpioRunScript(p[1], p[3]/4, (uint32_t *)buf); + break; + + case PI_CMD_PROCS: res = gpioStopScript(p[1]); break; + + case PI_CMD_PROCU: + res = gpioUpdateScript(p[1], p[3]/4, (uint32_t *)buf); + break; + + case PI_CMD_PRRG: res = gpioGetPWMrealRange(p[1]); break; + + case PI_CMD_PRS: + if (myPermit(p[1])) res = gpioSetPWMrange(p[1], p[2]); + else + { + DBG(DBG_USER, + "gpioSetPWMrange: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_PUD: + if (myPermit(p[1])) res = gpioSetPullUpDown(p[1], p[2]); + else + { + DBG(DBG_USER, + "gpioSetPullUpDown: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_PWM: + if (myPermit(p[1])) res = gpioPWM(p[1], p[2]); + else + { + DBG(DBG_USER, "gpioPWM: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_READ: res = gpioRead(p[1]); break; + + case PI_CMD_SERVO: + if (myPermit(p[1])) res = gpioServo(p[1], p[2]); + else + { + DBG(DBG_USER, + "gpioServo: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + + + case PI_CMD_SERRB: res = serReadByte(p[1]); break; + + case PI_CMD_SERWB: res = serWriteByte(p[1], p[2]); break; + + case PI_CMD_SERC: res = serClose(p[1]); break; + + case PI_CMD_SERDA: res = serDataAvailable(p[1]); break; + + case PI_CMD_SERO: res = serOpen(buf, p[1], p[2]); break; + + case PI_CMD_SERR: + if (p[2] > bufSize) p[2] = bufSize; + res = serRead(p[1], buf, p[2]); + break; + + case PI_CMD_SERW: res = serWrite(p[1], buf, p[3]); break; + + + case PI_CMD_SHELL: + res = shell(buf, buf+p[1]+1); + break; + + + case PI_CMD_SLR: + if (p[2] > bufSize) p[2] = bufSize; + res = gpioSerialRead(p[1], buf, p[2]); + break; + + case PI_CMD_SLRC: res = gpioSerialReadClose(p[1]); break; + + case PI_CMD_SLRO: + memcpy(&p[4], buf, 4); + res = gpioSerialReadOpen(p[1], p[2], p[4]); break; + + case PI_CMD_SLRI: res = gpioSerialReadInvert(p[1], p[2]); break; + + case PI_CMD_SPIC: + res = spiClose(p[1]); + break; + + case PI_CMD_SPIO: + memcpy(&p[4], buf, 4); + res = spiOpen(p[1], p[2], p[4]); + break; + + case PI_CMD_SPIR: + if (p[2] > bufSize) p[2] = bufSize; + res = spiRead(p[1], buf, p[2]); + break; + + case PI_CMD_SPIW: + if (p[3] > bufSize) p[3] = bufSize; + res = spiWrite(p[1], buf, p[3]); + break; + + case PI_CMD_SPIX: + if (p[3] > bufSize) p[3] = bufSize; + res = spiXfer(p[1], buf, buf, p[3]); + break; + + case PI_CMD_TICK: res = gpioTick(); break; + + case PI_CMD_TRIG: + if (myPermit(p[1])) + { + memcpy(&p[4], buf, 4); + res = gpioTrigger(p[1], p[2], p[4]); + } + else + { + DBG(DBG_USER, + "gpioTrigger: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_WDOG: res = gpioSetWatchdog(p[1], p[2]); break; + + case PI_CMD_WRITE: + if (myPermit(p[1])) res = gpioWrite(p[1], p[2]); + else + { + DBG(DBG_USER, "gpioWrite: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + + + case PI_CMD_WVAG: + + /* need to mask off any non permitted gpios */ + + mask = gpioMask; + pulse = (gpioPulse_t *)buf; + j = p[3]/sizeof(gpioPulse_t); + masked = 0; + + for (i=0; i= 0)) res = PI_SOME_PERMITTED; + + break; + + case PI_CMD_WVAS: + if (myPermit(p[1])) + { + memcpy(&tmp1, buf, 4); /* databits */ + memcpy(&tmp2, buf+4, 4); /* stophalfbits */ + memcpy(&tmp3, buf+8, 4); /* offset */ + res = gpioWaveAddSerial + (p[1], p[2], tmp1, tmp2, tmp3, p[3]-12, buf+12); + } + else + { + DBG( + DBG_USER, + "gpioWaveAddSerial: gpio %"PRIdPTR", no permission to update", p[1]); + res = PI_NOT_PERMITTED; + } + break; + + case PI_CMD_WVBSY: res = gpioWaveTxBusy(); break; + + case PI_CMD_WVCHA: + if (p[3] > bufSize) p[3] = bufSize; + res = gpioWaveChain(buf, p[3]); + break; + + + case PI_CMD_WVCLR: res = gpioWaveClear(); break; + + 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; + + case PI_CMD_WVGOR: res = gpioWaveTxStart(PI_WAVE_MODE_REPEAT); break; + + case PI_CMD_WVHLT: res = gpioWaveTxStop(); break; + + case PI_CMD_WVNEW: res = gpioWaveAddNew(); break; + + case PI_CMD_WVSC: + switch(p[1]) + { + case 0: res = gpioWaveGetCbs(); break; + case 1: res = gpioWaveGetHighCbs(); break; + case 2: res = gpioWaveGetMaxCbs(); break; + default: res = PI_BAD_WVSC_COMMND; + } + break; + + case PI_CMD_WVSM: + switch(p[1]) + { + case 0: res = gpioWaveGetMicros(); break; + case 1: res = gpioWaveGetHighMicros(); break; + case 2: res = gpioWaveGetMaxMicros(); break; + default: res = PI_BAD_WVSM_COMMND; + } + break; + + case PI_CMD_WVSP: + switch(p[1]) + { + case 0: res = gpioWaveGetPulses(); break; + case 1: res = gpioWaveGetHighPulses(); break; + case 2: res = gpioWaveGetMaxPulses(); break; + default: res = PI_BAD_WVSP_COMMND; + } + break; + + case PI_CMD_WVTAT: res = gpioWaveTxAt(); break; + + case PI_CMD_WVTX: + res = gpioWaveTxSend(p[1], PI_WAVE_MODE_ONE_SHOT); break; + + case PI_CMD_WVTXM: + res = gpioWaveTxSend(p[1], p[2]); break; + + case PI_CMD_WVTXR: + res = gpioWaveTxSend(p[1], PI_WAVE_MODE_REPEAT); break; + + default: + res = PI_UNKNOWN_COMMAND; + break; + } + + return res; +} + +/* ----------------------------------------------------------------------- */ + +static void mySetGpioOff(unsigned gpio, int pos) +{ + int page, slot; + + myOffPageSlot(pos, &page, &slot); + + dmaIVirt[page]->gpioOff[slot] |= (1<gpioOff[slot] &= ~(1<gpioOn[slot] |= (1<gpioOn[slot] &= ~(1< oldOff) + { + for (i=0; i oldOff) + { + for (i=0; ihandle) + { + mbUnmapMem(DMAMemP->virtual_addr, DMAMemP->size); + mbUnlockMemory(fdMbox, DMAMemP->handle); + mbReleaseMemory(fdMbox, DMAMemP->handle); + DMAMemP->handle = 0; + } +} + +static int mbDMAAlloc(DMAMem_t *DMAMemP, unsigned size, uint32_t pi_mem_flag) +{ + DMAMemP->size = size; + + DMAMemP->handle = + mbAllocateMemory(fdMbox, size, PAGE_SIZE, pi_mem_flag); + + if (DMAMemP->handle) + { + DMAMemP->bus_addr = mbLockMemory(fdMbox, DMAMemP->handle); + + DMAMemP->virtual_addr = + mbMapMem(BUS_TO_PHYS(DMAMemP->bus_addr), size); + + return 1; + } + return 0; +} + + +/* ======================================================================= */ + +rawCbs_t * rawWaveCBAdr(int cbNum) +{ + int page, slot; + + page = cbNum/CBS_PER_OPAGE; + slot = cbNum%CBS_PER_OPAGE; + + return &dmaOVirt[page]->cb[slot]; +} + + +/* ----------------------------------------------------------------------- */ + +static uint32_t waveCbPOadr(int pos) +{ + int page, slot; + + page = pos/CBS_PER_OPAGE; + slot = pos%CBS_PER_OPAGE; + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaOBus contains bus addresses, not virtual addresses. + return (uint32_t)(uintptr_t) &dmaOBus[page]->cb[slot]; +} + +/* ----------------------------------------------------------------------- */ + +static void waveOOLPageSlot(int pos, int *page, int *slot) +{ + *page = pos/OOL_PER_OPAGE; + *slot = pos%OOL_PER_OPAGE; +} + + +/* ----------------------------------------------------------------------- */ + +static void waveSetOOL(int pos, uint32_t OOL) +{ + int page, slot; + + waveOOLPageSlot(pos, &page, &slot); + + dmaOVirt[page]->OOL[slot] = OOL; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t waveOOLPOadr(int pos) +{ + int page, slot; + + waveOOLPageSlot(pos, &page, &slot); + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaOBus contains bus addresses, not virtual addresses. + return (uint32_t)(uintptr_t) &dmaOBus[page]->OOL[slot]; +} + + +/* ----------------------------------------------------------------------- */ + +static void waveBitDelay + (unsigned baud, unsigned bits, unsigned stops, unsigned *bitDelay) +{ + unsigned fullBit, last, diff, t, i; + + /* scaled 1000X */ + + fullBit = 1000000000 / baud; + last = 0; + + for (i=0; i<=bits; i++) + { + t = (((i+1)*fullBit)+500)/1000; + diff = t - last; + last = t; + bitDelay[i] = diff; + } + + t = (((bits+1)*fullBit) + ((stops*fullBit)/2) + 500)/1000; + diff = t - last; + bitDelay[i] = diff; +} + +static int waveDelayCBs(uint32_t delay) +{ + uint32_t cbs; + + if (!delay) return 0; + if (gpioCfg.DMAsecondaryChannel < DMA_LITE_FIRST) return 1; + cbs = BPD * delay / DMA_LITE_MAX; + if ((BPD * delay) % DMA_LITE_MAX) cbs++; + return cbs; +} + +/* ----------------------------------------------------------------------- */ + +static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs) +{ + int numCB=0, numBOOL=0, numTOOL=0; + + unsigned i; + + unsigned numWaves; + + rawWave_t *waves; + + numWaves = wfc[wfcur]; + waves = wf [wfcur]; + + /* delay cb at start of DMA */ + + numCB++; + + for (i=0; iinfo = NORMAL_DMA | TIMED_DMA(2); + p->dst = PCM_TIMER; + } + else + { + p->info = NORMAL_DMA | TIMED_DMA(5); + p->dst = PWM_TIMER; + } + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaOBus contains bus addresses, not virtual addresses. + p->src = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + p->length = BPD * 20 / PI_WF_MICROS; /* 20 micros delay */ + p->next = waveCbPOadr(botCB); + + repeatCB = botCB; + + for (i=0; iinfo = 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); + + p = rawWaveCBAdr(botCB++); + + p->info = NORMAL_DMA; + p->src = waveOOLPOadr(botOOL++); + p->dst = ((GPIO_BASE + (GPSET0*4)) & 0x00ffffff) | PI_PERI_BUS; + p->length = 4; + p->next = waveCbPOadr(botCB); + } + if (waves[i].gpioOff && !waves[i].gpioOn) + { + waveSetOOL(botOOL, waves[i].gpioOff); + + p = rawWaveCBAdr(botCB++); + + p->info = NORMAL_DMA; + p->src = waveOOLPOadr(botOOL++); + p->dst = ((GPIO_BASE + (GPCLR0*4)) & 0x00ffffff) | PI_PERI_BUS; + p->length = 4; + p->next = waveCbPOadr(botCB); + } + if (waves[i].flags & WAVE_FLAG_READ) + { + p = rawWaveCBAdr(botCB++); + + p->info = NORMAL_DMA; + p->src = ((GPIO_BASE + (GPLEV0*4)) & 0x00ffffff) | PI_PERI_BUS; + p->dst = waveOOLPOadr(--topOOL); + p->length = 4; + p->next = waveCbPOadr(botCB); + } + + if (waves[i].flags & WAVE_FLAG_TICK) + { + p = rawWaveCBAdr(botCB++); + + p->info = NORMAL_DMA; + p->src = ((SYST_BASE + (SYST_CLO*4)) & 0x00ffffff) | PI_PERI_BUS; + p->dst = waveOOLPOadr(--topOOL); + p->length = 4; + p->next = waveCbPOadr(botCB); + } + + if (waves[i].usDelay) + { + delayLeft = waves[i].usDelay; + + delayCBs = waveDelayCBs(delayLeft); + + for (dcb=0; dcbinfo = NORMAL_DMA | TIMED_DMA(2); + p->dst = PCM_TIMER; + } + else + { + p->info = NORMAL_DMA | TIMED_DMA(5); + p->dst = PWM_TIMER; + } + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaOBus contains bus addresses, not virtual addresses. + p->src = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + + p->length = BPD * delayLeft / PI_WF_MICROS; + + if ((gpioCfg.DMAsecondaryChannel >= DMA_LITE_FIRST) && + (p->length > DMA_LITE_MAX)) + { + p->length = DMA_LITE_MAX; + } + + delayLeft -= (p->length / BPD); + + p->next = waveCbPOadr(botCB); + } + } + } + + 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) + p->next = 0; + else p->next = waveCbPOadr(repeatCB); + } + + status = botCB - *CB; + + *CB = botCB; + *BOOL = botOOL; + *TOOL = topOOL; + + return status; +} + +/* ----------------------------------------------------------------------- */ + +static void waveRxSerial(wfRx_t *w, int level, uint32_t tick) +{ + int diffTicks, lastLevel; + int newWritePos; + + level = level ^ w->s.invert; + + if (w->s.bit >= 0) + { + diffTicks = tick - w->s.startBitTick; + + if (level != PI_TIMEOUT) + { + w->s.level = level; + lastLevel = !level; + } + else lastLevel = w->s.level; + + while ((w->s.bit <= w->s.dataBits) && + (diffTicks > (w->s.nextBitDiff/1000))) + { + if (w->s.bit) + { + if (lastLevel) w->s.data |= (1<<(w->s.bit-1)); + } + else w->s.data = 0; + + ++(w->s.bit); + + w->s.nextBitDiff += w->s.fullBit; + } + + if (w->s.bit > w->s.dataBits) + { + memcpy(w->s.buf + w->s.writePos, &w->s.data, w->s.bytes); + + /* don't let writePos catch readPos */ + + newWritePos = (w->s.writePos + w->s.bytes) % (w->s.bufSize); + + if (newWritePos != w->s.readPos) w->s.writePos = newWritePos; + + if (level == 0) + { + gpioSetWatchdog(w->gpio, w->s.timeout); + w->s.bit = 0; + w->s.startBitTick = tick; + w->s.nextBitDiff = w->s.halfBit; + } + else + { + w->s.bit = -1; + gpioSetWatchdog(w->gpio, 0); + } + } + } + else + { + /* start bit if high->low */ + + if (level == 0) + { + gpioSetWatchdog(w->gpio, w->s.timeout); + w->s.level = 0; + w->s.bit = 0; + w->s.startBitTick = tick; + w->s.nextBitDiff = w->s.halfBit; + } + } +} + + +/* ----------------------------------------------------------------------- */ + +static void waveRxBit(int gpio, int level, uint32_t tick) +{ + switch (wfRx[gpio].mode) + { + case PI_WFRX_SERIAL: + waveRxSerial(&wfRx[gpio], level, tick); + } +} + + +/* ----------------------------------------------------------------------- */ + +int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1) +{ + unsigned inPos1=0, inPos2=0, outPos=0, level = NUM_WAVE_OOL; + + unsigned cbs=0; + + unsigned numIn2, numOut; + + uint32_t tNow, tNext1, tNext2, tDelay, tMax; + + rawWave_t *in2, *out; + + numIn2 = wfc[wfcur]; + in2 = wf[wfcur]; + + numOut = PI_WAVE_MAX_PULSES; + out = wf[1-wfcur]; + + tNow = 0; + tMax = 0; + + if (!numIn1) tNext1 = -1; else tNext1 = 0; + if (!numIn2) tNext2 = -1; else tNext2 = 0; + + while (((inPos1= numIn1) tNext1 = -1; + if (inPos2 >= numIn2) tNext2 = -1; + + } + + if (tNow < tMax) + { + /* extend previous delay */ + out[outPos-1].usDelay += (tMax - tNow); + tNow = tMax; + } + + if ((outPos < numOut) && (outPos < level)) + { + wfStats.micros = tNow; + + if (tNow > wfStats.highMicros) wfStats.highMicros = tNow; + + wfStats.pulses = outPos; + + if (outPos > wfStats.highPulses) wfStats.highPulses = outPos; + + wfStats.cbs = cbs; + + if (cbs > wfStats.highCbs) wfStats.highCbs = cbs; + + wfc[1-wfcur] = outPos; + wfcur = 1 - wfcur; + + return outPos; + } + else return PI_TOO_MANY_PULSES; +} + +/* ======================================================================= */ + +int i2cWriteQuick(unsigned handle, unsigned bit) +{ + int status; + + DBG(DBG_USER, "handle=%d bit=%d", handle, bit); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_QUICK) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (bit > 1) + SOFT_ERROR(PI_BAD_PARAM, "bad bit (%d)", bit); + + status = my_smbus_access( + i2cInfo[handle].fd, bit, 0, PI_I2C_SMBUS_QUICK, NULL); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_WRITE_FAILED; + } + + return status; +} + +int i2cReadByte(unsigned handle) +{ + union my_smbus_data data; + int status; + + DBG(DBG_USER, "handle=%d", handle); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_BYTE) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + status = my_smbus_access( + i2cInfo[handle].fd, PI_I2C_SMBUS_READ, 0, PI_I2C_SMBUS_BYTE, &data); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_READ_FAILED; + } + + return 0xFF & data.byte; +} + + +int i2cWriteByte(unsigned handle, unsigned bVal) +{ + int status; + + DBG(DBG_USER, "handle=%d bVal=%d", handle, bVal); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_BYTE) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (bVal > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad bVal (%d)", bVal); + + status = my_smbus_access( + i2cInfo[handle].fd, + PI_I2C_SMBUS_WRITE, + bVal, + PI_I2C_SMBUS_BYTE, + NULL); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_WRITE_FAILED; + } + + return status; +} + + +int i2cReadByteData(unsigned handle, unsigned reg) +{ + union my_smbus_data data; + int status; + + DBG(DBG_USER, "handle=%d reg=%d", handle, reg); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_BYTE_DATA) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + status = my_smbus_access(i2cInfo[handle].fd, + PI_I2C_SMBUS_READ, reg, PI_I2C_SMBUS_BYTE_DATA, &data); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_READ_FAILED; + } + + return 0xFF & data.byte; +} + + +int i2cWriteByteData(unsigned handle, unsigned reg, unsigned bVal) +{ + union my_smbus_data data; + + int status; + + DBG(DBG_USER, "handle=%d reg=%d bVal=%d", handle, reg, bVal); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_BYTE_DATA) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + if (bVal > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad bVal (%d)", bVal); + + data.byte = bVal; + + status = my_smbus_access( + i2cInfo[handle].fd, + PI_I2C_SMBUS_WRITE, + reg, + PI_I2C_SMBUS_BYTE_DATA, + &data); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_WRITE_FAILED; + } + + return status; +} + + +int i2cReadWordData(unsigned handle, unsigned reg) +{ + union my_smbus_data data; + int status; + + DBG(DBG_USER, "handle=%d reg=%d", handle, reg); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_WORD_DATA) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + status = (my_smbus_access( + i2cInfo[handle].fd, + PI_I2C_SMBUS_READ, + reg, + PI_I2C_SMBUS_WORD_DATA, + &data)); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_READ_FAILED; + } + + return 0xFFFF & data.word; +} + + +int i2cWriteWordData(unsigned handle, unsigned reg, unsigned wVal) +{ + union my_smbus_data data; + + int status; + + DBG(DBG_USER, "handle=%d reg=%d wVal=%d", handle, reg, wVal); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_WORD_DATA) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + if (wVal > 0xFFFF) + SOFT_ERROR(PI_BAD_PARAM, "bad wVal (%d)", wVal); + + data.word = wVal; + + status = my_smbus_access( + i2cInfo[handle].fd, + PI_I2C_SMBUS_WRITE, + reg, + PI_I2C_SMBUS_WORD_DATA, + &data); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_WRITE_FAILED; + } + + return status; +} + + +int i2cProcessCall(unsigned handle, unsigned reg, unsigned wVal) +{ + union my_smbus_data data; + int status; + + DBG(DBG_USER, "handle=%d reg=%d wVal=%d", handle, reg, wVal); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_PROC_CALL) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + if (wVal > 0xFFFF) + SOFT_ERROR(PI_BAD_PARAM, "bad wVal (%d)", wVal); + + data.word = wVal; + + status = (my_smbus_access( + i2cInfo[handle].fd, + PI_I2C_SMBUS_WRITE, + reg, PI_I2C_SMBUS_PROC_CALL, + &data)); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_READ_FAILED; + } + + return 0xFFFF & data.word; +} + + +int i2cReadBlockData(unsigned handle, unsigned reg, char *buf) +{ + union my_smbus_data data; + + int i, status; + + DBG(DBG_USER, "handle=%d reg=%d buf=%08"PRIXPTR, handle, reg, (uintptr_t)buf); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_BLOCK_DATA) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + status = (my_smbus_access( + i2cInfo[handle].fd, + PI_I2C_SMBUS_READ, + reg, + PI_I2C_SMBUS_BLOCK_DATA, + &data)); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_READ_FAILED; + } + else + { + if (data.block[0] <= PI_I2C_SMBUS_BLOCK_MAX) + { + for (i=0; i= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + if ((count < 1) || (count > 32)) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + for (i=1; i<=count; i++) data.block[i] = buf[i-1]; + data.block[0] = count; + + status = my_smbus_access( + i2cInfo[handle].fd, + PI_I2C_SMBUS_WRITE, + reg, + PI_I2C_SMBUS_BLOCK_DATA, + &data); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_WRITE_FAILED; + } + + return status; +} + + +int i2cBlockProcessCall( + unsigned handle, unsigned reg, char *buf, unsigned count) +{ + union my_smbus_data data; + + int i, status; + + DBG(DBG_USER, "handle=%d reg=%d count=%d [%s]", + handle, reg, count, myBuf2Str(count, buf)); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_PROC_CALL) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + if ((count < 1) || (count > 32)) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + for (i=1; i<=count; i++) data.block[i] = buf[i-1]; + data.block[0] = count; + + status = (my_smbus_access( + i2cInfo[handle].fd, PI_I2C_SMBUS_WRITE, reg, + PI_I2C_SMBUS_BLOCK_PROC_CALL, &data)); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_READ_FAILED; + } + else + { + if (data.block[0] <= PI_I2C_SMBUS_BLOCK_MAX) + { + for (i=0; i= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_I2C_BLOCK) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + if ((count < 1) || (count > 32)) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + if (count == 32) + size = PI_I2C_SMBUS_I2C_BLOCK_BROKEN; + else + size = PI_I2C_SMBUS_I2C_BLOCK_DATA; + + data.block[0] = count; + + status = (my_smbus_access( + i2cInfo[handle].fd, PI_I2C_SMBUS_READ, reg, size, &data)); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_READ_FAILED; + } + else + { + if (data.block[0] <= PI_I2C_SMBUS_I2C_BLOCK_MAX) + { + for (i=0; i= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) == 0) + SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver"); + + if (reg > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg); + + if ((count < 1) || (count > 32)) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + for (i=1; i<=count; i++) data.block[i] = buf[i-1]; + + data.block[0] = count; + + status = my_smbus_access( + i2cInfo[handle].fd, + PI_I2C_SMBUS_WRITE, + reg, + PI_I2C_SMBUS_I2C_BLOCK_BROKEN, + &data); + + if (status < 0) + { + DBG(DBG_USER, "error=%d (%m)", status); + return PI_I2C_WRITE_FAILED; + } + + return status; +} + +int i2cWriteDevice(unsigned handle, char *buf, unsigned count) +{ + int bytes; + + DBG(DBG_USER, "handle=%d count=%d [%s]", + handle, count, myBuf2Str(count, buf)); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((count < 1) || (count > PI_MAX_I2C_DEVICE_COUNT)) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + bytes = write(i2cInfo[handle].fd, buf, count); + + if (bytes != count) + { + DBG(DBG_USER, "error=%d (%m)", bytes); + return PI_I2C_WRITE_FAILED; + } + + return 0; +} + +int i2cReadDevice(unsigned handle, char *buf, unsigned count) +{ + int bytes; + + DBG(DBG_USER, "handle=%d count=%d buf=%08"PRIXPTR, + handle, count, (uintptr_t)buf); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if ((count < 1) || (count > PI_MAX_I2C_DEVICE_COUNT)) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + bytes = read(i2cInfo[handle].fd, buf, count); + + if (bytes != count) + { + DBG(DBG_USER, "error=%d (%m)", bytes); + return PI_I2C_READ_FAILED; + } + + return bytes; +} + +int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags) +{ + static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + char dev[32]; + int i, slot, fd; + uint32_t funcs; + + DBG(DBG_USER, "i2cBus=%d i2cAddr=%d flags=0x%X", + i2cBus, i2cAddr, i2cFlags); + + CHECK_INITED; + + if (i2cAddr > PI_MAX_I2C_ADDR) + SOFT_ERROR(PI_BAD_I2C_ADDR, "bad I2C address (%d)", i2cAddr); + + if (i2cFlags) + SOFT_ERROR(PI_BAD_FLAGS, "bad flags (0x%X)", i2cFlags); + + slot = -1; + + pthread_mutex_lock(&mutex); + + for (i=0; i= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].fd >= 0) close(i2cInfo[handle].fd); + + i2cInfo[handle].fd = -1; + i2cInfo[handle].state = PI_I2C_CLOSED; + + return 0; +} + +void i2cSwitchCombined(int setting) +{ + int fd; + + DBG(DBG_USER, "setting=%d", setting); + + fd = open(PI_I2C_COMBINED, O_WRONLY); + + if (fd >= 0) + { + if (setting) + { + if (write(fd, "1\n", 2) == -1) { /* ignore errors */ } + } + else + { + if (write(fd, "0\n", 2) == -1) { /* ignore errors */ } + } + + close(fd); + } +} + +int i2cSegments(unsigned handle, pi_i2c_msg_t *segs, unsigned numSegs) +{ + int retval; + my_i2c_rdwr_ioctl_data_t rdwr; + + DBG(DBG_USER, "handle=%d", handle); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (segs == NULL) + SOFT_ERROR(PI_BAD_POINTER, "null segments"); + + if (numSegs > PI_I2C_RDRW_IOCTL_MAX_MSGS) + SOFT_ERROR(PI_TOO_MANY_SEGS, "too many segments (%d)", numSegs); + + rdwr.msgs = segs; + rdwr.nmsgs = numSegs; + + retval = ioctl(i2cInfo[handle].fd, PI_I2C_RDWR, &rdwr); + + if (retval >= 0) return retval; + else return PI_BAD_I2C_SEG; +} + +int i2cZip( + unsigned handle, + char *inBuf, unsigned inLen, char *outBuf, unsigned outLen) +{ + int numSegs, inPos, outPos, status, bytes, flags, addr; + int esc, setesc; + pi_i2c_msg_t segs[PI_I2C_RDRW_IOCTL_MAX_MSGS]; + + DBG(DBG_USER, "handle=%d inBuf=%s outBuf=%08"PRIXPTR" len=%d", + handle, myBuf2Str(inLen, (char *)inBuf), (uintptr_t)outBuf, outLen); + + CHECK_INITED; + + if (handle >= PI_I2C_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (i2cInfo[handle].state != PI_I2C_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (!inBuf || !inLen) + SOFT_ERROR(PI_BAD_POINTER, "input buffer can't be NULL"); + + if (!outBuf && outLen) + SOFT_ERROR(PI_BAD_POINTER, "output buffer can't be NULL"); + + numSegs = 0; + + inPos = 0; + outPos = 0; + status = 0; + + addr = i2cInfo[handle].addr; + flags = 0; + esc = 0; + setesc = 0; + + while (!status && (inPos < inLen)) + { + DBG(DBG_INTERNAL, "status=%d inpos=%d inlen=%d cmd=%d addr=%d flags=%x", + status, inPos, inLen, inBuf[inPos], addr, flags); + + switch (inBuf[inPos++]) + { + case PI_I2C_END: + status = 1; + break; + + case PI_I2C_COMBINED_ON: + /* Run prior transactions before setting combined flag */ + if (numSegs) + { + status = i2cSegments(handle, segs, numSegs); + if (status >= 0) status = 0; /* continue */ + numSegs = 0; + } + i2cSwitchCombined(1); + break; + + case PI_I2C_COMBINED_OFF: + /* Run prior transactions before clearing combined flag */ + if (numSegs) + { + status = i2cSegments(handle, segs, numSegs); + if (status >= 0) status = 0; /* continue */ + numSegs = 0; + } + i2cSwitchCombined(0); + break; + + case PI_I2C_ADDR: + addr = myI2CGetPar(inBuf, &inPos, inLen, &esc); + if (addr < 0) status = PI_BAD_I2C_CMD; + break; + + case PI_I2C_FLAGS: + /* cheat to force two byte flags */ + esc = 1; + flags = myI2CGetPar(inBuf, &inPos, inLen, &esc); + if (flags < 0) status = PI_BAD_I2C_CMD; + break; + + case PI_I2C_ESC: + setesc = 1; + break; + + case PI_I2C_READ: + + bytes = myI2CGetPar(inBuf, &inPos, inLen, &esc); + + if (bytes >= 0) + { + if ((bytes + outPos) < outLen) + { + segs[numSegs].addr = addr; + segs[numSegs].flags = (flags|1); + segs[numSegs].len = bytes; + segs[numSegs].buf = (uint8_t *)(outBuf + outPos); + outPos += bytes; + numSegs++; + if (numSegs >= PI_I2C_RDRW_IOCTL_MAX_MSGS) + { + status = i2cSegments(handle, segs, numSegs); + if (status >= 0) status = 0; /* continue */ + numSegs = 0; + } + } + else status = PI_BAD_I2C_RLEN; + } + else status = PI_BAD_I2C_RLEN; + break; + + case PI_I2C_WRITE: + + bytes = myI2CGetPar(inBuf, &inPos, inLen, &esc); + + if (bytes >= 0) + { + if ((bytes + inPos) < inLen) + { + segs[numSegs].addr = addr; + segs[numSegs].flags = (flags&0xfffe); + segs[numSegs].len = bytes; + segs[numSegs].buf = (uint8_t *)(inBuf + inPos); + inPos += bytes; + numSegs++; + if (numSegs >= PI_I2C_RDRW_IOCTL_MAX_MSGS) + { + status = i2cSegments(handle, segs, numSegs); + if (status >= 0) status = 0; /* continue */ + numSegs = 0; + } + } + else status = PI_BAD_I2C_WLEN; + } + else status = PI_BAD_I2C_WLEN; + break; + + default: + status = PI_BAD_I2C_CMD; + } + + if (setesc) esc = 1; else esc = 0; + + setesc = 0; + } + + if (status >= 0) + { + if (numSegs) status = i2cSegments(handle, segs, numSegs); + } + + if (status >= 0) status = outPos; + + return status; +} + +/* ======================================================================= */ + +/*SPI */ + +static uint32_t _spiTXBits(char *buf, int pos, int bitlen, int msbf) +{ + uint32_t bits=0; + + if (buf) + { + if (bitlen <= 8) bits = *((( uint8_t*)buf)+pos); + else if (bitlen <= 16) bits = *(((uint16_t*)buf)+pos); + else bits = *(((uint32_t*)buf)+pos); + + if (msbf) bits <<= (32-bitlen); + } + + return bits; +} + +static void _spiRXBits( + char *buf, int pos, int bitlen, int msbf, uint32_t bits) +{ + if (buf) + { + if (!msbf) bits >>= (32-bitlen); + + if (bitlen <= 8) *((( uint8_t*)buf)+pos) = bits; + else if (bitlen <= 16) *(((uint16_t*)buf)+pos) = bits; + else *(((uint32_t*)buf)+pos) = bits; + } +} + +static void spiACS(int channel, int on) +{ + int gpio; + + switch (channel) + { + case 0: gpio = PI_ASPI_CE0; break; + case 1: gpio = PI_ASPI_CE1; break; + default: gpio = PI_ASPI_CE2; break; + } + myGpioWrite(gpio, on); +} + +static void spiGoA( + unsigned speed, /* bits per second */ + uint32_t flags, /* flags */ + char *txBuf, /* tx buffer */ + char *rxBuf, /* rx buffer */ + unsigned count) /* number of bytes */ +{ + int cs; + char bit_ir[4] = {1, 0, 0, 1}; /* read on rising edge */ + char bit_or[4] = {0, 1, 1, 0}; /* write on rising edge */ + char bit_ic[4] = {0, 0, 1, 1}; /* invert clock */ + + int mode, bitlen, txmsbf, rxmsbf, channel; + unsigned txCnt=0; + unsigned rxCnt=0; + uint32_t spiDefaults; + uint32_t statusReg; + int txFull, rxEmpty; + + channel = PI_SPI_FLAGS_GET_CHANNEL(flags); + mode = PI_SPI_FLAGS_GET_MODE (flags); + + bitlen = PI_SPI_FLAGS_GET_BITLEN (flags); + + if (!bitlen) bitlen = 8; + + /* correct count for word size */ + + if (bitlen > 8) count /= 2; + if (bitlen > 16) count /= 2; + + txmsbf = !PI_SPI_FLAGS_GET_TX_LSB (flags); + rxmsbf = !PI_SPI_FLAGS_GET_RX_LSB (flags); + + cs = PI_SPI_FLAGS_GET_CSPOLS(flags) & (1<>28)&15) > 2); + + if (rxCnt < count) + { + if (!rxEmpty) + { + _spiRXBits( + rxBuf, rxCnt++, bitlen, rxmsbf, auxReg[AUX_SPI0_IO_REG]); + } + } + + if (txCnt < count) + { + if (!txFull) + { + if (txCnt != (count-1)) + { + auxReg[AUX_SPI0_TX_HOLD] = + _spiTXBits(txBuf, txCnt++, bitlen, txmsbf); + } + else + { + auxReg[AUX_SPI0_IO_REG] = + _spiTXBits(txBuf, txCnt++, bitlen, txmsbf); + } + } + } + } + + while ((auxReg[AUX_SPI0_STAT_REG] & AUXSPI_STAT_BUSY)) ; + + spiACS(channel, !cs); +} + +static void spiGoS( + unsigned speed, + uint32_t flags, + char *txBuf, + char *rxBuf, + unsigned count) +{ + unsigned txCnt=0; + unsigned rxCnt=0; + unsigned cnt, cnt4w, cnt3w; + uint32_t spiDefaults; + unsigned mode, channel, cspol, cspols, flag3w, ren3w; + + channel = PI_SPI_FLAGS_GET_CHANNEL(flags); + mode = PI_SPI_FLAGS_GET_MODE (flags); + cspols = PI_SPI_FLAGS_GET_CSPOLS(flags); + cspol = (cspols>>channel) & 1; + flag3w = PI_SPI_FLAGS_GET_3WIRE(flags); + ren3w = PI_SPI_FLAGS_GET_3WREN(flags); + + spiDefaults = SPI_CS_MODE(mode) | + SPI_CS_CSPOLS(cspols) | + SPI_CS_CS(channel) | + SPI_CS_CSPOL(cspol) | + SPI_CS_CLEAR(3); + + spiReg[SPI_DLEN] = 2; /* undocumented, stops inter-byte gap */ + + spiReg[SPI_CS] = spiDefaults; /* stop */ + + if (!count) return; + + if (flag3w) + { + if (ren3w < count) + { + cnt4w = ren3w; + cnt3w = count - ren3w; + } + else + { + cnt4w = count; + cnt3w = 0; + } + } + else + { + cnt4w = count; + cnt3w = 0; + } + + spiReg[SPI_CLK] = 250000000/speed; + + spiReg[SPI_CS] = spiDefaults | SPI_CS_TA; /* start */ + + cnt = cnt4w; + + while((txCnt < cnt) || (rxCnt < cnt)) + { + while((rxCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_RXD))) + { + if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO]; + else spi_dummy = spiReg[SPI_FIFO]; + rxCnt++; + } + + while((txCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_TXD))) + { + if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt]; + else spiReg[SPI_FIFO] = 0; + txCnt++; + } + } + + while (!(spiReg[SPI_CS] & SPI_CS_DONE)) ; + + /* now switch to 3-wire bus */ + + cnt += cnt3w; + + spiReg[SPI_CS] |= SPI_CS_REN; + + while((txCnt < cnt) || (rxCnt < cnt)) + { + while((rxCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_RXD))) + { + if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO]; + else spi_dummy = spiReg[SPI_FIFO]; + rxCnt++; + } + + while((txCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_TXD))) + { + if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt]; + else spiReg[SPI_FIFO] = 0; + txCnt++; + } + } + + while (!(spiReg[SPI_CS] & SPI_CS_DONE)) ; + + spiReg[SPI_CS] = spiDefaults; /* stop */ +} + +static void spiGo( + unsigned speed, + uint32_t flags, + char *txBuf, + char *rxBuf, + unsigned count) +{ + static pthread_mutex_t main_mutex = PTHREAD_MUTEX_INITIALIZER; + static pthread_mutex_t aux_mutex = PTHREAD_MUTEX_INITIALIZER; + + if (PI_SPI_FLAGS_GET_AUX_SPI(flags)) + { + pthread_mutex_lock(&aux_mutex); + spiGoA(speed, flags, txBuf, rxBuf, count); + pthread_mutex_unlock(&aux_mutex); + } + else + { + pthread_mutex_lock(&main_mutex); + spiGoS(speed, flags, txBuf, rxBuf, count); + pthread_mutex_unlock(&main_mutex); + } +} + +static int spiAnyOpen(uint32_t flags) +{ + int i, aux; + + aux = PI_SPI_FLAGS_GET_AUX_SPI(flags); + + for (i=0; i= i) + SOFT_ERROR(PI_BAD_SPI_CHANNEL, "bad spiChan (%d)", spiChan); + + if ((baud < PI_SPI_MIN_BAUD) || (baud > PI_SPI_MAX_BAUD)) + SOFT_ERROR(PI_BAD_SPI_SPEED, "bad baud (%d)", baud); + + if (spiFlags > (1<<22)) + SOFT_ERROR(PI_BAD_FLAGS, "bad spiFlags (0x%X)", spiFlags); + + if (!spiAnyOpen(spiFlags)) /* initialise on first open */ + { + spiInit(spiFlags); + spiGo(baud, spiFlags, NULL, NULL, 0); + } + + slot = -1; + + pthread_mutex_lock(&mutex); + + for (i=0; i= PI_SPI_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (spiInfo[handle].state != PI_SPI_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + spiInfo[handle].state = PI_SPI_CLOSED; + + if (!spiAnyOpen(spiInfo[handle].flags)) + spiTerm(spiInfo[handle].flags); /* terminate on last close */ + + return 0; +} + +int spiRead(unsigned handle, char *buf, unsigned count) +{ + DBG(DBG_USER, "handle=%d count=%d [%s]", + handle, count, myBuf2Str(count, buf)); + + CHECK_INITED; + + if (handle >= PI_SPI_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (spiInfo[handle].state != PI_SPI_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (count > PI_MAX_SPI_DEVICE_COUNT) + SOFT_ERROR(PI_BAD_SPI_COUNT, "bad count (%d)", count); + + spiGo(spiInfo[handle].speed, spiInfo[handle].flags, NULL, buf, count); + + return count; +} + +int spiWrite(unsigned handle, char *buf, unsigned count) +{ + DBG(DBG_USER, "handle=%d count=%d [%s]", + handle, count, myBuf2Str(count, buf)); + + CHECK_INITED; + + if (handle >= PI_SPI_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (spiInfo[handle].state != PI_SPI_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (count > PI_MAX_SPI_DEVICE_COUNT) + SOFT_ERROR(PI_BAD_SPI_COUNT, "bad count (%d)", count); + + spiGo(spiInfo[handle].speed, spiInfo[handle].flags, buf, NULL, count); + + return count; +} + +int spiXfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count) +{ + DBG(DBG_USER, "handle=%d count=%d [%s]", + handle, count, myBuf2Str(count, txBuf)); + + CHECK_INITED; + + if (handle >= PI_SPI_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (spiInfo[handle].state != PI_SPI_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (count > PI_MAX_SPI_DEVICE_COUNT) + SOFT_ERROR(PI_BAD_SPI_COUNT, "bad count (%d)", count); + + spiGo(spiInfo[handle].speed, spiInfo[handle].flags, txBuf, rxBuf, count); + + return count; +} + +/* ======================================================================= */ + + +int serOpen(char *tty, unsigned serBaud, unsigned serFlags) +{ + static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + struct termios new; + int speed; + int fd; + int i, slot; + + DBG(DBG_USER, "tty=%s serBaud=%d serFlags=0x%X", tty, serBaud, serFlags); + + SER_CHECK_INITED; + + if (strncmp("/dev/tty", tty, 8) && strncmp("/dev/serial", tty, 11)) + SOFT_ERROR(PI_BAD_SER_DEVICE, "bad device (%s)", tty); + + switch (serBaud) + { + case 50: speed = B50; break; + case 75: speed = B75; break; + case 110: speed = B110; break; + case 134: speed = B134; break; + case 150: speed = B150; break; + case 200: speed = B200; break; + case 300: speed = B300; break; + case 600: speed = B600; break; + case 1200: speed = B1200; break; + case 1800: speed = B1800; break; + case 2400: speed = B2400; break; + case 4800: speed = B4800; break; + case 9600: speed = B9600; break; + case 19200: speed = B19200; break; + case 38400: speed = B38400; break; + case 57600: speed = B57600; break; + case 115200: speed = B115200; break; + case 230400: speed = B230400; break; + + default: + SOFT_ERROR(PI_BAD_SER_SPEED, "bad speed (%d)", serBaud); + } + + if (serFlags) + SOFT_ERROR(PI_BAD_FLAGS, "bad flags (0x%X)", serFlags); + + slot = -1; + + pthread_mutex_lock(&mutex); + + for (i=0; i= PI_SER_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (serInfo[handle].state != PI_SER_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (serInfo[handle].fd >= 0) close(serInfo[handle].fd); + + serInfo[handle].fd = -1; + serInfo[handle].state = PI_SER_CLOSED; + + return 0; +} + +int serWriteByte(unsigned handle, unsigned bVal) +{ + char c; + + DBG(DBG_USER, "handle=%d bVal=%d", handle, bVal); + + SER_CHECK_INITED; + + if (handle >= PI_SER_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (serInfo[handle].state != PI_SER_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (bVal > 0xFF) + SOFT_ERROR(PI_BAD_PARAM, "bad parameter (%d)", bVal); + + c = bVal; + + if (write(serInfo[handle].fd, &c, 1) != 1) + return PI_SER_WRITE_FAILED; + else + return 0; +} + +int serReadByte(unsigned handle) +{ + int r; + char x; + + DBG(DBG_USER, "handle=%d", handle); + + SER_CHECK_INITED; + + if (handle >= PI_SER_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (serInfo[handle].state != PI_SER_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + r = read(serInfo[handle].fd, &x, 1); + + if (r == 1) + return ((int)x) & 0xFF; + + else if (r == 0) + return PI_SER_READ_NO_DATA; + + else if ((r == -1) && (errno == EAGAIN)) + return PI_SER_READ_NO_DATA; + + else + return PI_SER_READ_FAILED; +} + +int serWrite(unsigned handle, char *buf, unsigned count) +{ + int written=0, wrote=0; + + DBG(DBG_USER, "handle=%d count=%d [%s]", + handle, count, myBuf2Str(count, buf)); + + SER_CHECK_INITED; + + if (handle >= PI_SER_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (serInfo[handle].state != PI_SER_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (!count) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + while ((written != count) && (wrote >= 0)) + { + wrote = write(serInfo[handle].fd, buf+written, count-written); + + if (wrote >= 0) + { + written += wrote; + + if (written != count) time_sleep(0.05); + } + } + + if (written != count) + return PI_SER_WRITE_FAILED; + else + return 0; +} + +int serRead(unsigned handle, char *buf, unsigned count) +{ + int r; + + DBG(DBG_USER, "handle=%d count=%d buf=0x%"PRIXPTR, handle, count, (uintptr_t)buf); + + SER_CHECK_INITED; + + if (handle >= PI_SER_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (serInfo[handle].state != PI_SER_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (!count) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + r = read(serInfo[handle].fd, buf, count); + + if (r == -1) + { + if (errno == EAGAIN) + return PI_SER_READ_NO_DATA; + else + return PI_SER_READ_FAILED; + } + else + { + if (r < count) buf[r] = 0; + return r; + } +} + +int serDataAvailable(unsigned handle) +{ + int result; + + DBG(DBG_USER, "handle=%d", handle); + + SER_CHECK_INITED; + + if (handle >= PI_SER_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (serInfo[handle].state != PI_SER_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (ioctl(serInfo[handle].fd, FIONREAD, &result) == -1) return 0; + + return result; +} + +/* ======================================================================= */ + +static int chooseBestClock + (clkInf_t *clkInf, unsigned f, unsigned numc, unsigned *cf) +{ + int c, valid; + double fdiv, offby, best_offby; + unsigned div, frac; + + valid = 0; + best_offby = 0; + + for (c=0; c 1) && (div < 4096)) + { + offby = f - (cf[c] / (div + (frac / 4096.0))); + if (offby < 0) offby = - offby; + if ((!valid) || (offby <= best_offby)) + { + valid = 1; + clkInf->div = div; + clkInf->frac = frac; + clkInf->clock = c; + best_offby = offby; + } + } + } + return valid; +} + +/* ======================================================================= */ + +static rawCbs_t * dmaCB2adr(int pos) +{ + int page, slot; + + page = pos/CBS_PER_IPAGE; + slot = pos%CBS_PER_IPAGE; + + return &dmaIVirt[page]->cb[slot]; +} + +/* ----------------------------------------------------------------------- */ + +static void dmaCbPrint(int pos) +{ + rawCbs_t * p; + + p = dmaCB2adr(pos); + + fprintf(stderr, "i=%x s=%x d=%x len=%x s=%x nxt=%x\n", + p->info, p->src, p->dst, p->length, p->stride, p->next); +} + +/* ----------------------------------------------------------------------- */ + +static unsigned dmaNowAtICB(void) +{ + unsigned cb; + static unsigned lastPage=0; + unsigned page; + uint32_t cbAddr; + uint32_t startTick, endTick; + + startTick = systReg[SYST_CLO]; + + cbAddr = dmaIn[DMA_CONBLK_AD]; + + page = lastPage; + + /* which page are we dma'ing? */ + + while (1) + { + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + cb = (cbAddr - ((int)(uintptr_t)dmaIBus[page])) / 32; + + if (cb < CBS_PER_IPAGE) + { + endTick = systReg[SYST_CLO]; + + if (endTick != startTick) + gpioStats.cbTicks += (endTick - startTick); + + gpioStats.cbCalls++; + + lastPage = page; + + return (page*CBS_PER_IPAGE) + cb; + } + + if (page++ >= DMAI_PAGES) page=0; + + if (page == lastPage) break; + } + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +static int dmaNowAtOCB(void) +{ + unsigned cb; + unsigned page; + uint32_t cbAddr; + + cbAddr = dmaOut[DMA_CONBLK_AD]; + + if (!cbAddr) return -PI_NO_TX_WAVE; + + page = 0; + + /* which page are we dma'ing? */ + + while (1) + { + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + cb = (cbAddr - ((int)(uintptr_t)dmaOBus[page])) / 32; + + if (cb < CBS_PER_OPAGE) return (page*CBS_PER_OPAGE) + cb; + + if (page++ >= DMAO_PAGES) break; + } + + /* Try twice */ + + cbAddr = dmaOut[DMA_CONBLK_AD]; + + if (!cbAddr) return -PI_NO_TX_WAVE; + + page = 0; + + /* which page are we dma'ing? */ + + while (1) + { + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + cb = (cbAddr - ((int)(uintptr_t)dmaOBus[page])) / 32; + + if (cb < CBS_PER_OPAGE) return (page*CBS_PER_OPAGE) + cb; + + if (page++ >= DMAO_PAGES) break; + } + + return -PI_WAVE_NOT_FOUND; +} + +/* ----------------------------------------------------------------------- */ + +unsigned rawWaveCB(void) +{ + unsigned cb; + static unsigned lastPage=0; + unsigned page; + uint32_t cbAddr; + + cbAddr = dmaOut[DMA_CONBLK_AD]; + + if (!cbAddr) return -1; + + page = lastPage; + + /* which page are we dma'ing? */ + + while (1) + { + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + cb = (cbAddr - ((int)(uintptr_t)dmaOBus[page])) / 32; + + if (cb < CBS_PER_OPAGE) + { + lastPage = page; + + return (page*CBS_PER_OPAGE) + cb; + } + + if (page++ >= DMAO_PAGES) page=0; + + if (page == lastPage) break; + } + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +static unsigned dmaCurrentSlot(unsigned pos) +{ + unsigned cycle=0, slot=0, tmp; + + cycle = (pos/CBS_PER_CYCLE); + tmp = (pos%CBS_PER_CYCLE); + + if (tmp > 2) slot = ((tmp-2)/3); + + return (cycle*PULSE_PER_CYCLE)+slot; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t dmaPwmDataAdr(int pos) +{ + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + return (uint32_t)(uintptr_t) &dmaIBus[pos]->periphData; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t dmaGpioOnAdr(int pos) +{ + int page, slot; + + page = pos/ON_PER_IPAGE; + slot = pos%ON_PER_IPAGE; + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + return (uint32_t)(uintptr_t) &dmaIBus[page]->gpioOn[slot]; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t dmaGpioOffAdr(int pos) +{ + int page, slot; + + myOffPageSlot(pos, &page, &slot); + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + return (uint32_t)(uintptr_t) &dmaIBus[page]->gpioOff[slot]; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t dmaTickAdr(int pos) +{ + int page, slot; + + myTckPageSlot(pos, &page, &slot); + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + return (uint32_t)(uintptr_t) &dmaIBus[page]->tick[slot]; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t dmaReadLevelsAdr(int pos) +{ + int page, slot; + + myLvsPageSlot(pos, &page, &slot); + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + return (uint32_t)(uintptr_t) &dmaIBus[page]->level[slot]; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t dmaCbAdr(int pos) +{ + int page, slot; + + page = (pos/CBS_PER_IPAGE); + slot = (pos%CBS_PER_IPAGE); + + //cast twice to suppress compiler warning, I belive this cast is ok + //because dmaIbus contains bus addresses, not user addresses. --plugwash + return (uint32_t)(uintptr_t) &dmaIBus[page]->cb[slot]; +} + +/* ----------------------------------------------------------------------- */ + +static void dmaGpioOnCb(int b, int pos) +{ + rawCbs_t * p; + + p = dmaCB2adr(b); + + p->info = NORMAL_DMA; + p->src = dmaGpioOnAdr(pos); + p->dst = ((GPIO_BASE + (GPSET0*4)) & 0x00ffffff) | PI_PERI_BUS; + p->length = 4; + p->next = dmaCbAdr(b+1); +} + +/* ----------------------------------------------------------------------- */ + +static void dmaTickCb(int b, int pos) +{ + rawCbs_t * p; + + p = dmaCB2adr(b); + + p->info = NORMAL_DMA; + p->src = ((SYST_BASE + (SYST_CLO*4)) & 0x00ffffff) | PI_PERI_BUS; + p->dst = dmaTickAdr(pos); + p->length = 4; + p->next = dmaCbAdr(b+1); +} + +/* ----------------------------------------------------------------------- */ + +static void dmaGpioOffCb(int b, int pos) +{ + rawCbs_t * p; + + p = dmaCB2adr(b); + + p->info = NORMAL_DMA; + p->src = dmaGpioOffAdr(pos); + p->dst = ((GPIO_BASE + (GPCLR0*4)) & 0x00ffffff) | PI_PERI_BUS; + p->length = 4; + p->next = dmaCbAdr(b+1); +} + +/* ----------------------------------------------------------------------- */ + +static void dmaReadLevelsCb(int b, int pos) +{ + rawCbs_t * p; + + p = dmaCB2adr(b); + + p->info = NORMAL_DMA; + p->src = ((GPIO_BASE + (GPLEV0*4)) & 0x00ffffff) | PI_PERI_BUS; + p->dst = dmaReadLevelsAdr(pos); + p->length = 4; + p->next = dmaCbAdr(b+1); +} + +/* ----------------------------------------------------------------------- */ + +static void dmaDelayCb(int b) +{ + rawCbs_t * p; + + p = dmaCB2adr(b); + + if (gpioCfg.clockPeriph == PI_CLOCK_PCM) + { + p->info = NORMAL_DMA | TIMED_DMA(2); + p->dst = PCM_TIMER; + } + else + { + p->info = NORMAL_DMA | TIMED_DMA(5); + p->dst = PWM_TIMER; + } + + p->src = dmaPwmDataAdr(b%DMAI_PAGES); + p->length = 4; + p->next = dmaCbAdr(b+1); +} + +/* ----------------------------------------------------------------------- */ + +static void dmaInitCbs(void) +{ + int b, pulse, level, cycle; + + rawCbs_t * p; + + /* set up the DMA control blocks */ + + DBG(DBG_STARTUP, ""); + + gpioStats.dmaInitCbsCount++; + + b = -1; + level = 0; + + for (cycle=0; cyclenext = dmaCbAdr(0); + + DBG(DBG_STARTUP, "DMA page type count = %zd", sizeof(dmaIPage_t)); + + DBG(DBG_STARTUP, "%d control blocks (exp=%d)", b+1, NUM_CBS); +} + +/* ======================================================================= */ + + +static void sigHandler(int signum) +{ + if ((signum >= PI_MIN_SIGNUM) && (signum <= PI_MAX_SIGNUM)) + { + if (gpioSignal[signum].func) + { + if (gpioSignal[signum].ex) + { + (gpioSignal[signum].func)(signum, gpioSignal[signum].userdata); + } + else + { + (gpioSignal[signum].func)(signum); + } + } + else + { + switch(signum) + { + case SIGUSR1: + + if (gpioCfg.dbgLevel > DBG_MIN_LEVEL) --gpioCfg.dbgLevel; + else gpioCfg.dbgLevel = DBG_MIN_LEVEL; + DBG(DBG_USER, "Debug level %d\n", gpioCfg.dbgLevel); + break; + + case SIGUSR2: + if (gpioCfg.dbgLevel < DBG_MAX_LEVEL) ++gpioCfg.dbgLevel; + else gpioCfg.dbgLevel = DBG_MAX_LEVEL; + DBG(DBG_USER, "Debug level %d\n", gpioCfg.dbgLevel); + break; + + case SIGPIPE: + case SIGWINCH: + DBG(DBG_USER, "signal %d ignored", signum); + break; + + case SIGCHLD: + /* Used to notify threads of events */ + break; + + default: + DBG(DBG_ALWAYS, "Unhandled signal %d, terminating\n", signum); + gpioTerminate(); + exit(-1); + } + } + } + else + { + /* exit */ + + DBG(DBG_ALWAYS, "Unhandled signal %d, terminating\n", signum); + gpioTerminate(); + exit(-1); + } +} + +/* ----------------------------------------------------------------------- */ + +static void sigSetHandler(void) +{ + int i; + struct sigaction new; + + for (i=PI_MIN_SIGNUM; i<=PI_MAX_SIGNUM; i++) + { + + memset(&new, 0, sizeof(new)); + new.sa_handler = sigHandler; + + sigaction(i, &new, NULL); + } +} + +/* + freq mics net + 0 1000 1000 900 + 1 4000 250 225 + 2 3750 266 240 + 3 3500 285 257 + 4 3250 307 276 + 5 3000 333 300 + 6 2750 363 327 + 7 2500 400 360 + 8 2250 444 400 + 9 2000 500 450 +10 1750 571 514 +11 1500 666 600 +12 1250 800 720 +13 1000 1000 900 +14 750 1333 1200 +15 500 2000 1800 +*/ + +unsigned alert_delays[]= +{ + 900000, 225000, 240000, 257142, 276923, 300000, 327272, 360000, + 400000, 450000, 514285, 600000, 720000, 900000, 1200000, 1800000 +}; + +/* ======================================================================= */ + +static void alertGlitchFilter(gpioSample_t *sample, int numSamples) +{ + int i, j, diff; + uint32_t steadyUs, changedTick, RBitV, LBitV, initialised; + uint32_t bit, bitV; + + for (i=0; i<=PI_MAX_USER_GPIO; i++) + { + bit = (1< 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; + changedTick = gpioAlert[i].gfTick; + + for (j=0; j= steadyUs) + { + /* Level stable for steady period. */ + RBitV = bitV; + } + else + { + /* Keep reporting old level. */ + + sample[j].level ^= bit; + } + } + + } + + gpioAlert[i].gfRBitV = RBitV; + gpioAlert[i].gfLBitV = LBitV; + gpioAlert[i].gfTick = changedTick; + } + } +} + +static void alertNoiseFilter(gpioSample_t *sample, int numSamples) +{ + int i, j, diff; + uint32_t LBitV; + uint32_t bit, bitV; + uint32_t nowTick; + + for (i=0; i<=PI_MAX_USER_GPIO; i++) + { + bit = (1<= 0) + { + /* Stop reporting gpio changes */ + + gpioAlert[i].nfActive = 0; + gpioAlert[i].nfTick1 = nowTick; + } + } + else /* waiting for steady us */ + { + if (bitV != LBitV) + { + diff = nowTick - gpioAlert[i].nfTick1; + gpioAlert[i].nfTick1 = nowTick; + + if (diff >= gpioAlert[i].nfSteadyUs) + { + /* Start reporting gpio changes */ + + gpioAlert[i].nfRBitV = LBitV; + gpioAlert[i].nfActive = 1; + gpioAlert[i].nfTick2 = + nowTick + gpioAlert[i].nfActiveUs; + } + } + } + + if (!gpioAlert[i].nfActive) + { + if (bitV != gpioAlert[i].nfRBitV) + sample[j].level ^= bit; + } + + LBitV = bitV; + } + + gpioAlert[i].nfLBitV = LBitV; + + } + } +} + +static void alertEmit( + gpioSample_t *sample, int numSamples, uint32_t changedBits, uint32_t eTick) +{ + uint32_t oldLevel, newLevel; + int32_t diff; + int emit, seqno, emitted; + uint32_t changes, bits, timeoutBits, eventBits; + int d; + int b, n, v; + int err; + int max_emits; + char fifo[32]; + /* ensure space for maximum number of watchdog and event notifications */ + gpioReport_t report[MAX_REPORT+PI_MAX_USER_GPIO+1+PI_MAX_EVENT+1]; + + if (changedBits) + { + if (gpioGetSamples.func) + { + if (gpioGetSamples.ex) + { + (gpioGetSamples.func) + (sample, numSamples, gpioGetSamples.userdata); + } + else + { + (gpioGetSamples.func)(sample, numSamples); + } + } + } + + eventBits = 0; + + if (bscFR != (bscsReg[BSC_FR]&0xffff)) + { + bscFR = bscsReg[BSC_FR]&0xffff; + eventAlert[PI_EVENT_BSC].fired = 1; + } + + for (b=0; b<=PI_MAX_EVENT; b++) + { + if (eventAlert[b].fired && (!eventAlert[b].ignore)) + { + eventBits |= (1<= gpioAlert[b].wdSteadyUs) + { + timeoutBits |= (1<= PI_NOTIFY_OPENED) + { + bits = gpioNotify[n].bits; + + emit = 0; + + seqno = gpioNotify[n].seqno; + + if (gpioNotify[n].state == PI_NOTIFY_RUNNING) + { + /* check to see if any bits have changed for this + notification. + + bits is the set of notification bits + changedBits is the set of changed bits + */ + + if (changedBits & bits) + { + oldLevel = reportedLevel & bits; + + for (d=0; d 60000000) + { + if (numSamples) + newLevel = sample[numSamples-1].level; + else + newLevel = reportedLevel; + + report[emit].seqno = seqno; + report[emit].flags = PI_NTFY_FLAGS_ALIVE; + report[emit].tick = eTick; + report[emit].level = newLevel; + + emit++; + seqno++; + } + } + + if (emit) + { + DBG(DBG_FAST_TICK, "notification %d (%d reports, %x-%x)", + n, emit, report[0].seqno, report[emit-1].seqno); + gpioNotify[n].lastReportTick = eTick; + max_emits = gpioNotify[n].max_emits; + + if (emit > gpioStats.maxEmit) gpioStats.maxEmit = emit; + + emitted = 0; + + while (emit > 0) + { + if (emit > max_emits) + { + gpioStats.emitFrags++; + + err = write(gpioNotify[n].fd, + report+emitted, + max_emits*sizeof(gpioReport_t)); + + if (err != (max_emits*sizeof(gpioReport_t))) + { + if (err < 0) + { + if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) + { + /* serious error, no point continuing */ + + DBG(DBG_ALWAYS, "fd=%d err=%d errno=%d", + gpioNotify[n].fd, err, errno); + + DBG(DBG_ALWAYS, "%s", strerror(errno)); + + gpioNotify[n].bits = 0; + gpioNotify[n].state = PI_NOTIFY_CLOSING; + intNotifyBits(); + break; + } + else gpioStats.wouldBlockPipeWrite++; + } + else + { + gpioStats.shortPipeWrite++; + DBG(DBG_ALWAYS, "emitted %zd, asked for %d", + err/sizeof(gpioReport_t), max_emits); + } + } + else + { + gpioStats.goodPipeWrite++; + } + + emitted += max_emits; + emit -= max_emits; + } + else + { + err = write(gpioNotify[n].fd, + report+emitted, + emit*sizeof(gpioReport_t)); + + if (err != (emit*sizeof(gpioReport_t))) + { + if (err < 0) + { + if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) + { + DBG(DBG_ALWAYS, "fd=%d err=%d errno=%d", + gpioNotify[n].fd, err, errno); + + DBG(DBG_ALWAYS, "%s", strerror(errno)); + + /* serious error, no point continuing */ + gpioNotify[n].bits = 0; + gpioNotify[n].state = PI_NOTIFY_CLOSING; + intNotifyBits(); + break; + } + else gpioStats.wouldBlockPipeWrite++; + } + else + { + gpioStats.shortPipeWrite++; + DBG(DBG_ALWAYS, "emitted %zd, asked for %d", + err/sizeof(gpioReport_t), emit); + } + } + else + { + gpioStats.goodPipeWrite++; + } + + emitted += emit; + emit = 0; + } + } + + gpioNotify[n].seqno = seqno; + } + } + } + + if (changedBits & scriptBits) + { + for (n=0; n= PULSE_PER_CYCLE) + { + pulse = 0; + + if (++cycle >= bufferCycles) + { + cycle = 0; + oldSlot = 0; + } + + expected = sTick; + + sTick = myGetTick(cycle); + + if (stickInited) + { + diff = sTick - expected; + + if (abs(diff) > minDiff) + { + ft = sample[numSamples-PULSE_PER_CYCLE].tick; + + ticks = sTick - ft; + + for (i=1; i= TICKSLOTS) + { + gpioStats.diffTick[TICKSLOTS-1]++; + } + + else gpioStats.diffTick[diff]++; + } + else + { + stickInited = 1; + numSamples = 0; + if (!(gpioCfg.ifFlags & PI_DISABLE_ALERT)) + { + pthAlertRunning = PI_THREAD_RUNNING; + } + } + } + } + + if (oldSlot == newSlot) moreToDo = 0; else moreToDo = 1; + + /* Apply glitch filter */ + + if (numSamples && gFilterBits) alertGlitchFilter(sample, numSamples); + + /* Apply noise filter */ + + if (numSamples && nFilterBits) alertNoiseFilter(sample, numSamples); + + /* Compact samples */ + + changedBits = 0; + oldLevel &= monitorBits; + reports = 0; + totalSamples = 0; + + for (rp=0; rp= MAX_REPORT) + { + totalSamples += reports; + + /* Rebase watchdog timeouts */ + if (wdogBits) alertWdogCheck(sample, reports); + + gpioStats.numSamples += reports; + + alertEmit(sample, reports, changedBits, sample[rp].tick); + + changedBits = 0; + reports = 0; + } + } + } + + if (reports) + { + totalSamples += reports; + + /* Rebase watchdog timeouts */ + if (wdogBits) alertWdogCheck(sample, reports); + + gpioStats.numSamples += reports; + } + + alertEmit(sample, reports, changedBits, sTick); + reportedLevel = sample[numSamples -1].level; + + if (totalSamples > gpioStats.maxSamples) + gpioStats.maxSamples = numSamples; + + req.tv_sec = 0; + req.tv_nsec = alert_delays[(gpioCfg.internals>>PI_CFG_ALERT_FREQ)&15]; + + if (moreToDo) + { + gpioStats.moreToDo++; + } + else + { + gpioStats.alertTicks++; + + while (nanosleep(&req, &rem)) + { + req.tv_sec = rem.tv_sec; + req.tv_nsec = rem.tv_nsec; + } + } + } + + return 0; +} + +/* ======================================================================= */ + +static int scrPop(gpioScript_t *s, int *SP, int *S) +{ + if ((*SP) > 0) + { + return S[--(*SP)]; + } + else + { + s->run_state = PI_SCRIPT_FAILED; + DBG(DBG_ALWAYS, "script %d too many pops", s->id); + return 0; + } +} + +/* ----------------------------------------------------------------------- */ + +static void scrPush(gpioScript_t *s, int *SP, int *S, int val) +{ + if ((*SP) < PI_SCRIPT_STACK_SIZE) + { + S[(*SP)++] = val; + } + else + { + s->run_state = PI_SCRIPT_FAILED; + DBG(DBG_ALWAYS, "script %d too many pushes", s->id); + } +} + +/* ----------------------------------------------------------------------- */ + +static void scrSwap(int *v1, int *v2) +{ + int t; + + t=*v1; *v1=*v2; *v2= t; +} + +/* ----------------------------------------------------------------------- */ + +static int scrEvtWait(gpioScript_t *s, uint32_t bits) +{ + pthread_mutex_lock(&s->pthMutex); + + if (s->request == PI_SCRIPT_RUN) + { + s->run_state = PI_SCRIPT_WAITING; + s->eventBits = bits; + intScriptEventBits(); + + pthread_cond_wait(&s->pthCond, &s->pthMutex); + + s->waitBits = 0; + intScriptEventBits(); + s->run_state = PI_SCRIPT_RUNNING; + } + + pthread_mutex_unlock(&s->pthMutex); + + return s->changedBits; +} + +/* ----------------------------------------------------------------------- */ + +static int scrWait(gpioScript_t *s, uint32_t bits) +{ + pthread_mutex_lock(&s->pthMutex); + + if (s->request == PI_SCRIPT_RUN) + { + s->run_state = PI_SCRIPT_WAITING; + s->waitBits = bits; + intScriptBits(); + + pthread_cond_wait(&s->pthCond, &s->pthMutex); + + s->waitBits = 0; + intScriptBits(); + s->run_state = PI_SCRIPT_RUNNING; + } + + pthread_mutex_unlock(&s->pthMutex); + + return s->changedBits; +} + +/* ----------------------------------------------------------------------- */ + +static int scrSys(char *cmd, uint32_t p1, uint32_t p2) +{ + char buf[1024]; + int status; + + if (!myScriptNameValid(cmd)) + SOFT_ERROR(PI_BAD_SCRIPT_NAME, "bad script name (%s)", cmd); + + snprintf(buf, sizeof(buf), "/opt/pigpio/cgi/%s %u %u", cmd, p1, p2); + + DBG(DBG_USER, "%s", buf); + + status = system(buf); + + if (status < 0) status = PI_BAD_SHELL_STATUS; + + return status; +} + +/* ----------------------------------------------------------------------- */ + +static void *pthScript(void *x) +{ + gpioScript_t *s; + cmdInstr_t instr; + int p1, p2, p1o, p2o, p3o, *t1, *t2; + int PC, A, F, SP; + int S[PI_SCRIPT_STACK_SIZE]; + char buf[CMD_MAX_EXTENSION]; + + + S[0] = 0; /* to prevent compiler warning */ + + s = x; + + while ((volatile int)s->request != PI_SCRIPT_DELETE) + { + pthread_mutex_lock(&s->pthMutex); + s->run_state = PI_SCRIPT_HALTED; + pthread_cond_wait(&s->pthCond, &s->pthMutex); + pthread_mutex_unlock(&s->pthMutex); + + s->run_state = PI_SCRIPT_RUNNING; + + A = 0; + F = 0; + PC = 0; + SP = 0; + + while (((volatile int)s->request == PI_SCRIPT_RUN ) && + (s->run_state == PI_SCRIPT_RUNNING)) + { + instr = s->script.instr[PC]; + + p1o = instr.p[1]; + p2o = instr.p[2]; + + if (instr.opt[1] == CMD_VAR) instr.p[1] = s->script.var[p1o]; + else if (instr.opt[1] == CMD_PAR) instr.p[1] = s->script.par[p1o]; + + if (instr.opt[2] == CMD_VAR) instr.p[2] = s->script.var[p2o]; + else if (instr.opt[2] == CMD_PAR) instr.p[2] = s->script.par[p2o]; +/* + fprintf(stderr, "PC=%d cmd=%d p1o=%d p1=%d p2o=%d p2=%d\n", + PC, instr.p[0], p1o, instr.p[1], p2o, instr.p[2]); + fflush(stderr); +*/ + if (instr.p[0] < PI_CMD_SCRIPT) + { + if (instr.p[3]) + { + if ((instr.p[3] == sizeof(int)) && ((instr.opt[3] == CMD_VAR) || (instr.opt[3] == CMD_PAR))) + { + /* Hack to allow register use in 3rd parameter */ + memcpy((char*)&p3o, (char *)instr.p[4], sizeof(int)); + if (instr.opt[3] == CMD_VAR) memcpy(buf, (char *)&(s->script.var[p3o]), sizeof(int)); + else memcpy(buf, (char *)&(s->script.par[p3o]), sizeof(int)); + } + else + { + memcpy(buf, (char *)instr.p[4], instr.p[3]); + } + } + + A = myDoCommand(instr.p, sizeof(buf)-1, buf); + + F = A; + + PC++; + } + else + { + p1 = instr.p[1]; + p2 = instr.p[2]; + + switch (instr.p[0]) + { + case PI_CMD_ADD: A+=p1; F=A; PC++; break; + + case PI_CMD_AND: A&=p1; F=A; PC++; break; + + case PI_CMD_CALL: scrPush(s, &SP, S, PC+1); PC = p1; break; + + case PI_CMD_CMP: F=A-p1; PC++; break; + + case PI_CMD_DCR: + if (instr.opt[1] == CMD_PAR) + {--s->script.par[p1o]; F=s->script.par[p1o];} + else + {--s->script.var[p1o]; F=s->script.var[p1o];} + PC++; + break; + + case PI_CMD_DCRA: --A; F=A; PC++; break; + + case PI_CMD_DIV: A/=p1; F=A; PC++; break; + + case PI_CMD_HALT: s->run_state = PI_SCRIPT_HALTED; break; + + case PI_CMD_EVTWT: A=scrEvtWait(s, p1); F=A; PC++; break; + + case PI_CMD_INR: + if (instr.opt[1] == CMD_PAR) + {++s->script.par[p1o]; F=s->script.par[p1o];} + else + {++s->script.var[p1o]; F=s->script.var[p1o];} + PC++; + break; + + case PI_CMD_INRA: ++A; F=A; PC++; break; + + case PI_CMD_JM: if (F<0) PC=p1; else PC++; break; + + case PI_CMD_JMP: PC=p1; break; + + case PI_CMD_JNZ: if (F) PC=p1; else PC++; break; + + case PI_CMD_JP: if (F>=0) PC=p1; else PC++; break; + + case PI_CMD_JZ: if (!F) PC=p1; else PC++; break; + + case PI_CMD_LD: + if (instr.opt[1] == CMD_PAR) s->script.par[p1o]=p2; + else s->script.var[p1o]=p2; + PC++; + break; + + case PI_CMD_LDA: A=p1; PC++; break; + + case PI_CMD_LDAB: + if ((p1 >= 0) && (p1 < sizeof(buf))) A = buf[p1]; + PC++; + break; + + case PI_CMD_MLT: A*=p1; F=A; PC++; break; + + case PI_CMD_MOD: A%=p1; F=A; PC++; break; + + case PI_CMD_OR: A|=p1; F=A; PC++; break; + + case PI_CMD_POP: + if (instr.opt[1] == CMD_PAR) + s->script.par[p1o]=scrPop(s, &SP, S); + else + s->script.var[p1o]=scrPop(s, &SP, S); + PC++; + break; + + case PI_CMD_POPA: A=scrPop(s, &SP, S); PC++; break; + + case PI_CMD_PUSH: + if (instr.opt[1] == CMD_PAR) + scrPush(s, &SP, S, s->script.par[p1o]); + else + scrPush(s, &SP, S, s->script.var[p1o]); + PC++; + break; + + case PI_CMD_PUSHA: scrPush(s, &SP, S, A); PC++; break; + + case PI_CMD_RET: PC=scrPop(s, &SP, S); break; + + case PI_CMD_RL: + if (instr.opt[1] == CMD_PAR) + {s->script.par[p1o]<<=p2; F=s->script.par[p1o];} + else + {s->script.var[p1o]<<=p2; F=s->script.var[p1o];} + PC++; + break; + + case PI_CMD_RLA: A<<=p1; F=A; PC++; break; + + case PI_CMD_RR: + if (instr.opt[1] == CMD_PAR) + {s->script.par[p1o]>>=p2; F=s->script.par[p1o];} + else + {s->script.var[p1o]>>=p2; F=s->script.var[p1o];} + PC++; + break; + + case PI_CMD_RRA: A>>=p1; F=A; PC++; break; + + case PI_CMD_STA: + if (instr.opt[1] == CMD_PAR) s->script.par[p1o]=A; + else s->script.var[p1o]=A; + PC++; + break; + + case PI_CMD_STAB: + if ((p1 >= 0) && (p1 < sizeof(buf))) buf[p1] = A; + PC++; + break; + + case PI_CMD_SUB: A-=p1; F=A; PC++; break; + + case PI_CMD_SYS: + A=scrSys((char*)instr.p[4], A, *(gpioReg + GPLEV0)); + F=A; + PC++; + break; + + case PI_CMD_WAIT: A=scrWait(s, p1); F=A; PC++; break; + + case PI_CMD_X: + if (instr.opt[1] == CMD_PAR) t1 = &s->script.par[p1o]; + else t1 = &s->script.var[p1o]; + + if (instr.opt[2] == CMD_PAR) t2 = &s->script.par[p2o]; + else t2 = &s->script.var[p2o]; + + scrSwap(t1, t2); + PC++; + break; + + case PI_CMD_XA: + if (instr.opt[1] == CMD_PAR) + scrSwap(&s->script.par[p1o], &A); + else + scrSwap(&s->script.var[p1o], &A); + PC++; + break; + + case PI_CMD_XOR: A^=p1; F=A; PC++; break; + + } + } + + if (PC >= s->script.instrs) s->run_state = PI_SCRIPT_HALTED; + + } + + if ((volatile int)s->request == PI_SCRIPT_HALT) + s->run_state = PI_SCRIPT_HALTED; + + } + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +static void * pthTimerTick(void *x) +{ + gpioTimer_t *tp; + struct timespec req, rem; + + tp = x; + + while (1) + { + req.tv_sec = tp->millis / THOUSAND; + req.tv_nsec = (tp->millis % THOUSAND) * THOUSAND * THOUSAND; + + while (nanosleep(&req, &rem)) + { + req.tv_sec = rem.tv_sec; + req.tv_nsec = rem.tv_nsec; + } + + if (tp->ex) (tp->func)(tp->userdata); + else (tp->func)(); + } + + return 0; +} + +/* ----------------------------------------------------------------------- */ + + +static void * pthFifoThread(void *x) +{ + char buf[CMD_MAX_EXTENSION]; + int idx, flags, len, res, i; + uintptr_t p[CMD_P_ARR]; + cmdCtlParse_t ctl; + uint32_t *param; + char v[CMD_MAX_EXTENSION]; + + myCreatePipe(PI_INPFIFO, 0662); + + if ((inpFifo = fopen(PI_INPFIFO, "r+")) == NULL) + SOFT_ERROR((void*)PI_INIT_FAILED, "fopen %s failed(%m)", PI_INPFIFO); + + myCreatePipe(PI_OUTFIFO, 0664); + + if ((outFifo = fopen(PI_OUTFIFO, "w+")) == NULL) + SOFT_ERROR((void*)PI_INIT_FAILED, "fopen %s failed (%m)", PI_OUTFIFO); + + /* set outFifo non-blocking */ + + flags = fcntl(fileno(outFifo), F_GETFL, 0); + fcntl(fileno(outFifo), F_SETFL, flags | O_NONBLOCK); + + /* don't start until DMA started */ + + spinWhileStarting(); + + while (1) + { + if (fgets(buf, sizeof(buf), inpFifo) == NULL) + SOFT_ERROR((void*)PI_INIT_FAILED, "fifo fgets failed (%m)"); + + len = strlen(buf); + + if (len) + { + --len; + buf[len] = 0; /* replace terminating */ + } + + ctl.eaten = 0; + idx = 0; + + while (((ctl.eaten)= 0)) + { + if ((idx=cmdParse(buf, p, CMD_MAX_EXTENSION, v, &ctl)) >= 0) + { + /* make sure extensions are null terminated */ + + v[p[3]] = 0; + + res = myDoCommand(p, sizeof(v)-1, v); + + switch (cmdInfo[idx].rv) + { + case 0: + fprintf(outFifo, "%d\n", res); + break; + + case 1: + fprintf(outFifo, "%d\n", res); + break; + + case 2: + fprintf(outFifo, "%d\n", res); + break; + + case 3: + fprintf(outFifo, "%08X\n", res); + break; + + case 4: + fprintf(outFifo, "%u\n", res); + break; + + case 5: + fprintf(outFifo, "%s", cmdUsage); + break; + + case 6: + fprintf(outFifo, "%d", res); + if (res > 0) + { + for (i=0; i= 0) + { + memcpy(buf, &p[3], 4); + p[3] = 4 + (4*PI_MAX_SCRIPT_PARAMS); + } + break; + + default: + p[3] = myDoCommand(p, sizeof(buf)-1, buf); + } + + 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]) + { + /* extensions */ + + case PI_CMD_BI2CZ: + case PI_CMD_BSCX: + case PI_CMD_CF2: + case PI_CMD_FL: + case PI_CMD_FR: + case PI_CMD_I2CPK: + case PI_CMD_I2CRD: + case PI_CMD_I2CRI: + case PI_CMD_I2CRK: + case PI_CMD_I2CZ: + case PI_CMD_PROCP: + case PI_CMD_SERR: + case PI_CMD_SLR: + case PI_CMD_SPIX: + case PI_CMD_SPIR: + case PI_CMD_BSPIX: + + if (((int)p[3]) > 0) + { + if (write(sock, buf, p[3]) == 1) { /* ignore errors */ } + } + break; + + default: + break; + } + } + + closeOrphanedNotifications(-1, sock); + + close(sock); + + DBG(DBG_USER, "Socket %d closed", sock); + + return 0; +} + +static int addrAllowed(struct sockaddr *saddr) +{ + int i; + uint32_t addr; + + if (!numSockNetAddr) return 1; + + // FIXME: add IPv6 whitelisting support + if (saddr->sa_family != AF_INET) return 0; + + addr = ((struct sockaddr_in *) saddr)->sin_addr.s_addr; + + for (i=0; i= 0) + { + pthread_t thr; + + fdC = accept(fdSock, (struct sockaddr *)&client, (socklen_t*)&c); + + closeOrphanedNotifications(-1, fdC); + + if (addrAllowed((struct sockaddr *)&client)) + { + DBG(DBG_USER, "Connection accepted on socket %d", fdC); + + sock = malloc(sizeof(int)); + + *sock = fdC; + + /* Enable tcp_keepalive */ + int optval = 1; + socklen_t optlen = sizeof(optval); + + if (setsockopt(fdC, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) + { + DBG(DBG_ALWAYS, "setsockopt() fail, closing socket %d", fdC); + close(fdC); + } + + DBG(DBG_USER, "SO_KEEPALIVE enabled on socket %d\n", fdC); + + if (pthread_create + (&thr, &attr, pthSocketThreadHandler, (void*) sock) < 0) + SOFT_ERROR((void*)PI_INIT_FAILED, + "socket pthread_create failed (%m)"); + } + else + { + DBG(DBG_ALWAYS, "Connection rejected, closing"); + close(fdC); + } + } + + if (fdC < 0) + SOFT_ERROR((void*)PI_INIT_FAILED, "accept failed (%m)"); + + return 0; +} + +/* ======================================================================= */ + +static void initCheckLockFile(void) +{ + int fd; + int count; + int pid; + int err; + int delete; + char str[20]; + + fd = open(PI_LOCKFILE, O_RDONLY); + + if (fd != -1) + { + DBG(DBG_STARTUP, "lock file exists"); + delete = 1; + + count = read(fd, str, sizeof(str)-1); + + if (count) + { + pid = atoi(str); + err = kill(pid, 0); + if (!err) delete = 0; /* process still exists */ + DBG(DBG_STARTUP, "lock file pid=%d err=%d", pid, err); + } + + close(fd); + DBG(DBG_STARTUP, "lock file delete=%d", delete); + + if (delete) unlink(PI_LOCKFILE); + } +} + +static int initGrabLockFile(void) +{ + int fd; + int lockResult; + char pidStr[20]; + + initCheckLockFile(); + + /* try to grab the lock file */ + + fd = open(PI_LOCKFILE, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0644); + + if (fd != -1) + { + lockResult = flock(fd, LOCK_EX|LOCK_NB); + + if(lockResult == 0) + { + sprintf(pidStr, "%d\n", (int)getpid()); + + if (write(fd, pidStr, strlen(pidStr)) == -1) + { + /* ignore errors */ + } + } + else + { + close(fd); + return -1; + } + } + + return fd; +} + +/* ----------------------------------------------------------------------- */ + +static uint32_t * initMapMem(int fd, uint32_t addr, uint32_t len) +{ + return (uint32_t *) mmap(0, len, + PROT_READ|PROT_WRITE, + MAP_SHARED|MAP_LOCKED, + fd, addr); +} + +/* ----------------------------------------------------------------------- */ + +static int initCheckPermitted(void) +{ + DBG(DBG_STARTUP, ""); + + if (!pi_ispi) + { + DBG(DBG_ALWAYS, + "\n" \ + "+---------------------------------------------------------+\n" \ + "|Sorry, this system does not appear to be a raspberry pi. |\n" \ + "|aborting. |\n" \ + "+---------------------------------------------------------+\n\n"); + return -1; + } + + if ((fdMem = open("/dev/mem", O_RDWR | O_SYNC) ) < 0) + { + DBG(DBG_ALWAYS, + "\n" \ + "+---------------------------------------------------------+\n" \ + "|Sorry, you don't have permission to run this program. |\n" \ + "|Try running as root, e.g. precede the command with sudo. |\n" \ + "+---------------------------------------------------------+\n\n"); + return -1; + } + return 0; +} + +/* ----------------------------------------------------------------------- */ + +static int initPeripherals(void) +{ + DBG(DBG_STARTUP, ""); + + gpioReg = initMapMem(fdMem, GPIO_BASE, GPIO_LEN); + + if (gpioReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap gpio failed (%m)"); + + dmaReg = initMapMem(fdMem, DMA_BASE, DMA_LEN); + + if (dmaReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap dma failed (%m)"); + + /* we should know if we are running on a BCM2711 by now */ + + if (gpioCfg.DMAprimaryChannel == PI_DEFAULT_DMA_NOT_SET) + { + 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 @ %08"PRIXPTR, + gpioCfg.DMAprimaryChannel, (uintptr_t)dmaIn); + + DBG(DBG_STARTUP, "debug reg is %08X", dmaIn[DMA_DEBUG]); + + clkReg = initMapMem(fdMem, CLK_BASE, CLK_LEN); + + if (clkReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap clk failed (%m)"); + + systReg = initMapMem(fdMem, SYST_BASE, SYST_LEN); + + if (systReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap syst failed (%m)"); + + spiReg = initMapMem(fdMem, SPI_BASE, SPI_LEN); + + if (spiReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap spi failed (%m)"); + + pwmReg = initMapMem(fdMem, PWM_BASE, PWM_LEN); + + if (pwmReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap pwm failed (%m)"); + + pcmReg = initMapMem(fdMem, PCM_BASE, PCM_LEN); + + if (pcmReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap pcm failed (%m)"); + + auxReg = initMapMem(fdMem, AUX_BASE, AUX_LEN); + + if (auxReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap aux failed (%m)"); + + padsReg = initMapMem(fdMem, PADS_BASE, PADS_LEN); + + if (padsReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap pads failed (%m)"); + + bscsReg = initMapMem(fdMem, BSCS_BASE, BSCS_LEN); + + if (bscsReg == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap bscs failed (%m)"); + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +static int initZaps + (int pmapFd, void *virtualBase, int basePage, int pages) +{ + int n; + uintptr_t index; + off_t offset; + ssize_t t; + uint32_t physical; + int status; + uintptr_t pageAdr; + unsigned long long pa; + + DBG(DBG_STARTUP, ""); + + status = 0; + + pageAdr = (uintptr_t) dmaVirt[basePage]; + + index = ((uintptr_t)virtualBase / PAGE_SIZE) * 8; + + offset = lseek(pmapFd, index, SEEK_SET); + + if (offset != index) + SOFT_ERROR(PI_INIT_FAILED, "lseek pagemap failed (%m)"); + + for (n=0; n PI_DEFAULT_BUFFER_MILLIS))) + { + /* pagemap allocation of DMA memory */ + + dmaPMapBlk = mmap( + 0, (bufferBlocks+PI_WAVE_BLOCKS)*sizeof(dmaPage_t *), + PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_LOCKED, + -1, 0); + + if (dmaPMapBlk == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "pagemap mmap block failed (%m)"); + + fdPmap = open("/proc/self/pagemap", O_RDONLY); + + if (fdPmap < 0) + SOFT_ERROR(PI_INIT_FAILED, "pagemap open failed(%m)"); + + for (i=0; i<(bufferBlocks+PI_WAVE_BLOCKS); i++) + { + status = initPagemapBlock(i); + if (status < 0) + { + close(fdPmap); + return status; + } + } + + close(fdPmap); + + DBG(DBG_STARTUP, "dmaPMapBlk=%08"PRIXPTR" dmaIn=%08"PRIXPTR, + (uintptr_t)dmaPMapBlk, (uintptr_t)dmaIn); + } + else + { + /* mailbox allocation of DMA memory */ + + dmaMboxBlk = mmap( + 0, (bufferBlocks+PI_WAVE_BLOCKS)*sizeof(DMAMem_t), + PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_LOCKED, + -1, 0); + + if (dmaMboxBlk == MAP_FAILED) + SOFT_ERROR(PI_INIT_FAILED, "mmap mbox block failed (%m)"); + + fdMbox = mbOpen(); + + if (fdMbox < 0) + SOFT_ERROR(PI_INIT_FAILED, "mbox open failed(%m)"); + + for (i=0; i<(bufferBlocks+PI_WAVE_BLOCKS); i++) + { + status = initMboxBlock(i); + if (status < 0) + { + mbClose(fdMbox); + return status; + } + } + + mbClose(fdMbox); + + DBG(DBG_STARTUP, "dmaMboxBlk=%08"PRIXPTR" dmaIn=%08"PRIXPTR, + (uintptr_t)dmaMboxBlk, (uintptr_t)dmaIn); + } + + DBG(DBG_STARTUP, + "gpioReg=%08"PRIXPTR" pwmReg=%08"PRIXPTR" pcmReg=%08"PRIXPTR" clkReg=%08"PRIXPTR" auxReg=%08"PRIXPTR, + (uintptr_t)gpioReg, (uintptr_t)pwmReg, + (uintptr_t)pcmReg, (uintptr_t)clkReg, (uintptr_t)auxReg); + + for (i=0; i= DBG_DMACBS) + { + fprintf(stderr, "*** INPUT DMA CONTROL BLOCKS ***\n"); + for (i=0; iperiphData = 1; + + /* enable PWM DMA, raise panic and dreq thresholds to 15 */ + + pwmReg[PWM_DMAC] = PWM_DMAC_ENAB | + PWM_DMAC_PANIC(15) | + PWM_DMAC_DREQ(15); + + myGpioDelay(10); + + /* clear PWM fifo */ + + pwmReg[PWM_CTL] = PWM_CTL_CLRF1; + + myGpioDelay(10); + + /* enable PWM channel 1 and use fifo */ + + pwmReg[PWM_CTL] = PWM_CTL_USEF1 | PWM_CTL_MODE1 | PWM_CTL_PWEN1; +} + +/* ----------------------------------------------------------------------- */ + +static void initPCM(unsigned bits) +{ + DBG(DBG_STARTUP, "bits=%d", bits); + + /* disable PCM so we can modify the regs */ + + pcmReg[PCM_CS] = 0; + + myGpioDelay(1000); + + pcmReg[PCM_FIFO] = 0; + pcmReg[PCM_MODE] = 0; + pcmReg[PCM_RXC] = 0; + pcmReg[PCM_TXC] = 0; + pcmReg[PCM_DREQ] = 0; + pcmReg[PCM_INTEN] = 0; + pcmReg[PCM_INTSTC] = 0; + pcmReg[PCM_GRAY] = 0; + + myGpioDelay(1000); + + pcmReg[PCM_MODE] = PCM_MODE_FLEN(bits-1); /* # bits in frame */ + + /* enable channel 1 with # bits width */ + + pcmReg[PCM_TXC] = PCM_TXC_CH1EN | PCM_TXC_CH1WID(bits-8); + + pcmReg[PCM_CS] |= PCM_CS_STBY; /* clear standby */ + + myGpioDelay(1000); + + pcmReg[PCM_CS] |= PCM_CS_TXCLR; /* clear TX FIFO */ + + pcmReg[PCM_CS] |= PCM_CS_DMAEN; /* enable DREQ */ + + pcmReg[PCM_DREQ] = PCM_DREQ_TX_PANIC(16) | PCM_DREQ_TX_REQ_L(30); + + pcmReg[PCM_INTSTC] = 0b1111; /* clear status bits */ + + /* enable PCM */ + + pcmReg[PCM_CS] |= PCM_CS_EN; + + /* enable tx */ + + pcmReg[PCM_CS] |= PCM_CS_TXON; + + dmaIVirt[0]->periphData = 0x0F; +} + +/* ----------------------------------------------------------------------- */ + +static void initHWClk + (int clkCtl, int clkDiv, int clkSrc, int divI, int divF, int MASH) +{ + DBG(DBG_INTERNAL, "ctl=%d div=%d src=%d /I=%d /f=%d M=%d", + clkCtl, clkDiv, clkSrc, divI, divF, MASH); + + /* kill the clock if busy, anything else isn't reliable */ + + if (clkReg[clkCtl] & CLK_CTL_BUSY) + { + do + { + clkReg[clkCtl] = BCM_PASSWD | CLK_CTL_KILL; + } + while (clkReg[clkCtl] & CLK_CTL_BUSY); + } + + clkReg[clkDiv] = (BCM_PASSWD | CLK_DIV_DIVI(divI) | CLK_DIV_DIVF(divF)); + + usleep(10); + + clkReg[clkCtl] = (BCM_PASSWD | CLK_CTL_MASH(MASH) | CLK_CTL_SRC(clkSrc)); + + usleep(10); + + clkReg[clkCtl] |= (BCM_PASSWD | CLK_CTL_ENAB); +} + +static void initClock(int mainClock) +{ + const unsigned BITS=10; + int clockPWM; + unsigned clkCtl, clkDiv, clkSrc, clkDivI, clkDivF, clkMash, clkBits; + char *per; + unsigned micros; + + DBG(DBG_STARTUP, "mainClock=%d", mainClock); + + if (mainClock) micros = gpioCfg.clockMicros; + else micros = PI_WF_MICROS; + + clockPWM = mainClock ^ (gpioCfg.clockPeriph == PI_CLOCK_PCM); + + if (clockPWM) + { + clkCtl = CLK_PWMCTL; + clkDiv = CLK_PWMDIV; + per = "PWM"; + } + else + { + clkCtl = CLK_PCMCTL; + clkDiv = CLK_PCMDIV; + per = "PCM"; + } + + clkSrc = CLK_CTL_SRC_PLLD; + clkDivI = clk_plld_freq / (10000000 / micros); /* 10 MHz - 1 MHz */ + clkBits = BITS; /* 10/BITS MHz - 1/BITS MHz */ + clkDivF = 0; + clkMash = 0; + + DBG(DBG_STARTUP, "%s PLLD divi=%d divf=%d mash=%d bits=%d", + per, clkDivI, clkDivF, clkMash, clkBits); + + initHWClk(clkCtl, clkDiv, clkSrc, clkDivI, clkDivF, clkMash); + + if (clockPWM) initPWM(BITS); + else initPCM(BITS); + + 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, ""); + + initKillDMA(dmaAddr); + + dmaAddr[DMA_CS] = DMA_INTERRUPT_STATUS | DMA_END_FLAG; + + dmaAddr[DMA_CONBLK_AD] = cbAddr; + + /* clear READ/FIFO/READ_LAST_NOT_SET error bits */ + + dmaAddr[DMA_DEBUG] = DMA_DEBUG_READ_ERR | + DMA_DEBUG_FIFO_ERR | + DMA_DEBUG_RD_LST_NOT_SET_ERR; + + + dmaAddr[DMA_CS] = DMA_WAIT_ON_WRITES | + DMA_PANIC_PRIORITY(8) | + DMA_PRIORITY(8) | + DMA_ACTIVE; +} + +/* ----------------------------------------------------------------------- */ + +static void initClearGlobals(void) +{ + int i; + + DBG(DBG_STARTUP, ""); + + alertBits = 0; + monitorBits = 0; + notifyBits = 0; + scriptBits = 0; + gFilterBits = 0; + nFilterBits = 0; + wdogBits = 0; + + pthAlertRunning = PI_THREAD_NONE; + pthFifoRunning = PI_THREAD_NONE; + pthSocketRunning = PI_THREAD_NONE; + + wfc[0] = 0; + wfc[1] = 0; + wfc[2] = 0; + + wfcur=0; + + wfStats.micros = 0; + wfStats.highMicros = 0; + wfStats.maxMicros = PI_WAVE_MAX_MICROS; + + wfStats.pulses = 0; + wfStats.highPulses = 0; + wfStats.maxPulses = PI_WAVE_MAX_PULSES; + + wfStats.cbs = 0; + wfStats.highCbs = 0; + wfStats.maxCbs = (PI_WAVE_BLOCKS * PAGES_PER_BLOCK * CBS_PER_OPAGE); + + gpioGetSamples.func = NULL; + gpioGetSamples.ex = 0; + gpioGetSamples.userdata = NULL; + gpioGetSamples.bits = 0; + + for (i=0; i<=PI_MAX_USER_GPIO; i++) + { + wfRx[i].mode = PI_WFRX_NONE; + pthread_mutex_init(&wfRx[i].mutex, NULL); + gpioAlert[i].func = NULL; + } + + for (i=0; i<=PI_MAX_GPIO; i++) + { + gpioInfo [i].is = GPIO_UNDEFINED; + gpioInfo [i].width = 0; + gpioInfo [i].range = PI_DEFAULT_DUTYCYCLE_RANGE; + gpioInfo [i].freqIdx = DEFAULT_PWM_IDX; + } + + for (i=0; i> 4) & 0xFF; + + /* model + 0=A 1=B + 2=A+ 3=B+ + 4=Pi2B + 5=Alpha + 6=Compute Module + 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 + || 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; + } + + gpioMaskSet = 1; + } + +#ifndef EMBEDDED_IN_VM + if (!(gpioCfg.internals & PI_CFG_NOSIGHANDLER)) + sigSetHandler(); +#endif + + if (initPeripherals() < 0) return PI_INIT_FAILED; + + if (initAllocDMAMem() < 0) return PI_INIT_FAILED; + + /* done with /dev/mem */ + + if (fdMem != -1) + { + close(fdMem); + fdMem = -1; + } + + param.sched_priority = sched_get_priority_max(SCHED_FIFO); + + if (gpioCfg.internals & PI_CFG_RT_PRIORITY) + sched_setscheduler(0, SCHED_FIFO, ¶m); + + initClock(1); /* initialise main clock */ + + atexit(gpioTerminate); + + if (pthread_attr_init(&pthAttr)) + SOFT_ERROR(PI_INIT_FAILED, "pthread_attr_init failed (%m)"); + + if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE)) + SOFT_ERROR(PI_INIT_FAILED, "pthread_attr_setstacksize failed (%m)"); + + if (!(gpioCfg.ifFlags & PI_DISABLE_ALERT)) + { + if (pthread_create(&pthAlert, &pthAttr, pthAlertThread, &i)) + SOFT_ERROR(PI_INIT_FAILED, "pthread_create alert failed (%m)"); + + pthAlertRunning = PI_THREAD_STARTED; + } + + if (!(gpioCfg.ifFlags & PI_DISABLE_FIFO_IF)) + { + if (pthread_create(&pthFifo, &pthAttr, pthFifoThread, &i)) + SOFT_ERROR(PI_INIT_FAILED, "pthread_create fifo failed (%m)"); + + pthFifoRunning = PI_THREAD_STARTED; + } + + if (!(gpioCfg.ifFlags & PI_DISABLE_SOCK_IF)) + { + portStr = getenv(PI_ENVPORT); + if (portStr) port = atoi(portStr); else port = gpioCfg.socketPort; + + // Accept connections on IPv6, unless we have an IPv4-only whitelist + if (!numSockNetAddr) + { + fdSock = socket(AF_INET6, SOCK_STREAM , 0); + + if (fdSock != -1) + { + bzero((char *)&server6, sizeof(server6)); + server6.sin6_family = AF_INET6; + if (gpioCfg.ifFlags & PI_LOCALHOST_SOCK_IF) + { + server6.sin6_addr = in6addr_loopback; + } + else + { + server6.sin6_addr = in6addr_any; + } + server6.sin6_port = htons(port); + + 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); + } + } + + if (numSockNetAddr || fdSock == -1) + { + fdSock = socket(AF_INET , SOCK_STREAM , 0); + + if (fdSock == -1) + SOFT_ERROR(PI_INIT_FAILED, "socket failed (%m)"); + else + { + int opt = 1; + setsockopt(fdSock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); + } + server.sin_family = AF_INET; + if (gpioCfg.ifFlags & PI_LOCALHOST_SOCK_IF) + { + server.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + } + else + { + server.sin_addr.s_addr = htonl(INADDR_ANY); + } + server.sin_port = htons(port); + + if (bind(fdSock,(struct sockaddr *)&server , sizeof(server)) < 0) + SOFT_ERROR(PI_INIT_FAILED, "bind to port %d failed (%m)", port); + } + + if (pthread_create(&pthSocket, &pthAttr, pthSocketThread, &i)) + SOFT_ERROR(PI_INIT_FAILED, "pthread_create socket failed (%m)"); + + pthSocketRunning = PI_THREAD_STARTED; + } + + myGpioDelay(1000); + + dmaInitCbs(); + + flushMemory(); + + //cast twice to suppress compiler warning, I belive this cast + //is ok because dmaIBus contains bus addresses, not virtual + //addresses. + initDMAgo((uint32_t *)dmaIn, (uint32_t)(uintptr_t)dmaIBus[0]); + + return PIGPIO_VERSION; +} + + +/* ======================================================================= */ + +int getBitInBytes(int bitPos, char *buf, int numBits) +{ + int bitp, bufp; + + if (bitPos < numBits) + { + bufp = bitPos / 8; + bitp = 7 - (bitPos % 8); + if (buf[bufp] & (1<= 0) && (pos < NUM_WAVE_OOL)) + { + waveOOLPageSlot(pos, &page, &slot); + return (dmaOVirt[page]->OOL[slot]); + } + + return -1; +} + +/* ----------------------------------------------------------------------- */ + +void rawWaveSetOOL(int pos, uint32_t value) +{ + int page, slot; + + if ((pos >= 0) && (pos < NUM_WAVE_OOL)) + { + waveOOLPageSlot(pos, &page, &slot); + dmaOVirt[page]->OOL[slot] = value; + } +} + + +/* ----------------------------------------------------------------------- */ + +uint32_t rawWaveGetOut(int pos) +{ + int page, slot; + + if ((pos >= 0) && (pos < NUM_WAVE_OOL)) + { + waveOOLPageSlot(pos, &page, &slot); + return (dmaOVirt[page]->OOL[slot]); + } + + return -1; +} + +/* ----------------------------------------------------------------------- */ + +void rawWaveSetOut(int pos, uint32_t value) +{ + int page, slot; + + if ((pos >= 0) && (pos < NUM_WAVE_OOL)) + { + waveOOLPageSlot(pos, &page, &slot); + dmaOVirt[page]->OOL[slot] = value; + } +} + + +/* ----------------------------------------------------------------------- */ + +uint32_t rawWaveGetIn(int pos) +{ + int page, slot; + + if ((pos >= 0) && (pos < NUM_WAVE_OOL)) + { + waveOOLPageSlot((NUM_WAVE_OOL-1)-pos, &page, &slot); + return (dmaOVirt[page]->OOL[slot]); + } + + return -1; +} + +/* ----------------------------------------------------------------------- */ + +void rawWaveSetIn(int pos, uint32_t value) +{ + int page, slot; + + if ((pos >= 0) && (pos < NUM_WAVE_OOL)) + { + waveOOLPageSlot((NUM_WAVE_OOL-1)-pos, &page, &slot); + dmaOVirt[page]->OOL[slot] = value; + } +} + +/* ----------------------------------------------------------------------- */ + +rawWaveInfo_t rawWaveInfo(int wave_id) +{ + rawWaveInfo_t dummy = {0, 0, 0, 0, 0, 0, 0, 0}; + + if ((wave_id >=0) && (wave_id < PI_MAX_WAVES)) return waveInfo[wave_id]; + else return dummy; +} + +/* ----------------------------------------------------------------------- */ + +double time_time(void) +{ + struct timeval tv; + double t; + + gettimeofday(&tv, 0); + + t = (double)tv.tv_sec + ((double)tv.tv_usec / 1E6); + + return t; +} + +/* ----------------------------------------------------------------------- */ + +void time_sleep(double seconds) +{ + struct timespec ts, rem; + + if (seconds > 0.0) + { + ts.tv_sec = seconds; + ts.tv_nsec = (seconds-(double)ts.tv_sec) * 1E9; + + while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem)) + { + /* copy remaining time to ts */ + ts.tv_sec = rem.tv_sec; + ts.tv_nsec = rem.tv_nsec; + } + } +} + +/* ----------------------------------------------------------------------- */ + +void rawDumpWave(void) +{ + int i; + + unsigned numWaves, t; + + rawWave_t *waves; + + numWaves = wfc[wfcur]; + waves = wf [wfcur]; + + t = 0; + + for (i=0; i= PI_MAX_SCRIPTS) return; + + if (gpioScript[script_id].state == PI_SCRIPT_IN_USE) + { + + for (i=0; i> 4) & 3; + + if (pwm == 0) pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN1); + else pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN2); + + gpioInfo[i].width = 0; + gpioInfo[i].is = GPIO_UNDEFINED; + } + } +} + +/* ----------------------------------------------------------------------- */ + +int gpioSetMode(unsigned gpio, unsigned mode) +{ + int reg, shift, old_mode; + + DBG(DBG_USER, "gpio=%d mode=%d", gpio, mode); + + CHECK_INITED; + + if (gpio > PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + if (mode > PI_ALT3) + SOFT_ERROR(PI_BAD_MODE, "gpio %d, bad mode (%d)", gpio, mode); + + reg = gpio/10; + shift = (gpio%10) * 3; + + old_mode = (gpioReg[reg] >> shift) & 7; + + if (mode != old_mode) + { + switchFunctionOff(gpio); + + gpioInfo[gpio].is = GPIO_UNDEFINED; + } + + gpioReg[reg] = (gpioReg[reg] & ~(7< PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + reg = gpio/10; + shift = (gpio%10) * 3; + + return (gpioReg[reg] >> shift) & 7; +} + + +/* ----------------------------------------------------------------------- */ + +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; + + if (gpio > PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + if (pud > PI_PUD_UP) + SOFT_ERROR(PI_BAD_PUD, "gpio %d, bad pud (%d)", gpio, 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; + } + + 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; + + myGpioDelay(1); + + *(gpioReg + GPPUD) = 0; + + *(gpioReg + GPPUDCLK0 + BANK) = 0; + } + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioRead(unsigned gpio) +{ + DBG(DBG_USER, "gpio=%d", gpio); + + CHECK_INITED; + + if (gpio > PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + if ((*(gpioReg + GPLEV0 + BANK) & BIT) != 0) return PI_ON; + else return PI_OFF; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioWrite(unsigned gpio, unsigned level) +{ + DBG(DBG_USER, "gpio=%d level=%d", gpio, level); + + CHECK_INITED; + + if (gpio > PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + if (level > PI_ON) + SOFT_ERROR(PI_BAD_LEVEL, "gpio %d, bad level (%d)", gpio, level); + + if (gpio <= PI_MAX_GPIO) + { + if (gpioInfo[gpio].is != GPIO_WRITE) + { + /* stop a glitch between setting mode then level */ + if (level == PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT; + else *(gpioReg + GPSET0 + BANK) = BIT; + + switchFunctionOff(gpio); + + gpioInfo[gpio].is = GPIO_WRITE; + } + } + + myGpioSetMode(gpio, PI_OUTPUT); + + if (level == PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT; + else *(gpioReg + GPSET0 + BANK) = BIT; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioPWM(unsigned gpio, unsigned val) +{ + DBG(DBG_USER, "gpio=%d dutycycle=%d", gpio, val); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (val > gpioInfo[gpio].range) + SOFT_ERROR(PI_BAD_DUTYCYCLE, "gpio %d, bad dutycycle (%d)", gpio, val); + + if (gpioInfo[gpio].is != GPIO_PWM) + { + switchFunctionOff(gpio); + + gpioInfo[gpio].is = GPIO_PWM; + + if (!val) myGpioWrite(gpio, 0); + } + + myGpioSetMode(gpio, PI_OUTPUT); + + myGpioSetPwm(gpio, gpioInfo[gpio].width, val); + + gpioInfo[gpio].width=val; + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioGetPWMdutycycle(unsigned gpio) +{ + unsigned pwm; + + DBG(DBG_USER, "gpio=%d", gpio); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + switch (gpioInfo[gpio].is) + { + case GPIO_PWM: + return gpioInfo[gpio].width; + + case GPIO_HW_PWM: + pwm = (PWMDef[gpio] >> 4) & 3; + return hw_pwm_duty[pwm]; + + case GPIO_HW_CLK: + return PI_HW_PWM_RANGE/2; + + default: + SOFT_ERROR(PI_NOT_PWM_GPIO, "not a PWM gpio (%d)", gpio); + } +} + + +/* ----------------------------------------------------------------------- */ + +int gpioSetPWMrange(unsigned gpio, unsigned range) +{ + int oldWidth, newWidth; + + DBG(DBG_USER, "gpio=%d range=%d", gpio, range); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if ((range < PI_MIN_DUTYCYCLE_RANGE) || (range > PI_MAX_DUTYCYCLE_RANGE)) + SOFT_ERROR(PI_BAD_DUTYRANGE, "gpio %d, bad range (%d)", gpio, range); + + oldWidth = gpioInfo[gpio].width; + + if (oldWidth) + { + if (gpioInfo[gpio].is == GPIO_PWM) + { + newWidth = (range * oldWidth) / gpioInfo[gpio].range; + + myGpioSetPwm(gpio, oldWidth, 0); + gpioInfo[gpio].range = range; + gpioInfo[gpio].width = newWidth; + myGpioSetPwm(gpio, 0, newWidth); + } + } + + gpioInfo[gpio].range = range; + + /* return the actual range for the current gpio frequency */ + + return pwmRealRange[gpioInfo[gpio].freqIdx]; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioGetPWMrange(unsigned gpio) +{ + DBG(DBG_USER, "gpio=%d", gpio); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + switch (gpioInfo[gpio].is) + { + case GPIO_HW_PWM: + case GPIO_HW_CLK: + return PI_HW_PWM_RANGE; + + default: + return gpioInfo[gpio].range; + } +} + + +/* ----------------------------------------------------------------------- */ + +int gpioGetPWMrealRange(unsigned gpio) +{ + unsigned pwm; + + DBG(DBG_USER, "gpio=%d", gpio); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + switch (gpioInfo[gpio].is) + { + case GPIO_HW_PWM: + pwm = (PWMDef[gpio] >> 4) & 3; + return hw_pwm_real_range[pwm]; + + case GPIO_HW_CLK: + return PI_HW_PWM_RANGE; + + default: + return pwmRealRange[gpioInfo[gpio].freqIdx]; + } +} + + +/* ----------------------------------------------------------------------- */ + +int gpioSetPWMfrequency(unsigned gpio, unsigned frequency) +{ + int i, width; + unsigned diff, best, idx; + + DBG(DBG_USER, "gpio=%d frequency=%d", gpio, frequency); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (frequency > pwmFreq[0]) idx = 0; + else if (frequency < pwmFreq[PWM_FREQS-1]) idx = PWM_FREQS-1; + else + { + best = 100000; /* impossibly high frequency difference */ + idx = 0; + + for (i=0; i pwmFreq[i]) diff = frequency - pwmFreq[i]; + else diff = pwmFreq[i] - frequency; + + if (diff < best) + { + best = diff; + idx = i; + } + } + } + + width = gpioInfo[gpio].width; + + if (width) + { + if (gpioInfo[gpio].is == GPIO_PWM) + { + myGpioSetPwm(gpio, width, 0); + gpioInfo[gpio].freqIdx = idx; + myGpioSetPwm(gpio, 0, width); + } + } + + gpioInfo[gpio].freqIdx = idx; + + return pwmFreq[idx]; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioGetPWMfrequency(unsigned gpio) +{ + unsigned pwm, clock; + + DBG(DBG_USER, "gpio=%d", gpio); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + switch (gpioInfo[gpio].is) + { + case GPIO_HW_PWM: + pwm = (PWMDef[gpio] >> 4) & 3; + return hw_pwm_freq[pwm]; + + case GPIO_HW_CLK: + clock = (clkDef[gpio] >> 4) & 3; + return hw_clk_freq[clock]; + + default: + return pwmFreq[gpioInfo[gpio].freqIdx]; + } +} + + +/* ----------------------------------------------------------------------- */ + +int gpioServo(unsigned gpio, unsigned val) +{ + DBG(DBG_USER, "gpio=%d pulsewidth=%d", gpio, val); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if ((val!=PI_SERVO_OFF) && (valPI_MAX_SERVO_PULSEWIDTH) + SOFT_ERROR(PI_BAD_PULSEWIDTH, + "gpio %d, bad pulsewidth (%d)", gpio, val); + + if (gpioInfo[gpio].is != GPIO_SERVO) + { + switchFunctionOff(gpio); + + gpioInfo[gpio].is = GPIO_SERVO; + + if (!val) myGpioWrite(gpio, 0); + } + + myGpioSetMode(gpio, PI_OUTPUT); + + myGpioSetServo(gpio, gpioInfo[gpio].width, val); + + gpioInfo[gpio].width=val; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioGetServoPulsewidth(unsigned gpio) +{ + DBG(DBG_USER, "gpio=%d", gpio); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (gpioInfo[gpio].is != GPIO_SERVO) + SOFT_ERROR(PI_NOT_SERVO_GPIO, "not a servo gpio (%d)", gpio); + + return gpioInfo[gpio].width; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioWaveClear(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + wfc[0] = 0; + wfc[1] = 0; + wfc[2] = 0; + + wfcur = 0; + + wfStats.micros = 0; + wfStats.pulses = 0; + wfStats.cbs = 0; + + waveOutBotCB = PI_WAVE_COUNT_PAGES*CBS_PER_OPAGE; + waveOutBotOOL = PI_WAVE_COUNT_PAGES*OOL_PER_OPAGE; + waveOutTopOOL = NUM_WAVE_OOL; + + waveOutCount = 0; + + waveEndPtr = NULL; + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveAddNew(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + wfc[0] = 0; + wfc[1] = 0; + wfc[2] = 0; + + wfcur = 0; + + wfStats.micros = 0; + wfStats.pulses = 0; + wfStats.cbs = 0; + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses) +{ + int p; + + DBG(DBG_USER, "numPulses=%u pulses=%08"PRIXPTR, numPulses, (uintptr_t)pulses); + + CHECK_INITED; + + if (numPulses > PI_WAVE_MAX_PULSES) + SOFT_ERROR(PI_TOO_MANY_PULSES, "bad number of pulses (%d)", numPulses); + + if (!pulses) SOFT_ERROR(PI_BAD_POINTER, "bad (NULL) pulses pointer"); + + for (p=0; p PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if ((baud < PI_WAVE_MIN_BAUD) || (baud > PI_WAVE_MAX_BAUD)) + SOFT_ERROR(PI_BAD_WAVE_BAUD, "bad baud rate (%d)", baud); + + if ((data_bits < PI_MIN_WAVE_DATABITS) || + (data_bits > PI_MAX_WAVE_DATABITS)) + SOFT_ERROR(PI_BAD_DATABITS, "bad number of databits (%d)", data_bits); + + if ((stop_bits < PI_MIN_WAVE_HALFSTOPBITS) || + (stop_bits > PI_MAX_WAVE_HALFSTOPBITS)) + SOFT_ERROR(PI_BAD_STOPBITS, + "bad number of (half) stop bits (%d)", stop_bits); + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (numBytes > PI_WAVE_MAX_CHARS) + SOFT_ERROR(PI_TOO_MANY_CHARS, "too many chars (%d)", numBytes); + + if (offset > PI_WAVE_MAX_MICROS) + SOFT_ERROR(PI_BAD_SER_OFFSET, "offset too large (%d)", offset); + + if (data_bits > 8) numBytes /= 2; + if (data_bits > 16) numBytes /= 2; + + if (!numBytes) return 0; + + waveBitDelay(baud, data_bits, stop_bits, bitDelay); + + p = 0; + + wf[2][p].gpioOn = (1< bitDelay[0]) wf[2][p].usDelay = offset; + else wf[2][p].usDelay = bitDelay[0]; + + for (i=0; i PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", spiSS); + + /* + CPOL CPHA + 0 0 read rising/write falling + 0 1 read falling/write rising + 1 0 read falling/write rising + 1 1 read rising/write falling + */ + + if (spi->clk_pol) {rising_edge[0] = 0; rising_edge[1] = 1;} + else {rising_edge[0] = 1; rising_edge[1] = 0;} + + if (spi->clk_pha) {read_cycle[0] = 0; read_cycle[1] = 1;} + else {read_cycle[0] = 1; read_cycle[1] = 0;} + + p = 0; + + if (offset) + { + wf[2][p].gpioOn = 0; + wf[2][p].gpioOff = 0; + wf[2][p].flags = 0; + wf[2][p].usDelay = offset; + p++; + } + + on_bits = 0; + off_bits = 0; + + tx_bit_pos = 0; + + /* preset initial mosi bit */ + + if (getBitInBytes(tx_bit_pos, buf, spiTxBits)) + { + on_bits |= (1<<(spi->mosi)); + dbv = 1; + } + else + { + off_bits |= (1<<(spi->mosi)); + dbv = 0; + } + + if (!spi->clk_pha) tx_bit_pos ++; + + if (spi->ss_pol) off_bits |= (1<clk_pol) on_bits |= (1<<(spi->clk)); + else off_bits |= (1<<(spi->clk)); + + wf[2][p].gpioOn = on_bits; + wf[2][p].gpioOff = off_bits; + wf[2][p].flags = 0; + + if (spi->clk_us > spi->ss_us) wf[2][p].usDelay = spi->clk_us; + else wf[2][p].usDelay = spi->ss_us; + + p++; + + for (bit=1; bit<=spiBits; bit++) + { + for (halfbit=0; halfbit<2; halfbit++) + { + wf[2][p].usDelay = spi->clk_us; + wf[2][p].flags = 0; + + on_bits = 0; + off_bits = 0; + + if (read_cycle[halfbit]) + { + if ((bit>=spiBitFirst) && (bit<=spiBitLast)) + wf[2][p].flags = WAVE_FLAG_READ; + } + else + { + if (getBitInBytes(tx_bit_pos, buf, spiTxBits)) + { + if (!dbv) on_bits |= (1<<(spi->mosi)); + dbv = 1; + } + else + { + if (dbv) off_bits |= (1<<(spi->mosi)); + dbv = 0; + } + + ++tx_bit_pos; + } + + if (rising_edge[halfbit]) on_bits |= (1<<(spi->clk)); + else off_bits |= (1<<(spi->clk)); + + wf[2][p].gpioOn = on_bits; + wf[2][p].gpioOff = off_bits; + + p++; + } + } + + on_bits = 0; + off_bits = 0; + + if (spi->ss_pol) on_bits |= (1< 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, 0, 0, 0); + + /* 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 Stats: 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 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 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) +{ + DBG(DBG_USER, "wave id=%d", wave_id); + + CHECK_INITED; + + if ((wave_id >= waveOutCount) || waveInfo[wave_id].deleted) + SOFT_ERROR(PI_BAD_WAVE_ID, "bad wave id (%d)", wave_id); + + waveInfo[wave_id].deleted = 1; + + if (wave_id == (waveOutCount-1)) + { + /* top wave deleted, garbage collect any other deleted waves */ + + while ((wave_id > 0) && (waveInfo[wave_id-1].deleted)) --wave_id; + + waveOutBotCB = waveInfo[wave_id].botCB; + waveOutBotOOL = waveInfo[wave_id].botOOL; + waveOutTopOOL = waveInfo[wave_id].topOOL; + + waveOutCount = wave_id; + } + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveTxStart(unsigned wave_mode) +{ + /* This function is deprecated and has been removed. */ + + CHECK_INITED; + + SOFT_ERROR(PI_DEPRECATED, "deprected function removed"); +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode) +{ + rawCbs_t *p=NULL; + + DBG(DBG_USER, "wave_id=%d wave_mode=%d", wave_id, wave_mode); + + CHECK_INITED; + + if ((wave_id >= waveOutCount) || waveInfo[wave_id].deleted) + SOFT_ERROR(PI_BAD_WAVE_ID, "bad wave id (%d)", wave_id); + + if (wave_mode > PI_WAVE_MODE_REPEAT_SYNC) + SOFT_ERROR(PI_BAD_WAVE_MODE, "bad wave mode (%d)", wave_mode); + + if (!waveClockInited) + { + stopHardwarePWM(); + initClock(0); /* initialise secondary clock */ + waveClockInited = 1; + PWMClockInited = 0; + } + + if (wave_mode < PI_WAVE_MODE_ONE_SHOT_SYNC) initKillDMA(dmaOut); + + p = rawWaveCBAdr(waveInfo[wave_id].topCB); + + if ((wave_mode & 1) == PI_WAVE_MODE_ONE_SHOT) + p->next = 0; + else + p->next = waveCbPOadr(waveInfo[wave_id].botCB+1); + + if (waveEndPtr && (wave_mode > PI_WAVE_MODE_REPEAT)) + { + *waveEndPtr = waveCbPOadr(waveInfo[wave_id].botCB+1); + + if (!dmaOut[DMA_CONBLK_AD]) + { + initDMAgo((uint32_t *)dmaOut, waveCbPOadr(waveInfo[wave_id].botCB)); + } + } + else + { + initDMAgo((uint32_t *)dmaOut, waveCbPOadr(waveInfo[wave_id].botCB)); + } + + waveEndPtr = &p->next; + + /* for compatability with the deprecated gpioWaveTxStart return the + number of cbs + */ + return (waveInfo[wave_id].topCB - waveInfo[wave_id].botCB) + 1; +} + + +/* ----------------------------------------------------------------------- */ + +static int chainGetCB(int n) +{ + int block, index; + + if (n < (WCB_CHAIN_CBS * PI_WAVE_COUNT_PAGES)) + { + block = n / WCB_CHAIN_CBS; + index = n % WCB_CHAIN_CBS; + return (block*CBS_PER_OPAGE) + WCB_COUNTER_CBS + index; + } + return -1; +} + +static void chainSetVal(int n, uint32_t val) +{ + int block, index; + uint32_t *p; + + if (n < (WCB_CHAIN_OOL * PI_WAVE_COUNT_PAGES)) + { + block = n / WCB_CHAIN_OOL; + index = n % WCB_CHAIN_OOL; + p = (uint32_t *) dmaOVirt[block] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8; + p[index] = val; + } +} + +static uint32_t chainGetValPadr(int n) +{ + int block, index; + uint32_t *p; + + if (n < (WCB_CHAIN_OOL * PI_WAVE_COUNT_PAGES)) + { + block = n / WCB_CHAIN_OOL; + index = n % WCB_CHAIN_OOL; + p = (uint32_t *) dmaOBus[block] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8; + //cast twice to suppress warning, I belive this is ok as dmaOBus + //contains bus addresses not virtual addresses. + return (uint32_t)(uintptr_t) (p + index); + } + return 0; +} + +static uint32_t chainGetCntVal(int counter, int slot) +{ + uint32_t *p; + int page, offset; + page = counter / 2; + offset = (counter % 2 ? WCB_COUNTER_OOL : 0); + p = (uint32_t *) dmaOVirt[page] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8; + return p[WCB_CHAIN_OOL+ offset + slot]; +} + +static void chainSetCntVal(int counter, int slot, uint32_t value) +{ + uint32_t *p; + int page, offset; + page = counter / 2; + offset = (counter % 2 ? WCB_COUNTER_OOL : 0); + p = (uint32_t *) dmaOVirt[page] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8; + p[WCB_CHAIN_OOL + offset + slot] = value; +} + +static uint32_t chainGetCntValPadr(int counter, int slot) +{ + uint32_t *p; + int page, offset; + page = counter / 2; + offset = (counter % 2 ? WCB_COUNTER_OOL : 0); + p = (uint32_t *) dmaOBus[page] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8; + //cast twice to suppress warning, I belive this is ok as dmaOBus + //contains bus addresses not virtual addresses. --plugwash + return (uint32_t)(uintptr_t)(p + WCB_CHAIN_OOL + offset + slot); +} + +static int chainGetCntCB(int counter) +{ + int page, offset; + page = counter / 2; + offset = (counter % 2 ? WCB_CNT_CBS : 0); + return ((page * CBS_PER_OPAGE) + offset); +} + +static void chainMakeCounter( + unsigned counter, + unsigned blklen, + unsigned blocks, + unsigned count, + uint32_t repeat, + uint32_t next) +{ + rawCbs_t *p=NULL; + + int b, baseCB, dig; + uint32_t nxt; + + int botCB; + + botCB = chainGetCntCB(counter); + + baseCB = botCB; + + /* set up all the OOLs */ + for (b=0; b < (blocks*(blklen+1)); b++) chainSetCntVal(counter, b, repeat); + + for (b=0; binfo = NORMAL_DMA; + + p->src = chainGetCntValPadr(counter, b*(blklen+1)); + p->dst = (waveCbPOadr(botCB+1) + 20); + + p->length = 4; + p->next = waveCbPOadr(botCB); + + /* copy BOTTOM to TOP */ + + p = rawWaveCBAdr(botCB++); + + p->info = NORMAL_DMA; + + p->src = chainGetCntValPadr(counter, b*(blklen+1)); + p->dst = chainGetCntValPadr(counter, (b*(blklen+1))+blklen); + + p->length = 4; + p->next = waveCbPOadr(botCB); + + /* shift all down one */ + + p = rawWaveCBAdr(botCB++); + + p->info = NORMAL_DMA|DMA_SRC_INC|DMA_DEST_INC; + + p->src = chainGetCntValPadr(counter, ((b*(blklen+1))+1)); + p->dst = chainGetCntValPadr(counter, ((b*(blklen+1))+0)); + + p->length = blklen*4; + p->next = repeat; + } + + /* reset the counter */ + + p = rawWaveCBAdr(botCB); + + p->info = NORMAL_DMA|DMA_SRC_INC|DMA_DEST_INC; + + p->src = chainGetCntValPadr(counter, blocks*(blklen+1)); + p->dst = chainGetCntValPadr(counter, 0); + + p->length = blocks*(blklen+1)*4; + p->next = next; + + b = 0; + + while (count && (binfo = NORMAL_DMA | TIMED_DMA(2); + p->dst = PCM_TIMER; + } + else + { + p->info = NORMAL_DMA | TIMED_DMA(5); + p->dst = PWM_TIMER; + } + + //cast twice to suppress warning, I belive this is ok as dmaOBus + //contains bus addresses not virtual addresses. --plugwash + p->src = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + p->length = BPD * 20 / PI_WF_MICROS; /* 20 micros delay */ + p->next = waveCbPOadr(chainGetCB(cb)); + + counters = 0; + wid = -1; + + i = 0; + + while (i bufSize) + SOFT_ERROR(PI_BAD_CHAIN_CMD, + "incomplete chain command (at %d)", i); + + cmd = buf[i+1]; + + if (cmd == 0) /* loop begin */ + { + if (stk_lev >= (sizeof(stk_pos)/sizeof(int))) + SOFT_ERROR(PI_CHAIN_NESTING, + "chain counters nested too deep (at %d)", i); + + stk_pos[stk_lev++] = cb; + + i += 2; + } + else if (cmd == 1) /* loop end */ + { + if (counters >= WCB_COUNTERS) + SOFT_ERROR(PI_CHAIN_COUNTER, + "too many chain counters (at %d)", i); + + if ((i+4) > bufSize) + SOFT_ERROR(PI_BAD_CHAIN_CMD, + "incomplete chain command (at %d)", i); + + loop = 0; + if (--stk_lev >= 0) loop = stk_pos[stk_lev]; + + if ((loop < 1) || (loop == cb)) + SOFT_ERROR(PI_BAD_CHAIN_LOOP, + "empty chain loop (at %d)", i); + + cycles = ((unsigned)buf[i+3] << 8) + (unsigned)buf[i+2]; + + i += 4; + + if (cycles > PI_MAX_WAVE_CYCLES) + SOFT_ERROR(PI_CHAIN_LOOP_CNT, + "bad chain loop count (%d)", cycles); + + if (cycles == 0) + { + /* Skip the complete loop block. Change + the next pointing to the start of the + loop block to the current cb. + */ + p = rawWaveCBAdr(chainGetCB(loop)); + p->next = waveCbPOadr(chainGetCB(cb)); + } + else if (cycles == 1) + { + /* Nothing to do, no need for a counter. */ + } + else + { + chaincb = chainGetCB(cb++); + if (chaincb < 0) + SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb); + + p = rawWaveCBAdr(chaincb); + + repeat = waveCbPOadr(chainGetCB(loop)); + + /* Need to check next cb as well. */ + + chaincb = chainGetCB(cb); + + if (chaincb < 0) + SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb); + + next = waveCbPOadr(chainGetCB(cb)); + + /* dummy src and dest */ + p->info = NORMAL_DMA; + //cast twice to suppress warning, I belive this is ok as dmaOBus + //contains bus addresses not virtual addresses. --plugwash + p->src = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + p->dst = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + p->length = 4; + p->next = waveCbPOadr(chainGetCntCB(counters)); + + chainMakeCounter(counters, blklen, blocks, + cycles-1, repeat, next); + + counters++; + } + } + else if (cmd == 2) /* delay us */ + { + if ((i+4) > bufSize) + SOFT_ERROR(PI_BAD_CHAIN_CMD, + "incomplete chain command (at %d)", i); + + cycles = ((unsigned)buf[i+3] << 8) + (unsigned)buf[i+2]; + + i += 4; + + if (cycles > PI_MAX_WAVE_DELAY) + SOFT_ERROR(PI_BAD_CHAIN_DELAY, + "bad chain delay micros (%d)", cycles); + + if (cycles) + { + delayLeft = cycles; + delayCBs = waveDelayCBs(delayLeft); + for (dcb=0; dcbinfo = NORMAL_DMA | TIMED_DMA(2); + p->dst = PCM_TIMER; + } + else + { + p->info = NORMAL_DMA | TIMED_DMA(5); + p->dst = PWM_TIMER; + } + + //cast twice to suppress warning, I belive this is ok as dmaOBus + //contains bus addresses not virtual addresses. --plugwash + p->src = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + + p->length = BPD * delayLeft / PI_WF_MICROS; + + if ((gpioCfg.DMAsecondaryChannel >= DMA_LITE_FIRST) && + (p->length > DMA_LITE_MAX)) + { + p->length = DMA_LITE_MAX; + } + + delayLeft -= (p->length / BPD); + + p->next = waveCbPOadr(chainGetCB(cb)); + } + } + } + else if (cmd == 3) /* repeat loop forever */ + { + i += 2; + + loop = 0; + if (--stk_lev >= 0) loop = stk_pos[stk_lev]; + + if ((loop < 1) || (loop == cb)) + SOFT_ERROR(PI_BAD_CHAIN_LOOP, + "empty chain loop (at %d)", i); + + chaincb = chainGetCB(cb++); + if (chaincb < 0) + SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb); + + if (i < bufSize) + SOFT_ERROR(PI_BAD_FOREVER, + "loop forever must be last command"); + + p = rawWaveCBAdr(chaincb); + + /* dummy src and dest */ + p->info = NORMAL_DMA; + //cast twice to suppress warning, I belive this is ok as dmaOBus + //contains bus addresses not virtual addresses. --plugwash + p->src = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + p->dst = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + p->length = 4; + p->next = waveCbPOadr(chainGetCB(loop)); + endPtr = &p->next; + } + else + SOFT_ERROR(PI_BAD_CHAIN_CMD, + "unknown chain command (255 %d)", cmd); + } + else if ((wid >= waveOutCount) || waveInfo[wid].deleted) + SOFT_ERROR(PI_BAD_WAVE_ID, "undefined wave (%d)", wid); + else + { + chaincb = chainGetCB(cb++); + + if (chaincb < 0) + SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb); + + p = rawWaveCBAdr(chaincb); + + chaincb = chainGetCB(cb); + + if (chaincb < 0) + SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb); + + chainSetVal(cb-1, waveCbPOadr(chaincb)); + + /* patch next of wid topCB to next cb */ + + p->info = NORMAL_DMA; + p->src = chainGetValPadr(cb-1); /* this next */ + p->dst = waveCbPOadr(waveInfo[wid].topCB) + 20; /* wid next */ + p->length = 4; + p->next = waveCbPOadr(waveInfo[wid].botCB+1); + + i += 1; + } + } + + chaincb = chainGetCB(cb++); + + if (chaincb < 0) + SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb); + + p = rawWaveCBAdr(chaincb); + + p->info = NORMAL_DMA; + + //cast twice to suppress warning, I belive this is ok as dmaOBus + //contains bus addresses not virtual addresses. --plugwash + p->src = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + p->dst = (uint32_t)(uintptr_t) (&dmaOBus[0]->periphData); + p->length = 4; + p->next = 0; + + if (!endPtr) endPtr = &p->next; + + initDMAgo((uint32_t *)dmaOut, waveCbPOadr(chainGetCB(0))); + + waveEndPtr = endPtr; + + return 0; +} + +/*-------------------------------------------------------------------------*/ + +int gpioWaveTxBusy(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + if (dmaOut[DMA_CONBLK_AD]) + return 1; + else + return 0; +} + +/*-------------------------------------------------------------------------*/ + +int gpioWaveTxAt(void) +{ + int i, cb; + + DBG(DBG_USER, ""); + + CHECK_INITED; + + cb = dmaNowAtOCB(); + + if (cb < 0) return -cb; + + for (i=0; i= waveInfo[i].botCB) && + (cb <= waveInfo[i].topCB) ) return i; + } + + return PI_WAVE_NOT_FOUND; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveTxStop(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + initKillDMA(dmaOut); + + waveEndPtr = NULL; + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetMicros(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.micros; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetHighMicros(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.highMicros; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetMaxMicros(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.maxMicros; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetPulses(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.pulses; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetHighPulses(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.highPulses; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetMaxPulses(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.maxPulses; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetCbs(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.cbs; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetHighCbs(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.highCbs; +} + +/* ----------------------------------------------------------------------- */ + +int gpioWaveGetMaxCbs(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return wfStats.maxCbs; +} + +/* ----------------------------------------------------------------------- */ + +static int read_SDA(wfRx_t *w) +{ + myGpioSetMode(w->I.SDA, PI_INPUT); + return myGpioRead(w->I.SDA); +} + +static void set_SDA(wfRx_t *w) +{ + myGpioSetMode(w->I.SDA, PI_INPUT); +} + +static void clear_SDA(wfRx_t *w) +{ + myGpioSetMode(w->I.SDA, PI_OUTPUT); + myGpioWrite(w->I.SDA, 0); +} + +static void clear_SCL(wfRx_t *w) +{ + myGpioSetMode(w->I.SCL, PI_OUTPUT); + myGpioWrite(w->I.SCL, 0); +} + +static void I2C_delay(wfRx_t *w) +{ + myGpioDelay(w->I.delay); +} + +static void I2C_clock_stretch(wfRx_t *w) +{ + uint32_t now, max_stretch=100000; + + myGpioSetMode(w->I.SCL, PI_INPUT); + now = gpioTick(); + while ((myGpioRead(w->I.SCL) == 0) && ((gpioTick()-now) < max_stretch)); +} + +static void I2CStart(wfRx_t *w) +{ + if (w->I.started) + { + set_SDA(w); + I2C_delay(w); + I2C_clock_stretch(w); + I2C_delay(w); + } + + clear_SDA(w); + I2C_delay(w); + clear_SCL(w); + I2C_delay(w); + + w->I.started = 1; +} + +static void I2CStop(wfRx_t *w) +{ + clear_SDA(w); + I2C_delay(w); + I2C_clock_stretch(w); + I2C_delay(w); + set_SDA(w); + I2C_delay(w); + + w->I.started = 0; +} + +static void I2CPutBit(wfRx_t *w, int bit) +{ + if (bit) set_SDA(w); + else clear_SDA(w); + + I2C_delay(w); + I2C_clock_stretch(w); + I2C_delay(w); + clear_SCL(w); +} + +static int I2CGetBit(wfRx_t *w) +{ + int bit; + + set_SDA(w); /* let SDA float */ + I2C_delay(w); + I2C_clock_stretch(w); + bit = read_SDA(w); + I2C_delay(w); + clear_SCL(w); + + return bit; +} + +static int I2CPutByte(wfRx_t *w, int byte) +{ + int bit, nack; + + for(bit=0; bit<8; bit++) + { + I2CPutBit(w, byte & 0x80); + byte <<= 1; + } + + nack = I2CGetBit(w); + + return nack; +} + +static uint8_t I2CGetByte(wfRx_t *w, int nack) +{ + int bit, byte=0; + + for (bit=0; bit<8; bit++) + { + byte = (byte << 1) | I2CGetBit(w); + } + + I2CPutBit(w, nack); + + return byte; +} + +/*-------------------------------------------------------------------------*/ + +int bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud) +{ + DBG(DBG_USER, "SDA=%d SCL=%d baud=%d", SDA, SCL, baud); + + CHECK_INITED; + + if (SDA > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad SDA (%d)", SDA); + + if (SCL > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad SCL (%d)", SCL); + + if ((baud < PI_BB_I2C_MIN_BAUD) || (baud > PI_BB_I2C_MAX_BAUD)) + SOFT_ERROR(PI_BAD_I2C_BAUD, + "SDA %d, bad baud rate (%d)", SDA, baud); + + if (wfRx[SDA].mode != PI_WFRX_NONE) + SOFT_ERROR(PI_GPIO_IN_USE, "gpio %d is already being used", SDA); + + if ((wfRx[SCL].mode != PI_WFRX_NONE) || (SCL == SDA)) + SOFT_ERROR(PI_GPIO_IN_USE, "gpio %d is already being used", SCL); + + wfRx[SDA].gpio = SDA; + wfRx[SDA].mode = PI_WFRX_I2C_SDA; + wfRx[SDA].baud = baud; + + wfRx[SDA].I.started = 0; + wfRx[SDA].I.SDA = SDA; + wfRx[SDA].I.SCL = SCL; + wfRx[SDA].I.delay = 500000 / baud; + wfRx[SDA].I.SDAMode = gpioGetMode(SDA); + wfRx[SDA].I.SCLMode = gpioGetMode(SCL); + + wfRx[SCL].gpio = SCL; + wfRx[SCL].mode = PI_WFRX_I2C_SCL; + + myGpioSetMode(SDA, PI_INPUT); + myGpioSetMode(SCL, PI_INPUT); + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int bbI2CClose(unsigned SDA) +{ + DBG(DBG_USER, "SDA=%d", SDA); + + CHECK_INITED; + + if (SDA > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", SDA); + + switch(wfRx[SDA].mode) + { + case PI_WFRX_I2C_SDA: + + myGpioSetMode(wfRx[SDA].I.SDA, wfRx[SDA].I.SDAMode); + myGpioSetMode(wfRx[SDA].I.SCL, wfRx[SDA].I.SCLMode); + + wfRx[wfRx[SDA].I.SDA].mode = PI_WFRX_NONE; + wfRx[wfRx[SDA].I.SCL].mode = PI_WFRX_NONE; + + break; + + default: + + SOFT_ERROR(PI_NOT_I2C_GPIO, "no I2C on gpio (%d)", SDA); + + break; + + } + + return 0; +} + +/*-------------------------------------------------------------------------*/ + +int bbI2CZip( + unsigned SDA, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen) +{ + int i, ack, inPos, outPos, status, bytes; + int addr, flags, esc, setesc; + wfRx_t *w; + + DBG(DBG_USER, "gpio=%d inBuf=%s outBuf=%08"PRIXPTR" len=%d", + SDA, myBuf2Str(inLen, (char *)inBuf), (uintptr_t)outBuf, outLen); + + CHECK_INITED; + + if (SDA > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", SDA); + + if (wfRx[SDA].mode != PI_WFRX_I2C_SDA) + SOFT_ERROR(PI_NOT_I2C_GPIO, "no I2C on gpio (%d)", SDA); + + if (!inBuf || !inLen) + SOFT_ERROR(PI_BAD_POINTER, "input buffer can't be NULL"); + + if (!outBuf && outLen) + SOFT_ERROR(PI_BAD_POINTER, "output buffer can't be NULL"); + + w = &wfRx[SDA]; + + inPos = 0; + outPos = 0; + status = 0; + + addr = 0; + flags = 0; + esc = 0; + setesc = 0; + + wfRx_lock(SDA); + + while (!status && (inPos < inLen)) + { + DBG(DBG_INTERNAL, "status=%d inpos=%d inlen=%d cmd=%d addr=%d flags=%x", + status, inPos, inLen, inBuf[inPos], addr, flags); + + switch (inBuf[inPos++]) + { + case PI_I2C_END: + status = 1; + break; + + case PI_I2C_START: + I2CStart(w); + break; + + case PI_I2C_STOP: + I2CStop(w); + break; + + case PI_I2C_ADDR: + addr = myI2CGetPar(inBuf, &inPos, inLen, &esc); + if (addr < 0) status = PI_BAD_I2C_CMD; + break; + + case PI_I2C_FLAGS: + /* cheat to force two byte flags */ + esc = 1; + flags = myI2CGetPar(inBuf, &inPos, inLen, &esc); + if (flags < 0) status = PI_BAD_I2C_CMD; + break; + + case PI_I2C_ESC: + setesc = 1; + break; + + case PI_I2C_READ: + + bytes = myI2CGetPar(inBuf, &inPos, inLen, &esc); + + if (bytes >= 0) ack = I2CPutByte(w, (addr<<1)|1); + + if (bytes > 0) + { + if (!ack) + { + if ((bytes + outPos) <= outLen) + { + for (i=0; i<(bytes-1); i++) + { + outBuf[outPos++] = I2CGetByte(w, 0); + } + outBuf[outPos++] = I2CGetByte(w, 1); + } + else status = PI_BAD_I2C_RLEN; + } + else status = PI_I2C_READ_FAILED; + } + else status = PI_BAD_I2C_CMD; + break; + + case PI_I2C_WRITE: + + bytes = myI2CGetPar(inBuf, &inPos, inLen, &esc); + + if (bytes >= 0) ack = I2CPutByte(w, addr<<1); + + if (bytes > 0) + { + if (!ack) + { + if ((bytes + inPos) <= inLen) + { + for (i=0; i<(bytes-1); i++) + { + ack = I2CPutByte(w, inBuf[inPos++]); + if (ack) status = PI_I2C_WRITE_FAILED; + } + ack = I2CPutByte(w, inBuf[inPos++]); + } + else status = PI_BAD_I2C_WLEN; + } else status = PI_I2C_WRITE_FAILED; + } + else status = PI_BAD_I2C_CMD; + break; + + default: + status = PI_BAD_I2C_CMD; + } + + if (setesc) esc = 1; else esc = 0; + + setesc = 0; + } + + wfRx_unlock(SDA); + + if (status >= 0) status = outPos; + + return status; +} + +/* ----------------------------------------------------------------------- */ + +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 */ + + 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(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 */ + + 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(miso, PI_INPUT); + gpioSetMode(ce, PI_INPUT); + } +} + +int bscXfer(bsc_xfer_t *xfer) +{ + static int bscMode = 0; + + int copied=0; + int active, mode; + + DBG(DBG_USER, "control=0x%X (sa=0x%X, cr=0x%X) tx=%d [%s]", + xfer->control, + ((xfer->control)>>16) & 127, + (xfer->control) & 0x3fff, + xfer->txCnt, + myBuf2Str(xfer->txCnt, (char *)xfer->txBuf)); + + CHECK_INITED; + + eventAlert[PI_EVENT_BSC].ignore = 1; + + if (xfer->control) + { + /* + bscMode (0=None, 1=I2C, 2=SPI) tracks which GPIO have been + set to BSC mode + */ + if (xfer->control & 2) mode = 2; /* SPI */ + else mode = 1; /* assume I2C */ + + if (mode > bscMode) + { + bscInit(mode); + bscMode = mode; + } + } + else + { + if (bscMode) bscTerm(bscMode); + bscMode = 0; + return 0; /* leave ignore set */ + } + + xfer->rxCnt = 0; + + bscsReg[BSC_SLV] = ((xfer->control)>>16) & 127; + bscsReg[BSC_CR] = (xfer->control) & 0x3fff; + bscsReg[BSC_RSR]=0; /* clear underrun and overrun errors */ + + active = 1; + + while (active) + { + active = 0; + + while ((copied < xfer->txCnt) && + (!(bscsReg[BSC_FR] & BSC_FR_TXFF))) + { + bscsReg[BSC_DR] = xfer->txBuf[copied++]; + active = 1; + } + + while ((xfer->rxCnt < BSC_FIFO_SIZE) && + (!(bscsReg[BSC_FR] & BSC_FR_RXFE))) + { + xfer->rxBuf[xfer->rxCnt++] = bscsReg[BSC_DR]; + active = 1; + } + + if (!active) + { + active = bscsReg[BSC_FR] & (BSC_FR_RXBUSY | BSC_FR_TXBUSY); + } + + if (active) myGpioSleep(0, 20); + } + + bscFR = bscsReg[BSC_FR] & 0xffff; + + eventAlert[PI_EVENT_BSC].ignore = 0; + + return (copied<<16) | bscFR; +} + +/* ----------------------------------------------------------------------- */ + +static void set_CS(wfRx_t *w) +{ + myGpioWrite(w->S.CS, PI_SPI_FLAGS_GET_CSPOL(w->S.spiFlags)); +} + +static void clear_CS(wfRx_t *w) +{ + myGpioWrite(w->S.CS, !PI_SPI_FLAGS_GET_CSPOL(w->S.spiFlags)); +} + +static void set_SCLK(wfRx_t *w) +{ + myGpioWrite(w->S.SCLK, !PI_SPI_FLAGS_GET_CPOL(w->S.spiFlags)); +} + +static void clear_SCLK(wfRx_t *w) +{ + myGpioWrite(w->S.SCLK, PI_SPI_FLAGS_GET_CPOL(w->S.spiFlags)); +} + +static void SPI_delay(wfRx_t *w) +{ + myGpioDelay(w->S.delay); +} + +static void bbSPIStart(wfRx_t *w) +{ + clear_SCLK(w); + + SPI_delay(w); + + set_CS(w); + + SPI_delay(w); +} + +static void bbSPIStop(wfRx_t *w) +{ + SPI_delay(w); + + clear_CS(w); + + SPI_delay(w); + + clear_SCLK(w); +} + +static uint8_t bbSPIXferByte(wfRx_t *w, char txByte) +{ + uint8_t bit, rxByte=0; + + if (PI_SPI_FLAGS_GET_CPHA(w->S.spiFlags)) + { + /* + CPHA = 1 + write on set clock + read on clear clock + */ + + for (bit=0; bit<8; bit++) + { + set_SCLK(w); + + if (PI_SPI_FLAGS_GET_TX_LSB(w->S.spiFlags)) + { + myGpioWrite(w->S.MOSI, txByte & 0x01); + txByte >>= 1; + } + else + { + myGpioWrite(w->S.MOSI, txByte & 0x80); + txByte <<= 1; + } + + SPI_delay(w); + + clear_SCLK(w); + + if (PI_SPI_FLAGS_GET_RX_LSB(w->S.spiFlags)) + { + rxByte = (rxByte >> 1) | myGpioRead(w->S.MISO) << 7; + } + else + { + rxByte = (rxByte << 1) | myGpioRead(w->S.MISO); + } + + SPI_delay(w); + } + } + else + { + /* + CPHA = 0 + read on set clock + write on clear clock + */ + + for (bit=0; bit<8; bit++) + { + if (PI_SPI_FLAGS_GET_TX_LSB(w->S.spiFlags)) + { + myGpioWrite(w->S.MOSI, txByte & 0x01); + txByte >>= 1; + } + else + { + myGpioWrite(w->S.MOSI, txByte & 0x80); + txByte <<= 1; + } + + SPI_delay(w); + + set_SCLK(w); + + if (PI_SPI_FLAGS_GET_RX_LSB(w->S.spiFlags)) + { + rxByte = (rxByte >> 1) | myGpioRead(w->S.MISO) << 7; + } + else + { + rxByte = (rxByte << 1) | myGpioRead(w->S.MISO); + } + + SPI_delay(w); + + clear_SCLK(w); + } + } + + return rxByte; +} + +/*-------------------------------------------------------------------------*/ + +int bbSPIOpen( + unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, + unsigned baud, unsigned spiFlags) +{ + int valid; + uint32_t bits; + + DBG(DBG_USER, "CS=%d MISO=%d MOSI=%d SCLK=%d baud=%d flags=%d", + CS, MISO, MOSI, SCLK, baud, spiFlags); + + CHECK_INITED; + + if (CS > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad CS (%d)", CS); + + if (MISO > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad MISO (%d)", MISO); + + if (MOSI > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad MOSI (%d)", MOSI); + + if (SCLK > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad SCLK (%d)", SCLK); + + if ((baud < PI_BB_SPI_MIN_BAUD) || (baud > PI_BB_SPI_MAX_BAUD)) + SOFT_ERROR(PI_BAD_SPI_BAUD, "CS %d, bad baud (%d)", CS, baud); + + if (wfRx[CS].mode != PI_WFRX_NONE) + SOFT_ERROR(PI_GPIO_IN_USE, + "CS %d is already being used, mode %d", CS, wfRx[CS].mode); + + valid = 0; + + /* check all GPIO unique */ + + bits = (1< PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", CS); + + switch(wfRx[CS].mode) + { + case PI_WFRX_SPI_CS: + + myGpioSetMode(wfRx[CS].S.CS, wfRx[CS].S.CSMode); + wfRx[CS].mode = PI_WFRX_NONE; + + SCLK = wfRx[CS].S.SCLK; + + if (--wfRx[SCLK].S.usage <= 0) + { + myGpioSetMode(wfRx[SCLK].S.MISO, wfRx[SCLK].S.MISOMode); + myGpioSetMode(wfRx[SCLK].S.MOSI, wfRx[SCLK].S.MOSIMode); + myGpioSetMode(wfRx[SCLK].S.SCLK, wfRx[SCLK].S.SCLKMode); + + wfRx[wfRx[SCLK].S.MISO].mode = PI_WFRX_NONE; + wfRx[wfRx[SCLK].S.MOSI].mode = PI_WFRX_NONE; + wfRx[wfRx[SCLK].S.SCLK].mode = PI_WFRX_NONE; + } + + break; + + default: + + SOFT_ERROR(PI_NOT_SPI_GPIO, "no SPI on gpio (%d)", CS); + + break; + + } + + return 0; +} + +/*-------------------------------------------------------------------------*/ + +int bbSPIXfer( + unsigned CS, + char *inBuf, + char *outBuf, + unsigned count) +{ + int SCLK; + int pos; + wfRx_t *w; + + DBG(DBG_USER, "CS=%d inBuf=%s outBuf=%08"PRIXPTR" count=%d", + CS, myBuf2Str(count, (char *)inBuf), (uintptr_t)outBuf, count); + + CHECK_INITED; + + if (CS > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", CS); + + if (wfRx[CS].mode != PI_WFRX_SPI_CS) + SOFT_ERROR(PI_NOT_SPI_GPIO, "no SPI on gpio (%d)", CS); + + if (!inBuf || !count) + SOFT_ERROR(PI_BAD_POINTER, "input buffer can't be NULL"); + + if (!outBuf && count) + SOFT_ERROR(PI_BAD_POINTER, "output buffer can't be NULL"); + + SCLK = wfRx[CS].S.SCLK; + + wfRx[SCLK].S.CS = CS; + wfRx[SCLK].baud = wfRx[CS].baud; + wfRx[SCLK].S.delay = wfRx[CS].S.delay; + wfRx[SCLK].S.spiFlags = wfRx[CS].S.spiFlags; + + w = &wfRx[SCLK]; + + wfRx_lock(SCLK); + + bbSPIStart(w); + + for (pos=0; pos < count; pos++) + { + outBuf[pos] = bbSPIXferByte(w, inBuf[pos]); + } + + bbSPIStop(w); + + wfRx_unlock(SCLK); + + return count; +} + +/*-------------------------------------------------------------------------*/ + +int gpioSerialReadOpen(unsigned gpio, unsigned baud, unsigned data_bits) +{ + int bitTime, timeout; + + DBG(DBG_USER, "gpio=%d baud=%d data_bits=%d", gpio, baud, data_bits); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if ((baud < PI_BB_SER_MIN_BAUD) || (baud > PI_BB_SER_MAX_BAUD)) + SOFT_ERROR(PI_BAD_WAVE_BAUD, + "gpio %d, bad baud rate (%d)", gpio, baud); + + if ((data_bits < PI_MIN_WAVE_DATABITS) || + (data_bits > PI_MAX_WAVE_DATABITS)) + SOFT_ERROR(PI_BAD_DATABITS, + "gpio %d, bad data bits (%d)", gpio, data_bits); + + if (wfRx[gpio].mode != PI_WFRX_NONE) + SOFT_ERROR(PI_GPIO_IN_USE, "gpio %d is already being used", gpio); + + bitTime = (1000 * MILLION) / baud; /* nanos */ + + timeout = ((data_bits+2) * bitTime)/MILLION; /* millis */ + + if (timeout < 1) timeout = 1; + + wfRx[gpio].gpio = gpio; + wfRx[gpio].mode = PI_WFRX_SERIAL; + wfRx[gpio].baud = baud; + + wfRx[gpio].s.buf = malloc(SRX_BUF_SIZE); + wfRx[gpio].s.bufSize = SRX_BUF_SIZE; + wfRx[gpio].s.timeout = timeout; + wfRx[gpio].s.fullBit = bitTime; /* nanos */ + wfRx[gpio].s.halfBit = (bitTime/2)+500; /* nanos (500 for rounding) */ + wfRx[gpio].s.readPos = 0; + wfRx[gpio].s.writePos = 0; + wfRx[gpio].s.bit = -1; + wfRx[gpio].s.dataBits = data_bits; + wfRx[gpio].s.invert = PI_BB_SER_NORMAL; + + if (data_bits < 9) wfRx[gpio].s.bytes = 1; + else if (data_bits < 17) wfRx[gpio].s.bytes = 2; + else wfRx[gpio].s.bytes = 4; + + gpioSetAlertFunc(gpio, waveRxBit); + + return 0; +} + +/*-------------------------------------------------------------------------*/ + +int gpioSerialReadInvert(unsigned gpio, unsigned invert) +{ + DBG(DBG_USER, "gpio=%d invert=%d", gpio, invert); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (wfRx[gpio].mode != PI_WFRX_SERIAL) + SOFT_ERROR(PI_NOT_SERIAL_GPIO, "no serial read on gpio (%d)", gpio); + + if ((invert < PI_BB_SER_NORMAL) || + (invert > PI_BB_SER_INVERT)) + SOFT_ERROR(PI_BAD_SER_INVERT, + "bad invert level for gpio %d (%d)", gpio, invert); + + wfRx[gpio].s.invert = invert; + + return 0; +} + +/*-------------------------------------------------------------------------*/ + +int gpioSerialRead(unsigned gpio, void *buf, size_t bufSize) +{ + unsigned bytes=0, wpos; + volatile wfRx_t *w; + + DBG(DBG_USER, "gpio=%d buf=%08"PRIXPTR" bufSize=%zd", gpio, (uintptr_t)buf, bufSize); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (bufSize == 0) + SOFT_ERROR(PI_BAD_SERIAL_COUNT, "buffer size can't be zero"); + + if (wfRx[gpio].mode != PI_WFRX_SERIAL) + SOFT_ERROR(PI_NOT_SERIAL_GPIO, "no serial read on gpio (%d)", gpio); + + w = &wfRx[gpio]; + + if (w->s.readPos != w->s.writePos) + { + wpos = w->s.writePos; + + if (wpos > w->s.readPos) bytes = wpos - w->s.readPos; + else bytes = w->s.bufSize - w->s.readPos; + + if (bytes > bufSize) bytes = bufSize; + + /* copy in multiples of the data size in bytes */ + + bytes = (bytes / w->s.bytes) * w->s.bytes; + + if (buf) memcpy(buf, w->s.buf+w->s.readPos, bytes); + + w->s.readPos += bytes; + + if (w->s.readPos >= w->s.bufSize) w->s.readPos = 0; + } + return bytes; +} + + +/*-------------------------------------------------------------------------*/ + +int gpioSerialReadClose(unsigned gpio) +{ + DBG(DBG_USER, "gpio=%d", gpio); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + switch(wfRx[gpio].mode) + { + case PI_WFRX_NONE: + + SOFT_ERROR(PI_NOT_SERIAL_GPIO, "no serial read on gpio (%d)", gpio); + + break; + + case PI_WFRX_SERIAL: + + free(wfRx[gpio].s.buf); + + gpioSetWatchdog(gpio, 0); /* switch off timeouts */ + + gpioSetAlertFunc(gpio, NULL); /* cancel alert */ + + wfRx[gpio].mode = PI_WFRX_NONE; + + break; + } + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +static int intEventSetFunc( + unsigned event, + void * f, + int user, + void * userdata) +{ + DBG(DBG_INTERNAL, "event=%d function=%08"PRIXPTR", user=%d, userdata=%08"PRIXPTR, + event, (uintptr_t)f, user, (uintptr_t)userdata); + + eventAlert[event].ex = user; + eventAlert[event].userdata = userdata; + + eventAlert[event].func = f; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int eventSetFunc(unsigned event, eventFunc_t f) +{ + DBG(DBG_USER, "event=%d function=%08"PRIXPTR, event, (uintptr_t)f); + + CHECK_INITED; + + if (event > PI_MAX_EVENT) + SOFT_ERROR(PI_BAD_EVENT_ID, "bad event (%d)", event); + + intEventSetFunc(event, f, 0, NULL); + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int eventSetFuncEx(unsigned event, eventFuncEx_t f, void *userdata) +{ + DBG(DBG_USER, "event=%d function=%08"PRIxPTR" userdata=%08"PRIxPTR, + event, (uintptr_t)f, (uintptr_t)userdata); + + CHECK_INITED; + + if (event > PI_MAX_EVENT) + SOFT_ERROR(PI_BAD_EVENT_ID, "bad event (%d)", event); + + intEventSetFunc(event, f, 1, userdata); + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int eventMonitor(unsigned handle, uint32_t bits) +{ + DBG(DBG_USER, "handle=%d bits=%08X", handle, bits); + + CHECK_INITED; + + if (handle >= PI_NOTIFY_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (gpioNotify[handle].state <= PI_NOTIFY_CLOSING) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + gpioNotify[handle].eventBits = bits; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int eventTrigger(unsigned event) +{ + DBG(DBG_USER, "event=%d", event); + + CHECK_INITED; + + if (event > PI_MAX_EVENT) + SOFT_ERROR(PI_BAD_EVENT_ID, "bad event (%d)", event); + + eventAlert[event].fired = 1; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +static int intGpioSetAlertFunc( + unsigned gpio, + void * f, + int user, + void * userdata) +{ + DBG(DBG_INTERNAL, "gpio=%d function=%08"PRIXPTR", user=%d, userdata=%08"PRIXPTR, + gpio, (uintptr_t)f, user, (uintptr_t)userdata); + + gpioAlert[gpio].ex = user; + gpioAlert[gpio].userdata = userdata; + + gpioAlert[gpio].func = f; + + if (f) + { + alertBits |= BIT; + } + else + { + alertBits &= ~BIT; + } + + monitorBits = alertBits | notifyBits | scriptBits | gpioGetSamples.bits; + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioSetAlertFunc(unsigned gpio, gpioAlertFunc_t f) +{ + DBG(DBG_USER, "gpio=%d function=%08"PRIXPTR, gpio, (uintptr_t)f); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + intGpioSetAlertFunc(gpio, f, 0, NULL); + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioSetAlertFuncEx(unsigned gpio, gpioAlertFuncEx_t f, void *userdata) +{ + DBG(DBG_USER, "gpio=%d function=%08"PRIXPTR" userdata=%08"PRIXPTR, + gpio, (uintptr_t)f, (uintptr_t)userdata); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + intGpioSetAlertFunc(gpio, f, 1, userdata); + + return 0; +} + +static void *pthISRThread(void *x) +{ + gpioISR_t *isr = x; + int fd; + int retval; + uint32_t tick; + int level; + uint32_t levels; + struct pollfd pfd; + char buf[64]; + + DBG(DBG_USER, "gpio=%d edge=%d timeout=%d f=%"PRIxPTR" u=%d data=%"PRIxPTR, + isr->gpio, isr->edge, isr->timeout, (uintptr_t)isr->func, + isr->ex, (uintptr_t)isr->userdata); + + 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; + + lseek(fd, 0, SEEK_SET); /* consume any prior interrupt */ + if (read(fd, buf, sizeof buf) == -1) { /* ignore errors */ } + + while (1) + { + retval = poll(&pfd, 1, isr->timeout); /* wait for interrupt */ + + tick = systReg[SYST_CLO]; + + levels = *(gpioReg + GPLEV0); + + if (retval >= 0) + { + lseek(fd, 0, SEEK_SET); /* consume interrupt */ + if (read(fd, buf, sizeof buf) == -1) { /* ignore errors */ } + + if (retval) + { + if (levels & (1<gpio)) level = PI_ON; else level = PI_OFF; + } + else level = PI_TIMEOUT; + + if (isr->ex) (isr->func)(isr->gpio, level, tick, isr->userdata); + else (isr->func)(isr->gpio, level, tick); + } + } + + return NULL; +} + + +/* ----------------------------------------------------------------------- */ + +static int intGpioSetISRFunc( + unsigned gpio, + unsigned edge, + int timeout, + void *f, + int user, + void *userdata) +{ + char buf[64]; + + char *edge_str[]={"rising\n", "falling\n", "both\n"}; + int fd; + int err; + + DBG(DBG_INTERNAL, + "gpio=%d edge=%d timeout=%d function=%08"PRIXPTR" user=%d userdata=%08"PRIXPTR, + gpio, edge, timeout, (uintptr_t)f, user, (uintptr_t)userdata); + + if (f) + { + if (!gpioISR[gpio].inited) /* export gpio if unexported */ + { + fd = open("/sys/class/gpio/export", O_WRONLY); + if (fd < 0) return PI_BAD_ISR_INIT; + + /* ignore write fail if already exported */ + sprintf(buf, "%d\n", gpio); + err = write(fd, buf, strlen(buf)); + close(fd); + + sprintf(buf, "/sys/class/gpio/gpio%d/direction", gpio); + fd = open(buf, O_WRONLY); + if (fd < 0) return PI_BAD_ISR_INIT; + + err = write(fd, "in\n", 3); + close(fd); + if (err != 3) return PI_BAD_ISR_INIT; + + gpioISR[gpio].gpio = gpio; + gpioISR[gpio].edge = -1; + gpioISR[gpio].timeout = -1; + + gpioISR[gpio].inited = 1; + } + + if (gpioISR[gpio].edge != edge) + { + sprintf(buf, "/sys/class/gpio/gpio%d/edge", gpio); + fd = open(buf, O_WRONLY); + if (fd < 0) return PI_BAD_ISR_INIT; + + err = write(fd, edge_str[edge], strlen(edge_str[edge])); + close(fd); + if (err != strlen(edge_str[edge])) return PI_BAD_ISR_INIT; + + gpioISR[gpio].edge = edge; + + if (gpioISR[gpio].pth != NULL) + pthread_kill(*gpioISR[gpio].pth, SIGCHLD); + } + + if (timeout <= 0) timeout = -1; + if (gpioISR[gpio].timeout != timeout) + { + gpioISR[gpio].timeout = timeout; + + if (gpioISR[gpio].pth != NULL) + pthread_kill(*gpioISR[gpio].pth, SIGCHLD); + } + + gpioISR[gpio].func = f; + gpioISR[gpio].ex = user; + gpioISR[gpio].userdata = userdata; + + if (gpioISR[gpio].pth == NULL) + gpioISR[gpio].pth = gpioStartThread(pthISRThread, &gpioISR[gpio]); + } + else /* null function, delete ISR, unexport gpio */ + { + 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; + } + + if (gpioISR[gpio].inited) /* unexport the gpio */ + { + fd = open("/sys/class/gpio/unexport", O_WRONLY); + if (fd < 0) return PI_BAD_ISR_INIT; + sprintf(buf, "%d\n", gpio); + err = write(fd, buf, strlen(buf)); + close(fd); + if (err != strlen(buf)) return PI_BAD_ISR_INIT; + gpioISR[gpio].inited = 0; + } + } + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioSetISRFunc( + unsigned gpio, + unsigned edge, + int timeout, + gpioISRFunc_t f) +{ + DBG(DBG_USER, "gpio=%d edge=%d timeout=%d function=%08"PRIXPTR, + gpio, edge, timeout, (uintptr_t)f); + + CHECK_INITED; + + if (gpio > PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + if (edge > EITHER_EDGE) + SOFT_ERROR(PI_BAD_EDGE, "bad ISR edge (%d)", edge); + + return intGpioSetISRFunc(gpio, edge, timeout, f, 0, NULL); +} + + +/* ----------------------------------------------------------------------- */ + +int gpioSetISRFuncEx( + unsigned gpio, + unsigned edge, + int timeout, + gpioAlertFuncEx_t f, + void *userdata) +{ + DBG(DBG_USER, "gpio=%d edge=%d timeout=%d function=%08"PRIXPTR" userdata=%08"PRIXPTR, + gpio, edge, timeout, (uintptr_t)f, (uintptr_t)userdata); + + CHECK_INITED; + + if (gpio > PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + if (edge > EITHER_EDGE) + SOFT_ERROR(PI_BAD_EDGE, "bad ISR edge (%d)", edge); + + return intGpioSetISRFunc(gpio, edge, timeout, f, 1, userdata); +} + +static void closeOrphanedNotifications(int slot, int fd) +{ + int i; + + /* Check for and close any orphaned notifications. */ + + for (i=0; i= PI_NOTIFY_OPENED) && + (gpioNotify[i].fd == fd)) + { + DBG(DBG_USER, "closed orphaned fd=%d (handle=%d)", fd, i); + gpioNotify[i].state = PI_NOTIFY_CLOSED; + intNotifyBits(); + } + } +} + +/* ----------------------------------------------------------------------- */ + +static void notifyMutex(int lock) +{ + static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + if (lock) pthread_mutex_lock(&mutex); + else pthread_mutex_unlock(&mutex); +} + +/* ----------------------------------------------------------------------- */ + +int gpioNotifyOpenWithSize(int bufSize) +{ + int i, slot, fd; + char name[32]; + + DBG(DBG_USER, "bufSize=%d", bufSize); + + CHECK_INITED; + + slot = -1; + + notifyMutex(1); + + for (i=0; i= PI_NOTIFY_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (gpioNotify[handle].state <= PI_NOTIFY_CLOSING) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + gpioNotify[handle].bits = bits; + + gpioNotify[handle].state = PI_NOTIFY_RUNNING; + + intNotifyBits(); + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioNotifyPause (unsigned handle) +{ + DBG(DBG_USER, "handle=%d", handle); + + CHECK_INITED; + + if (handle >= PI_NOTIFY_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (gpioNotify[handle].state <= PI_NOTIFY_CLOSING) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + gpioNotify[handle].bits = 0; + + gpioNotify[handle].state = PI_NOTIFY_PAUSED; + + intNotifyBits(); + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioNotifyClose(unsigned handle) +{ + char fifo[32]; + + DBG(DBG_USER, "handle=%d", handle); + + CHECK_INITED; + + if (handle >= PI_NOTIFY_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (gpioNotify[handle].state <= PI_NOTIFY_CLOSING) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + gpioNotify[handle].bits = 0; + + gpioNotify[handle].state = PI_NOTIFY_CLOSING; + + intNotifyBits(); + + 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; +} + +/* ----------------------------------------------------------------------- */ + +int gpioTrigger(unsigned gpio, unsigned pulseLen, unsigned level) +{ + DBG(DBG_USER, "gpio=%d pulseLen=%d level=%d", gpio, pulseLen, level); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (level > PI_ON) + SOFT_ERROR(PI_BAD_LEVEL, "gpio %d, bad level (%d)", gpio, level); + + if ((pulseLen > PI_MAX_BUSY_DELAY) || (!pulseLen)) + SOFT_ERROR(PI_BAD_PULSELEN, + "gpio %d, bad pulseLen (%d)", gpio, pulseLen); + + if (level == PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT; + else *(gpioReg + GPSET0 + BANK) = BIT; + + myGpioDelay(pulseLen); + + if (level != PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT; + else *(gpioReg + GPSET0 + BANK) = BIT; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioSetWatchdog(unsigned gpio, unsigned timeout) +{ + DBG(DBG_USER, "gpio=%d timeout=%d", gpio, timeout); + + CHECK_INITED; + + if (gpio > PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (timeout > PI_MAX_WDOG_TIMEOUT) + SOFT_ERROR(PI_BAD_WDOG_TIMEOUT, + "gpio %d, bad timeout (%d)", gpio, timeout); + + gpioAlert[gpio].wdTick = systReg[SYST_CLO]; + gpioAlert[gpio].wdSteadyUs = timeout*1000; + + if (timeout) wdogBits |= (1< PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (steady > PI_MAX_STEADY) + SOFT_ERROR(PI_BAD_FILTER, "bad steady (%d)", steady); + + if (active > PI_MAX_ACTIVE) + SOFT_ERROR(PI_BAD_FILTER, "bad active (%d)", active); + + gpioAlert[gpio].nfTick1 = systReg[SYST_CLO]; + gpioAlert[gpio].nfTick2 = gpioAlert[gpio].nfTick1; + gpioAlert[gpio].nfSteadyUs = steady; + gpioAlert[gpio].nfActiveUs = active; + gpioAlert[gpio].nfActive = 0; + + if (steady) nFilterBits |= (1< PI_MAX_USER_GPIO) + SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio); + + if (steady > PI_MAX_STEADY) + SOFT_ERROR(PI_BAD_FILTER, "bad steady (%d)", steady); + + if (steady) + { + /* Initialise values next time we process alerts */ + gpioAlert[gpio].gfInitialised = 0; + } + + gpioAlert[gpio].gfSteadyUs = steady; + + if (steady) gFilterBits |= (1< PI_MAX_TIMER) + SOFT_ERROR(PI_BAD_TIMER, "bad timer id (%d)", id); + + if ((millis < PI_MIN_MS) || (millis > PI_MAX_MS)) + SOFT_ERROR(PI_BAD_MS, "timer %d, bad millis (%d)", id, millis); + + intGpioSetTimerFunc(id, millis, f, 0, NULL); + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioSetTimerFuncEx(unsigned id, unsigned millis, gpioTimerFuncEx_t f, + void * userdata) +{ + DBG(DBG_USER, "id=%d millis=%d function=%08"PRIXPTR", userdata=%08"PRIXPTR, + id, millis, (uintptr_t)f, (uintptr_t)userdata); + + CHECK_INITED; + + if (id > PI_MAX_TIMER) + SOFT_ERROR(PI_BAD_TIMER, "bad timer id (%d)", id); + + if ((millis < PI_MIN_MS) || (millis > PI_MAX_MS)) + SOFT_ERROR(PI_BAD_MS, "timer %d, bad millis (%d)", id, millis); + + intGpioSetTimerFunc(id, millis, f, 1, userdata); + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +pthread_t *gpioStartThread(gpioThreadFunc_t f, void *userdata) +{ + pthread_t *pth; + pthread_attr_t pthAttr; + + DBG(DBG_USER, "f=%08"PRIXPTR", userdata=%08"PRIXPTR, (uintptr_t)f, (uintptr_t)userdata); + + CHECK_INITED_RET_NULL_PTR; + + pth = malloc(sizeof(pthread_t)); + + if (pth) + { + if (pthread_attr_init(&pthAttr)) + { + free(pth); + SOFT_ERROR(NULL, "pthread_attr_init failed"); + } + + if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE)) + { + free(pth); + SOFT_ERROR(NULL, "pthread_attr_setstacksize failed"); + } + + if (pthread_create(pth, &pthAttr, f, userdata)) + { + free(pth); + SOFT_ERROR(NULL, "pthread_create failed"); + } + } + return pth; +} + +/* ----------------------------------------------------------------------- */ + +void gpioStopThread(pthread_t *pth) +{ + DBG(DBG_USER, "pth=%08"PRIXPTR, (uintptr_t)pth); + + CHECK_INITED_RET_NIL; + + if (pth) + { + if (pthread_self() == *pth) + { + free(pth); + pthread_exit(NULL); + } + else + { + pthread_cancel(*pth); + pthread_join(*pth, NULL); + free(pth); + } + } +} + +/* ----------------------------------------------------------------------- */ + +int gpioStoreScript(char *script) +{ + static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + gpioScript_t *s; + int status, slot, i; + + DBG(DBG_USER, "script=[%s]", script); + + CHECK_INITED; + + slot = -1; + + pthread_mutex_lock(&mutex); + + for (i=0; iscript, 0); + + if (status == 0) + { + s->request = PI_SCRIPT_HALT; + s->run_state = PI_SCRIPT_INITING; + + pthread_cond_init(&s->pthCond, NULL); + pthread_mutex_init(&s->pthMutex, NULL); + + s->id = slot; + + gpioScript[slot].state = PI_SCRIPT_IN_USE; + + s->pthIdp = gpioStartThread(pthScript, s); + + status = slot; + } + else + { + if (s->script.par) free(s->script.par); + s->script.par = NULL; + gpioScript[slot].state = PI_SCRIPT_FREE; + } + + return status; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioRunScript(unsigned script_id, unsigned numParam, uint32_t *param) +{ + int status = 0; + + DBG(DBG_USER, "script_id=%d numParam=%d param=%08"PRIXPTR, + script_id, numParam, (uintptr_t)param); + + CHECK_INITED; + + if (script_id >= PI_MAX_SCRIPTS) + SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id); + + if (numParam > PI_MAX_SCRIPT_PARAMS) + SOFT_ERROR(PI_TOO_MANY_PARAM, "bad number of parameters(%d)", numParam); + + if (gpioScript[script_id].state == PI_SCRIPT_IN_USE) + { + pthread_mutex_lock(&gpioScript[script_id].pthMutex); + + if (gpioScript[script_id].run_state != PI_SCRIPT_INITING) + { + if ((numParam > 0) && (param != 0)) + { + memcpy(gpioScript[script_id].script.par, param, + sizeof(uint32_t) * numParam); + } + + gpioScript[script_id].request = PI_SCRIPT_RUN; + + pthread_cond_signal(&gpioScript[script_id].pthCond); + } + else + { + status = PI_SCRIPT_NOT_READY; + } + + pthread_mutex_unlock(&gpioScript[script_id].pthMutex); + + return status; + } + else + { + return PI_BAD_SCRIPT_ID; + } +} + + +/* ----------------------------------------------------------------------- */ + +int gpioUpdateScript(unsigned script_id, unsigned numParam, uint32_t *param) +{ + DBG(DBG_USER, "script_id=%d numParam=%d param=%08"PRIXPTR, + script_id, numParam, (uintptr_t)param); + + CHECK_INITED; + + if (script_id >= PI_MAX_SCRIPTS) + SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id); + + if (numParam > PI_MAX_SCRIPT_PARAMS) + SOFT_ERROR(PI_TOO_MANY_PARAM, "bad number of parameters(%d)", numParam); + + if (gpioScript[script_id].state == PI_SCRIPT_IN_USE) + { + if ((numParam > 0) && (param != 0)) + { + memcpy(gpioScript[script_id].script.par, param, + sizeof(uint32_t) * numParam); + } + } + else + { + return PI_BAD_SCRIPT_ID; + } + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioScriptStatus(unsigned script_id, uint32_t *param) +{ + DBG(DBG_USER, "script_id=%d param=%08"PRIXPTR, script_id, (uintptr_t)param); + + CHECK_INITED; + + if (script_id >= PI_MAX_SCRIPTS) + SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id); + + if (gpioScript[script_id].state == PI_SCRIPT_IN_USE) + { + if (param != NULL) + { + memcpy(param, gpioScript[script_id].script.par, + sizeof(uint32_t) * PI_MAX_SCRIPT_PARAMS); + } + + return gpioScript[script_id].run_state; + } + else return PI_BAD_SCRIPT_ID; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioStopScript(unsigned script_id) +{ + DBG(DBG_USER, "script_id=%d", script_id); + + CHECK_INITED; + + if (script_id >= PI_MAX_SCRIPTS) + SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id); + + if (gpioScript[script_id].state == PI_SCRIPT_IN_USE) + { + pthread_mutex_lock(&gpioScript[script_id].pthMutex); + + gpioScript[script_id].request = PI_SCRIPT_HALT; + + if (gpioScript[script_id].run_state == PI_SCRIPT_WAITING) + { + pthread_cond_signal(&gpioScript[script_id].pthCond); + } + + pthread_mutex_unlock(&gpioScript[script_id].pthMutex); + + return 0; + } + else return PI_BAD_SCRIPT_ID; +} + +/* ----------------------------------------------------------------------- */ + +int gpioDeleteScript(unsigned script_id) +{ + DBG(DBG_USER, "script_id=%d", script_id); + + CHECK_INITED; + + if (script_id >= PI_MAX_SCRIPTS) + SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id); + + if (gpioScript[script_id].state == PI_SCRIPT_IN_USE) + { + gpioScript[script_id].state = PI_SCRIPT_DYING; + + pthread_mutex_lock(&gpioScript[script_id].pthMutex); + + gpioScript[script_id].request = PI_SCRIPT_HALT; + + if (gpioScript[script_id].run_state == PI_SCRIPT_WAITING) + { + pthread_cond_signal(&gpioScript[script_id].pthCond); + } + + pthread_mutex_unlock(&gpioScript[script_id].pthMutex); + + while (gpioScript[script_id].run_state == PI_SCRIPT_RUNNING) + { + myGpioSleep(0, 5000); /* give script time to halt */ + } + + gpioStopThread(gpioScript[script_id].pthIdp); + + if (gpioScript[script_id].script.par) + free(gpioScript[script_id].script.par); + + gpioScript[script_id].script.par = NULL; + + gpioScript[script_id].state = PI_SCRIPT_FREE; + + return 0; + } + else return PI_BAD_SCRIPT_ID; +} + + + +/* ----------------------------------------------------------------------- */ + +int gpioSetSignalFunc(unsigned signum, gpioSignalFunc_t f) +{ + DBG(DBG_USER, "signum=%d function=%08"PRIXPTR, signum, (uintptr_t)f); + + CHECK_INITED; + + if (signum > PI_MAX_SIGNUM) + SOFT_ERROR(PI_BAD_SIGNUM, "bad signum (%d)", signum); + + gpioSignal[signum].ex = 0; + gpioSignal[signum].userdata = NULL; + + gpioSignal[signum].func = f; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioSetSignalFuncEx(unsigned signum, gpioSignalFuncEx_t f, + void *userdata) +{ + DBG(DBG_USER, "signum=%d function=%08"PRIXPTR" userdata=%08"PRIXPTR, + signum, (uintptr_t)f, (uintptr_t)userdata); + + CHECK_INITED; + + if (signum > PI_MAX_SIGNUM) + SOFT_ERROR(PI_BAD_SIGNUM, "bad signum (%d)", signum); + + gpioSignal[signum].ex = 1; + gpioSignal[signum].userdata = userdata; + + gpioSignal[signum].func = f; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +uint32_t gpioRead_Bits_0_31(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return (*(gpioReg + GPLEV0)); +} + + +/* ----------------------------------------------------------------------- */ + +uint32_t gpioRead_Bits_32_53(void) +{ + DBG(DBG_USER, ""); + + CHECK_INITED; + + return (*(gpioReg + GPLEV1)); +} + + +/* ----------------------------------------------------------------------- */ + +int gpioWrite_Bits_0_31_Clear(uint32_t bits) +{ + DBG(DBG_USER, "bits=%08X", bits); + + CHECK_INITED; + + *(gpioReg + GPCLR0) = bits; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioWrite_Bits_32_53_Clear(uint32_t bits) +{ + DBG(DBG_USER, "bits=%08X", bits); + + CHECK_INITED; + + *(gpioReg + GPCLR1) = bits; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioWrite_Bits_0_31_Set(uint32_t bits) +{ + DBG(DBG_USER, "bits=%08X", bits); + + CHECK_INITED; + + *(gpioReg + GPSET0) = bits; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioWrite_Bits_32_53_Set(uint32_t bits) +{ + DBG(DBG_USER, "bits=%08X", bits); + + CHECK_INITED; + + *(gpioReg + GPSET1) = bits; + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +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}; + unsigned clock, mode, mash; + int password = 0; + double f; + clkInf_t clkInf={0,0,0}; + + DBG(DBG_USER, "gpio=%d frequency=%d", gpio, frequency); + + CHECK_INITED; + + if ((gpio >> 24) == 0x5A) password = 1; + + gpio &= 0xFFFFFF; + + if (gpio > PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + if (!clkDef[gpio]) + SOFT_ERROR(PI_NOT_HCLK_GPIO, "bad gpio for clock (%d)", gpio); + + if (((frequency < hw_clk_min_freq) || + (frequency > hw_clk_max_freq)) && + (frequency)) + SOFT_ERROR(PI_BAD_HCLK_FREQ, + "bad hardware clock frequency %d-%d: (%d)", + hw_clk_min_freq, hw_clk_max_freq, frequency); + + clock = (clkDef[gpio] >> 4) & 3; + + if ((clock == 1) && (!password)) + SOFT_ERROR(PI_BAD_HCLK_PASS, + "Need password to use clock 1 (%d)", gpio); + + mode = clkDef[gpio] & 7; + mash = frequency < PI_MASH_MAX_FREQ ? 1 : 0; + + if (frequency) + { + if (chooseBestClock(&clkInf, frequency, CLK_SRCS, cfreq)) + { + if (clkInf.frac == 0) mash = 0; + + initHWClk(cctl[clock], cdiv[clock], + csrc[clkInf.clock], clkInf.div, clkInf.frac, mash); + + myGpioSetMode(gpio, mode); + + gpioInfo[gpio].is = GPIO_HW_CLK; + + f = (double) cfreq[clkInf.clock] / + ((double)clkInf.div + ((double)clkInf.frac / 4096.0)); + + hw_clk_freq[clock] = (f + 0.5); + + DBG(DBG_USER, "cf=%d div=%d frac=%d mash=%d", + cfreq[clkInf.clock], clkInf.div, clkInf.frac, mash); + } + else + { + SOFT_ERROR(PI_BAD_HCLK_FREQ, + "bad hardware clock frequency %d-%d: (%d)", + hw_clk_min_freq, hw_clk_max_freq, frequency); + } + } + else + { + /* frequency 0, stop clock */ + clkReg[cctl[clock]] = BCM_PASSWD | CLK_CTL_KILL; + + if (gpioInfo[gpio].is == GPIO_HW_CLK) + gpioInfo[gpio].is = GPIO_UNDEFINED; + } + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioHardwarePWM( + unsigned gpio, unsigned frequency, unsigned dutycycle) +{ + uint32_t old_PWM_CTL; + unsigned pwm, mode; + uint32_t real_range, real_dutycycle; + + DBG(DBG_USER, "gpio=%d frequency=%d dutycycle=%d", + gpio, frequency, dutycycle); + + CHECK_INITED; + + if (gpio > PI_MAX_GPIO) + SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio); + + if (!PWMDef[gpio]) + SOFT_ERROR(PI_NOT_HPWM_GPIO, "bad gpio for PWM (%d)", gpio); + + if (dutycycle > PI_HW_PWM_RANGE) + SOFT_ERROR(PI_BAD_HPWM_DUTY, "bad PWM dutycycle (%d)", dutycycle); + + if (((frequency < PI_HW_PWM_MIN_FREQ) || + (frequency > hw_pwm_max_freq)) && + (frequency)) + SOFT_ERROR(PI_BAD_HPWM_FREQ, + "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"); + + pwm = (PWMDef[gpio] >> 4) & 3; + mode = PWMDef[gpio] & 7; + + if (frequency) + { + 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; + + hw_pwm_duty[pwm] = dutycycle; + + hw_pwm_real_range[pwm] = real_range; + + /* Abort any waveform transmission in progress */ + + if (gpioWaveTxBusy()) gpioWaveTxStop(); + + waveClockInited = 0; + + /* preserve channel enable only and mark space mode */ + + old_PWM_CTL = pwmReg[PWM_CTL] & + (PWM_CTL_PWEN1 | PWM_CTL_MSEN1 | PWM_CTL_PWEN2 | PWM_CTL_MSEN2); + + if (!PWMClockInited) + { + pwmReg[PWM_CTL] = 0; + + myGpioDelay(10); + + initHWClk(CLK_PWMCTL, CLK_PWMDIV, CLK_CTL_SRC_PLLD, 2, 0, 0); + + PWMClockInited = 1; + } + + if (pwm == 0) + { + pwmReg[PWM_RNG1] = real_range; + myGpioDelay(10); + pwmReg[PWM_DAT1] = real_dutycycle; + myGpioDelay(10); + + pwmReg[PWM_CTL] = (old_PWM_CTL | PWM_CTL_PWEN1 | PWM_CTL_MSEN1); + } + else + { + pwmReg[PWM_RNG2] = real_range; + myGpioDelay(10); + pwmReg[PWM_DAT2] = real_dutycycle; + myGpioDelay(10); + + pwmReg[PWM_CTL] = (old_PWM_CTL | PWM_CTL_PWEN2 | PWM_CTL_MSEN2); + } + + if (gpioInfo[gpio].is != GPIO_HW_PWM) + { + switchFunctionOff(gpio); + + myGpioSetMode(gpio, mode); + + gpioInfo[gpio].is = GPIO_HW_PWM; + } + } + else + { + /* frequency 0, stop PWM */ + + if (gpioInfo[gpio].is == GPIO_HW_PWM) + { + if (pwm == 0) pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN1); + else pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN2); + + gpioInfo[gpio].is = GPIO_UNDEFINED; + } + } + + return 0; +} + + +int gpioSetPad(unsigned pad, unsigned padStrength) +{ + DBG(DBG_USER, "pad=%d padStrength=%d", pad, padStrength); + + CHECK_INITED; + + if (pad > PI_MAX_PAD) + SOFT_ERROR(PI_BAD_PAD, "bad pad number (%d)", pad); + + if ((padStrength < PI_MIN_PAD_STRENGTH) || + (padStrength > PI_MAX_PAD_STRENGTH)) + SOFT_ERROR(PI_BAD_STRENGTH, "bad pad drive strength (%d)", pad); + + /* 1-16 -> 0-7 */ + + padStrength += 1; + padStrength /= 2; + padStrength -= 1; + + padsReg[11+pad] = BCM_PASSWD | 0x18 | (padStrength & 7) ; + + return 0; +} + +int gpioGetPad(unsigned pad) +{ + int strength; + + DBG(DBG_USER, "pad=%d", pad); + + CHECK_INITED; + + if (pad > PI_MAX_PAD) + SOFT_ERROR(PI_BAD_PAD, "bad pad (%d)", pad); + + strength = padsReg[11+pad] & 7; + + strength *= 2; + strength += 2; + + return strength; +} + +int shell(char *scriptName, char *scriptString) +{ + int status; + char buf[4096]; + + DBG(DBG_USER, "name=%s string=%s", scriptName, scriptString); + + CHECK_INITED; + + if (!myScriptNameValid(scriptName)) + SOFT_ERROR(PI_BAD_SCRIPT_NAME, "bad script name (%s)", scriptName); + + snprintf(buf, sizeof(buf), + "/opt/pigpio/cgi/%s %s", scriptName, scriptString); + + DBG(DBG_USER, "%s", buf); + + status = system(buf); + + if (status < 0) status = PI_BAD_SHELL_STATUS; + + return status; +} + + +int fileApprove(char *filename) +{ + char match[PI_MAX_PATH]; + char buffer[PI_MAX_PATH]; + char line[PI_MAX_PATH]; + char mperm=0; + char perm; + char term; + FILE *f; + + 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; + + while (!feof(f)) + { + buffer[0] = 0; + perm = 0; + term = 0; + if (fgets(line, sizeof(line), f)) + { + sscanf(line, " %511s %c%c", buffer, &perm, &term); + if (term == 10) + { + if (myPathBad(buffer)) continue; /* disallow risky lines */ + + if (fnmatch(buffer, filename, 0) == 0) + { + if (match[0]) + { + if (fnmatch(match, buffer, 0) == 0) + { + strcpy(match, buffer); + mperm = perm; + } + } + else + { + strcpy(match, buffer); + mperm = perm; + } + } + } + } + } + + fclose(f); + + if (match[0]) + { + switch (toupper(mperm)) + { + case 'R': return PI_FILE_READ; + case 'W': return PI_FILE_WRITE; + case 'U': return PI_FILE_RW; + default : return PI_FILE_NONE; + } + } + + return PI_FILE_NONE; +} + +int fileOpen(char *file, unsigned mode) +{ + static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + int fd=-1; + int i, slot, oflag, omode, pmode, rmode; + struct stat statbuf; + + DBG(DBG_USER, "file=%s mode=%d", file, mode); + + CHECK_INITED; + + if ( (mode < PI_FILE_MIN) || + (mode > PI_FILE_MAX) || + ((mode & PI_FILE_RW) == 0) ) + SOFT_ERROR(PI_BAD_FILE_MODE, "bad mode (%d)", mode); + + 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); + + for (i=0; i= PI_FILE_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (fileInfo[handle].state != PI_FILE_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (fileInfo[handle].fd >= 0) close(fileInfo[handle].fd); + + fileInfo[handle].fd = -1; + fileInfo[handle].state = PI_FILE_CLOSED; + + return 0; +} + +int fileWrite(unsigned handle, char *buf, unsigned count) +{ + int w; + + DBG(DBG_USER, "handle=%d count=%d [%s]", + handle, count, myBuf2Str(count, buf)); + + CHECK_INITED; + + if (handle >= PI_FILE_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (fileInfo[handle].state != PI_FILE_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (!count) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + if (!(fileInfo[handle].mode & PI_FILE_WRITE)) + SOFT_ERROR(PI_FILE_NOT_WOPEN, "file not opened for write"); + + w = write(fileInfo[handle].fd, buf, count); + + if (w != count) + { + if (w == -1) DBG(DBG_USER, "write failed with errno %d", errno); + + return PI_BAD_FILE_WRITE; + } + return 0; +} + +int fileRead(unsigned handle, char *buf, unsigned count) +{ + int r; + + DBG(DBG_USER, "handle=%d count=%d buf=0x%"PRIXPTR, handle, count, (uintptr_t)buf); + + CHECK_INITED; + + if (handle >= PI_FILE_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (fileInfo[handle].state != PI_FILE_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (!count) + SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count); + + if (!(fileInfo[handle].mode & PI_FILE_READ)) + SOFT_ERROR(PI_FILE_NOT_ROPEN, "file not opened for read"); + + r = read(fileInfo[handle].fd, buf, count); + + if (r == -1) + { + DBG(DBG_USER, "read failed with errno %d", errno); + return PI_BAD_FILE_READ; + } + else + { + buf[r] = 0; + return r; + } +} + + +int fileSeek(unsigned handle, int32_t seekOffset, int seekFrom) +{ + int whence, s; + + DBG(DBG_USER, "handle=%d offset=%d from=%d", + handle, seekOffset, seekFrom); + + CHECK_INITED; + + if (handle >= PI_FILE_SLOTS) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + if (fileInfo[handle].state != PI_FILE_OPENED) + SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle); + + switch (seekFrom) + { + case PI_FROM_START: + whence = SEEK_SET; + break; + + case PI_FROM_CURRENT: + whence = SEEK_CUR; + break; + + case PI_FROM_END: + whence = SEEK_END; + break; + + default: + SOFT_ERROR(PI_BAD_FILE_SEEK, "bad seek from (%d)", seekFrom); + } + + s = lseek(fileInfo[handle].fd, seekOffset, whence); + + if (s == -1) + { + DBG(DBG_USER, "seek failed with errno %d", errno); + return PI_BAD_FILE_SEEK; + } + + return s; +} + +int fileList(char *fpat, char *buf, unsigned count) +{ + int len, bufpos; + glob_t pglob; + int i; + + DBG(DBG_USER, "fpat=%s count=%d buf=%"PRIxPTR, fpat, count, (uintptr_t)buf); + + CHECK_INITED; + + if ((fileApprove(fpat) & PI_FILE_READ) != PI_FILE_READ) + SOFT_ERROR(PI_NO_FILE_ACCESS, "no permission to access file (%s)", fpat); + + bufpos = 0; + + if (glob(fpat, GLOB_MARK, NULL, &pglob) == 0) + { + for (i=0; i PI_TIME_ABSOLUTE) + SOFT_ERROR(PI_BAD_TIMETYPE, "bad timetype (%d)", timetype); + + if (timetype == PI_TIME_ABSOLUTE) + { + clock_gettime(CLOCK_REALTIME, &ts); + *seconds = ts.tv_sec; + *micros = ts.tv_nsec/1000; + } + else + { + clock_gettime(CLOCK_REALTIME, &ts); + + TIMER_SUB(&ts, &libStarted, &ts); + + *seconds = ts.tv_sec; + *micros = ts.tv_nsec/1000; + } + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioSleep(unsigned timetype, int seconds, int micros) +{ + struct timespec ts, rem; + + DBG(DBG_USER, "timetype=%d seconds=%d micros=%d", + timetype, seconds, micros); + + CHECK_INITED; + + if (timetype > PI_TIME_ABSOLUTE) + SOFT_ERROR(PI_BAD_TIMETYPE, "bad timetype (%d)", timetype); + + if (seconds < 0) + SOFT_ERROR(PI_BAD_SECONDS, "bad seconds (%d)", seconds); + + if ((micros < 0) || (micros > 999999)) + SOFT_ERROR(PI_BAD_MICROS, "bad micros (%d)", micros); + + ts.tv_sec = seconds; + ts.tv_nsec = micros * 1000; + + if (timetype == PI_TIME_ABSOLUTE) + { + while (clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts, &rem)); + } + else + { + while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem)) + { + /* copy remaining time to ts */ + ts.tv_sec = rem.tv_sec; + ts.tv_nsec = rem.tv_nsec; + } + } + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +uint32_t gpioDelay(uint32_t micros) +{ + uint32_t start; + + DBG(DBG_USER, "microseconds=%u", micros); + + CHECK_INITED; + + start = systReg[SYST_CLO]; + + if (micros <= PI_MAX_BUSY_DELAY) + while ((systReg[SYST_CLO] - start) <= micros); + else + gpioSleep(PI_TIME_RELATIVE, (micros/MILLION), (micros%MILLION)); + + return (systReg[SYST_CLO] - start); +} + + +/* ----------------------------------------------------------------------- */ + +uint32_t gpioTick(void) +{ + CHECK_INITED; + + return systReg[SYST_CLO]; +} + + +/* ----------------------------------------------------------------------- */ + +unsigned gpioVersion(void) +{ + DBG(DBG_USER, ""); + + return PIGPIO_VERSION; +} + + +/* ----------------------------------------------------------------------- */ + +/* +2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 +5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + +W W S M M M B B B B P P P P T T T T T T T T R R R R + +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 3=2GB 4=4GB + +B 0=Sony 1=Egoman 2=Embest 3=Sony Japan 4=Embest 5=Stadium + +P 0=2835, 1=2836, 2=2837 3=2711 + +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 + +*/ + +unsigned gpioHardwareRevision(void) +{ + static unsigned rev = 0; + + FILE * filp; + char buf[512]; + char term; + + DBG(DBG_USER, ""); + + if (rev) return rev; + + filp = fopen ("/proc/cpuinfo", "r"); + + + if (filp != NULL) + { + while (fgets(buf, sizeof(buf), filp) != NULL) + { + if (!strncasecmp("revision\t:", buf, 10)) + { + if (sscanf(buf+10, "%x%c", &rev, &term) == 2) + { + if (term != '\n') rev = 0; + } + } + } + fclose(filp); + } + + /* (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) + { + 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); + } + } + + 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 */ + { + 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; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioCfgBufferSize(unsigned millis) +{ + DBG(DBG_USER, "millis=%d", millis); + + CHECK_NOT_INITED; + + if ((millis < PI_BUF_MILLIS_MIN) || (millis > PI_BUF_MILLIS_MAX)) + SOFT_ERROR(PI_BAD_BUF_MILLIS, "bad millis (%d)", millis); + + gpioCfg.bufferMilliseconds = millis; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioCfgClock(unsigned micros, unsigned peripheral, unsigned source) +{ + DBG(DBG_USER, "micros=%d peripheral=%d", micros, peripheral); + + CHECK_NOT_INITED; + + if ((micros < 1) || (micros > 10)) + SOFT_ERROR(PI_BAD_CLK_MICROS, "bad micros (%d)", micros); + + if (!clkCfg[micros].valid) + SOFT_ERROR(PI_BAD_CLK_MICROS, "bad micros (%d)", micros); + + if (peripheral > PI_CLOCK_PCM) + SOFT_ERROR(PI_BAD_CLK_PERIPH, "bad peripheral (%d)", peripheral); + + gpioCfg.clockMicros = micros; + gpioCfg.clockPeriph = peripheral; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioCfgDMAchannel(unsigned DMAchannel) +{ + DBG(DBG_USER, "channel=%d", DMAchannel); + + CHECK_NOT_INITED; + + if ((DMAchannel < PI_MIN_DMA_CHANNEL) || (DMAchannel > PI_MAX_DMA_CHANNEL)) + SOFT_ERROR(PI_BAD_CHANNEL, "bad channel (%d)", DMAchannel); + + gpioCfg.DMAprimaryChannel = DMAchannel; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioCfgDMAchannels(unsigned primaryChannel, unsigned secondaryChannel) +{ + DBG(DBG_USER, "primary channel=%d, secondary channel=%d", + primaryChannel, secondaryChannel); + + CHECK_NOT_INITED; + + if (primaryChannel > PI_MAX_DMA_CHANNEL) + SOFT_ERROR(PI_BAD_PRIM_CHANNEL, "bad primary channel (%d)", + primaryChannel); + + if ((secondaryChannel > PI_MAX_DMA_CHANNEL) || + ((secondaryChannel == primaryChannel) && + (secondaryChannel != PI_DEFAULT_DMA_NOT_SET))) + SOFT_ERROR(PI_BAD_SECO_CHANNEL, "bad secondary channel (%d)", + secondaryChannel); + + gpioCfg.DMAprimaryChannel = primaryChannel; + gpioCfg.DMAsecondaryChannel = secondaryChannel; + + return 0; +} + + +/*-------------------------------------------------------------------------*/ + +int gpioCfgPermissions(uint64_t updateMask) +{ + DBG(DBG_USER, "gpio update mask=%"PRIX64, updateMask); + + CHECK_NOT_INITED; + + gpioMask = updateMask; + + gpioMaskSet = 1; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioCfgInterfaces(unsigned ifFlags) +{ + DBG(DBG_USER, "ifFlags=%X", ifFlags); + + CHECK_NOT_INITED; + + if (ifFlags > 15) + SOFT_ERROR(PI_BAD_IF_FLAGS, "bad ifFlags (%X)", ifFlags); + + gpioCfg.ifFlags = ifFlags; + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioCfgSocketPort(unsigned port) +{ + DBG(DBG_USER, "port=%d", port); + + CHECK_NOT_INITED; + + if ((port < PI_MIN_SOCKET_PORT) || (port > PI_MAX_SOCKET_PORT)) + SOFT_ERROR(PI_BAD_SOCKET_PORT, "bad port (%d)", port); + + gpioCfg.socketPort = port; + + return 0; +} + + +/* ----------------------------------------------------------------------- */ + +int gpioCfgMemAlloc(unsigned memAllocMode) +{ + DBG(DBG_USER, "memAllocMode=%d", memAllocMode); + + CHECK_NOT_INITED; + + if (memAllocMode > PI_MEM_ALLOC_MAILBOX) + SOFT_ERROR( + PI_BAD_MALLOC_MODE, "bad mem alloc mode (%d)", memAllocMode); + + gpioCfg.memAllocMode = memAllocMode; + + return 0; +} + +/* ----------------------------------------------------------------------- */ + +int gpioCfgNetAddr(int numSockAddr, uint32_t *sockAddr) +{ + int i; + + DBG(DBG_USER, "numSockAddr=%d sockAddr=%08"PRIXPTR, + numSockAddr, (uintptr_t)sockAddr); + + CHECK_NOT_INITED; + + if (numSockAddr <= 0) numSockNetAddr = 0; + else + { + if (numSockAddr >= MAX_CONNECT_ADDRESSES) + numSockAddr = MAX_CONNECT_ADDRESSES; + + for (i=0; i>4) & 0xF; + return 0; +} + + +/* include any user customisations */ + +#include "custom.cext" + diff --git a/pigpio.h b/pigpio.h new file mode 100644 index 0000000..40d21fc --- /dev/null +++ b/pigpio.h @@ -0,0 +1,6579 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +#ifndef PIGPIO_H +#define PIGPIO_H + +#include +#include + +#define PIGPIO_VERSION 78 + +/*TEXT + +pigpio is a C library for the Raspberry which allows control of the GPIO. + +*Features* + +o hardware timed PWM on any of GPIO 0-31 + +o hardware timed servo pulses on any of GPIO 0-31 + +o callbacks when any of GPIO 0-31 change state + +o callbacks at timed intervals + +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 rudimentary permission control over GPIO + +o a simple interface to start and stop new threads + +o I2C, SPI, and serial link wrappers + +o creating and running scripts + +*GPIO* + +ALL GPIO are identified by their Broadcom number. + +*Credits* + +The PWM and servo pulses are timed using the DMA and PWM peripherals. + +This use was inspired by Richard Hirst's servoblaster kernel module. + +*Usage* + +Include in your source files. + +Assuming your source is in prog.c use the following command to build and +run the executable. + +. . +gcc -Wall -pthread -o prog prog.c -lpigpio -lrt +sudo ./prog +. . + +For examples of usage see the C programs within the pigpio archive file. + +*Notes* + +All the functions which return an int return < 0 on error. + +[*gpioInitialise*] must be called before all other library functions +with the following exceptions: + +. . +[*gpioCfg**] +[*gpioVersion*] +[*gpioHardwareRevision*] +. . + +If the library is not initialised all but the [*gpioCfg**], +[*gpioVersion*], and [*gpioHardwareRevision*] functions will +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 + +ESSENTIAL + +gpioInitialise Initialise library +gpioTerminate Stop library + +BASIC + +gpioSetMode Set a GPIO mode +gpioGetMode Get a GPIO mode + +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 + +gpioGetPWMrealRange Get underlying PWM range for a GPIO + +Servo_(overrides_PWM_commands_on_same_GPIO) + +gpioServo Start/stop servo pulses on a GPIO + +gpioGetServoPulsewidth Get pulsewidth setting on a GPIO + +INTERMEDIATE + +gpioTrigger Send a trigger pulse to 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 + +gpioWrite_Bits_0_31_Clear Clear selected GPIO in bank 1 +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 + +gpioSetAlertFunc Request a GPIO level change callback +gpioSetAlertFuncEx Request a GPIO change callback, extended + +gpioSetTimerFunc Request a regular timed callback +gpioSetTimerFuncEx Request a regular timed callback, extended + +gpioStartThread Start a new thread +gpioStopThread Stop a previously started thread + +ADVANCED + +gpioNotifyOpen Request a notification handle +gpioNotifyClose Close a notification +gpioNotifyOpenWithSize Request a notification with sized pipe +gpioNotifyBegin Start notifications for selected GPIO +gpioNotifyPause Pause notifications + +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 + +gpioSetPad Sets a pads drive strength +gpioGetPad Gets a pads drive strength + +shell Executes a shell command + +gpioSetISRFunc Request a GPIO interrupt callback +gpioSetISRFuncEx Request a GPIO interrupt callback, extended + +gpioSetSignalFunc Request a signal callback +gpioSetSignalFuncEx Request a signal callback, extended + +gpioSetGetSamplesFunc Requests a GPIO samples callback +gpioSetGetSamplesFuncEx Requests a GPIO samples callback, extended + +Custom + +gpioCustom1 User custom function 1 +gpioCustom2 User custom function 2 + +Events + +eventMonitor Sets the events to monitor +eventSetFunc Request an event callback +eventSetFuncEx Request an event callback, extended + +eventTrigger Trigger an event + +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 + +I2C + +i2cOpen Opens an I2C device +i2cClose Closes an I2C device + +i2cWriteQuick SMBus write quick + +i2cReadByte SMBus read byte +i2cWriteByte SMBus write byte + +i2cReadByteData SMBus read byte data +i2cWriteByteData SMBus write byte data + +i2cReadWordData SMBus read word data +i2cWriteWordData SMBus write word data + +i2cReadBlockData SMBus read block data +i2cWriteBlockData SMBus write 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 bit banged I2C transactions + +I2C/SPI_SLAVE + +bscXfer I2C/SPI as slave transfer + +SERIAL + +serOpen Opens a serial device +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 + +WAVES + +gpioWaveClear Deletes all waveforms + +gpioWaveAddNew Starts a new waveform +gpioWaveAddGeneric Adds a series of pulses to the waveform +gpioWaveAddSerial Adds serial data to the waveform + +gpioWaveCreate Creates a waveform from added data +gpioWaveCreatePad Creates a waveform of fixed size from added data +gpioWaveDelete Deletes a waveform + +gpioWaveTxSend Transmits a waveform + +gpioWaveChain Transmits a chain of waveforms + +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 +gpioVersion Get the pigpio version + +getBitInBytes Get the value of a bit +putBitInBytes Set the value of a bit + +gpioTime Get current time +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 +rawWaveAddGeneric Not intended for general use +rawWaveCB Not intended for general use +rawWaveCBAdr Not intended for general use +rawWaveGetOOL Not intended for general use +rawWaveSetOOL Not intended for general use +rawWaveGetOut Not intended for general use +rawWaveSetOut Not intended for general use +rawWaveGetIn Not intended for general use +rawWaveSetIn Not intended for general use +rawWaveInfo Not intended for general use +rawDumpWave Not intended for general use +rawDumpScript Not intended for general use + +OVERVIEW*/ + +#define PI_INPFIFO "/dev/pigpio" +#define PI_OUTFIFO "/dev/pigout" +#define PI_ERRFIFO "/dev/pigerr" + +#define PI_ENVPORT "PIGPIO_PORT" +#define PI_ENVADDR "PIGPIO_ADDR" + +#define PI_LOCKFILE "/var/run/pigpio.pid" + +#define PI_I2C_COMBINED "/sys/module/i2c_bcm2708/parameters/combined" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + uint16_t func; + uint16_t size; +} gpioHeader_t; + +typedef struct +{ + size_t size; + void *ptr; + uint32_t data; +} gpioExtent_t; + +typedef struct +{ + uint32_t tick; + uint32_t level; +} gpioSample_t; + +typedef struct +{ + uint16_t seqno; + uint16_t flags; + uint32_t tick; + uint32_t level; +} gpioReport_t; + +typedef struct +{ + uint32_t gpioOn; + uint32_t gpioOff; + uint32_t usDelay; +} gpioPulse_t; + +#define WAVE_FLAG_READ 1 +#define WAVE_FLAG_TICK 2 + +typedef struct +{ + uint32_t gpioOn; + uint32_t gpioOff; + uint32_t usDelay; + uint32_t flags; +} rawWave_t; + +/* +CBs are used in order from the lowest numbered CB up to +the maximum NUM_WAVE_CBS. + +OOLS are used from the bottom climbing up and from +the top climbing down. + +The GPIO on and off settings climb up from the bottom (botOOL/numBOOL). + +The level and tick read values are stored in descending locations +from the top (topOOL/numTOOL). +*/ + +typedef struct +{ + uint16_t botCB; /* first CB used by wave */ + uint16_t topCB; /* last CB used by wave */ + uint16_t botOOL; /* first bottom OOL used by wave */ + /* botOOL to botOOL + numBOOL - 1 are in use */ + uint16_t topOOL; /* last top OOL used by wave */ + /* topOOL - numTOOL to topOOL are in use.*/ + uint16_t deleted; + uint16_t numCB; + uint16_t numBOOL; + uint16_t numTOOL; +} rawWaveInfo_t; + +typedef struct +{ + int clk; /* GPIO for clock */ + int mosi; /* GPIO for MOSI */ + int miso; /* GPIO for MISO */ + int ss_pol; /* slave select off state */ + int ss_us; /* delay after slave select */ + int clk_pol; /* clock off state */ + int clk_pha; /* clock phase */ + int clk_us; /* clock micros */ +} rawSPI_t; + +typedef struct { /* linux/arch/arm/mach-bcm2708/include/mach/dma.h */ + uint32_t info; + uint32_t src; + uint32_t dst; + uint32_t length; + uint32_t stride; + uint32_t next; + uint32_t pad[2]; +} rawCbs_t; + +typedef struct +{ + uint16_t addr; /* slave address */ + uint16_t flags; + uint16_t len; /* msg length */ + uint8_t *buf; /* pointer to msg data */ +} pi_i2c_msg_t; + +/* BSC FIFO size */ + +#define BSC_FIFO_SIZE 512 + +typedef struct +{ + uint32_t control; /* Write */ + int rxCnt; /* Read only */ + char rxBuf[BSC_FIFO_SIZE]; /* Read only */ + int txCnt; /* Write */ + char txBuf[BSC_FIFO_SIZE]; /* Write */ +} bsc_xfer_t; + + +typedef void (*gpioAlertFunc_t) (int gpio, + int level, + uint32_t tick); + +typedef void (*gpioAlertFuncEx_t) (int gpio, + int level, + uint32_t tick, + void *userdata); + +typedef void (*eventFunc_t) (int event, + uint32_t tick); + +typedef void (*eventFuncEx_t) (int event, + uint32_t tick, + void *userdata); + +typedef void (*gpioISRFunc_t) (int gpio, + int level, + uint32_t tick); + +typedef void (*gpioISRFuncEx_t) (int gpio, + int level, + uint32_t tick, + void *userdata); + +typedef void (*gpioTimerFunc_t) (void); + +typedef void (*gpioTimerFuncEx_t) (void *userdata); + +typedef void (*gpioSignalFunc_t) (int signum); + +typedef void (*gpioSignalFuncEx_t) (int signum, + void *userdata); + +typedef void (*gpioGetSamplesFunc_t) (const gpioSample_t *samples, + int numSamples); + +typedef void (*gpioGetSamplesFuncEx_t) (const gpioSample_t *samples, + int numSamples, + void *userdata); + +typedef void *(gpioThreadFunc_t) (void *); + + +/* gpio: 0-53 */ + +#define PI_MIN_GPIO 0 +#define PI_MAX_GPIO 53 + +/* user_gpio: 0-31 */ + +#define PI_MAX_USER_GPIO 31 + +/* level: 0-1 */ + +#define PI_OFF 0 +#define PI_ON 1 + +#define PI_CLEAR 0 +#define PI_SET 1 + +#define PI_LOW 0 +#define PI_HIGH 1 + +/* level: only reported for GPIO time-out, see gpioSetWatchdog */ + +#define PI_TIMEOUT 2 + +/* mode: 0-7 */ + +#define PI_INPUT 0 +#define PI_OUTPUT 1 +#define PI_ALT0 4 +#define PI_ALT1 5 +#define PI_ALT2 6 +#define PI_ALT3 7 +#define PI_ALT4 3 +#define PI_ALT5 2 + +/* pud: 0-2 */ + +#define PI_PUD_OFF 0 +#define PI_PUD_DOWN 1 +#define PI_PUD_UP 2 + +/* dutycycle: 0-range */ + +#define PI_DEFAULT_DUTYCYCLE_RANGE 255 + +/* range: 25-40000 */ + +#define PI_MIN_DUTYCYCLE_RANGE 25 +#define PI_MAX_DUTYCYCLE_RANGE 40000 + +/* pulsewidth: 0, 500-2500 */ + +#define PI_SERVO_OFF 0 +#define PI_MIN_SERVO_PULSEWIDTH 500 +#define PI_MAX_SERVO_PULSEWIDTH 2500 + +/* hardware PWM */ + +#define PI_HW_PWM_MIN_FREQ 1 +#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_MIN_FREQ_2711 13184 +#define PI_HW_CLK_MAX_FREQ 250000000 +#define PI_HW_CLK_MAX_FREQ_2711 375000000 + +#define PI_NOTIFY_SLOTS 32 + +#define PI_NTFY_FLAGS_EVENT (1 <<7) +#define PI_NTFY_FLAGS_ALIVE (1 <<6) +#define PI_NTFY_FLAGS_WDOG (1 <<5) +#define PI_NTFY_FLAGS_BIT(x) (((x)<<0)&31) + +#define PI_WAVE_BLOCKS 4 +#define PI_WAVE_MAX_PULSES (PI_WAVE_BLOCKS * 3000) +#define PI_WAVE_MAX_CHARS (PI_WAVE_BLOCKS * 300) + +#define PI_BB_I2C_MIN_BAUD 50 +#define PI_BB_I2C_MAX_BAUD 500000 + +#define PI_BB_SPI_MIN_BAUD 50 +#define PI_BB_SPI_MAX_BAUD 250000 + +#define PI_BB_SER_MIN_BAUD 50 +#define PI_BB_SER_MAX_BAUD 250000 + +#define PI_BB_SER_NORMAL 0 +#define PI_BB_SER_INVERT 1 + +#define PI_WAVE_MIN_BAUD 50 +#define PI_WAVE_MAX_BAUD 1000000 + +#define PI_SPI_MIN_BAUD 32000 +#define PI_SPI_MAX_BAUD 125000000 + +#define PI_MIN_WAVE_DATABITS 1 +#define PI_MAX_WAVE_DATABITS 32 + +#define PI_MIN_WAVE_HALFSTOPBITS 2 +#define PI_MAX_WAVE_HALFSTOPBITS 8 + +#define PI_WAVE_MAX_MICROS (30 * 60 * 1000000) /* half an hour */ + +#define PI_MAX_WAVES 250 + +#define PI_MAX_WAVE_CYCLES 65535 +#define PI_MAX_WAVE_DELAY 65535 + +#define PI_WAVE_COUNT_PAGES 10 + +/* wave tx mode */ + +#define PI_WAVE_MODE_ONE_SHOT 0 +#define PI_WAVE_MODE_REPEAT 1 +#define PI_WAVE_MODE_ONE_SHOT_SYNC 2 +#define PI_WAVE_MODE_REPEAT_SYNC 3 + +/* special wave at return values */ + +#define PI_WAVE_NOT_FOUND 9998 /* Transmitted wave not found. */ +#define PI_NO_TX_WAVE 9999 /* No wave being transmitted. */ + +/* Files, I2C, SPI, SER */ + +#define PI_FILE_SLOTS 16 +#define PI_I2C_SLOTS 512 +#define PI_SPI_SLOTS 32 +#define PI_SER_SLOTS 16 + +#define PI_MAX_I2C_ADDR 0x7F + +#define PI_NUM_AUX_SPI_CHANNEL 3 +#define PI_NUM_STD_SPI_CHANNEL 2 + +#define PI_MAX_I2C_DEVICE_COUNT (1<<16) +#define PI_MAX_SPI_DEVICE_COUNT (1<<16) + +/* max pi_i2c_msg_t per transaction */ + +#define PI_I2C_RDRW_IOCTL_MAX_MSGS 42 + +/* flags for i2cTransaction, pi_i2c_msg_t */ + +#define PI_I2C_M_WR 0x0000 /* write data */ +#define PI_I2C_M_RD 0x0001 /* read data */ +#define PI_I2C_M_TEN 0x0010 /* ten bit chip address */ +#define PI_I2C_M_RECV_LEN 0x0400 /* length will be first received byte */ +#define PI_I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */ +#define PI_I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */ +#define PI_I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */ +#define PI_I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */ + +/* bbI2CZip and i2cZip commands */ + +#define PI_I2C_END 0 +#define PI_I2C_ESC 1 +#define PI_I2C_START 2 +#define PI_I2C_COMBINED_ON 2 +#define PI_I2C_STOP 3 +#define PI_I2C_COMBINED_OFF 3 +#define PI_I2C_ADDR 4 +#define PI_I2C_FLAGS 5 +#define PI_I2C_READ 6 +#define PI_I2C_WRITE 7 + +/* SPI */ + +#define PI_SPI_FLAGS_BITLEN(x) ((x&63)<<16) +#define PI_SPI_FLAGS_RX_LSB(x) ((x&1)<<15) +#define PI_SPI_FLAGS_TX_LSB(x) ((x&1)<<14) +#define PI_SPI_FLAGS_3WREN(x) ((x&15)<<10) +#define PI_SPI_FLAGS_3WIRE(x) ((x&1)<<9) +#define PI_SPI_FLAGS_AUX_SPI(x) ((x&1)<<8) +#define PI_SPI_FLAGS_RESVD(x) ((x&7)<<5) +#define PI_SPI_FLAGS_CSPOLS(x) ((x&7)<<2) +#define PI_SPI_FLAGS_MODE(x) ((x&3)) + +/* BSC registers */ + +#define BSC_DR 0 +#define BSC_RSR 1 +#define BSC_SLV 2 +#define BSC_CR 3 +#define BSC_FR 4 +#define BSC_IFLS 5 +#define BSC_IMSC 6 +#define BSC_RIS 7 +#define BSC_MIS 8 +#define BSC_ICR 9 +#define BSC_DMACR 10 +#define BSC_TDR 11 +#define BSC_GPUSTAT 12 +#define BSC_HCTRL 13 +#define BSC_DEBUG_I2C 14 +#define BSC_DEBUG_SPI 15 + +#define BSC_CR_TESTFIFO 2048 +#define BSC_CR_RXE 512 +#define BSC_CR_TXE 256 +#define BSC_CR_BRK 128 +#define BSC_CR_CPOL 16 +#define BSC_CR_CPHA 8 +#define BSC_CR_I2C 4 +#define BSC_CR_SPI 2 +#define BSC_CR_EN 1 + +#define BSC_FR_RXBUSY 32 +#define BSC_FR_TXFE 16 +#define BSC_FR_RXFF 8 +#define BSC_FR_TXFF 4 +#define BSC_FR_RXFE 2 +#define BSC_FR_TXBUSY 1 + +/* BSC GPIO */ + +#define BSC_SDA_MOSI 18 +#define BSC_SCL_SCLK 19 +#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 + +/* timeout: 0-60000 */ + +#define PI_MIN_WDOG_TIMEOUT 0 +#define PI_MAX_WDOG_TIMEOUT 60000 + +/* timer: 0-9 */ + +#define PI_MIN_TIMER 0 +#define PI_MAX_TIMER 9 + +/* millis: 10-60000 */ + +#define PI_MIN_MS 10 +#define PI_MAX_MS 60000 + +#define PI_MAX_SCRIPTS 32 + +#define PI_MAX_SCRIPT_TAGS 50 +#define PI_MAX_SCRIPT_VARS 150 +#define PI_MAX_SCRIPT_PARAMS 10 + +/* script status */ + +#define PI_SCRIPT_INITING 0 +#define PI_SCRIPT_HALTED 1 +#define PI_SCRIPT_RUNNING 2 +#define PI_SCRIPT_WAITING 3 +#define PI_SCRIPT_FAILED 4 + +/* signum: 0-63 */ + +#define PI_MIN_SIGNUM 0 +#define PI_MAX_SIGNUM 63 + +/* timetype: 0-1 */ + +#define PI_TIME_RELATIVE 0 +#define PI_TIME_ABSOLUTE 1 + +#define PI_MAX_MICS_DELAY 1000000 /* 1 second */ +#define PI_MAX_MILS_DELAY 60000 /* 60 seconds */ + +/* cfgMillis */ + +#define PI_BUF_MILLIS_MIN 100 +#define PI_BUF_MILLIS_MAX 10000 + +/* cfgMicros: 1, 2, 4, 5, 8, or 10 */ + +/* cfgPeripheral: 0-1 */ + +#define PI_CLOCK_PWM 0 +#define PI_CLOCK_PCM 1 + +/* DMA channel: 0-15, 15 is unset */ + +#define PI_MIN_DMA_CHANNEL 0 +#define PI_MAX_DMA_CHANNEL 15 + +/* port */ + +#define PI_MIN_SOCKET_PORT 1024 +#define PI_MAX_SOCKET_PORT 32000 + + +/* ifFlags: */ + +#define PI_DISABLE_FIFO_IF 1 +#define PI_DISABLE_SOCK_IF 2 +#define PI_LOCALHOST_SOCK_IF 4 +#define PI_DISABLE_ALERT 8 + +/* memAllocMode */ + +#define PI_MEM_ALLOC_AUTO 0 +#define PI_MEM_ALLOC_PAGEMAP 1 +#define PI_MEM_ALLOC_MAILBOX 2 + +/* filters */ + +#define PI_MAX_STEADY 300000 +#define PI_MAX_ACTIVE 1000000 + +/* gpioCfgInternals */ + +#define PI_CFG_DBG_LEVEL 0 /* bits 0-3 */ +#define PI_CFG_ALERT_FREQ 4 /* bits 4-7 */ +#define PI_CFG_RT_PRIORITY (1<<8) +#define PI_CFG_STATS (1<<9) +#define PI_CFG_NOSIGHANDLER (1<<10) + +#define PI_CFG_ILLEGAL_VAL (1<<11) + + +/* gpioISR */ + +#define RISING_EDGE 0 +#define FALLING_EDGE 1 +#define EITHER_EDGE 2 + + +/* pads */ + +#define PI_MAX_PAD 2 + +#define PI_MIN_PAD_STRENGTH 1 +#define PI_MAX_PAD_STRENGTH 16 + +/* files */ + +#define PI_FILE_NONE 0 +#define PI_FILE_MIN 1 +#define PI_FILE_READ 1 +#define PI_FILE_WRITE 2 +#define PI_FILE_RW 3 +#define PI_FILE_APPEND 4 +#define PI_FILE_CREATE 8 +#define PI_FILE_TRUNC 16 +#define PI_FILE_MAX 31 + +#define PI_FROM_START 0 +#define PI_FROM_CURRENT 1 +#define PI_FROM_END 2 + +/* Allowed socket connect addresses */ + +#define MAX_CONNECT_ADDRESSES 256 + +/* events */ + +#define PI_MAX_EVENT 31 + +/* Event auto generated on BSC slave activity */ + +#define PI_EVENT_BSC 31 + +/*F*/ +int gpioInitialise(void); +/*D +Initialises the library. + +Returns the pigpio version number if OK, otherwise PI_INIT_FAILED. + +gpioInitialise must be called before using the other library functions +with the following exceptions: + +. . +[*gpioCfg**] +[*gpioVersion*] +[*gpioHardwareRevision*] +. . + +... +if (gpioInitialise() < 0) +{ + // pigpio initialisation failed. +} +else +{ + // pigpio initialised okay. +} +... +D*/ + + +/*F*/ +void gpioTerminate(void); +/*D +Terminates the library. + +Returns nothing. + +Call before program exit. + +This function resets the used DMA channels, releases memory, and +terminates any running threads. + +... +gpioTerminate(); +... +D*/ + + +/*F*/ +int gpioSetMode(unsigned gpio, unsigned mode); +/*D +Sets the GPIO mode, typically input or output. + +. . +gpio: 0-53 +mode: 0-7 +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_MODE. + +Arduino style: pinMode. + +... +gpioSetMode(17, PI_INPUT); // Set GPIO17 as input. + +gpioSetMode(18, PI_OUTPUT); // Set GPIO18 as output. + +gpioSetMode(22,PI_ALT0); // Set GPIO22 to alternative mode 0. +... + +See [[http://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf]] page 102 for an overview of the modes. +D*/ + + +/*F*/ +int gpioGetMode(unsigned gpio); +/*D +Gets the GPIO mode. + +. . +gpio: 0-53 +. . + +Returns the GPIO mode if OK, otherwise PI_BAD_GPIO. + +... +if (gpioGetMode(17) != PI_ALT0) +{ + gpioSetMode(17, PI_ALT0); // set GPIO17 to ALT0 +} +... +D*/ + + +/*F*/ +int gpioSetPullUpDown(unsigned gpio, unsigned pud); +/*D +Sets or clears resistor pull ups or downs on the GPIO. + +. . +gpio: 0-53 + pud: 0-2 +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_PUD. + +... +gpioSetPullUpDown(17, PI_PUD_UP); // Sets a pull-up. + +gpioSetPullUpDown(18, PI_PUD_DOWN); // Sets a pull-down. + +gpioSetPullUpDown(23, PI_PUD_OFF); // Clear any pull-ups/downs. +... +D*/ + + +/*F*/ +int gpioRead (unsigned gpio); +/*D +Reads the GPIO level, on or off. + +. . +gpio: 0-53 +. . + +Returns the GPIO level if OK, otherwise PI_BAD_GPIO. + +Arduino style: digitalRead. + +... +printf("GPIO24 is level %d", gpioRead(24)); +... +D*/ + + +/*F*/ +int gpioWrite(unsigned gpio, unsigned level); +/*D +Sets the GPIO level, on or off. + +. . + gpio: 0-53 +level: 0-1 +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL. + +If PWM or servo pulses are active on the GPIO they are switched off. + +Arduino style: digitalWrite + +... +gpioWrite(24, 1); // Set GPIO24 high. +... +D*/ + + +/*F*/ +int gpioPWM(unsigned user_gpio, unsigned dutycycle); +/*D +Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on). +Range defaults to 255. + +. . +user_gpio: 0-31 +dutycycle: 0-range +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYCYCLE. + +Arduino style: analogWrite + +This and the servo functionality use the DMA and PWM or PCM peripherals +to control and schedule the pulse lengths and dutycycles. + +The [*gpioSetPWMrange*] function may be used to change the default +range of 255. + +... +gpioPWM(17, 255); // Sets GPIO17 full on. + +gpioPWM(18, 128); // Sets GPIO18 half on. + +gpioPWM(23, 0); // Sets GPIO23 full off. +... +D*/ + + +/*F*/ +int gpioGetPWMdutycycle(unsigned user_gpio); +/*D +Returns the PWM dutycycle setting for the GPIO. + +. . +user_gpio: 0-31 +. . + +Returns between 0 (off) and range (fully on) if OK, otherwise +PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. + +For normal PWM the dutycycle will be out of the defined range +for the GPIO (see [*gpioGetPWMrange*]). + +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). + +Normal PWM range defaults to 255. +D*/ + + +/*F*/ +int gpioSetPWMrange(unsigned user_gpio, unsigned range); +/*D +Selects the dutycycle range to be used for the GPIO. Subsequent calls +to gpioPWM will use a dutycycle between 0 (off) and range (fully on). + +. . +user_gpio: 0-31 + range: 25-40000 +. . + +Returns the real range for the given GPIO's frequency if OK, +otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE. + +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. + +. . + 25, 50, 100, 125, 200, 250, 400, 500, 625, + 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000 +. . + +The real value set by [*gpioPWM*] is (dutycycle * real range) / range. + +... +gpioSetPWMrange(24, 2000); // Now 2000 is fully on + // 1000 is half on + // 500 is quarter on, etc. +... +D*/ + + +/*F*/ +int gpioGetPWMrange(unsigned user_gpio); +/*D +Returns the dutycycle range used for the GPIO if OK, otherwise +PI_BAD_USER_GPIO. + +. . +user_gpio: 0-31 +. . + +If a hardware clock or hardware PWM is active on the GPIO +the reported range will be 1000000 (1M). + +... +r = gpioGetPWMrange(23); +... +D*/ + + +/*F*/ +int gpioGetPWMrealRange(unsigned user_gpio); +/*D +Returns the real range used for the GPIO if OK, otherwise +PI_BAD_USER_GPIO. + +. . +user_gpio: 0-31 +. . + +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. + +... +rr = gpioGetPWMrealRange(17); +... +D*/ + + +/*F*/ +int gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency); +/*D +Sets the frequency in hertz to be used for the GPIO. + +. . +user_gpio: 0-31 +frequency: >=0 +. . + +Returns the numerically closest frequency if OK, otherwise +PI_BAD_USER_GPIO. + +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 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 +. . + +... +gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency. + +gpioSetPWMfrequency(24, 500); // Set GPIO24 to 500Hz. + +gpioSetPWMfrequency(25, 100000); // Set GPIO25 to highest frequency. +... +D*/ + + +/*F*/ +int gpioGetPWMfrequency(unsigned user_gpio); +/*D +Returns the frequency (in hertz) used for the GPIO if OK, otherwise +PI_BAD_USER_GPIO. + +. . +user_gpio: 0-31 +. . + +For normal PWM the frequency will be that defined for the GPIO by +[*gpioSetPWMfrequency*]. + +If a hardware clock is active on the GPIO the reported frequency +will be that set by [*gpioHardwareClock*]. + +If hardware PWM is active on the GPIO the reported frequency +will be that set by [*gpioHardwarePWM*]. + +... +f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23. +... +D*/ + + +/*F*/ +int gpioServo(unsigned user_gpio, unsigned pulsewidth); +/*D +Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to +2500 (most clockwise). + +. . + user_gpio: 0-31 +pulsewidth: 0, 500-2500 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_PULSEWIDTH. + +The range supported by servos varies and should probably be determined +by experiment. 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. + +The following 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. + +... +gpioServo(17, 1000); // Move servo to safe position anti-clockwise. + +gpioServo(23, 1500); // Move servo to centre position. + +gpioServo(25, 2000); // Move servo to safe position clockwise. +... + +OTHER UPDATE RATES: + +This function updates servos at 50Hz. If you wish to use a different +update frequency you will have to use the PWM functions. + +. . +PWM Hz 50 100 200 400 500 +1E6/Hz 20000 10000 5000 2500 2000 +. . + +Firstly set the desired PWM frequency using [*gpioSetPWMfrequency*]. + +Then set the PWM range using [*gpioSetPWMrange*] to 1E6/frequency. +Doing this allows you to use units of microseconds when setting +the servo pulsewidth. + +E.g. If you want to update a servo connected to GPIO25 at 400Hz + +. . +gpioSetPWMfrequency(25, 400); + +gpioSetPWMrange(25, 2500); +. . + +Thereafter use the PWM command to move the servo, +e.g. gpioPWM(25, 1500) will set a 1500 us pulse. +D*/ + + +/*F*/ +int gpioGetServoPulsewidth(unsigned user_gpio); +/*D +Returns the servo pulsewidth setting for the GPIO. + +. . +user_gpio: 0-31 +. . + +Returns 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise) +if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO. +D*/ + + +/*F*/ +int gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f); +/*D +Registers a function to be called (a callback) when the specified +GPIO changes state. + +. . +user_gpio: 0-31 + f: the callback function +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO. + +One callback may be registered per GPIO. + +The callback is passed the GPIO, the new level, and the tick. + +. . +Parameter Value Meaning + +GPIO 0-31 The GPIO which has changed state + +level 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (a watchdog timeout) + +tick 32 bit The number of microseconds since boot + WARNING: this wraps around from + 4294967295 to 0 roughly every 72 minutes +. . + +The alert may be cancelled by passing NULL as the function. + +The GPIO are sampled at a rate set when the library is started. + +If a value isn't specifically set the default of 5 us is used. + +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 +. . + +Level changes shorter than the sample rate may be missed. + +The thread which calls the alert functions is triggered nominally +1000 times per second. The active alert functions will be called +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. + +... +void aFunction(int gpio, int level, uint32_t tick) +{ + printf("GPIO %d became %d at %d", gpio, level, tick); +} + +// call aFunction whenever GPIO 4 changes state + +gpioSetAlertFunc(4, aFunction); +... +D*/ + + +/*F*/ +int gpioSetAlertFuncEx( + unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata); +/*D +Registers a function to be called (a callback) when the specified +GPIO changes state. + +. . +user_gpio: 0-31 + f: the callback function + userdata: pointer to arbitrary user data +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO. + +One callback may be registered per GPIO. + +The callback is passed the GPIO, the new level, the tick, and +the userdata pointer. + +. . +Parameter Value Meaning + +GPIO 0-31 The GPIO which has changed state + +level 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (a watchdog timeout) + +tick 32 bit The number of microseconds since boot + WARNING: this wraps around from + 4294967295 to 0 roughly every 72 minutes + +userdata pointer Pointer to an arbitrary object +. . + +See [*gpioSetAlertFunc*] for further details. + +Only one of [*gpioSetAlertFunc*] or [*gpioSetAlertFuncEx*] can be +registered per GPIO. +D*/ + + +/*F*/ +int gpioSetISRFunc( + unsigned gpio, unsigned edge, int timeout, gpioISRFunc_t f); +/*D +Registers a function to be called (a callback) whenever the specified +GPIO interrupt occurs. + +. . + gpio: 0-53 + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE +timeout: interrupt timeout in milliseconds (<=0 to cancel) + f: the callback function +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_EDGE, +or PI_BAD_ISR_INIT. + +One function may be registered per GPIO. + +The function is passed the GPIO, the current level, and the +current tick. The level will be PI_TIMEOUT if the optional +interrupt timeout expires. + +. . +Parameter Value Meaning + +GPIO 0-53 The GPIO which has changed state + +level 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (interrupt timeout) + +tick 32 bit The number of microseconds since boot + WARNING: this wraps around from + 4294967295 to 0 roughly every 72 minutes +. . + +The underlying Linux sysfs GPIO interface is used to provide +the interrupt services. + +The first time the function is called, with a non-NULL f, the +GPIO is exported, set to be an input, and set to interrupt +on the given edge and timeout. + +Subsequent calls, with a non-NULL f, can vary one or more of the +edge, timeout, or function. + +The ISR may be cancelled by passing a NULL f, in which case the +GPIO is unexported. + +The tick is that read at the time the process was informed of +the interrupt. This will be a variable number of microseconds +after the interrupt occurred. Typically the latency will be of +the order of 50 microseconds. The latency is not guaranteed +and will vary with system load. + +The level is that read at the time the process was informed of +the interrupt, or PI_TIMEOUT if the optional interrupt timeout +expired. It may not be the same as the expected edge as +interrupts happening in rapid succession may be missed by the +kernel (i.e. this mechanism can not be used to capture several +interrupts only a few microseconds apart). +D*/ + + +/*F*/ +int gpioSetISRFuncEx( + unsigned gpio, + unsigned edge, + int timeout, + gpioISRFuncEx_t f, + void *userdata); +/*D +Registers a function to be called (a callback) whenever the specified +GPIO interrupt occurs. + +. . + gpio: 0-53 + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE + timeout: interrupt timeout in milliseconds (<=0 to cancel) + f: the callback function +userdata: pointer to arbitrary user data +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_EDGE, +or PI_BAD_ISR_INIT. + +The function is passed the GPIO, the current level, the +current tick, and the userdata pointer. + +. . +Parameter Value Meaning + +GPIO 0-53 The GPIO which has changed state + +level 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (interrupt timeout) + +tick 32 bit The number of microseconds since boot + WARNING: this wraps around from + 4294967295 to 0 roughly every 72 minutes + +userdata pointer Pointer to an arbitrary object +. . + +Only one of [*gpioSetISRFunc*] or [*gpioSetISRFuncEx*] can be +registered per GPIO. + +See [*gpioSetISRFunc*] for further details. +D*/ + + +/*F*/ +int gpioNotifyOpen(void); +/*D +This function requests a free notification handle. + +Returns a handle greater than or equal to zero if OK, +otherwise PI_NO_HANDLE. + +A notification is a method for being notified of GPIO state changes +via a pipe or socket. + +Pipe notifications for handle x will be available at the pipe +named /dev/pigpiox (where x is the handle number). E.g. if the +function returns 15 then the notifications must be read +from /dev/pigpio15. + +Socket notifications are returned to the socket which requested the +handle. + +... +h = gpioNotifyOpen(); + +if (h >= 0) +{ + sprintf(str, "/dev/pigpio%d", h); + + fd = open(str, O_RDONLY); + + if (fd >= 0) + { + // Okay. + } + else + { + // Error. + } +} +else +{ + // Error. +} +... +D*/ + + +/*F*/ +int gpioNotifyOpenWithSize(int bufSize); +/*D +This function requests a free notification handle. + +It differs from [*gpioNotifyOpen*] in that the pipe size may be +specified, whereas [*gpioNotifyOpen*] uses the default pipe size. + +See [*gpioNotifyOpen*] for further details. +D*/ + + +/*F*/ +int gpioNotifyBegin(unsigned handle, uint32_t bits); +/*D +This function starts notifications on a previously opened handle. + +. . +handle: >=0, as returned by [*gpioNotifyOpen*] + bits: a bit mask indicating the GPIO of interest +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +The notification sends state changes for each GPIO whose corresponding +bit in bits is set. + +Each notification occupies 12 bytes in the fifo and has the +following structure. + +. . +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: three flags are defined, PI_NTFY_FLAGS_WDOG, +PI_NTFY_FLAGS_ALIVE, and PI_NTFY_FLAGS_EVENT. + +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. + +If bit 7 is set (PI_NTFY_FLAGS_EVENT) then bits 0-4 of the flags +indicate an event which has been triggered. + +tick: the number of microseconds since system boot. It wraps around +after 1h12m. + +level: indicates the level of each GPIO. If bit 1<=0, as returned by [*gpioNotifyOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +Notifications for the handle are suspended until [*gpioNotifyBegin*] +is called again. + +... +gpioNotifyPause(h); +... +D*/ + + +/*F*/ +int gpioNotifyClose(unsigned handle); +/*D +This function stops notifications on a previously opened handle +and releases the handle for reuse. + +. . +handle: >=0, as returned by [*gpioNotifyOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +... +gpioNotifyClose(h); +... +D*/ + + +/*F*/ +int gpioWaveClear(void); +/*D +This function clears all waveforms and any data added by calls to the +[*gpioWaveAdd**] functions. + +Returns 0 if OK. + +... +gpioWaveClear(); +... +D*/ + + +/*F*/ +int gpioWaveAddNew(void); +/*D +This function starts a new empty waveform. + +You wouldn't normally need to call this function as it is automatically +called after a waveform is created with the [*gpioWaveCreate*] function. + +Returns 0 if OK. + +... +gpioWaveAddNew(); +... +D*/ + + +/*F*/ +int gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses); +/*D +This function adds a number of pulses to the current waveform. + +. . +numPulses: the number of pulses + pulses: an array of pulses +. . + +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_TOO_MANY_PULSES. + +The pulses are interleaved in time order within the existing waveform +(if any). + +Merging allows the waveform to be built in parts, that is the settings +for GPIO#1 can be added, and then GPIO#2 etc. + +If the added waveform is intended to start after or within the existing +waveform then the first pulse should consist of a delay. + +... +// Construct and send a 30 microsecond square wave. + +gpioSetMode(gpio, PI_OUTPUT); + +pulse[0].gpioOn = (1<= 0) +{ + gpioWaveTxSend(wave_id, PI_WAVE_MODE_REPEAT); + + // Transmit for 30 seconds. + + sleep(30); + + gpioWaveTxStop(); +} +else +{ + // Wave create failed. +} +... +D*/ + + +/*F*/ +int gpioWaveAddSerial + (unsigned user_gpio, + unsigned baud, + unsigned data_bits, + unsigned stop_bits, + unsigned offset, + unsigned numBytes, + char *str); +/*D +This function adds a waveform representing serial data to the +existing waveform (if any). The serial data starts offset +microseconds from the start of the waveform. + +. . +user_gpio: 0-31 + baud: 50-1000000 +data_bits: 1-32 +stop_bits: 2-8 + offset: >=0 + numBytes: >=1 + str: an array of chars (which may contain nulls) +. . + +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS, +PI_BAD_STOPBITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET, +or PI_TOO_MANY_PULSES. + +NOTES: + +The serial data is formatted as one start bit, data_bits data bits, and +stop_bits/2 stop bits. + +It is legal to add serial data streams with different baud rates to +the same waveform. + +numBytes is the number of bytes of data in str. + +The bytes required for each character depend upon data_bits. + +For data_bits 1-8 there will be one byte per character. +For data_bits 9-16 there will be two bytes per character. +For data_bits 17-32 there will be four bytes per character. + +... +#define MSG_LEN 8 + +int i; +char *str; +char data[MSG_LEN]; + +str = "Hello world!"; + +gpioWaveAddSerial(4, 9600, 8, 2, 0, strlen(str), str); + +for (i=0; i=0, as returned by [*gpioWaveCreate*] +. . + +Wave ids are allocated in order, 0, 1, 2, etc. + +Returns 0 if OK, otherwise PI_BAD_WAVE_ID. +D*/ + + +/*F*/ +int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode); +/*D +This function transmits the waveform with id wave_id. The mode +determines whether the waveform is sent once or cycles endlessly. +The SYNC variants wait for the current waveform to reach the +end of a cycle or finish before starting the new waveform. + +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 [*gpioHardwarePWM*] will be cancelled. + +. . + wave_id: >=0, as returned by [*gpioWaveCreate*] +wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT, + PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC +. . + +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. +D*/ + + +/*F*/ +int gpioWaveChain(char *buf, unsigned bufSize); +/*D +This function transmits a chain of waveforms. + +NOTE: Any hardware PWM started by [*gpioHardwarePWM*] will be cancelled. + +The waves to be transmitted are specified by the contents of buf +which contains an ordered list of [*wave_id*]s and optional command +codes and related data. + +. . + buf: pointer to the wave_ids and optional command codes +bufSize: the number of bytes in buf +. . + +Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER, +PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID. + +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. + +... +#include +#include + +#define WAVES 5 +#define GPIO 4 + +int main(int argc, char *argv[]) +{ + int i, wid[WAVES]; + + if (gpioInitialise()<0) return -1; + + gpioSetMode(GPIO, PI_OUTPUT); + + printf("start piscope, press return"); getchar(); + + for (i=0; i=0 +. . + +Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO +or PI_NOT_SERIAL_GPIO. + +The bytes returned for each character depend upon the number of +data bits [*data_bits*] specified in the [*gpioSerialReadOpen*] command. + +For [*data_bits*] 1-8 there will be one byte per character. +For [*data_bits*] 9-16 there will be two bytes per character. +For [*data_bits*] 17-32 there will be four bytes per character. +D*/ + + +/*F*/ +int gpioSerialReadClose(unsigned user_gpio); +/*D +This function closes a GPIO for bit bang reading of serial data. + +. . +user_gpio: 0-31, previously opened with [*gpioSerialReadOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO. +D*/ + +/*F*/ +int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags); +/*D +This returns a handle for the device at the address on the I2C bus. + +. . + i2cBus: >=0 + i2cAddr: 0-0x7F +i2cFlags: 0 +. . + +No flags are currently defined. This parameter should be set to zero. + +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 + +Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR, +PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED. + +For the SMBus commands the low level transactions are shown at the end +of the function description. The following abbreviations are used. + +. . +S (1 bit) : Start bit +P (1 bit) : Stop bit +Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. +A, NA (1 bit) : Accept and not accept bit. +Addr (7 bits): I2C 7 bit address. +i2cReg (8 bits): Command byte, a byte which often selects a register. +Data (8 bits): A data byte. +Count (8 bits): A byte defining the length of a block operation. + +[..]: Data sent by the device. +. . +D*/ + + +/*F*/ +int i2cClose(unsigned handle); +/*D +This closes the I2C device associated with the handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + + +/*F*/ +int i2cWriteQuick(unsigned handle, unsigned bit); +/*D +This sends a single bit (in the Rd/Wr bit) to the device associated +with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] + bit: 0-1, the value to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Quick command. SMBus 2.0 5.5.1 +. . +S Addr bit [A] P +. . +D*/ + + +/*F*/ +int i2cWriteByte(unsigned handle, unsigned bVal); +/*D +This sends a single byte to the device associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] + bVal: 0-0xFF, the value to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Send byte. SMBus 2.0 5.5.2 +. . +S Addr Wr [A] bVal [A] P +. . +D*/ + + +/*F*/ +int i2cReadByte(unsigned handle); +/*D +This reads a single byte from the device associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +. . + +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +or PI_I2C_READ_FAILED. + +Receive byte. SMBus 2.0 5.5.3 +. . +S Addr Rd [A] [Data] NA P +. . +D*/ + + +/*F*/ +int i2cWriteByteData(unsigned handle, unsigned i2cReg, unsigned bVal); +/*D +This writes a single byte to the specified register of the device +associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to write + bVal: 0-0xFF, the value to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Write byte. SMBus 2.0 5.5.4 +. . +S Addr Wr [A] i2cReg [A] bVal [A] P +. . +D*/ + + +/*F*/ +int i2cWriteWordData(unsigned handle, unsigned i2cReg, unsigned wVal); +/*D +This writes a single 16 bit word to the specified register of the device +associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to write + wVal: 0-0xFFFF, the value to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Write word. SMBus 2.0 5.5.4 +. . +S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A] P +. . +D*/ + + +/*F*/ +int i2cReadByteData(unsigned handle, unsigned i2cReg); +/*D +This reads a single byte from the specified register of the device +associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to read +. . + +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Read byte. SMBus 2.0 5.5.5 +. . +S Addr Wr [A] i2cReg [A] S Addr Rd [A] [Data] NA P +. . +D*/ + + +/*F*/ +int i2cReadWordData(unsigned handle, unsigned i2cReg); +/*D +This reads a single 16 bit word from the specified register of the device +associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to read +. . + +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Read word. SMBus 2.0 5.5.5 +. . +S Addr Wr [A] i2cReg [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P +. . +D*/ + + +/*F*/ +int i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal); +/*D +This writes 16 bits of data to the specified register of the device +associated with handle and reads 16 bits of data in return. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to write/read + wVal: 0-0xFFFF, the value to write +. . + +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Process call. SMBus 2.0 5.5.6 +. . +S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A] + S Addr Rd [A] [DataLow] A [DataHigh] NA P +. . +D*/ + + +/*F*/ +int i2cWriteBlockData( +unsigned handle, unsigned i2cReg, char *buf, unsigned count); +/*D +This writes up to 32 bytes to the specified register of the device +associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to write + buf: an array with the data to send + count: 1-32, the number of bytes to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Block write. SMBus 2.0 5.5.7 +. . +S Addr Wr [A] i2cReg [A] count [A] + buf0 [A] buf1 [A] ... [A] bufn [A] P +. . +D*/ + + +/*F*/ +int i2cReadBlockData(unsigned handle, unsigned i2cReg, char *buf); +/*D +This reads a block of up to 32 bytes from the specified register of +the device associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to read + buf: an array to receive the read data +. . + +The amount of returned data is set by the device. + +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Block read. SMBus 2.0 5.5.7 +. . +S Addr Wr [A] i2cReg [A] + S Addr Rd [A] [Count] A [buf0] A [buf1] A ... A [bufn] NA P +. . +D*/ + + +/*F*/ +int i2cBlockProcessCall( +unsigned handle, unsigned i2cReg, char *buf, unsigned count); +/*D +This writes data bytes to the specified register of the device +associated with handle and reads a device specified number +of bytes of data in return. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to write/read + buf: an array with the data to send and to receive the read data + count: 1-32, the number of bytes to write +. . + +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +The SMBus 2.0 documentation states that a minimum of 1 byte may be +sent and a minimum of 1 byte may be received. The total number of +bytes sent/received must be 32 or less. + +Block write-block read. SMBus 2.0 5.5.8 +. . +S Addr Wr [A] i2cReg [A] count [A] buf0 [A] ... bufn [A] + S Addr Rd [A] [Count] A [buf0] A ... [bufn] A P +. . +D*/ + + +/*F*/ +int i2cReadI2CBlockData( +unsigned handle, unsigned i2cReg, char *buf, unsigned count); +/*D +This reads count bytes from the specified register of the device +associated with handle . The count may be 1-32. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to read + buf: an array to receive the read data + count: 1-32, the number of bytes to read +. . + +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +. . +S Addr Wr [A] i2cReg [A] + S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P +. . +D*/ + + +/*F*/ +int i2cWriteI2CBlockData( +unsigned handle, unsigned i2cReg, char *buf, unsigned count); +/*D +This writes 1 to 32 bytes to the specified register of the device +associated with handle. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] +i2cReg: 0-255, the register to write + buf: the data to write + count: 1-32, the number of bytes to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +. . +S Addr Wr [A] i2cReg [A] buf0 [A] buf1 [A] ... [A] bufn [A] P +. . +D*/ + +/*F*/ +int i2cReadDevice(unsigned handle, char *buf, unsigned count); +/*D +This reads count bytes from the raw device into buf. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] + buf: an array to receive the read data bytes + count: >0, the number of bytes to read +. . + +Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_READ_FAILED. + +. . +S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P +. . +D*/ + + +/*F*/ +int i2cWriteDevice(unsigned handle, char *buf, unsigned count); +/*D +This writes count bytes from buf to the raw device. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] + buf: an array containing the data bytes to write + count: >0, the number of bytes to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +. . +S Addr Wr [A] buf0 [A] buf1 [A] ... [A] bufn [A] P +. . +D*/ + +/*F*/ +void i2cSwitchCombined(int setting); +/*D +This sets the I2C (i2c-bcm2708) module "use combined transactions" +parameter on or off. + +. . +setting: 0 to set the parameter off, non-zero to set it on +. . + + +NOTE: when the flag is on a write followed by a read to the same +slave address will use a repeated start (rather than a stop/start). +D*/ + +/*F*/ +int i2cSegments(unsigned handle, pi_i2c_msg_t *segs, unsigned numSegs); +/*D +This function executes multiple I2C segments in one transaction by +calling the I2C_RDWR ioctl. + +. . + handle: >=0, as returned by a call to [*i2cOpen*] + segs: an array of I2C segments +numSegs: >0, the number of I2C segments +. . + +Returns the number of segments if OK, otherwise PI_BAD_I2C_SEG. +D*/ + +/*F*/ +int i2cZip( + unsigned handle, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen); +/*D +This function executes a sequence of I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] + inBuf: pointer to the concatenated I2C commands, see below + inLen: size of command buffer +outBuf: pointer to buffer to hold returned data +outLen: size of output buffer +. . + +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN. +PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG. + +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. +The flags default to 0. The address and flags maintain their +previous value until updated. + +The returned I2C data is stored in consecutive locations of outBuf. + +... +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 +... +D*/ + +/*F*/ +int bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud); +/*D +This function selects a pair of GPIO for bit banging I2C at a +specified baud rate. + +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 + +. . + SDA: 0-31 + SCL: 0-31 +baud: 50-500000 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or +PI_GPIO_IN_USE. + +NOTE: + +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. +D*/ + +/*F*/ +int bbI2CClose(unsigned SDA); +/*D +This function stops bit banging I2C on a pair of GPIO previously +opened with [*bbI2COpen*]. + +. . +SDA: 0-31, the SDA GPIO used in a prior call to [*bbI2COpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO. +D*/ + +/*F*/ +int bbI2CZip( + unsigned SDA, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen); +/*D +This function executes a sequence of bit banged I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +. . + SDA: 0-31 (as used in a prior call to [*bbI2COpen*]) + inBuf: pointer to the concatenated I2C commands, see below + inLen: size of command buffer +outBuf: pointer to buffer to hold returned data +outLen: size of output buffer +. . + +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER, +PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN, +PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED. + +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. + +The returned I2C data is stored in consecutive locations of outBuf. + +... +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 +... +D*/ + +/*F*/ +int bscXfer(bsc_xfer_t *bsc_xfer); +/*D +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 +receive buffer. + +. . +bsc_xfer:= a structure defining the transfer + +typedef struct +{ + uint32_t control; // Write + int rxCnt; // Read only + char rxBuf[BSC_FIFO_SIZE]; // Read only + int txCnt; // Write + char txBuf[BSC_FIFO_SIZE]; // Write +} bsc_xfer_t; +. . + +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. + +Note that the control word sets the BSC mode. The BSC will stay in +that mode until a different control word is sent. + +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 returned function value is the status of the transfer (see below). + +If there was an error the status will be less than zero +(and will contain the error code). + +The most significant word of the returned status contains the number +of bytes actually copied from txBuf to the BSC transmit FIFO (may be +less than requested if the FIFO already contained untransmitted data). + +control 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 + +The following example shows how to configure the BSC peripheral as +an I2C slave with address 0x13 and send four bytes. + +... +bsc_xfer_t xfer; + +xfer.control = (0x13<<16) | 0x305; + +memcpy(xfer.txBuf, "ABCD", 4); +xfer.txCnt = 4; + +status = bscXfer(&xfer); + +if (status >= 0) +{ + // process transfer +} +... +D*/ + +/*F*/ +int bbSPIOpen( + unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, + unsigned baud, unsigned spiFlags); +/*D +This function selects a set of GPIO for bit banging SPI with +a specified baud rate and mode. + +. . + CS: 0-31 + MISO: 0-31 + MOSI: 0-31 + SCLK: 0-31 + baud: 50-250000 +spiFlags: see below +. . + +spiFlags 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, defaults to 0 + +. . +Mode CPOL CPHA + 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. + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or +PI_GPIO_IN_USE. + +If more than one device is connected to the SPI bus (defined by +SCLK, MOSI, and MISO) each must have its own CS. + +... +bbSPIOpen(10, MISO, MOSI, SCLK, 10000, 0); // device 1 +bbSPIOpen(11, MISO, MOSI, SCLK, 20000, 3); // device 2 +... +D*/ + +/*F*/ +int bbSPIClose(unsigned CS); +/*D +This function stops bit banging SPI on a set of GPIO +opened with [*bbSPIOpen*]. + +. . +CS: 0-31, the CS GPIO used in a prior call to [*bbSPIOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO. +D*/ + +/*F*/ +int bbSPIXfer( + unsigned CS, + char *inBuf, + char *outBuf, + unsigned count); +/*D +This function executes a bit banged SPI transfer. + +. . + CS: 0-31 (as used in a prior call to [*bbSPIOpen*]) + inBuf: pointer to buffer to hold data to be sent +outBuf: pointer to buffer to hold returned data + count: size of data transfer +. . + +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_SPI_GPIO or PI_BAD_POINTER. + +... +// gcc -Wall -pthread -o bbSPIx_test bbSPIx_test.c -lpigpio +// sudo ./bbSPIx_test + + +#include + +#include "pigpio.h" + +#define CE0 5 +#define CE1 6 +#define MISO 13 +#define MOSI 19 +#define SCLK 12 + +int main(int argc, char *argv[]) +{ + int i, count, set_val, read_val; + unsigned char inBuf[3]; + char cmd1[] = {0, 0}; + char cmd2[] = {12, 0}; + char cmd3[] = {1, 128, 0}; + + if (gpioInitialise() < 0) + { + fprintf(stderr, "pigpio initialisation failed.\n"); + return 1; + } + + bbSPIOpen(CE0, MISO, MOSI, SCLK, 10000, 0); // MCP4251 DAC + bbSPIOpen(CE1, MISO, MOSI, SCLK, 20000, 3); // MCP3008 ADC + + for (i=0; i<256; i++) + { + cmd1[1] = i; + + count = bbSPIXfer(CE0, cmd1, (char *)inBuf, 2); // > DAC + + if (count == 2) + { + count = bbSPIXfer(CE0, cmd2, (char *)inBuf, 2); // < DAC + + if (count == 2) + { + set_val = inBuf[1]; + + count = bbSPIXfer(CE1, cmd3, (char *)inBuf, 3); // < ADC + + if (count == 3) + { + read_val = ((inBuf[1]&3)<<8) | inBuf[2]; + printf("%d %d\n", set_val, read_val); + } + } + } + } + + bbSPIClose(CE0); + bbSPIClose(CE1); + + gpioTerminate(); + + return 0; +} +... +D*/ + +/*F*/ +int spiOpen(unsigned spiChan, unsigned baud, unsigned spiFlags); +/*D +This function returns a handle for the SPI device on the channel. +Data will be transferred at baud bits per second. The flags may +be used to modify the default behaviour of 4-wire operation, mode 0, +active low chip select. + +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 + +. . + spiChan: 0-1 (0-2 for the auxiliary SPI) + baud: 32K-125M (values above 30M are unlikely to work) +spiFlags: see below +. . + +Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL, +PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED. + +spiFlags 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 [*spiRead*], [*spiWrite*], and [*spiXfer*] functions +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 word. +For bits 9-16 there will be two bytes per word. +For bits 17-32 there will be four bytes per word. + +Multi-byte transfers are made in least significant byte first order. + +E.g. to transfer 32 11-bit words buf should contain 64 bytes +and count should be 64. + +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. +D*/ + +/*F*/ +int spiClose(unsigned handle); +/*D +This functions closes the SPI device identified by the handle. + +. . +handle: >=0, as returned by a call to [*spiOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + + +/*F*/ +int spiRead(unsigned handle, char *buf, unsigned count); +/*D +This function reads count bytes of data from the SPI +device associated with the handle. + +. . +handle: >=0, as returned by a call to [*spiOpen*] + buf: an array to receive the read data bytes + count: the number of bytes to read +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + + +/*F*/ +int spiWrite(unsigned handle, char *buf, unsigned count); +/*D +This function writes count bytes of data from buf to the SPI +device associated with the handle. + +. . +handle: >=0, as returned by a call to [*spiOpen*] + buf: the data bytes to write + count: the number of bytes to write +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + +/*F*/ +int spiXfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count); +/*D +This function transfers count bytes of data from txBuf to the SPI +device associated with the handle. Simultaneously count bytes of +data are read from the device and placed in rxBuf. + +. . +handle: >=0, as returned by a call to [*spiOpen*] + txBuf: the data bytes to write + rxBuf: the received data bytes + count: the number of bytes to transfer +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + + +/*F*/ +int serOpen(char *sertty, unsigned baud, unsigned serFlags); +/*D +This function opens a serial device at a specified baud rate +and with specified flags. The device name must start with +/dev/tty or /dev/serial. + +. . + sertty: the serial device to open + baud: the baud rate in bits per second, see below +serFlags: 0 +. . + +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or +PI_SER_OPEN_FAILED. + +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. + +No flags are currently defined. This parameter should be set to zero. +D*/ + + +/*F*/ +int serClose(unsigned handle); +/*D +This function closes the serial device associated with handle. + +. . +handle: >=0, as returned by a call to [*serOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int serWriteByte(unsigned handle, unsigned bVal); +/*D +This function writes bVal to the serial port associated with handle. + +. . +handle: >=0, as returned by a call to [*serOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. +D*/ + +/*F*/ +int serReadByte(unsigned handle); +/*D +This function reads a byte from the serial port associated with handle. + +. . +handle: >=0, as returned by a call to [*serOpen*] +. . + +Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED. + +If no data is ready PI_SER_READ_NO_DATA is returned. +D*/ + +/*F*/ +int serWrite(unsigned handle, char *buf, unsigned count); +/*D +This function writes count bytes from buf to the the serial port +associated with handle. + +. . +handle: >=0, as returned by a call to [*serOpen*] + buf: the array of bytes to write + count: the number of bytes to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. +D*/ + + +/*F*/ +int serRead(unsigned handle, char *buf, unsigned count); +/*D +This function reads up count bytes from the the serial port +associated with handle and writes them to buf. + +. . +handle: >=0, as returned by a call to [*serOpen*] + buf: an array to receive the read data + count: the maximum number of bytes to read +. . + +Returns the number of bytes read (>0=) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_SER_READ_NO_DATA. + +If no data is ready zero is returned. +D*/ + + +/*F*/ +int serDataAvailable(unsigned handle); +/*D +This function returns the number of bytes available +to be read from the device associated with handle. + +. . +handle: >=0, as returned by a call to [*serOpen*] +. . + +Returns the number of bytes of data available (>=0) if OK, +otherwise PI_BAD_HANDLE. +D*/ + + +/*F*/ +int gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level); +/*D +This function sends a trigger pulse to a GPIO. The GPIO is set to +level for pulseLen microseconds and then reset to not level. + +. . +user_gpio: 0-31 + pulseLen: 1-100 + level: 0,1 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL, +or PI_BAD_PULSELEN. +D*/ + + +/*F*/ +int gpioSetWatchdog(unsigned user_gpio, unsigned timeout); +/*D +Sets a watchdog for a GPIO. + +. . +user_gpio: 0-31 + timeout: 0-60000 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_WDOG_TIMEOUT. + +The watchdog is nominally in milliseconds. + +One watchdog may be registered per GPIO. + +The watchdog may be cancelled by setting timeout to 0. + +Until cancelled a timeout will be reported every timeout milliseconds +after the last GPIO activity. + +In particular: + +1) any registered alert function for the GPIO will be called with + the level set to PI_TIMEOUT. + +2) any notification for the GPIO will have a report written to the + fifo with the flags set to indicate a watchdog timeout. + +... +void aFunction(int gpio, int level, uint32_t tick) +{ + printf("GPIO %d became %d at %d", gpio, level, tick); +} + +// call aFunction whenever GPIO 4 changes state +gpioSetAlertFunc(4, aFunction); + +// or approximately every 5 millis +gpioSetWatchdog(4, 5); +... +D*/ + + +/*F*/ +int gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active); +/*D +Sets a noise filter on a GPIO. + +Level changes on the GPIO are ignored until a level which has +been stable for [*steady*] microseconds is detected. Level changes +on the GPIO are then reported for [*active*] microseconds after +which the process repeats. + +. . +user_gpio: 0-31 + steady: 0-300000 + active: 0-1000000 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + +This filter affects the GPIO samples returned to callbacks set up +with [*gpioSetAlertFunc*], [*gpioSetAlertFuncEx*], [*gpioSetGetSamplesFunc*], +and [*gpioSetGetSamplesFuncEx*]. + +It does not affect interrupts set up with [*gpioSetISRFunc*], +[*gpioSetISRFuncEx*], or levels read by [*gpioRead*], +[*gpioRead_Bits_0_31*], or [*gpioRead_Bits_32_53*]. + +Level changes before and after the active period may +be reported. Your software must be designed to cope with +such reports. +D*/ + + +/*F*/ +int gpioGlitchFilter(unsigned user_gpio, unsigned steady); +/*D +Sets a glitch filter on a GPIO. + +Level changes on the GPIO are not reported unless the level +has been stable for at least [*steady*] microseconds. The +level is then reported. Level changes of less than [*steady*] +microseconds are ignored. + +. . +user_gpio: 0-31 + steady: 0-300000 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + +This filter affects the GPIO samples returned to callbacks set up +with [*gpioSetAlertFunc*], [*gpioSetAlertFuncEx*], [*gpioSetGetSamplesFunc*], +and [*gpioSetGetSamplesFuncEx*]. + +It does not affect interrupts set up with [*gpioSetISRFunc*], +[*gpioSetISRFuncEx*], or levels read by [*gpioRead*], +[*gpioRead_Bits_0_31*], or [*gpioRead_Bits_32_53*]. + +Each (stable) edge will be timestamped [*steady*] microseconds +after it was first detected. +D*/ + + +/*F*/ +int gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits); +/*D +Registers a function to be called (a callback) every millisecond +with the latest GPIO samples. + +. . + f: the function to call +bits: the GPIO of interest +. . + +Returns 0 if OK. + +The function is passed a pointer to the samples (an array of +[*gpioSample_t*]), and the number of samples. + +Only one function can be registered. + +The callback may be cancelled by passing NULL as the function. + +The samples returned will be the union of bits, plus any active alerts, +plus any active notifications. + +e.g. if there are alerts for GPIO 7, 8, and 9, notifications for GPIO +8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for GPIO +7, 8, 9, 10, 17, 23, and 24 will be reported. +D*/ + + +/*F*/ +int gpioSetGetSamplesFuncEx( + gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata); +/*D +Registers a function to be called (a callback) every millisecond +with the latest GPIO samples. + +. . + f: the function to call + bits: the GPIO of interest +userdata: a pointer to arbitrary user data +. . + +Returns 0 if OK. + +The function is passed a pointer to the samples (an array of +[*gpioSample_t*]), the number of samples, and the userdata pointer. + +Only one of [*gpioGetSamplesFunc*] or [*gpioGetSamplesFuncEx*] can be +registered. + +See [*gpioSetGetSamplesFunc*] for further details. +D*/ + + +/*F*/ +int gpioSetTimerFunc(unsigned timer, unsigned millis, gpioTimerFunc_t f); +/*D +Registers a function to be called (a callback) every millis milliseconds. + +. . + timer: 0-9 +millis: 10-60000 + f: the function to call +. . + +Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED. + +10 timers are supported numbered 0 to 9. + +One function may be registered per timer. + +The timer may be cancelled by passing NULL as the function. + +... +void bFunction(void) +{ + printf("two seconds have elapsed"); +} + +// call bFunction every 2000 milliseconds +gpioSetTimerFunc(0, 2000, bFunction); +... +D*/ + + +/*F*/ +int gpioSetTimerFuncEx( + unsigned timer, unsigned millis, gpioTimerFuncEx_t f, void *userdata); +/*D +Registers a function to be called (a callback) every millis milliseconds. + +. . + timer: 0-9. + millis: 10-60000 + f: the function to call +userdata: a pointer to arbitrary user data +. . + +Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED. + +The function is passed the userdata pointer. + +Only one of [*gpioSetTimerFunc*] or [*gpioSetTimerFuncEx*] can be +registered per timer. + +See [*gpioSetTimerFunc*] for further details. +D*/ + + +/*F*/ +pthread_t *gpioStartThread(gpioThreadFunc_t f, void *userdata); +/*D +Starts a new thread of execution with f as the main routine. + +. . + f: the main function for the new thread +userdata: a pointer to arbitrary user data +. . + +Returns a pointer to pthread_t if OK, otherwise NULL. + +The function is passed the single argument arg. + +The thread can be cancelled by passing the pointer to pthread_t to +[*gpioStopThread*]. + +... +#include +#include + +void *myfunc(void *arg) +{ + while (1) + { + printf("%s", arg); + sleep(1); + } +} + +int main(int argc, char *argv[]) +{ + pthread_t *p1, *p2, *p3; + + if (gpioInitialise() < 0) return 1; + + p1 = gpioStartThread(myfunc, "thread 1"); sleep(3); + + p2 = gpioStartThread(myfunc, "thread 2"); sleep(3); + + p3 = gpioStartThread(myfunc, "thread 3"); sleep(3); + + gpioStopThread(p3); sleep(3); + + gpioStopThread(p2); sleep(3); + + gpioStopThread(p1); sleep(3); + + gpioTerminate(); +} +... +D*/ + + +/*F*/ +void gpioStopThread(pthread_t *pth); +/*D +Cancels the thread pointed at by pth. + +. . +pth: a thread pointer returned by [*gpioStartThread*] +. . + +No value is returned. + +The thread to be stopped should have been started with [*gpioStartThread*]. +D*/ + + +/*F*/ +int gpioStoreScript(char *script); +/*D +This function stores a null terminated script for later execution. + +See [[http://abyz.me.uk/rpi/pigpio/pigs.html#Scripts]] for details. + +. . +script: the text of the script +. . + +The function returns a script id if the script is valid, +otherwise PI_BAD_SCRIPT. +D*/ + + +/*F*/ +int gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param); +/*D +This function runs a stored script. + +. . +script_id: >=0, as returned by [*gpioStoreScript*] + numPar: 0-10, the number of parameters + param: an array of parameters +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM. + +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. +D*/ + +/*F*/ +int gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param); +/*D +This function runs a stored script. + +. . +script_id: >=0, as returned by [*gpioStoreScript*] + numPar: 0-10, the number of parameters + param: an array of parameters +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM. + +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. +D*/ + + + +/*F*/ +int gpioUpdateScript(unsigned script_id, unsigned numPar, uint32_t *param); +/*D +This function sets the parameters of a script. The script may or +may not be running. The first numPar parameters of the script are +overwritten with the new values. + +. . +script_id: >=0, as returned by [*gpioStoreScript*] + numPar: 0-10, the number of parameters + param: an array of parameters +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM. + +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. +D*/ + + +/*F*/ +int gpioScriptStatus(unsigned script_id, uint32_t *param); +/*D +This function returns the run status of a stored script as well as +the current values of parameters 0 to 9. + +. . +script_id: >=0, as returned by [*gpioStoreScript*] + param: an array to hold the returned 10 parameters +. . + +The function returns greater than or equal to 0 if OK, +otherwise PI_BAD_SCRIPT_ID. + +The run status may be + +. . +PI_SCRIPT_INITING +PI_SCRIPT_HALTED +PI_SCRIPT_RUNNING +PI_SCRIPT_WAITING +PI_SCRIPT_FAILED +. . + +The current value of script parameters 0 to 9 are returned in param. +D*/ + + +/*F*/ +int gpioStopScript(unsigned script_id); +/*D +This function stops a running script. + +. . +script_id: >=0, as returned by [*gpioStoreScript*] +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. +D*/ + + +/*F*/ +int gpioDeleteScript(unsigned script_id); +/*D +This function deletes a stored script. + +. . +script_id: >=0, as returned by [*gpioStoreScript*] +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. +D*/ + + +/*F*/ +int gpioSetSignalFunc(unsigned signum, gpioSignalFunc_t f); +/*D +Registers a function to be called (a callback) when a signal occurs. + +. . +signum: 0-63 + f: the callback function +. . + +Returns 0 if OK, otherwise PI_BAD_SIGNUM. + +The function is passed the signal number. + +One function may be registered per signal. + +The callback may be cancelled by passing NULL. + +By default all signals are treated as fatal and cause the library +to call gpioTerminate and then exit. +D*/ + + +/*F*/ +int gpioSetSignalFuncEx( + unsigned signum, gpioSignalFuncEx_t f, void *userdata); +/*D +Registers a function to be called (a callback) when a signal occurs. + +. . + signum: 0-63 + f: the callback function +userdata: a pointer to arbitrary user data +. . + +Returns 0 if OK, otherwise PI_BAD_SIGNUM. + +The function is passed the signal number and the userdata pointer. + +Only one of gpioSetSignalFunc or gpioSetSignalFuncEx can be +registered per signal. + +See gpioSetSignalFunc for further details. +D*/ + + +/*F*/ +uint32_t gpioRead_Bits_0_31(void); +/*D +Returns the current level of GPIO 0-31. +D*/ + + +/*F*/ +uint32_t gpioRead_Bits_32_53(void); +/*D +Returns the current level of GPIO 32-53. +D*/ + + +/*F*/ +int gpioWrite_Bits_0_31_Clear(uint32_t bits); +/*D +Clears GPIO 0-31 if the corresponding bit in bits is set. + +. . +bits: a bit mask of GPIO to clear +. . + +Returns 0 if OK. + +... +// To clear (set to 0) GPIO 4, 7, and 15 +gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) ); +... +D*/ + + +/*F*/ +int gpioWrite_Bits_32_53_Clear(uint32_t bits); +/*D +Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set. + +. . +bits: a bit mask of GPIO to clear +. . + +Returns 0 if OK. +D*/ + + +/*F*/ +int gpioWrite_Bits_0_31_Set(uint32_t bits); +/*D +Sets GPIO 0-31 if the corresponding bit in bits is set. + +. . +bits: a bit mask of GPIO to set +. . + +Returns 0 if OK. +D*/ + + +/*F*/ +int gpioWrite_Bits_32_53_Set(uint32_t bits); +/*D +Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set. + +. . +bits: a bit mask of GPIO to set +. . + +Returns 0 if OK. + +... +// To set (set to 1) GPIO 32, 40, and 53 +gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32))); +... +D*/ + +/*F*/ +int gpioHardwareClock(unsigned gpio, unsigned clkfreq); +/*D +Starts a hardware clock on a GPIO at the specified frequency. +Frequencies above 30MHz are unlikely to work. + +. . + gpio: see description +clkfreq: 0 (off) or 4689-250M (13184-375M for the BCM2711) +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HCLK_GPIO, +PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS. + +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 Rev.2 B (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. +D*/ + +/*F*/ +int gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty); +/*D +Starts hardware PWM on a GPIO at the specified frequency and dutycycle. +Frequencies above 30MHz are unlikely to work. + +NOTE: Any waveform started by [*gpioWaveTxSend*], or +[*gpioWaveChain*] 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 by a call to +[*gpioCfgClock*]. + +. . + gpio: see description +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_BAD_GPIO, PI_NOT_HPWM_GPIO, +PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, or PI_HPWM_ILLEGAL. + +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/PWMfreq (375M/PWMfreq for the BCM2711). + +The actual frequency set is 250M/steps (375M/steps for the BCM2711). + +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*/ + +/*F*/ +int gpioTime(unsigned timetype, int *seconds, int *micros); +/*D +Updates the seconds and micros variables with the current time. + +. . +timetype: 0 (relative), 1 (absolute) + seconds: a pointer to an int to hold seconds + micros: a pointer to an int to hold microseconds +. . + +Returns 0 if OK, otherwise PI_BAD_TIMETYPE. + +If timetype is PI_TIME_ABSOLUTE updates seconds and micros with the +number of seconds and microseconds since the epoch (1st January 1970). + +If timetype is PI_TIME_RELATIVE updates seconds and micros with the +number of seconds and microseconds since the library was initialised. + +... +int secs, mics; + +// print the number of seconds since the library was started +gpioTime(PI_TIME_RELATIVE, &secs, &mics); +printf("library started %d.%03d seconds ago", secs, mics/1000); +... +D*/ + + +/*F*/ +int gpioSleep(unsigned timetype, int seconds, int micros); +/*D +Sleeps for the number of seconds and microseconds specified by seconds +and micros. + +. . +timetype: 0 (relative), 1 (absolute) + seconds: seconds to sleep + micros: microseconds to sleep +. . + +Returns 0 if OK, otherwise PI_BAD_TIMETYPE, PI_BAD_SECONDS, +or PI_BAD_MICROS. + +If timetype is PI_TIME_ABSOLUTE the sleep ends when the number of seconds +and microseconds since the epoch (1st January 1970) has elapsed. System +clock changes are taken into account. + +If timetype is PI_TIME_RELATIVE the sleep is for the specified number +of seconds and microseconds. System clock changes do not effect the +sleep length. + +For short delays (say, 50 microseonds or less) use [*gpioDelay*]. + +... +gpioSleep(PI_TIME_RELATIVE, 2, 500000); // sleep for 2.5 seconds + +gpioSleep(PI_TIME_RELATIVE, 0, 100000); // sleep for 0.1 seconds + +gpioSleep(PI_TIME_RELATIVE, 60, 0); // sleep for one minute +... +D*/ + + +/*F*/ +uint32_t gpioDelay(uint32_t micros); +/*D +Delays for at least the number of microseconds specified by micros. + +. . +micros: the number of microseconds to sleep +. . + +Returns the actual length of the delay in microseconds. + +Delays of 100 microseconds or less use busy waits. +D*/ + + +/*F*/ +uint32_t gpioTick(void); +/*D +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. + +You don't need to worry about the wrap around as long as you +take a tick (uint32_t) from another tick, i.e. the following +code will always provide the correct difference. + +... +uint32_t startTick, endTick; +int diffTick; + +startTick = gpioTick(); + +// do some processing + +endTick = gpioTick(); + +diffTick = endTick - startTick; + +printf("some processing took %d microseconds", diffTick); +... +D*/ + + +/*F*/ +unsigned gpioHardwareRevision(void); +/*D +Returns the hardware revision. + +If the hardware revision can not be found or is not a valid hexadecimal +number the function returns 0. + +The hardware revision is the last few characters on the Revision line of +/proc/cpuinfo. + +The revision number can be used to determine the assignment of GPIO +to pins (see [*gpio*]). + +There are at least 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 function returns 2. +for "Revision : 000f" the function returns 15. +for "Revision : 000g" the function returns 0. +D*/ + + +/*F*/ +unsigned gpioVersion(void); +/*D +Returns the pigpio version. +D*/ + + +/*F*/ +int gpioGetPad(unsigned pad); +/*D +This function returns the pad drive strength in mA. + +. . +pad: 0-2, the pad to get +. . + +Returns the pad drive strength if OK, otherwise PI_BAD_PAD. + +Pad @ GPIO +0 @ 0-27 +1 @ 28-45 +2 @ 46-53 + +... +strength = gpioGetPad(1); // get pad 1 strength +... +D*/ + + +/*F*/ +int gpioSetPad(unsigned pad, unsigned padStrength); +/*D +This function sets the pad drive strength in mA. + +. . + pad: 0-2, the pad to set +padStrength: 1-16 mA +. . + +Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH. + +Pad @ GPIO +0 @ 0-27 +1 @ 28-45 +2 @ 46-53 + +... +gpioSetPad(0, 16); // set pad 0 strength to 16 mA +... +D*/ + +/*F*/ +int eventMonitor(unsigned handle, uint32_t bits); +/*D +This function selects the events to be reported on a previously +opened handle. + +. . +handle: >=0, as returned by [*gpioNotifyOpen*] + bits: a bit mask indicating the events of interest +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +A report is sent each time an event is triggered providing the +corresponding bit in bits is set. + +See [*gpioNotifyBegin*] for the notification format. + +... +// Start reporting events 3, 6, and 7. + +// bit 76543210 +// (0xC8 = 0b11001000) + +eventMonitor(h, 0xC8); +... + +D*/ + +/*F*/ +int eventSetFunc(unsigned event, eventFunc_t f); +/*D +Registers a function to be called (a callback) when the specified +event occurs. + +. . +event: 0-31 + f: the callback function +. . + +Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + +One function may be registered per event. + +The function is passed the event, and the tick. + +The callback may be cancelled by passing NULL as the function. +D*/ + +/*F*/ +int eventSetFuncEx(unsigned event, eventFuncEx_t f, void *userdata); +/*D +Registers a function to be called (a callback) when the specified +event occurs. + +. . + event: 0-31 + f: the callback function +userdata: pointer to arbitrary user data +. . + +Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + +One function may be registered per event. + +The function is passed the event, the tick, and the ueserdata pointer. + +The callback may be cancelled by passing NULL as the function. + +Only one of [*eventSetFunc*] or [*eventSetFuncEx*] can be +registered per event. +D*/ + +/*F*/ +int eventTrigger(unsigned event); +/*D +This function signals the occurrence of an event. + +. . +event: 0-31, the event +. . + +Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + +An event is a signal used to inform one or more consumers +to start an action. Each consumer which has registered an interest +in the event (e.g. by calling [*eventSetFunc*]) will be informed by +a callback. + +One event, PI_EVENT_BSC (31) is predefined. This event is +auto generated on BSC slave activity. + +The meaning of other events is arbitrary. + +Note that other than its id and its tick there is no data associated +with an event. +D*/ + + +/*F*/ +int shell(char *scriptName, char *scriptString); +/*D +This function uses the system call to execute a shell script +with the given string as its parameter. + +. . + scriptName: the name of the script, only alphanumeric characters, + '-' and '_' are allowed in the name +scriptString: the string to pass to the script +. . + +The exit status of the system call is returned if OK, otherwise +PI_BAD_SHELL_STATUS. + +scriptName 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 +status = shell("scr1", "hello world"); + +// pass three parameters, hello, string with spaces, and world +status = shell("scr1", "hello 'string with spaces' world"); + +// pass one parameter, hello string with spaces world +status = shell("scr1", "\"hello string with spaces world\""); +... +D*/ + +#pragma GCC diagnostic push + +#pragma GCC diagnostic ignored "-Wcomment" + +/*F*/ +int fileOpen(char *file, unsigned mode); +/*D +This function returns a handle to a file opened in a specified mode. + +. . +file: the file to open +mode: the file open mode +. . + +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS, +PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR. + +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. + +Macro @ Value @ Meaning +PI_FILE_READ @ 1 @ open file for reading +PI_FILE_WRITE @ 2 @ open file for writing +PI_FILE_RW @ 3 @ open file for reading and writing + +The following values may be or'd into the mode. + +Macro @ Value @ Meaning +PI_FILE_APPEND @ 4 @ Writes append data to the end of the file +PI_FILE_CREATE @ 8 @ The file is created if it doesn't exist +PI_FILE_TRUNC @ 16 @ The file is truncated + +Newly created files are owned by root with permissions owner read and write. + +... +#include +#include + +int main(int argc, char *argv[]) +{ + int handle, c; + char buf[60000]; + + if (gpioInitialise() < 0) return 1; + + // assumes /opt/pigpio/access contains the following line + // /ram/*.c r + + handle = fileOpen("/ram/pigpio.c", PI_FILE_READ); + + if (handle >= 0) + { + while ((c=fileRead(handle, buf, sizeof(buf)-1))) + { + buf[c] = 0; + printf("%s", buf); + } + + fileClose(handle); + } + + gpioTerminate(); +} +... +D*/ + +#pragma GCC diagnostic pop + +/*F*/ +int fileClose(unsigned handle); +/*D +This function closes the file associated with handle. + +. . +handle: >=0, as returned by a call to [*fileOpen*] +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +... +fileClose(h); +... +D*/ + + +/*F*/ +int fileWrite(unsigned handle, char *buf, unsigned count); +/*D +This function writes count bytes from buf to the the file +associated with handle. + +. . +handle: >=0, as returned by a call to [*fileOpen*] + buf: the array of bytes to write + count: the number of bytes to write +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, +PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE. + +... +status = fileWrite(h, buf, count); +if (status == 0) +{ + // okay +} +else +{ + // error +} +... +D*/ + + +/*F*/ +int fileRead(unsigned handle, char *buf, unsigned count); +/*D +This function reads up to count bytes from the the file +associated with handle and writes them to buf. + +. . +handle: >=0, as returned by a call to [*fileOpen*] + buf: an array to receive the read data + count: the maximum number of bytes to read +. . + +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE. + +... +if (fileRead(h, buf, sizeof(buf)) > 0) +{ + // process read data +} +... +D*/ + + +/*F*/ +int fileSeek(unsigned handle, int32_t seekOffset, int seekFrom); +/*D +This function seeks to a position within the file associated +with handle. + +. . + handle: >=0, as returned by a call to [*fileOpen*] +seekOffset: the number of bytes to move. Positive offsets + move forward, negative offsets backwards. + seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1), + or PI_FROM_END (2) +. . + +Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK. + +... +fileSeek(0, 20, PI_FROM_START); // Seek to start plus 20 + +size = fileSeek(0, 0, PI_FROM_END); // Seek to end, return size + +pos = fileSeek(0, 0, PI_FROM_CURRENT); // Return current position +... +D*/ + +#pragma GCC diagnostic push + +#pragma GCC diagnostic ignored "-Wcomment" + +/*F*/ +int fileList(char *fpat, char *buf, unsigned count); +/*D +This function returns a list of files which match a pattern. The +pattern may contain wildcards. + +. . + fpat: file pattern to match + buf: an array to receive the matching file names +count: the maximum number of bytes to read +. . + +Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS, +or PI_NO_FILE_MATCH. + +The pattern must match an entry in /opt/pigpio/access. The pattern +may contain wildcards. See [*fileOpen*]. + +NOTE + +The returned value is not the number of files, it is the number +of bytes in the buffer. The file names are separated by newline +characters. + +... +#include +#include + +int main(int argc, char *argv[]) +{ + int c; + char buf[1000]; + + if (gpioInitialise() < 0) return 1; + + // assumes /opt/pigpio/access contains the following line + // /ram/*.c r + + c = fileList("/ram/p*.c", buf, sizeof(buf)); + + if (c >= 0) + { + // terminate string + buf[c] = 0; + printf("%s", buf); + } + + gpioTerminate(); +} +... +D*/ + +#pragma GCC diagnostic pop + + +/*F*/ +int gpioCfgBufferSize(unsigned cfgMillis); +/*D +Configures pigpio to buffer cfgMillis milliseconds of GPIO samples. + +This function is only effective if called before [*gpioInitialise*]. + +. . +cfgMillis: 100-10000 +. . + +The default setting is 120 milliseconds. + +The intention is to allow for bursts of data and protection against +other processes hogging cpu time. + +I haven't seen a process locked out for more than 100 milliseconds. + +Making the buffer bigger uses a LOT of memory at the more frequent +sampling rates as shown in the following table in MBs. + +. . + buffer milliseconds + 120 250 500 1sec 2sec 4sec 8sec + + 1 16 31 55 107 --- --- --- + 2 10 18 31 55 107 --- --- +sample 4 8 12 18 31 55 107 --- + rate 5 8 10 14 24 45 87 --- + (us) 8 6 8 12 18 31 55 107 + 10 6 8 10 14 24 45 87 +. . +D*/ + + +/*F*/ +int gpioCfgClock( + unsigned cfgMicros, unsigned cfgPeripheral, unsigned cfgSource); +/*D +Configures pigpio to use a particular sample rate timed by a specified +peripheral. + +This function is only effective if called before [*gpioInitialise*]. + +. . + cfgMicros: 1, 2, 4, 5, 8, 10 +cfgPeripheral: 0 (PWM), 1 (PCM) + cfgSource: deprecated, value is ignored +. . + +The timings are provided by the specified peripheral (PWM or PCM). + +The default setting is 5 microseconds using the PCM peripheral. + +The approximate CPU percentage used for each sample rate is: + +. . +sample cpu + rate % + + 1 25 + 2 16 + 4 11 + 5 10 + 8 15 + 10 14 +. . + +A sample rate of 5 microseconds seeems to be the sweet spot. +D*/ + + +/*F*/ +int gpioCfgDMAchannel(unsigned DMAchannel); /* DEPRECATED */ +/*D +Configures pigpio to use the specified DMA channel. + +This function is only effective if called before [*gpioInitialise*]. + +. . +DMAchannel: 0-14 +. . + +The default setting is to use channel 14. +D*/ + + +/*F*/ +int gpioCfgDMAchannels(unsigned primaryChannel, unsigned secondaryChannel); +/*D +Configures pigpio to use the specified DMA channels. + +This function is only effective if called before [*gpioInitialise*]. + +. . + primaryChannel: 0-14 +secondaryChannel: 0-14 +. . + +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. + +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. +D*/ + + +/*F*/ +int gpioCfgPermissions(uint64_t updateMask); +/*D +Configures pigpio to restrict GPIO updates via the socket or pipe +interfaces to the GPIO specified by the mask. Programs directly +calling the pigpio library (i.e. linked with -lpigpio are not +affected). A GPIO update is a write to a GPIO or a GPIO mode +change or any function which would force such an action. + +This function is only effective if called before [*gpioInitialise*]. + +. . +updateMask: bit (1<=0 +arg2: >=0 +argx: extra (byte) arguments +argc: number of extra arguments +. . + +Returns >= 0 if OK, less than 0 indicates a user defined error. +D*/ + + +/*F*/ +int gpioCustom2(unsigned arg1, char *argx, unsigned argc, + char *retBuf, unsigned retMax); +/*D +This function is available for user customisation. + +It differs from gpioCustom1 in that it returns an array of bytes +rather than just an integer. + +The returned value is an integer indicating the number of returned bytes. +. . + arg1: >=0 + argx: extra (byte) arguments + argc: number of extra arguments +retBuf: buffer for returned bytes +retMax: maximum number of bytes to return +. . + +Returns >= 0 if OK, less than 0 indicates a user defined error. + +The number of returned bytes must be retMax or less. +D*/ + + +/*F*/ +int rawWaveAddSPI( + rawSPI_t *spi, + unsigned offset, + unsigned spiSS, + char *buf, + unsigned spiTxBits, + unsigned spiBitFirst, + unsigned spiBitLast, + unsigned spiBits); +/*D +This function adds a waveform representing SPI data to the +existing waveform (if any). + +. . + spi: a pointer to a spi object + offset: microseconds from the start of the waveform + spiSS: the slave select GPIO + buf: the bits to transmit, most significant bit first + spiTxBits: the number of bits to write +spiBitFirst: the first bit to read + spiBitLast: the last bit to read + spiBits: the number of bits to transfer +. . + +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_BAD_USER_GPIO, PI_BAD_SER_OFFSET, or PI_TOO_MANY_PULSES. + +Not intended for general use. +D*/ + +/*F*/ +int rawWaveAddGeneric(unsigned numPulses, rawWave_t *pulses); +/*D +This function adds a number of pulses to the current waveform. + +. . +numPulses: the number of pulses + pulses: the array containing the pulses +. . + +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_TOO_MANY_PULSES. + +The advantage of this function over gpioWaveAddGeneric is that it +allows the setting of the flags field. + +The pulses are interleaved in time order within the existing waveform +(if any). + +Merging allows the waveform to be built in parts, that is the settings +for GPIO#1 can be added, and then GPIO#2 etc. + +If the added waveform is intended to start after or within the existing +waveform then the first pulse should consist of a delay. + +Not intended for general use. +D*/ + +/*F*/ +unsigned rawWaveCB(void); +/*D +Returns the number of the cb being currently output. + +Not intended for general use. +D*/ + +/*F*/ +rawCbs_t *rawWaveCBAdr(int cbNum); +/*D +Return the (Linux) address of contol block cbNum. + +. . +cbNum: the cb of interest +. . + +Not intended for general use. +D*/ + +/*F*/ +uint32_t rawWaveGetOOL(int pos); +/*D +Gets the OOL parameter stored at pos. + +. . +pos: the position of interest. +. . + +Not intended for general use. +D*/ + + +/*F*/ +void rawWaveSetOOL(int pos, uint32_t lVal); +/*D +Sets the OOL parameter stored at pos to value. + +. . + pos: the position of interest +lVal: the value to write +. . + +Not intended for general use. +D*/ + +/*F*/ +uint32_t rawWaveGetOut(int pos); +/*D +Gets the wave output parameter stored at pos. + +DEPRECATED: use rawWaveGetOOL instead. + +. . +pos: the position of interest. +. . + +Not intended for general use. +D*/ + + +/*F*/ +void rawWaveSetOut(int pos, uint32_t lVal); +/*D +Sets the wave output parameter stored at pos to value. + +DEPRECATED: use rawWaveSetOOL instead. + +. . + pos: the position of interest +lVal: the value to write +. . + +Not intended for general use. +D*/ + +/*F*/ +uint32_t rawWaveGetIn(int pos); +/*D +Gets the wave input value parameter stored at pos. + +DEPRECATED: use rawWaveGetOOL instead. + +. . +pos: the position of interest +. . + +Not intended for general use. +D*/ + + +/*F*/ +void rawWaveSetIn(int pos, uint32_t lVal); +/*D +Sets the wave input value stored at pos to value. + +DEPRECATED: use rawWaveSetOOL instead. + +. . + pos: the position of interest +lVal: the value to write +. . + +Not intended for general use. +D*/ + +/*F*/ +rawWaveInfo_t rawWaveInfo(int wave_id); +/*D +Gets details about the wave with id wave_id. + +. . +wave_id: the wave of interest +. . + +Not intended for general use. +D*/ + +/*F*/ +int getBitInBytes(int bitPos, char *buf, int numBits); +/*D +Returns the value of the bit bitPos bits from the start of buf. Returns +0 if bitPos is greater than or equal to numBits. + +. . + bitPos: bit index from the start of buf + buf: array of bits +numBits: number of valid bits in buf +. . + +D*/ + +/*F*/ +void putBitInBytes(int bitPos, char *buf, int bit); +/*D +Sets the bit bitPos bits from the start of buf to bit. + +. . +bitPos: bit index from the start of buf + buf: array of bits + bit: 0-1, value to set +. . + +D*/ + +/*F*/ +double time_time(void); +/*D +Return the current time in seconds since the Epoch. +D*/ + + +/*F*/ +void time_sleep(double seconds); +/*D +Delay execution for a given number of seconds + +. . +seconds: the number of seconds to sleep +. . +D*/ + + +/*F*/ +void rawDumpWave(void); +/*D +Used to print a readable version of the current waveform to stderr. + +Not intended for general use. +D*/ + + +/*F*/ +void rawDumpScript(unsigned script_id); +/*D +Used to print a readable version of a script to stderr. + +. . +script_id: >=0, a script_id returned by [*gpioStoreScript*] +. . + +Not intended for general use. +D*/ + + +#ifdef __cplusplus +} +#endif + +/*PARAMS + +active :: 0-1000000 + +The number of microseconds level changes are reported for once +a noise filter has been triggered (by [*steady*] microseconds of +a stable level). + +arg1:: + +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +arg2:: + +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +argc:: +The count of bytes passed to a user customised function. + +*argx:: +A pointer to an array of bytes passed to a user customised function. +Its meaning and content is defined by the customiser. + +baud:: +The speed of serial communication (I2C, SPI, serial link, waves) in +bits per second. + +bit:: +A value of 0 or 1. + +bitPos:: +A bit position within a byte or word. The least significant bit is +position 0. + +bits:: +A value used to select GPIO. If bit n of bits is set then GPIO n is +selected. + +A convenient way to set bit n is to or in (1<=0 + +The number of times a GPIO is swiched on and off per second. This +can be set per GPIO and may be as little as 5Hz or as much as +40KHz. The GPIO will be on for a proportion of the time as defined +by its dutycycle. + +gpio:: + +A Broadcom numbered GPIO, in the range 0-53. + +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 [*gpioHardwareRevision*]. + +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 - - - - +. . + +gpioAlertFunc_t:: +. . +typedef void (*gpioAlertFunc_t) (int gpio, int level, uint32_t tick); +. . + +gpioAlertFuncEx_t:: +. . +typedef void (*eventFuncEx_t) + (int event, int level, uint32_t tick, void *userdata); +. . + +gpioCfg*:: + +These functions are only effective if called before [*gpioInitialise*]. + +[*gpioCfgBufferSize*] +[*gpioCfgClock*] +[*gpioCfgDMAchannel*] +[*gpioCfgDMAchannels*] +[*gpioCfgPermissions*] +[*gpioCfgInterfaces*] +[*gpioCfgSocketPort*] +[*gpioCfgMemAlloc*] + +gpioGetSamplesFunc_t:: +. . +typedef void (*gpioGetSamplesFunc_t) + (const gpioSample_t *samples, int numSamples); +. . + +gpioGetSamplesFuncEx_t:: +. . +typedef void (*gpioGetSamplesFuncEx_t) + (const gpioSample_t *samples, int numSamples, void *userdata); +. . + +gpioISRFunc_t:: +. . +typedef void (*gpioISRFunc_t) + (int gpio, int level, uint32_t tick); +. . + +gpioISRFuncEx_t:: +. . +typedef void (*gpioISRFuncEx_t) + (int gpio, int level, uint32_t tick, void *userdata); +. . + +gpioPulse_t:: +. . +typedef struct +{ + uint32_t gpioOn; + uint32_t gpioOff; + uint32_t usDelay; +} gpioPulse_t; +. . + +gpioSample_t:: +. . +typedef struct +{ + uint32_t tick; + uint32_t level; +} gpioSample_t; +. . + +gpioSignalFunc_t:: +. . +typedef void (*gpioSignalFunc_t) (int signum); +. . + +gpioSignalFuncEx_t:: +. . +typedef void (*gpioSignalFuncEx_t) (int signum, void *userdata); +. . + +gpioThreadFunc_t:: +. . +typedef void *(gpioThreadFunc_t) (void *); +. . + +gpioTimerFunc_t:: +. . +typedef void (*gpioTimerFunc_t) (void); +. . + +gpioTimerFuncEx_t:: +. . +typedef void (*gpioTimerFuncEx_t) (void *userdata); +. . + +gpioWaveAdd*:: + +One of + +[*gpioWaveAddNew*] +[*gpioWaveAddGeneric*] +[*gpioWaveAddSerial*] + +handle::>=0 + +A number referencing an object opened by one of + +[*fileOpen*] +[*gpioNotifyOpen*] +[*i2cOpen*] +[*serOpen*] +[*spiOpen*] + +i2cAddr:: 0-0x7F +The address of a device on the I2C bus. + +i2cBus::>=0 + +An I2C bus number. + +i2cFlags::0 + +Flags which modify an I2C open command. None are currently defined. + +i2cReg:: 0-255 + +A register of an I2C device. + +ifFlags::0-3 +. . +PI_DISABLE_FIFO_IF 1 +PI_DISABLE_SOCK_IF 2 +. . + +*inBuf:: +A buffer used to pass data to a function. + +inLen:: +The number of bytes of data in a buffer. + +int:: +A whole number, negative or positive. + +int32_t:: +A 32-bit signed value. + +invert:: +A flag used to set normal or inverted bit bang serial data level logic. + +level:: +The level of a GPIO. Low or High. + +. . +PI_OFF 0 +PI_ON 1 + +PI_CLEAR 0 +PI_SET 1 + +PI_LOW 0 +PI_HIGH 1 +. . + +There is one exception. If a watchdog expires on a GPIO the level will be +reported as PI_TIMEOUT. See [*gpioSetWatchdog*]. + +. . +PI_TIMEOUT 2 +. . + + +lVal::0-4294967295 (Hex 0x0-0xFFFFFFFF, Octal 0-37777777777) + +A 32-bit word value. + +memAllocMode:: 0-2 + +The DMA memory allocation mode. + +. . +PI_MEM_ALLOC_AUTO 0 +PI_MEM_ALLOC_PAGEMAP 1 +PI_MEM_ALLOC_MAILBOX 2 +. . + +*micros:: + +A value representing microseconds. + +micros:: + +A value representing microseconds. + +millis:: + +A value representing milliseconds. + +MISO:: +The GPIO used for the MISO signal when bit banging SPI. + +mode:: + +1. The operational mode of a GPIO, normally INPUT or OUTPUT. + +. . +PI_INPUT 0 +PI_OUTPUT 1 +PI_ALT0 4 +PI_ALT1 5 +PI_ALT2 6 +PI_ALT3 7 +PI_ALT4 3 +PI_ALT5 2 +. . + +2. A file open mode. + +. . +PI_FILE_READ 1 +PI_FILE_WRITE 2 +PI_FILE_RW 3 +. . + +The following values can be or'd into the mode. + +. . +PI_FILE_APPEND 4 +PI_FILE_CREATE 8 +PI_FILE_TRUNC 16 +. . + +MOSI:: +The GPIO used for the MOSI signal when bit banging SPI. + +numBits:: + +The number of bits stored in a buffer. + +numBytes:: +The number of bytes used to store characters in a string. Depending +on the number of bits per character there may be 1, 2, or 4 bytes +per character. + +numPar:: 0-10 +The number of parameters passed to a script. + +numPulses:: +The number of pulses to be added to a waveform. + +numSegs:: +The number of segments in a combined I2C transaction. + +numSockAddr:: +The number of network addresses allowed to use the socket interface. + +0 means all addresses allowed. + +offset:: +The associated data starts this number of microseconds from the start of +the waveform. + +*outBuf:: +A buffer used to return data from a function. + +outLen:: +The size in bytes of an output buffer. + +pad:: 0-2 +A set of GPIO which share common drivers. + +Pad @ GPIO +0 @ 0-27 +1 @ 28-45 +2 @ 46-53 + +padStrength:: 1-16 +The mA which may be drawn from each GPIO whilst still guaranteeing the +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 +{ + uint16_t addr; // slave address + uint16_t flags; + uint16_t len; // msg length + uint8_t *buf; // pointer to msg data +} pi_i2c_msg_t; +. . + +port:: 1024-32000 +The port used to bind to the pigpio socket. Defaults to 8888. + +pos:: +The position of an item. + +primaryChannel:: 0-15 +The DMA channel used to time the sampling of GPIO and to time servo and +PWM pulses. + +*pth:: + +A thread identifier, returned by [*gpioStartThread*]. + +pthread_t:: + +A thread identifier. + +pud::0-2 + +The setting of the pull up/down resistor for a GPIO, which may be off, +pull-up, or pull-down. + +. . +PI_PUD_OFF 0 +PI_PUD_DOWN 1 +PI_PUD_UP 2 +. . + +pulseLen:: + +1-100, the length of a trigger pulse in microseconds. + +*pulses:: + +An array of pulses to be added to a waveform. + +pulsewidth::0, 500-2500 +. . +PI_SERVO_OFF 0 +PI_MIN_SERVO_PULSEWIDTH 500 +PI_MAX_SERVO_PULSEWIDTH 2500 +. . + +PWMduty::0-1000000 (1M) +The hardware PWM dutycycle. + +. . +PI_HW_PWM_RANGE 1000000 +. . + +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 +. . +PI_MIN_DUTYCYCLE_RANGE 25 +PI_MAX_DUTYCYCLE_RANGE 40000 +. . + +rawCbs_t:: +. . +typedef struct // linux/arch/arm/mach-bcm2708/include/mach/dma.h +{ + unsigned long info; + unsigned long src; + unsigned long dst; + unsigned long length; + unsigned long stride; + unsigned long next; + unsigned long pad[2]; +} rawCbs_t; +. . + +rawSPI_t:: +. . +typedef struct +{ + int clk; // GPIO for clock + int mosi; // GPIO for MOSI + int miso; // GPIO for MISO + int ss_pol; // slave select off state + int ss_us; // delay after slave select + int clk_pol; // clock off state + int clk_pha; // clock phase + int clk_us; // clock micros +} rawSPI_t; +. . + +rawWave_t:: +. . +typedef struct +{ + uint32_t gpioOn; + uint32_t gpioOff; + uint32_t usDelay; + uint32_t flags; +} rawWave_t; +. . + +rawWaveInfo_t:: +. . +typedef struct +{ + uint16_t botCB; // first CB used by wave + uint16_t topCB; // last CB used by wave + uint16_t botOOL; // last OOL used by wave + uint16_t topOOL; // first OOL used by wave + uint16_t deleted; + uint16_t numCB; + uint16_t numBOOL; + uint16_t numTOOL; +} rawWaveInfo_t; +. . + +*retBuf:: + +A buffer to hold a number of bytes returned to a used customised function, + +retMax:: + +The maximum number of bytes a user customised function should return. + +*rxBuf:: + +A pointer to a buffer to receive data. + +SCL:: +The user GPIO to use for the clock when bit banging I2C. + +SCLK:: +The GPIO used for the SCLK signal when bit banging SPI. + +*script:: +A pointer to the text of a script. + +script_id:: +An id of a stored script as returned by [*gpioStoreScript*]. + +*scriptName:: +The name of a [*shell*] script to be executed. The script must be present in +/opt/pigpio/cgi and must have execute permission. + +*scriptString:: +The string to be passed to a [*shell*] script to be executed. + +SDA:: +The user GPIO to use for data when bit banging I2C. + +secondaryChannel:: 0-6 + +The DMA channel used to time output waveforms. + +*seconds:: + +A pointer to a uint32_t to store the second component of +a returned time. + +seconds:: +The number of seconds. + +seekFrom:: + +. . +PI_FROM_START 0 +PI_FROM_CURRENT 1 +PI_FROM_END 2 +. . + +seekOffset:: +The number of bytes to move forward (positive) or backwards (negative) +from the seek position (start, current, or end of file). + +*segs:: +An array of segments which make up a combined I2C transaction. + +serFlags:: +Flags which modify a serial open command. None are currently defined. + +*sertty:: +The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1. + +setting:: +A value used to set a flag, 0 for false, non-zero for true. + +signum::0-63 +. . +PI_MIN_SIGNUM 0 +PI_MAX_SIGNUM 63 +. . + +size_t:: + +A standard type used to indicate the size of an object in bytes. + +*sockAddr:: +An array of network addresses allowed to use the socket interface encoded +as 32 bit numbers. + +E.g. address 192.168.1.66 would be encoded as 0x4201a8c0. + +*spi:: +A pointer to a [*rawSPI_t*] structure. + +spiBitFirst:: +GPIO reads are made from spiBitFirst to spiBitLast. + +spiBitLast:: + +GPIO reads are made from spiBitFirst to spiBitLast. + +spiBits:: +The number of bits to transfer in a raw SPI transaction. + +spiChan:: +A SPI channel, 0-2. + +spiFlags:: +See [*spiOpen*] and [*bbSPIOpen*]. + +spiSS:: +The SPI slave select GPIO in a raw SPI transaction. + +spiTxBits:: +The number of bits to transfer dring a raw SPI transaction + +steady :: 0-300000 + +The number of microseconds level changes must be stable for +before reporting the level changed ([*gpioGlitchFilter*]) or triggering +the active part of a noise filter ([*gpioNoiseFilter*]). + +stop_bits::2-8 +The number of (half) stop bits to be used when adding serial data +to a waveform. + +. . +PI_MIN_WAVE_HALFSTOPBITS 2 +PI_MAX_WAVE_HALFSTOPBITS 8 +. . + +*str:: +An array of characters. + +timeout:: +A GPIO level change timeout in milliseconds. + +[*gpioSetWatchdog*] +. . +PI_MIN_WDOG_TIMEOUT 0 +PI_MAX_WDOG_TIMEOUT 60000 +. . + +[*gpioSetISRFunc*] and [*gpioSetISRFuncEx*] +. . +<=0 cancel timeout +>0 timeout after specified milliseconds +. . + +timer:: +. . +PI_MIN_TIMER 0 +PI_MAX_TIMER 9 +. . + +timetype:: +. . +PI_TIME_RELATIVE 0 +PI_TIME_ABSOLUTE 1 +. . + +*txBuf:: + +An array of bytes to transmit. + +uint32_t::0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF) + +A 32-bit unsigned value. + +uint64_t::0-(2^64)-1 + +A 64-bit unsigned value. + +unsigned:: + +A whole number >= 0. + +updateMask:: + +A 64 bit mask indicating which GPIO may be written to by the user. + +If GPIO#n may be written then bit (1< 4 +#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-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 +#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call +#define PI_BAD_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX) +#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses +#define PI_TOO_MANY_CHARS -37 // waveform has too many chars +#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read on GPIO +#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter +#define PI_BAD_SERIAL_BUF -40 // bad (null) serial buf parameter +#define PI_NOT_PERMITTED -41 // GPIO operation not permitted +#define PI_SOME_PERMITTED -42 // one or more GPIO not permitted +#define PI_BAD_WVSC_COMMND -43 // bad WVSC subcommand +#define PI_BAD_WVSM_COMMND -44 // bad WVSM subcommand +#define PI_BAD_WVSP_COMMND -45 // bad WVSP subcommand +#define PI_BAD_PULSELEN -46 // trigger pulse length not 1-100 +#define PI_BAD_SCRIPT -47 // invalid script +#define PI_BAD_SCRIPT_ID -48 // unknown script id +#define PI_BAD_SER_OFFSET -49 // add serial data offset > 30 minutes +#define PI_GPIO_IN_USE -50 // GPIO already in use +#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time +#define PI_BAD_PARAM_NUM -52 // script parameter id not 0-9 +#define PI_DUP_TAG -53 // script has duplicate tag +#define PI_TOO_MANY_TAGS -54 // script has too many tags +#define PI_BAD_SCRIPT_CMD -55 // illegal script command +#define PI_BAD_VAR_NUM -56 // script variable id not 0-149 +#define PI_NO_SCRIPT_ROOM -57 // no more room for scripts +#define PI_NO_MEMORY -58 // can't allocate temporary memory +#define PI_SOCK_READ_FAILED -59 // socket read failed +#define PI_SOCK_WRIT_FAILED -60 // socket write failed +#define PI_TOO_MANY_PARAM -61 // too many script parameters (> 10) +#define PI_NOT_HALTED -62 // DEPRECATED +#define PI_SCRIPT_NOT_READY -62 // script initialising +#define PI_BAD_TAG -63 // script has unresolved tag +#define PI_BAD_MICS_DELAY -64 // bad MICS delay (too large) +#define PI_BAD_MILS_DELAY -65 // bad MILS delay (too large) +#define PI_BAD_WAVE_ID -66 // non existent wave id +#define PI_TOO_MANY_CBS -67 // No more CBs for waveform +#define PI_TOO_MANY_OOL -68 // No more OOL for waveform +#define PI_EMPTY_WAVEFORM -69 // attempt to create an empty waveform +#define PI_NO_WAVEFORM_ID -70 // no more waveforms +#define PI_I2C_OPEN_FAILED -71 // can't open I2C device +#define PI_SER_OPEN_FAILED -72 // can't open serial device +#define PI_SPI_OPEN_FAILED -73 // can't open SPI device +#define PI_BAD_I2C_BUS -74 // bad I2C bus +#define PI_BAD_I2C_ADDR -75 // bad I2C address +#define PI_BAD_SPI_CHANNEL -76 // bad SPI channel +#define PI_BAD_FLAGS -77 // bad i2c/spi/ser open flags +#define PI_BAD_SPI_SPEED -78 // bad SPI speed +#define PI_BAD_SER_DEVICE -79 // bad serial device name +#define PI_BAD_SER_SPEED -80 // bad serial baud rate +#define PI_BAD_PARAM -81 // bad i2c/spi/ser parameter +#define PI_I2C_WRITE_FAILED -82 // i2c write failed +#define PI_I2C_READ_FAILED -83 // i2c read failed +#define PI_BAD_SPI_COUNT -84 // bad SPI count +#define PI_SER_WRITE_FAILED -85 // ser write failed +#define PI_SER_READ_FAILED -86 // ser read failed +#define PI_SER_READ_NO_DATA -87 // ser read no data available +#define PI_UNKNOWN_COMMAND -88 // unknown command +#define PI_SPI_XFER_FAILED -89 // spi xfer/read/write failed +#define PI_BAD_POINTER -90 // bad (NULL) pointer +#define PI_NO_AUX_SPI -91 // no auxiliary SPI on Pi A or B +#define PI_NOT_PWM_GPIO -92 // GPIO is not in use for PWM +#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 // invalid hardware PWM frequency +#define PI_BAD_HPWM_DUTY -97 // hardware PWM dutycycle not 0-1M +#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 +#define PI_BAD_STOPBITS -102 // serial (half) stop bits not 2-8 +#define PI_MSG_TOOBIG -103 // socket/pipe message too big +#define PI_BAD_MALLOC_MODE -104 // bad memory allocation mode +#define PI_TOO_MANY_SEGS -105 // too many I2C transaction segments +#define PI_BAD_I2C_SEG -106 // an I2C transaction segment failed +#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver +#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO +#define PI_BAD_I2C_WLEN -109 // bad I2C write length +#define PI_BAD_I2C_RLEN -110 // bad I2C read length +#define PI_BAD_I2C_CMD -111 // bad I2C command +#define PI_BAD_I2C_BAUD -112 // bad I2C baud rate, not 50-500k +#define PI_CHAIN_LOOP_CNT -113 // bad chain loop count +#define PI_BAD_CHAIN_LOOP -114 // empty chain loop +#define PI_CHAIN_COUNTER -115 // too many chain counters +#define PI_BAD_CHAIN_CMD -116 // bad chain command +#define PI_BAD_CHAIN_DELAY -117 // bad chain delay micros +#define PI_CHAIN_NESTING -118 // chain counters nested too deeply +#define PI_CHAIN_TOO_BIG -119 // chain is too long +#define PI_DEPRECATED -120 // deprecated function removed +#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1 +#define PI_BAD_EDGE -122 // bad ISR edge value, not 0-2 +#define PI_BAD_ISR_INIT -123 // bad ISR initialisation +#define PI_BAD_FOREVER -124 // loop forever must be last command +#define PI_BAD_FILTER -125 // bad filter parameter +#define PI_BAD_PAD -126 // bad pad number +#define PI_BAD_STRENGTH -127 // bad pad drive strength +#define PI_FIL_OPEN_FAILED -128 // file open failed +#define PI_BAD_FILE_MODE -129 // bad file mode +#define PI_BAD_FILE_FLAG -130 // bad file flag +#define PI_BAD_FILE_READ -131 // bad file read +#define PI_BAD_FILE_WRITE -132 // bad file write +#define PI_FILE_NOT_ROPEN -133 // file not open for read +#define PI_FILE_NOT_WOPEN -134 // file not open for write +#define PI_BAD_FILE_SEEK -135 // bad file seek +#define PI_NO_FILE_MATCH -136 // no files match pattern +#define PI_NO_FILE_ACCESS -137 // no permission to access file +#define PI_FILE_IS_A_DIR -138 // file is a directory +#define PI_BAD_SHELL_STATUS -139 // bad shell return status +#define PI_BAD_SCRIPT_NAME -140 // bad script name +#define PI_BAD_SPI_BAUD -141 // bad SPI baud rate, not 50-500k +#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 + +#define PI_CUSTOM_ERR_0 -3000 +#define PI_CUSTOM_ERR_999 -3999 + +/*DEF_E*/ + +/*DEF_S Defaults*/ + +#define PI_DEFAULT_BUFFER_MILLIS 120 +#define PI_DEFAULT_CLK_MICROS 5 +#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM +#define PI_DEFAULT_IF_FLAGS 0 +#define PI_DEFAULT_FOREGROUND 0 +#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 "localhost" +#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0x0000000FFFFFFCLL +#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93 +#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C +#define PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS 0x0080480FFFFFFCLL +#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 + +#define PI_DEFAULT_CFG_INTERNALS 0 + +/*DEF_E*/ + +#endif + diff --git a/pigpio.py b/pigpio.py new file mode 100644 index 0000000..edb6734 --- /dev/null +++ b/pigpio.py @@ -0,0 +1,5783 @@ +""" +pigpio is a Python module for the Raspberry which talks to +the pigpio daemon to allow control of the general purpose +input outputs (GPIO). + +[http://abyz.me.uk/rpi/pigpio/python.html] + +*Features* + +o the pigpio Python module can run on Windows, Macs, or Linux + +o controls one or more Pi's + +o hardware timed PWM on any of GPIO 0-31 + +o hardware timed servo pulses on any of GPIO 0-31 + +o callbacks when any of GPIO 0-31 change state + +o creating and transmitting precisely timed waveforms + +o reading/writing GPIO and setting their modes + +o wrappers for I2C, SPI, and serial links + +o creating and running scripts on the pigpio daemon + +*GPIO* + +ALL GPIO are identified by their Broadcom number. + +*Notes* + +Transmitted waveforms are accurate to a microsecond. + +Callback level changes are time-stamped and will be +accurate to within a few microseconds. + +*Settings* + +A number of settings are determined when the pigpio daemon is started. + +o the sample rate (1, 2, 4, 5, 8, or 10 us, default 5 us). + +o the set of GPIO which may be updated (generally written to). The + default set is those available on the Pi board revision. + +o the available PWM frequencies (see [*set_PWM_frequency*]). + +*Exceptions* + +By default a fatal exception is raised if you pass an invalid +argument to a pigpio function. + +If you wish to handle the returned status yourself you should set +pigpio.exceptions to False. + +You may prefer to check the returned status in only a few parts +of your code. In that case do the following: + +... +pigpio.exceptions = False + +# Code where you want to test the error status. + +pigpio.exceptions = True +... + +*Usage* + +This module uses the services of the C pigpio library. pigpio +must be running on the Pi(s) whose GPIO are to be manipulated. + +The normal way to start pigpio is as a daemon (during system +start). + +sudo pigpiod + +Your Python program must import pigpio and create one or more +instances of the pigpio.pi class. This class gives access to +a specified Pi's GPIO. + +... +pi1 = pigpio.pi() # pi1 accesses the local Pi's GPIO +pi2 = pigpio.pi('tom') # pi2 accesses tom's GPIO +pi3 = pigpio.pi('dick') # pi3 accesses dick's GPIO + +pi1.write(4, 0) # set local Pi's GPIO 4 low +pi2.write(4, 1) # set tom's GPIO 4 to high +pi3.read(4) # get level of dick's GPIO 4 +... + +The later example code snippets assume that pi is an instance of +the pigpio.pi class. + +OVERVIEW + +ESSENTIAL + +pigpio.pi Initialise Pi connection +stop Stop a Pi connection + +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 + +INTERMEDIATE + +gpio_trigger Send a trigger pulse to a GPIO + +set_watchdog Set a watchdog on a GPIO + +read_bank_1 Read all bank 1 GPIO +read_bank_2 Read all bank 2 GPIO + +clear_bank_1 Clear selected GPIO in bank 1 +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 + +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 + +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 + +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 +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 + +i2c_open Opens an I2C device +i2c_close Closes an I2C device + +i2c_write_quick SMBus write quick + +i2c_read_byte SMBus read byte +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_write_word_data SMBus write word data + +i2c_read_block_data SMBus read block data +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 + +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 + +I2C/SPI_SLAVE + +bsc_xfer I2C/SPI as slave transfer +bsc_i2c I2C as slave transfer + +SERIAL + +serial_open Opens a serial device +serial_close Closes 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_data_available Returns number of bytes ready to be read + +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 + +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_create_and_pad Creates a waveform of fixed size 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_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) + +get_hardware_revision Get hardware revision +get_pigpio_version Get the pigpio version + +pigpio.error_text Gets error text from error number +pigpio.tickDiff Returns difference between two ticks +""" + +import sys +import socket +import struct +import time +import threading +import os +import atexit + +VERSION = "1.78" # sync minor number to pigpio library version + +exceptions = True + +# GPIO levels + +OFF = 0 +LOW = 0 +CLEAR = 0 + +ON = 1 +HIGH = 1 +SET = 1 + +TIMEOUT = 2 + +# GPIO edges + +RISING_EDGE = 0 +FALLING_EDGE = 1 +EITHER_EDGE = 2 + +# GPIO modes + +INPUT = 0 +OUTPUT = 1 +ALT0 = 4 +ALT1 = 5 +ALT2 = 6 +ALT3 = 7 +ALT4 = 3 +ALT5 = 2 + +# GPIO Pull Up Down + +PUD_OFF = 0 +PUD_DOWN = 1 +PUD_UP = 2 + +# script run status + +PI_SCRIPT_INITING=0 +PI_SCRIPT_HALTED =1 +PI_SCRIPT_RUNNING=2 +PI_SCRIPT_WAITING=3 +PI_SCRIPT_FAILED =4 + +# notification flags + +NTFY_FLAGS_EVENT = (1 << 7) +NTFY_FLAGS_ALIVE = (1 << 6) +NTFY_FLAGS_WDOG = (1 << 5) +NTFY_FLAGS_GPIO = 31 + +# wave modes + +WAVE_MODE_ONE_SHOT =0 +WAVE_MODE_REPEAT =1 +WAVE_MODE_ONE_SHOT_SYNC=2 +WAVE_MODE_REPEAT_SYNC =3 + +WAVE_NOT_FOUND = 9998 # Transmitted wave not found. +NO_TX_WAVE = 9999 # No wave being transmitted. + +FILE_READ=1 +FILE_WRITE=2 +FILE_RW=3 + +FILE_APPEND=4 +FILE_CREATE=8 +FILE_TRUNC=16 + +FROM_START=0 +FROM_CURRENT=1 +FROM_END=2 + +SPI_MODE_0 = 0 +SPI_MODE_1 = 1 +SPI_MODE_2 = 2 +SPI_MODE_3 = 3 + +SPI_CPHA = 1 << 0 +SPI_CPOL = 1 << 1 + +SPI_CS_HIGH_ACTIVE = 1 << 2 + +SPI_TX_LSBFIRST = 1 << 14 +SPI_RX_LSBFIRST = 1 << 15 + +EVENT_BSC = 31 + +_SOCK_CMD_LEN = 16 + +# pigpio command numbers + +_PI_CMD_MODES= 0 +_PI_CMD_MODEG= 1 +_PI_CMD_PUD= 2 +_PI_CMD_READ= 3 +_PI_CMD_WRITE= 4 +_PI_CMD_PWM= 5 +_PI_CMD_PRS= 6 +_PI_CMD_PFS= 7 +_PI_CMD_SERVO= 8 +_PI_CMD_WDOG= 9 +_PI_CMD_BR1= 10 +_PI_CMD_BR2= 11 +_PI_CMD_BC1= 12 +_PI_CMD_BC2= 13 +_PI_CMD_BS1= 14 +_PI_CMD_BS2= 15 +_PI_CMD_TICK= 16 +_PI_CMD_HWVER=17 + +_PI_CMD_NO= 18 +_PI_CMD_NB= 19 +_PI_CMD_NP= 20 +_PI_CMD_NC= 21 + +_PI_CMD_PRG= 22 +_PI_CMD_PFG= 23 +_PI_CMD_PRRG= 24 +_PI_CMD_HELP= 25 +_PI_CMD_PIGPV=26 + +_PI_CMD_WVCLR=27 +_PI_CMD_WVAG= 28 +_PI_CMD_WVAS= 29 +_PI_CMD_WVGO= 30 +_PI_CMD_WVGOR=31 +_PI_CMD_WVBSY=32 +_PI_CMD_WVHLT=33 +_PI_CMD_WVSM= 34 +_PI_CMD_WVSP= 35 +_PI_CMD_WVSC= 36 + +_PI_CMD_TRIG= 37 + +_PI_CMD_PROC= 38 +_PI_CMD_PROCD=39 +_PI_CMD_PROCR=40 +_PI_CMD_PROCS=41 + +_PI_CMD_SLRO= 42 +_PI_CMD_SLR= 43 +_PI_CMD_SLRC= 44 + +_PI_CMD_PROCP=45 +_PI_CMD_MICRO=46 +_PI_CMD_MILLI=47 +_PI_CMD_PARSE=48 + +_PI_CMD_WVCRE=49 +_PI_CMD_WVDEL=50 +_PI_CMD_WVTX =51 +_PI_CMD_WVTXR=52 +_PI_CMD_WVNEW=53 + +_PI_CMD_I2CO =54 +_PI_CMD_I2CC =55 +_PI_CMD_I2CRD=56 +_PI_CMD_I2CWD=57 +_PI_CMD_I2CWQ=58 +_PI_CMD_I2CRS=59 +_PI_CMD_I2CWS=60 +_PI_CMD_I2CRB=61 +_PI_CMD_I2CWB=62 +_PI_CMD_I2CRW=63 +_PI_CMD_I2CWW=64 +_PI_CMD_I2CRK=65 +_PI_CMD_I2CWK=66 +_PI_CMD_I2CRI=67 +_PI_CMD_I2CWI=68 +_PI_CMD_I2CPC=69 +_PI_CMD_I2CPK=70 + +_PI_CMD_SPIO =71 +_PI_CMD_SPIC =72 +_PI_CMD_SPIR =73 +_PI_CMD_SPIW =74 +_PI_CMD_SPIX =75 + +_PI_CMD_SERO =76 +_PI_CMD_SERC =77 +_PI_CMD_SERRB=78 +_PI_CMD_SERWB=79 +_PI_CMD_SERR =80 +_PI_CMD_SERW =81 +_PI_CMD_SERDA=82 + +_PI_CMD_GDC =83 +_PI_CMD_GPW =84 + +_PI_CMD_HC =85 +_PI_CMD_HP =86 + +_PI_CMD_CF1 =87 +_PI_CMD_CF2 =88 + +_PI_CMD_NOIB =99 + +_PI_CMD_BI2CC=89 +_PI_CMD_BI2CO=90 +_PI_CMD_BI2CZ=91 + +_PI_CMD_I2CZ =92 + +_PI_CMD_WVCHA=93 + +_PI_CMD_SLRI =94 + +_PI_CMD_CGI =95 +_PI_CMD_CSI =96 + +_PI_CMD_FG =97 +_PI_CMD_FN =98 + +_PI_CMD_WVTXM=100 +_PI_CMD_WVTAT=101 + +_PI_CMD_PADS =102 +_PI_CMD_PADG =103 + +_PI_CMD_FO =104 +_PI_CMD_FC =105 +_PI_CMD_FR =106 +_PI_CMD_FW =107 +_PI_CMD_FS =108 +_PI_CMD_FL =109 +_PI_CMD_SHELL=110 + +_PI_CMD_BSPIC=111 +_PI_CMD_BSPIO=112 +_PI_CMD_BSPIX=113 + +_PI_CMD_BSCX =114 + +_PI_CMD_EVM =115 +_PI_CMD_EVT =116 + +_PI_CMD_PROCU=117 +_PI_CMD_WVCAP=118 + +# pigpio error numbers + +_PI_INIT_FAILED =-1 +PI_BAD_USER_GPIO =-2 +PI_BAD_GPIO =-3 +PI_BAD_MODE =-4 +PI_BAD_LEVEL =-5 +PI_BAD_PUD =-6 +PI_BAD_PULSEWIDTH =-7 +PI_BAD_DUTYCYCLE =-8 +_PI_BAD_TIMER =-9 +_PI_BAD_MS =-10 +_PI_BAD_TIMETYPE =-11 +_PI_BAD_SECONDS =-12 +_PI_BAD_MICROS =-13 +_PI_TIMER_FAILED =-14 +PI_BAD_WDOG_TIMEOUT =-15 +_PI_NO_ALERT_FUNC =-16 +_PI_BAD_CLK_PERIPH =-17 +_PI_BAD_CLK_SOURCE =-18 +_PI_BAD_CLK_MICROS =-19 +_PI_BAD_BUF_MILLIS =-20 +PI_BAD_DUTYRANGE =-21 +_PI_BAD_SIGNUM =-22 +_PI_BAD_PATHNAME =-23 +PI_NO_HANDLE =-24 +PI_BAD_HANDLE =-25 +_PI_BAD_IF_FLAGS =-26 +_PI_BAD_CHANNEL =-27 +_PI_BAD_PRIM_CHANNEL=-27 +_PI_BAD_SOCKET_PORT =-28 +_PI_BAD_FIFO_COMMAND=-29 +_PI_BAD_SECO_CHANNEL=-30 +_PI_NOT_INITIALISED =-31 +_PI_INITIALISED =-32 +_PI_BAD_WAVE_MODE =-33 +_PI_BAD_CFG_INTERNAL=-34 +PI_BAD_WAVE_BAUD =-35 +PI_TOO_MANY_PULSES =-36 +PI_TOO_MANY_CHARS =-37 +PI_NOT_SERIAL_GPIO =-38 +_PI_BAD_SERIAL_STRUC=-39 +_PI_BAD_SERIAL_BUF =-40 +PI_NOT_PERMITTED =-41 +PI_SOME_PERMITTED =-42 +PI_BAD_WVSC_COMMND =-43 +PI_BAD_WVSM_COMMND =-44 +PI_BAD_WVSP_COMMND =-45 +PI_BAD_PULSELEN =-46 +PI_BAD_SCRIPT =-47 +PI_BAD_SCRIPT_ID =-48 +PI_BAD_SER_OFFSET =-49 +PI_GPIO_IN_USE =-50 +PI_BAD_SERIAL_COUNT =-51 +PI_BAD_PARAM_NUM =-52 +PI_DUP_TAG =-53 +PI_TOO_MANY_TAGS =-54 +PI_BAD_SCRIPT_CMD =-55 +PI_BAD_VAR_NUM =-56 +PI_NO_SCRIPT_ROOM =-57 +PI_NO_MEMORY =-58 +PI_SOCK_READ_FAILED =-59 +PI_SOCK_WRIT_FAILED =-60 +PI_TOO_MANY_PARAM =-61 +PI_SCRIPT_NOT_READY =-62 +PI_BAD_TAG =-63 +PI_BAD_MICS_DELAY =-64 +PI_BAD_MILS_DELAY =-65 +PI_BAD_WAVE_ID =-66 +PI_TOO_MANY_CBS =-67 +PI_TOO_MANY_OOL =-68 +PI_EMPTY_WAVEFORM =-69 +PI_NO_WAVEFORM_ID =-70 +PI_I2C_OPEN_FAILED =-71 +PI_SER_OPEN_FAILED =-72 +PI_SPI_OPEN_FAILED =-73 +PI_BAD_I2C_BUS =-74 +PI_BAD_I2C_ADDR =-75 +PI_BAD_SPI_CHANNEL =-76 +PI_BAD_FLAGS =-77 +PI_BAD_SPI_SPEED =-78 +PI_BAD_SER_DEVICE =-79 +PI_BAD_SER_SPEED =-80 +PI_BAD_PARAM =-81 +PI_I2C_WRITE_FAILED =-82 +PI_I2C_READ_FAILED =-83 +PI_BAD_SPI_COUNT =-84 +PI_SER_WRITE_FAILED =-85 +PI_SER_READ_FAILED =-86 +PI_SER_READ_NO_DATA =-87 +PI_UNKNOWN_COMMAND =-88 +PI_SPI_XFER_FAILED =-89 +_PI_BAD_POINTER =-90 +PI_NO_AUX_SPI =-91 +PI_NOT_PWM_GPIO =-92 +PI_NOT_SERVO_GPIO =-93 +PI_NOT_HCLK_GPIO =-94 +PI_NOT_HPWM_GPIO =-95 +PI_BAD_HPWM_FREQ =-96 +PI_BAD_HPWM_DUTY =-97 +PI_BAD_HCLK_FREQ =-98 +PI_BAD_HCLK_PASS =-99 +PI_HPWM_ILLEGAL =-100 +PI_BAD_DATABITS =-101 +PI_BAD_STOPBITS =-102 +PI_MSG_TOOBIG =-103 +PI_BAD_MALLOC_MODE =-104 +_PI_TOO_MANY_SEGS =-105 +_PI_BAD_I2C_SEG =-106 +PI_BAD_SMBUS_CMD =-107 +PI_NOT_I2C_GPIO =-108 +PI_BAD_I2C_WLEN =-109 +PI_BAD_I2C_RLEN =-110 +PI_BAD_I2C_CMD =-111 +PI_BAD_I2C_BAUD =-112 +PI_CHAIN_LOOP_CNT =-113 +PI_BAD_CHAIN_LOOP =-114 +PI_CHAIN_COUNTER =-115 +PI_BAD_CHAIN_CMD =-116 +PI_BAD_CHAIN_DELAY =-117 +PI_CHAIN_NESTING =-118 +PI_CHAIN_TOO_BIG =-119 +PI_DEPRECATED =-120 +PI_BAD_SER_INVERT =-121 +_PI_BAD_EDGE =-122 +_PI_BAD_ISR_INIT =-123 +PI_BAD_FOREVER =-124 +PI_BAD_FILTER =-125 +PI_BAD_PAD =-126 +PI_BAD_STRENGTH =-127 +PI_FIL_OPEN_FAILED =-128 +PI_BAD_FILE_MODE =-129 +PI_BAD_FILE_FLAG =-130 +PI_BAD_FILE_READ =-131 +PI_BAD_FILE_WRITE =-132 +PI_FILE_NOT_ROPEN =-133 +PI_FILE_NOT_WOPEN =-134 +PI_BAD_FILE_SEEK =-135 +PI_NO_FILE_MATCH =-136 +PI_NO_FILE_ACCESS =-137 +PI_FILE_IS_A_DIR =-138 +PI_BAD_SHELL_STATUS =-139 +PI_BAD_SCRIPT_NAME =-140 +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 + +_errors=[ + [_PI_INIT_FAILED , "pigpio initialisation failed"], + [PI_BAD_USER_GPIO , "GPIO not 0-31"], + [PI_BAD_GPIO , "GPIO not 0-53"], + [PI_BAD_MODE , "mode not 0-7"], + [PI_BAD_LEVEL , "level not 0-1"], + [PI_BAD_PUD , "pud not 0-2"], + [PI_BAD_PULSEWIDTH , "pulsewidth not 0 or 500-2500"], + [PI_BAD_DUTYCYCLE , "dutycycle not 0-range (default 255)"], + [_PI_BAD_TIMER , "timer not 0-9"], + [_PI_BAD_MS , "ms not 10-60000"], + [_PI_BAD_TIMETYPE , "timetype not 0-1"], + [_PI_BAD_SECONDS , "seconds < 0"], + [_PI_BAD_MICROS , "micros not 0-999999"], + [_PI_TIMER_FAILED , "gpioSetTimerFunc failed"], + [PI_BAD_WDOG_TIMEOUT , "timeout not 0-60000"], + [_PI_NO_ALERT_FUNC , "DEPRECATED"], + [_PI_BAD_CLK_PERIPH , "clock peripheral not 0-1"], + [_PI_BAD_CLK_SOURCE , "DEPRECATED"], + [_PI_BAD_CLK_MICROS , "clock micros not 1, 2, 4, 5, 8, or 10"], + [_PI_BAD_BUF_MILLIS , "buf millis not 100-10000"], + [PI_BAD_DUTYRANGE , "dutycycle range not 25-40000"], + [_PI_BAD_SIGNUM , "signum not 0-63"], + [_PI_BAD_PATHNAME , "can't open pathname"], + [PI_NO_HANDLE , "no handle available"], + [PI_BAD_HANDLE , "unknown handle"], + [_PI_BAD_IF_FLAGS , "ifFlags > 4"], + [_PI_BAD_CHANNEL , "DMA channel not 0-14"], + [_PI_BAD_SOCKET_PORT , "socket port not 1024-30000"], + [_PI_BAD_FIFO_COMMAND , "unknown fifo command"], + [_PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-14"], + [_PI_NOT_INITIALISED , "function called before gpioInitialise"], + [_PI_INITIALISED , "function called after gpioInitialise"], + [_PI_BAD_WAVE_MODE , "waveform mode not 0-1"], + [_PI_BAD_CFG_INTERNAL , "bad parameter in gpioCfgInternals call"], + [PI_BAD_WAVE_BAUD , "baud rate not 50-250000(RX)/1000000(TX)"], + [PI_TOO_MANY_PULSES , "waveform has too many pulses"], + [PI_TOO_MANY_CHARS , "waveform has too many chars"], + [PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on GPIO"], + [PI_NOT_PERMITTED , "no permission to update GPIO"], + [PI_SOME_PERMITTED , "no permission to update one or more GPIO"], + [PI_BAD_WVSC_COMMND , "bad WVSC subcommand"], + [PI_BAD_WVSM_COMMND , "bad WVSM subcommand"], + [PI_BAD_WVSP_COMMND , "bad WVSP subcommand"], + [PI_BAD_PULSELEN , "trigger pulse length not 1-100"], + [PI_BAD_SCRIPT , "invalid script"], + [PI_BAD_SCRIPT_ID , "unknown script id"], + [PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"], + [PI_GPIO_IN_USE , "GPIO already in use"], + [PI_BAD_SERIAL_COUNT , "must read at least a byte at a time"], + [PI_BAD_PARAM_NUM , "script parameter id not 0-9"], + [PI_DUP_TAG , "script has duplicate tag"], + [PI_TOO_MANY_TAGS , "script has too many tags"], + [PI_BAD_SCRIPT_CMD , "illegal script command"], + [PI_BAD_VAR_NUM , "script variable id not 0-149"], + [PI_NO_SCRIPT_ROOM , "no more room for scripts"], + [PI_NO_MEMORY , "can't allocate temporary memory"], + [PI_SOCK_READ_FAILED , "socket read failed"], + [PI_SOCK_WRIT_FAILED , "socket write failed"], + [PI_TOO_MANY_PARAM , "too many script parameters (> 10)"], + [PI_SCRIPT_NOT_READY , "script initialising"], + [PI_BAD_TAG , "script has unresolved tag"], + [PI_BAD_MICS_DELAY , "bad MICS delay (too large)"], + [PI_BAD_MILS_DELAY , "bad MILS delay (too large)"], + [PI_BAD_WAVE_ID , "non existent wave id"], + [PI_TOO_MANY_CBS , "No more CBs for waveform"], + [PI_TOO_MANY_OOL , "No more OOL for waveform"], + [PI_EMPTY_WAVEFORM , "attempt to create an empty waveform"], + [PI_NO_WAVEFORM_ID , "No more waveform ids"], + [PI_I2C_OPEN_FAILED , "can't open I2C device"], + [PI_SER_OPEN_FAILED , "can't open serial device"], + [PI_SPI_OPEN_FAILED , "can't open SPI device"], + [PI_BAD_I2C_BUS , "bad I2C bus"], + [PI_BAD_I2C_ADDR , "bad I2C address"], + [PI_BAD_SPI_CHANNEL , "bad SPI channel"], + [PI_BAD_FLAGS , "bad i2c/spi/ser open flags"], + [PI_BAD_SPI_SPEED , "bad SPI speed"], + [PI_BAD_SER_DEVICE , "bad serial device name"], + [PI_BAD_SER_SPEED , "bad serial baud rate"], + [PI_BAD_PARAM , "bad i2c/spi/ser parameter"], + [PI_I2C_WRITE_FAILED , "I2C write failed"], + [PI_I2C_READ_FAILED , "I2C read failed"], + [PI_BAD_SPI_COUNT , "bad SPI count"], + [PI_SER_WRITE_FAILED , "ser write failed"], + [PI_SER_READ_FAILED , "ser read failed"], + [PI_SER_READ_NO_DATA , "ser read no data available"], + [PI_UNKNOWN_COMMAND , "unknown command"], + [PI_SPI_XFER_FAILED , "SPI xfer/read/write failed"], + [_PI_BAD_POINTER , "bad (NULL) pointer"], + [PI_NO_AUX_SPI , "no auxiliary SPI on Pi A or B"], + [PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"], + [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 , "invalid hardware PWM frequency"], + [PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"], + [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"], + [PI_BAD_STOPBITS , "serial (half) stop bits not 2-8"], + [PI_MSG_TOOBIG , "socket/pipe message too big"], + [PI_BAD_MALLOC_MODE , "bad memory allocation mode"], + [_PI_TOO_MANY_SEGS , "too many I2C transaction segments"], + [_PI_BAD_I2C_SEG , "an I2C transaction segment failed"], + [PI_BAD_SMBUS_CMD , "SMBus command not supported"], + [PI_NOT_I2C_GPIO , "no bit bang I2C in progress on GPIO"], + [PI_BAD_I2C_WLEN , "bad I2C write length"], + [PI_BAD_I2C_RLEN , "bad I2C read length"], + [PI_BAD_I2C_CMD , "bad I2C command"], + [PI_BAD_I2C_BAUD , "bad I2C baud rate, not 50-500k"], + [PI_CHAIN_LOOP_CNT , "bad chain loop count"], + [PI_BAD_CHAIN_LOOP , "empty chain loop"], + [PI_CHAIN_COUNTER , "too many chain counters"], + [PI_BAD_CHAIN_CMD , "bad chain command"], + [PI_BAD_CHAIN_DELAY , "bad chain delay micros"], + [PI_CHAIN_NESTING , "chain counters nested too deeply"], + [PI_CHAIN_TOO_BIG , "chain is too long"], + [PI_DEPRECATED , "deprecated function removed"], + [PI_BAD_SER_INVERT , "bit bang serial invert not 0 or 1"], + [_PI_BAD_EDGE , "bad ISR edge value, not 0-2"], + [_PI_BAD_ISR_INIT , "bad ISR initialisation"], + [PI_BAD_FOREVER , "loop forever must be last chain command"], + [PI_BAD_FILTER , "bad filter parameter"], + [PI_BAD_PAD , "bad pad number"], + [PI_BAD_STRENGTH , "bad pad drive strength"], + [PI_FIL_OPEN_FAILED , "file open failed"], + [PI_BAD_FILE_MODE , "bad file mode"], + [PI_BAD_FILE_FLAG , "bad file flag"], + [PI_BAD_FILE_READ , "bad file read"], + [PI_BAD_FILE_WRITE , "bad file write"], + [PI_FILE_NOT_ROPEN , "file not open for read"], + [PI_FILE_NOT_WOPEN , "file not open for write"], + [PI_BAD_FILE_SEEK , "bad file seek"], + [PI_NO_FILE_MATCH , "no files match pattern"], + [PI_NO_FILE_ACCESS , "no permission to access file"], + [PI_FILE_IS_A_DIR , "file is a directory"], + [PI_BAD_SHELL_STATUS , "bad shell return status"], + [PI_BAD_SCRIPT_NAME , "bad script name"], + [PI_BAD_SPI_BAUD , "bad SPI baud rate, not 50-500k"], + [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{}" + +_except_z = "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + +_except_1 = """ +Did you start the pigpio daemon? E.g. sudo pigpiod + +Did you specify the correct Pi host/port in the environment +variables PIGPIO_ADDR/PIGPIO_PORT? +E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888 + +Did you specify the correct Pi host/port in the +pigpio.pi() function? E.g. pigpio.pi('soft', 8888)""" + +_except_2 = """ +Do you have permission to access the pigpio daemon? +Perhaps it was started with sudo pigpiod -nlocalhost""" + +_except_3 = """ +Can't create callback thread. +Perhaps too many simultaneous pigpio connections.""" + +class _socklock: + """ + A class to store socket and lock. + """ + def __init__(self): + self.s = None + self.l = threading.Lock() + +class error(Exception): + """pigpio module exception""" + def __init__(self, value): + self.value = value + def __str__(self): + return repr(self.value) + +class pulse: + """ + A class to store pulse information. + """ + + def __init__(self, gpio_on, gpio_off, delay): + """ + Initialises a pulse. + + gpio_on:= the GPIO to switch on at the start of the pulse. + gpio_off:= the GPIO to switch off at the start of the pulse. + delay:= the delay in microseconds before the next pulse. + + """ + self.gpio_on = gpio_on + self.gpio_off = gpio_off + self.delay = delay + +def error_text(errnum): + """ + Returns a text description of a pigpio error. + + errnum:= <0, the error number + + ... + print(pigpio.error_text(-5)) + level not 0-1 + ... + """ + for e in _errors: + if e[0] == errnum: + return e[1] + return "unknown error ({})".format(errnum) + +def tickDiff(t1, t2): + """ + Returns the microsecond difference between two ticks. + + t1:= the earlier tick + t2:= the later tick + + ... + print(pigpio.tickDiff(4294967272, 12)) + 36 + ... + """ + tDiff = t2 - t1 + if tDiff < 0: + tDiff += (1 << 32) + return tDiff + +# A couple of hacks to cope with different string handling +# between various Python versions +# 3 != 2.7.8 != 2.7.3 + +if sys.hexversion < 0x03000000: + def _b(x): + return x +else: + def _b(x): + return x.encode('latin-1') + +if sys.hexversion < 0x02070800: + def _str(x): + return buffer(x) +else: + def _str(x): + return x + +def u2i(uint32): + """ + Converts a 32 bit unsigned number to signed. + + uint32:= an unsigned 32 bit number + + ... + print(u2i(4294967272)) + -24 + print(u2i(37)) + 37 + ... + """ + mask = (2 ** 32) - 1 + if uint32 & (1 << 31): + v = uint32 | ~mask + else: + v = uint32 & mask + return v + +def _u2i(uint32): + """ + Converts a 32 bit unsigned number to signed. If the number + is negative it indicates an error. On error a pigpio + exception will be raised if exceptions is True. + """ + v = u2i(uint32) + if v < 0: + if exceptions: + raise error(error_text(v)) + return v + +def _pigpio_command(sl, cmd, p1, p2): + """ + Runs a pigpio socket command. + + sl:= command socket and lock. + cmd:= the command to be executed. + p1:= command parameter 1 (if applicable). + p2:= command parameter 2 (if applicable). + """ + res = PI_CMD_INTERRUPTED + with sl.l: + sl.s.send(struct.pack('IIII', cmd, p1, p2, 0)) + dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN)) + return res + +def _pigpio_command_nolock(sl, cmd, p1, p2): + """ + Runs a pigpio socket command. + + sl:= command socket and lock. + cmd:= the command to be executed. + p1:= command parameter 1 (if applicable). + p2:= command parameter 2 (if applicable). + """ + res = PI_CMD_INTERRUPTED + sl.s.send(struct.pack('IIII', cmd, p1, p2, 0)) + dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN)) + return res + +def _pigpio_command_ext(sl, cmd, p1, p2, p3, extents): + """ + Runs an extended pigpio socket command. + + sl:= command socket and lock. + cmd:= the command to be executed. + p1:= command parameter 1 (if applicable). + p2:= command parameter 2 (if applicable). + p3:= total size in bytes of following extents + extents:= additional data blocks + """ + ext = bytearray(struct.pack('IIII', cmd, p1, p2, p3)) + for x in extents: + if type(x) == type(""): + ext.extend(_b(x)) + else: + ext.extend(x) + res = PI_CMD_INTERRUPTED + with sl.l: + sl.s.sendall(ext) + dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN)) + return res + +def _pigpio_command_ext_nolock(sl, cmd, p1, p2, p3, extents): + """ + Runs an extended pigpio socket command. + + sl:= command socket and lock. + cmd:= the command to be executed. + p1:= command parameter 1 (if applicable). + p2:= command parameter 2 (if applicable). + p3:= total size in bytes of following extents + extents:= additional data blocks + """ + res = PI_CMD_INTERRUPTED + ext = bytearray(struct.pack('IIII', cmd, p1, p2, p3)) + for x in extents: + if type(x) == type(""): + ext.extend(_b(x)) + else: + ext.extend(x) + sl.s.sendall(ext) + dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN)) + return res + +class _event_ADT: + """ + An ADT class to hold event callback information. + """ + + def __init__(self, event, func): + """ + Initialises an event callback ADT. + + event:= the event id. + func:= a user function taking one argument, the event id. + """ + self.event = event + self.func = func + self.bit = 1<= MSG_SIZ: + msgbuf = buf[offset:offset + MSG_SIZ] + offset += MSG_SIZ + seq, flags, tick, level = (struct.unpack('HHII', msgbuf)) + + if flags == 0: + changed = level ^ lastLevel + lastLevel = level + for cb in self.callbacks: + if cb.bit & changed: + newLevel = 0 + if cb.bit & level: + newLevel = 1 + if (cb.edge ^ newLevel): + cb.func(cb.gpio, newLevel, tick) + else: + if flags & NTFY_FLAGS_WDOG: + gpio = flags & NTFY_FLAGS_GPIO + for cb in self.callbacks: + if cb.gpio == gpio: + cb.func(gpio, TIMEOUT, tick) + elif flags & NTFY_FLAGS_EVENT: + event = flags & NTFY_FLAGS_GPIO + for cb in self.events: + if cb.event == event: + cb.func(event, tick) + buf = buf[offset:] + + self.sl.s.close() + +class _callback: + """A class to provide GPIO level change callbacks.""" + + def __init__(self, notify, user_gpio, edge=RISING_EDGE, func=None): + """ + Initialise a callback and adds it to the notification thread. + """ + self._notify = notify + self.count=0 + self._reset = False + if func is None: + func=self._tally + self.callb = _callback_ADT(user_gpio, edge, func) + self._notify.append(self.callb) + + def cancel(self): + """Cancels a callback by removing it from the notification thread.""" + self._notify.remove(self.callb) + + def _tally(self, user_gpio, level, tick): + """Increment the callback called count.""" + if self._reset: + self._reset = False + self.count = 0 + self.count += 1 + + def tally(self): + """ + Provides a count of how many times the default tally + callback has triggered. + + The count will be zero if the user has supplied their own + callback function. + """ + return self.count + + def reset_tally(self): + """ + Resets the tally count to zero. + """ + self._reset = True + self.count = 0 + +class _event: + """A class to provide event callbacks.""" + + def __init__(self, notify, event, func=None): + """ + Initialise an event and adds it to the notification thread. + """ + self._notify = notify + self.count=0 + self._reset = False + if func is None: + func=self._tally + self.callb = _event_ADT(event, func) + self._notify.append_event(self.callb) + + def cancel(self): + """ + Cancels a event callback by removing it from the + notification thread. + """ + self._notify.remove_event(self.callb) + + def _tally(self, event, tick): + """Increment the event callback called count.""" + if self._reset: + self._reset = False + self.count = 0 + self.count += 1 + + def tally(self): + """ + Provides a count of how many times the default tally + callback has triggered. + + The count will be zero if the user has supplied their own + callback function. + """ + return self.count + + def reset_tally(self): + """ + Resets the tally count to zero. + """ + self._reset = True + self.count = 0 + +class _wait_for_edge: + """Encapsulates waiting for GPIO edges.""" + + def __init__(self, notify, gpio, edge, timeout): + """Initialises a wait_for_edge.""" + self._notify = notify + self.callb = _callback_ADT(gpio, edge, self.func) + self.trigger = False + self._notify.append(self.callb) + self.start = time.time() + while (self.trigger == False) and ((time.time()-self.start) < timeout): + time.sleep(0.05) + self._notify.remove(self.callb) + + def func(self, gpio, level, tick): + """Sets wait_for_edge triggered.""" + self.trigger = True + +class _wait_for_event: + """Encapsulates waiting for an event.""" + + def __init__(self, notify, event, timeout): + """Initialises wait_for_event.""" + self._notify = notify + self.callb = _event_ADT(event, self.func) + self.trigger = False + self._notify.append_event(self.callb) + self.start = time.time() + while (self.trigger == False) and ((time.time()-self.start) < timeout): + time.sleep(0.05) + self._notify.remove_event(self.callb) + + def func(self, event, tick): + """Sets wait_for_event triggered.""" + self.trigger = True + +class pi(): + + def _rxbuf(self, count): + """Returns count bytes from the command socket.""" + ext = bytearray(self.sl.s.recv(count)) + while len(ext) < count: + ext.extend(self.sl.s.recv(count - len(ext))) + return ext + + def set_mode(self, gpio, mode): + """ + Sets the GPIO mode. + + gpio:= 0-53. + mode:= INPUT, OUTPUT, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5. + + ... + pi.set_mode( 4, pigpio.INPUT) # GPIO 4 as input + pi.set_mode(17, pigpio.OUTPUT) # GPIO 17 as output + pi.set_mode(24, pigpio.ALT2) # GPIO 24 as ALT2 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_MODES, gpio, mode)) + + def get_mode(self, gpio): + """ + Returns the GPIO mode. + + gpio:= 0-53. + + Returns a value as follows + + . . + 0 = INPUT + 1 = OUTPUT + 2 = ALT5 + 3 = ALT4 + 4 = ALT0 + 5 = ALT1 + 6 = ALT2 + 7 = ALT3 + . . + + ... + print(pi.get_mode(0)) + 4 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_MODEG, gpio, 0)) + + def set_pull_up_down(self, gpio, pud): + """ + Sets or clears the internal GPIO pull-up/down resistor. + + gpio:= 0-53. + pud:= PUD_UP, PUD_DOWN, PUD_OFF. + + ... + pi.set_pull_up_down(17, pigpio.PUD_OFF) + pi.set_pull_up_down(23, pigpio.PUD_UP) + pi.set_pull_up_down(24, pigpio.PUD_DOWN) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PUD, gpio, pud)) + + def read(self, gpio): + """ + Returns the GPIO level. + + gpio:= 0-53. + + ... + pi.set_mode(23, pigpio.INPUT) + + pi.set_pull_up_down(23, pigpio.PUD_DOWN) + print(pi.read(23)) + 0 + + pi.set_pull_up_down(23, pigpio.PUD_UP) + print(pi.read(23)) + 1 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_READ, gpio, 0)) + + def write(self, gpio, level): + """ + Sets the GPIO level. + + GPIO:= 0-53. + level:= 0, 1. + + If PWM or servo pulses are active on the GPIO they are + switched off. + + ... + pi.set_mode(17, pigpio.OUTPUT) + + pi.write(17,0) + print(pi.read(17)) + 0 + + pi.write(17,1) + print(pi.read(17)) + 1 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WRITE, gpio, level)) + + def set_PWM_dutycycle(self, user_gpio, dutycycle): + """ + Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO. + + user_gpio:= 0-31. + dutycycle:= 0-range (range defaults to 255). + + The [*set_PWM_range*] function can change the default range of 255. + + ... + pi.set_PWM_dutycycle(4, 0) # PWM off + pi.set_PWM_dutycycle(4, 64) # PWM 1/4 on + pi.set_PWM_dutycycle(4, 128) # PWM 1/2 on + pi.set_PWM_dutycycle(4, 192) # PWM 3/4 on + pi.set_PWM_dutycycle(4, 255) # PWM full on + ... + """ + return _u2i(_pigpio_command( + self.sl, _PI_CMD_PWM, user_gpio, int(dutycycle))) + + def get_PWM_dutycycle(self, user_gpio): + """ + Returns the PWM dutycycle being used on the GPIO. + + user_gpio:= 0-31. + + Returns the PWM dutycycle. + + + For normal PWM the dutycycle will be out of the defined range + for the GPIO (see [*get_PWM_range*]). + + 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). + + ... + pi.set_PWM_dutycycle(4, 25) + print(pi.get_PWM_dutycycle(4)) + 25 + + pi.set_PWM_dutycycle(4, 203) + print(pi.get_PWM_dutycycle(4)) + 203 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_GDC, user_gpio, 0)) + + def set_PWM_range(self, user_gpio, range_): + """ + Sets the range of PWM values to be used on the GPIO. + + user_gpio:= 0-31. + range_:= 25-40000. + + ... + pi.set_PWM_range(9, 100) # now 25 1/4, 50 1/2, 75 3/4 on + pi.set_PWM_range(9, 500) # now 125 1/4, 250 1/2, 375 3/4 on + pi.set_PWM_range(9, 3000) # now 750 1/4, 1500 1/2, 2250 3/4 on + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PRS, user_gpio, range_)) + + def get_PWM_range(self, user_gpio): + """ + Returns the range of PWM values being used on the GPIO. + + user_gpio:= 0-31. + + If a hardware clock or hardware PWM is active on the GPIO + the reported range will be 1000000 (1M). + + ... + pi.set_PWM_range(9, 500) + print(pi.get_PWM_range(9)) + 500 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PRG, user_gpio, 0)) + + def get_PWM_real_range(self, user_gpio): + """ + Returns the real (underlying) range of PWM values being + used on the GPIO. + + user_gpio:= 0-31. + + 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. + + ... + pi.set_PWM_frequency(4, 800) + print(pi.get_PWM_real_range(4)) + 250 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PRRG, user_gpio, 0)) + + def set_PWM_frequency(self, user_gpio, frequency): + """ + Sets the frequency (in Hz) of the PWM to be used on the GPIO. + + user_gpio:= 0-31. + frequency:= >=0 Hz + + Returns the numerically closest frequency if OK, otherwise + PI_BAD_USER_GPIO or PI_NOT_PERMITTED. + + 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 + . . + + ... + pi.set_PWM_frequency(4,0) + print(pi.get_PWM_frequency(4)) + 10 + + pi.set_PWM_frequency(4,100000) + print(pi.get_PWM_frequency(4)) + 8000 + ... + """ + return _u2i( + _pigpio_command(self.sl, _PI_CMD_PFS, user_gpio, frequency)) + + def get_PWM_frequency(self, user_gpio): + """ + Returns the frequency of PWM being used on the GPIO. + + user_gpio:= 0-31. + + Returns the frequency (in Hz) used for the GPIO. + + For normal PWM the frequency will be that defined for the GPIO + by [*set_PWM_frequency*]. + + If a hardware clock is active on the GPIO the reported frequency + will be that set by [*hardware_clock*]. + + If hardware PWM is active on the GPIO the reported frequency + will be that set by [*hardware_PWM*]. + + ... + pi.set_PWM_frequency(4,0) + print(pi.get_PWM_frequency(4)) + 10 + + pi.set_PWM_frequency(4, 800) + print(pi.get_PWM_frequency(4)) + 800 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PFG, user_gpio, 0)) + + def set_servo_pulsewidth(self, user_gpio, pulsewidth): + """ + Starts (500-2500) or stops (0) servo pulses on the GPIO. + + user_gpio:= 0-31. + pulsewidth:= 0 (off), + 500 (most anti-clockwise) - 2500 (most clockwise). + + The selected pulsewidth will continue to be transmitted until + changed by a subsequent call to set_servo_pulsewidth. + + The pulsewidths supported by servos varies and should probably + be determined by experiment. 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. + + ... + pi.set_servo_pulsewidth(17, 0) # off + pi.set_servo_pulsewidth(17, 1000) # safe anti-clockwise + pi.set_servo_pulsewidth(17, 1500) # centre + pi.set_servo_pulsewidth(17, 2000) # safe clockwise + ... + """ + return _u2i(_pigpio_command( + self.sl, _PI_CMD_SERVO, user_gpio, int(pulsewidth))) + + def get_servo_pulsewidth(self, user_gpio): + """ + Returns the servo pulsewidth being used on the GPIO. + + user_gpio:= 0-31. + + Returns the servo pulsewidth. + + ... + pi.set_servo_pulsewidth(4, 525) + print(pi.get_servo_pulsewidth(4)) + 525 + + pi.set_servo_pulsewidth(4, 2130) + print(pi.get_servo_pulsewidth(4)) + 2130 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_GPW, user_gpio, 0)) + + def notify_open(self): + """ + Returns a notification handle (>=0). + + A notification is a method for being notified of GPIO state + changes via a pipe. + + Pipes are only accessible from the local machine so this + function serves no purpose if you are using Python from a + remote machine. The in-built (socket) notifications + provided by [*callback*] should be used instead. + + Notifications for handle x will be available at the pipe + named /dev/pigpiox (where x is the handle number). + + E.g. if the function returns 15 then the notifications must be + read from /dev/pigpio15. + + Notifications have the following structure: + + . . + H seqno + H flags + I tick + I level + . . + + seqno: starts at 0 each time the handle is opened and then + increments by one for each report. + + flags: three flags are defined, PI_NTFY_FLAGS_WDOG, + PI_NTFY_FLAGS_ALIVE, and PI_NTFY_FLAGS_EVENT. + + 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. + + If bit 7 is set (PI_NTFY_FLAGS_EVENT) then bits 0-4 of the + flags indicate an event which has been triggered. + + + tick: the number of microseconds since system boot. It wraps + around after 1h12m. + + level: indicates the level of each GPIO. If bit 1<= 0: + pi.notify_begin(h, 1234) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_NO, 0, 0)) + + def notify_begin(self, handle, bits): + """ + Starts notifications on a handle. + + handle:= >=0 (as returned by a prior call to [*notify_open*]) + bits:= a 32 bit mask indicating the GPIO to be notified. + + The notification sends state changes for each GPIO whose + corresponding bit in bits is set. + + The following code starts notifications for GPIO 1, 4, + 6, 7, and 10 (1234 = 0x04D2 = 0b0000010011010010). + + ... + h = pi.notify_open() + if h >= 0: + pi.notify_begin(h, 1234) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_NB, handle, bits)) + + def notify_pause(self, handle): + """ + Pauses notifications on a handle. + + handle:= >=0 (as returned by a prior call to [*notify_open*]) + + Notifications for the handle are suspended until + [*notify_begin*] is called again. + + ... + h = pi.notify_open() + if h >= 0: + pi.notify_begin(h, 1234) + ... + pi.notify_pause(h) + ... + pi.notify_begin(h, 1234) + ... + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_NB, handle, 0)) + + def notify_close(self, handle): + """ + Stops notifications on a handle and releases the handle for reuse. + + handle:= >=0 (as returned by a prior call to [*notify_open*]) + + ... + h = pi.notify_open() + if h >= 0: + pi.notify_begin(h, 1234) + ... + pi.notify_close(h) + ... + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_NC, handle, 0)) + + def set_watchdog(self, user_gpio, wdog_timeout): + """ + Sets a watchdog timeout for a GPIO. + + user_gpio:= 0-31. + wdog_timeout:= 0-60000. + + The watchdog is nominally in milliseconds. + + Only one watchdog may be registered per GPIO. + + The watchdog may be cancelled by setting timeout to 0. + + Once a watchdog has been started callbacks for the GPIO + will be triggered every timeout interval after the last + GPIO activity. + + The callback will receive the special level TIMEOUT. + + ... + pi.set_watchdog(23, 1000) # 1000 ms watchdog on GPIO 23 + pi.set_watchdog(23, 0) # cancel watchdog on GPIO 23 + ... + """ + return _u2i(_pigpio_command( + self.sl, _PI_CMD_WDOG, user_gpio, int(wdog_timeout))) + + def read_bank_1(self): + """ + Returns the levels of the bank 1 GPIO (GPIO 0-31). + + The returned 32 bit integer has a bit set if the corresponding + GPIO is high. GPIO n has bit value (1<=0) if OK, otherwise PI_EMPTY_WAVEFORM, + PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID. + + The data provided by the [*wave_add_**] functions is 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. + + Normal usage would be + + 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*] to create the waveform and get a unique id + + Repeat steps 2 and 3 as needed. + + Step 4. [*wave_send_**] with the id of the waveform to transmit. + + A waveform comprises 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. + + ... + wid = pi.wave_create() + ... + """ + 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. + + wave_id:= >=0 (as returned by a prior call to [*wave_create*]). + + Wave ids are allocated in order, 0, 1, 2, etc. + + 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). + + ... + pi.wave_delete(6) # delete waveform with id 6 + + pi.wave_delete(0) # delete waveform with id 0 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVDEL, wave_id, 0)) + + def wave_tx_start(self): # DEPRECATED + """ + This function is deprecated and has been removed. + + Use [*wave_create*]/[*wave_send_**] instead. + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVGO, 0, 0)) + + def wave_tx_repeat(self): # DEPRECATED + """ + This function is deprecated and has beeen removed. + + Use [*wave_create*]/[*wave_send_**] instead. + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVGOR, 0, 0)) + + def wave_send_once(self, wave_id): + """ + Transmits the waveform with id wave_id. The waveform is sent + once. + + NOTE: Any hardware PWM started by [*hardware_PWM*] will + be cancelled. + + wave_id:= >=0 (as returned by a prior call to [*wave_create*]). + + Returns the number of DMA control blocks used in the waveform. + + ... + cbs = pi.wave_send_once(wid) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTX, wave_id, 0)) + + def wave_send_repeat(self, wave_id): + """ + Transmits the waveform with id wave_id. The waveform repeats + until wave_tx_stop is called or another call to [*wave_send_**] + is made. + + NOTE: Any hardware PWM started by [*hardware_PWM*] will + be cancelled. + + wave_id:= >=0 (as returned by a prior call to [*wave_create*]). + + Returns the number of DMA control blocks used in the waveform. + + ... + cbs = pi.wave_send_repeat(wid) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXR, wave_id, 0)) + + def wave_send_using_mode(self, wave_id, mode): + """ + Transmits the waveform with id wave_id using mode mode. + + wave_id:= >=0 (as returned by a prior call to [*wave_create*]). + mode:= WAVE_MODE_ONE_SHOT, WAVE_MODE_REPEAT, + WAVE_MODE_ONE_SHOT_SYNC, or WAVE_MODE_REPEAT_SYNC. + + WAVE_MODE_ONE_SHOT: same as [*wave_send_once*]. + + WAVE_MODE_REPEAT same as [*wave_send_repeat*]. + + WAVE_MODE_ONE_SHOT_SYNC same as [*wave_send_once*] but tries + to sync with the previous waveform. + + WAVE_MODE_REPEAT_SYNC same as [*wave_send_repeat*] but tries + to sync with the previous waveform. + + 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 [*hardware_PWM*] will + be cancelled. + + wave_id:= >=0 (as returned by a prior call to [*wave_create*]). + + Returns the number of DMA control blocks used in the waveform. + + ... + cbs = pi.wave_send_using_mode(wid, WAVE_MODE_REPEAT_SYNC) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXM, wave_id, mode)) + + def wave_tx_at(self): + """ + Returns the id of the waveform currently being + transmitted using [*wave_send**]. Chained waves are not supported. + + Returns the waveform id or one of the following special + values: + + WAVE_NOT_FOUND (9998) - transmitted wave not found. + NO_TX_WAVE (9999) - no wave being transmitted. + + ... + wid = pi.wave_tx_at() + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTAT, 0, 0)) + + def wave_tx_busy(self): + """ + Returns 1 if a waveform is currently being transmitted, + otherwise 0. + + ... + pi.wave_send_once(0) # send first waveform + + while pi.wave_tx_busy(): # wait for waveform to be sent + time.sleep(0.1) + + pi.wave_send_once(1) # send next waveform + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVBSY, 0, 0)) + + def wave_tx_stop(self): + """ + Stops the transmission of the current waveform. + + This function is intended to stop a waveform started with + wave_send_repeat. + + ... + pi.wave_send_repeat(3) + + time.sleep(5) + + pi.wave_tx_stop() + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_WVHLT, 0, 0)) + + def wave_chain(self, data): + """ + This function transmits a chain of waveforms. + + NOTE: Any hardware PWM started by [*hardware_PWM*] + will be cancelled. + + The waves to be transmitted are specified by the contents + of data which contains an ordered list of [*wave_id*]s + and optional command codes and related data. + + Returns 0 if OK, otherwise PI_CHAIN_NESTING, + PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, + PI_CHAIN_COUNTER, PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, + or PI_BAD_WAVE_ID. + + 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. + + ... + #!/usr/bin/env python + + import time + import pigpio + + WAVES=5 + GPIO=4 + + wid=[0]*WAVES + + pi = pigpio.pi() # Connect to local Pi. + + pi.set_mode(GPIO, pigpio.OUTPUT); + + for i in range(WAVES): + pi.wave_add_generic([ + pigpio.pulse(1<=0) for the device at the I2C bus address. + + i2c_bus:= >=0. + i2c_address:= 0-0x7F. + i2c_flags:= 0, no flags are currently defined. + + 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 + + For the SMBus commands the low level transactions are shown + at the end of the function description. The following + abbreviations are used: + + . . + S (1 bit) : Start bit + P (1 bit) : Stop bit + Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. + A, NA (1 bit) : Accept and not accept bit. + Addr (7 bits): I2C 7 bit address. + reg (8 bits): Command byte, which often selects a register. + Data (8 bits): A data byte. + Count (8 bits): A byte defining the length of a block operation. + + [..]: Data sent by the device. + . . + + ... + h = pi.i2c_open(1, 0x53) # open device at address 0x53 on bus 1 + ... + """ + # I p1 i2c_bus + # I p2 i2c_addr + # I p3 4 + ## extension ## + # I i2c_flags + extents = [struct.pack("I", i2c_flags)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_I2CO, i2c_bus, i2c_address, 4, extents)) + + def i2c_close(self, handle): + """ + Closes the I2C device associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + + ... + pi.i2c_close(h) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CC, handle, 0)) + + def i2c_write_quick(self, handle, bit): + """ + Sends a single bit to the device associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + bit:= 0 or 1, the value to write. + + SMBus 2.0 5.5.1 - Quick command. + . . + S Addr bit [A] P + . . + + ... + pi.i2c_write_quick(0, 1) # send 1 to device 0 + pi.i2c_write_quick(3, 0) # send 0 to device 3 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CWQ, handle, bit)) + + def i2c_write_byte(self, handle, byte_val): + """ + Sends a single byte to the device associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + byte_val:= 0-255, the value to write. + + SMBus 2.0 5.5.2 - Send byte. + . . + S Addr Wr [A] byte_val [A] P + . . + + ... + pi.i2c_write_byte(1, 17) # send byte 17 to device 1 + pi.i2c_write_byte(2, 0x23) # send byte 0x23 to device 2 + ... + """ + return _u2i( + _pigpio_command(self.sl, _PI_CMD_I2CWS, handle, byte_val)) + + def i2c_read_byte(self, handle): + """ + Reads a single byte from the device associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + + SMBus 2.0 5.5.3 - Receive byte. + . . + S Addr Rd [A] [Data] NA P + . . + + ... + b = pi.i2c_read_byte(2) # read a byte from device 2 + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CRS, handle, 0)) + + def i2c_write_byte_data(self, handle, reg, byte_val): + """ + Writes a single byte to the specified register of the device + associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + byte_val:= 0-255, the value to write. + + SMBus 2.0 5.5.4 - Write byte. + . . + S Addr Wr [A] reg [A] byte_val [A] P + . . + + ... + # send byte 0xC5 to reg 2 of device 1 + pi.i2c_write_byte_data(1, 2, 0xC5) + + # send byte 9 to reg 4 of device 2 + pi.i2c_write_byte_data(2, 4, 9) + ... + """ + # I p1 handle + # I p2 reg + # I p3 4 + ## extension ## + # I byte_val + extents = [struct.pack("I", byte_val)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_I2CWB, handle, reg, 4, extents)) + + def i2c_write_word_data(self, handle, reg, word_val): + """ + Writes a single 16 bit word to the specified register of the + device associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + word_val:= 0-65535, the value to write. + + SMBus 2.0 5.5.4 - Write word. + . . + S Addr Wr [A] reg [A] word_val_Low [A] word_val_High [A] P + . . + + ... + # send word 0xA0C5 to reg 5 of device 4 + pi.i2c_write_word_data(4, 5, 0xA0C5) + + # send word 2 to reg 2 of device 5 + pi.i2c_write_word_data(5, 2, 23) + ... + """ + # I p1 handle + # I p2 reg + # I p3 4 + ## extension ## + # I word_val + extents = [struct.pack("I", word_val)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_I2CWW, handle, reg, 4, extents)) + + def i2c_read_byte_data(self, handle, reg): + """ + Reads a single byte from the specified register of the device + associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + + SMBus 2.0 5.5.5 - Read byte. + . . + S Addr Wr [A] reg [A] S Addr Rd [A] [Data] NA P + . . + + ... + # read byte from reg 17 of device 2 + b = pi.i2c_read_byte_data(2, 17) + + # read byte from reg 1 of device 0 + b = pi.i2c_read_byte_data(0, 1) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CRB, handle, reg)) + + def i2c_read_word_data(self, handle, reg): + """ + Reads a single 16 bit word from the specified register of the + device associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + + SMBus 2.0 5.5.5 - Read word. + . . + S Addr Wr [A] reg [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P + . . + + ... + # read word from reg 2 of device 3 + w = pi.i2c_read_word_data(3, 2) + + # read word from reg 7 of device 2 + w = pi.i2c_read_word_data(2, 7) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CRW, handle, reg)) + + def i2c_process_call(self, handle, reg, word_val): + """ + Writes 16 bits of data to the specified register of the device + associated with handle and reads 16 bits of data in return. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + word_val:= 0-65535, the value to write. + + SMBus 2.0 5.5.6 - Process call. + . . + S Addr Wr [A] reg [A] word_val_Low [A] word_val_High [A] + S Addr Rd [A] [DataLow] A [DataHigh] NA P + . . + + ... + r = pi.i2c_process_call(h, 4, 0x1231) + r = pi.i2c_process_call(h, 6, 0) + ... + """ + # I p1 handle + # I p2 reg + # I p3 4 + ## extension ## + # I word_val + extents = [struct.pack("I", word_val)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_I2CPC, handle, reg, 4, extents)) + + def i2c_write_block_data(self, handle, reg, data): + """ + Writes up to 32 bytes to the specified register of the device + associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + data:= the bytes to write. + + SMBus 2.0 5.5.7 - Block write. + . . + S Addr Wr [A] reg [A] len(data) [A] data0 [A] data1 [A] ... [A] + datan [A] P + . . + + ... + pi.i2c_write_block_data(4, 5, b'hello') + + pi.i2c_write_block_data(4, 5, "data bytes") + + pi.i2c_write_block_data(5, 0, b'\\x00\\x01\\x22') + + pi.i2c_write_block_data(6, 2, [0, 1, 0x22]) + ... + """ + # I p1 handle + # I p2 reg + # I p3 len + ## extension ## + # s len data bytes + if len(data): + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_I2CWK, handle, reg, len(data), [data])) + else: + return 0 + + def i2c_read_block_data(self, handle, reg): + """ + Reads a block of up to 32 bytes from the specified register of + the device associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + + SMBus 2.0 5.5.7 - Block read. + . . + S Addr Wr [A] reg [A] + S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P + . . + + The amount of returned data is set by the device. + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (b, d) = pi.i2c_read_block_data(h, 10) + if b >= 0: + # process data + else: + # process read failure + ... + """ + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_nolock( + self.sl, _PI_CMD_I2CRK, handle, reg)) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def i2c_block_process_call(self, handle, reg, data): + """ + Writes data bytes to the specified register of the device + associated with handle and reads a device specified number + of bytes of data in return. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + data:= the bytes to write. + + The SMBus 2.0 documentation states that a minimum of 1 byte may + be sent and a minimum of 1 byte may be received. The total + number of bytes sent/received must be 32 or less. + + SMBus 2.0 5.5.8 - Block write-block read. + . . + S Addr Wr [A] reg [A] len(data) [A] data0 [A] ... datan [A] + S Addr Rd [A] [Count] A [Data] ... A P + . . + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (b, d) = pi.i2c_block_process_call(h, 10, b'\\x02\\x05\\x00') + + (b, d) = pi.i2c_block_process_call(h, 10, b'abcdr') + + (b, d) = pi.i2c_block_process_call(h, 10, "abracad") + + (b, d) = pi.i2c_block_process_call(h, 10, [2, 5, 16]) + ... + """ + # I p1 handle + # I p2 reg + # I p3 len + ## extension ## + # s len data bytes + + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_I2CPK, handle, reg, len(data), [data])) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def i2c_write_i2c_block_data(self, handle, reg, data): + """ + Writes data bytes to the specified register of the device + associated with handle . 1-32 bytes may be written. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + data:= the bytes to write. + + . . + S Addr Wr [A] reg [A] data0 [A] data1 [A] ... [A] datan [NA] P + . . + + ... + pi.i2c_write_i2c_block_data(4, 5, 'hello') + + pi.i2c_write_i2c_block_data(4, 5, b'hello') + + pi.i2c_write_i2c_block_data(5, 0, b'\\x00\\x01\\x22') + + pi.i2c_write_i2c_block_data(6, 2, [0, 1, 0x22]) + ... + """ + # I p1 handle + # I p2 reg + # I p3 len + ## extension ## + # s len data bytes + if len(data): + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_I2CWI, handle, reg, len(data), [data])) + else: + return 0 + + def i2c_read_i2c_block_data(self, handle, reg, count): + """ + Reads count bytes from the specified register of the device + associated with handle . The count may be 1-32. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + reg:= >=0, the device register. + count:= >0, the number of bytes to read. + + . . + S Addr Wr [A] reg [A] + S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P + . . + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (b, d) = pi.i2c_read_i2c_block_data(h, 4, 32) + if b >= 0: + # process data + else: + # process read failure + ... + """ + # I p1 handle + # I p2 reg + # I p3 4 + ## extension ## + # I count + extents = [struct.pack("I", count)] + + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_I2CRI, handle, reg, 4, extents)) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def i2c_read_device(self, handle, count): + """ + Returns count bytes read from the raw device associated + with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + count:= >0, the number of bytes to read. + + . . + S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P + . . + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (count, data) = pi.i2c_read_device(h, 12) + ... + """ + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i( + _pigpio_command_nolock(self.sl, _PI_CMD_I2CRD, handle, count)) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def i2c_write_device(self, handle, data): + """ + Writes the data bytes to the raw device associated with handle. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + data:= the bytes to write. + + . . + S Addr Wr [A] data0 [A] data1 [A] ... [A] datan [A] P + . . + + ... + pi.i2c_write_device(h, b"\\x12\\x34\\xA8") + + pi.i2c_write_device(h, b"help") + + pi.i2c_write_device(h, 'help') + + pi.i2c_write_device(h, [23, 56, 231]) + ... + """ + # I p1 handle + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + if len(data): + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_I2CWD, handle, 0, len(data), [data])) + else: + return 0 + + + def i2c_zip(self, handle, data): + """ + This function executes a sequence of I2C operations. The + operations to be performed are specified by the contents of data + which contains the concatenated command codes and associated data. + + handle:= >=0 (as returned by a prior call to [*i2c_open*]). + data:= the concatenated I2C commands, see below + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (count, data) = pi.i2c_zip(h, [4, 0x53, 7, 1, 0x32, 6, 6, 0]) + ... + + 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. + The flags default to 0. The address and flags maintain their + previous value until updated. + + Any read I2C data is concatenated in the returned bytearray. + + ... + 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 + ... + """ + # I p1 handle + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_I2CZ, handle, 0, len(data), [data])) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + + def bb_spi_open(self, CS, MISO, MOSI, SCLK, baud=100000, spi_flags=0): + """ + This function selects a set of GPIO for bit banging SPI at a + specified baud rate. + + CS := 0-31 + MISO := 0-31 + MOSI := 0-31 + SCLK := 0-31 + baud := 50-250000 + spiFlags := see below + + spiFlags 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, defaults to 0 + + . . + Mode CPOL CPHA + 0 0 0 + 1 0 1 + 2 1 0 + 3 1 1 + . . + + The following constants may be used to set the mode: + + . . + pigpio.SPI_MODE_0 + pigpio.SPI_MODE_1 + pigpio.SPI_MODE_2 + pigpio.SPI_MODE_3 + . . + + Alternatively pigpio.SPI_CPOL and/or pigpio.SPI_CPHA + may be used. + + p is 0 if CS is active low (default) and 1 for active high. + pigpio.SPI_CS_HIGH_ACTIVE may be used to set this flag. + + T is 1 if the least significant bit is transmitted on MOSI first, + the default (0) shifts the most significant bit out first. + pigpio.SPI_TX_LSBFIRST may be used to set this flag. + + R is 1 if the least significant bit is received on MISO first, + the default (0) receives the most significant bit first. + pigpio.SPI_RX_LSBFIRST may be used to set this flag. + + The other bits in spiFlags should be set to zero. + + Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or + PI_GPIO_IN_USE. + + If more than one device is connected to the SPI bus (defined by + SCLK, MOSI, and MISO) each must have its own CS. + + ... + bb_spi_open(10, MISO, MOSI, SCLK, 10000, 0); // device 1 + bb_spi_open(11, MISO, MOSI, SCLK, 20000, 3); // device 2 + ... + """ + # I p1 CS + # I p2 0 + # I p3 20 + ## extension ## + # I MISO + # I MOSI + # I SCLK + # I baud + # I spi_flags + + extents = [struct.pack("IIIII", MISO, MOSI, SCLK, baud, spi_flags)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_BSPIO, CS, 0, 20, extents)) + + + def bb_spi_close(self, CS): + """ + This function stops bit banging SPI on a set of GPIO + opened with [*bb_spi_open*]. + + CS:= 0-31, the CS GPIO used in a prior call to [*bb_spi_open*] + + Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO. + + ... + pi.bb_spi_close(CS) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_BSPIC, CS, 0)) + + + def bb_spi_xfer(self, CS, data): + """ + This function executes a bit banged SPI transfer. + + CS:= 0-31 (as used in a prior call to [*bb_spi_open*]) + data:= data to be sent + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + #!/usr/bin/env python + + import pigpio + + CE0=5 + CE1=6 + MISO=13 + MOSI=19 + SCLK=12 + + pi = pigpio.pi() + if not pi.connected: + exit() + + pi.bb_spi_open(CE0, MISO, MOSI, SCLK, 10000, 0) # MCP4251 DAC + pi.bb_spi_open(CE1, MISO, MOSI, SCLK, 20000, 3) # MCP3008 ADC + + for i in range(256): + + count, data = pi.bb_spi_xfer(CE0, [0, i]) # Set DAC value + + if count == 2: + + count, data = pi.bb_spi_xfer(CE0, [12, 0]) # Read back DAC + + if count == 2: + + set_val = data[1] + + count, data = pi.bb_spi_xfer(CE1, [1, 128, 0]) # Read ADC + + if count == 3: + + read_val = ((data[1]&3)<<8) | data[2] + + print("{} {}".format(set_val, read_val)) + + pi.bb_spi_close(CE0) + pi.bb_spi_close(CE1) + + pi.stop() + ... + """ + # I p1 CS + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_BSPIX, CS, 0, len(data), [data])) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + + def bb_i2c_open(self, SDA, SCL, baud=100000): + """ + This function selects a pair of GPIO for bit banging I2C at a + specified baud rate. + + 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 + + SDA:= 0-31 + SCL:= 0-31 + baud:= 50-500000 + + Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or + PI_GPIO_IN_USE. + + NOTE: + + 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. + + ... + h = pi.bb_i2c_open(4, 5, 50000) # bit bang on GPIO 4/5 at 50kbps + ... + """ + # I p1 SDA + # I p2 SCL + # I p3 4 + ## extension ## + # I baud + extents = [struct.pack("I", baud)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_BI2CO, SDA, SCL, 4, extents)) + + + def bb_i2c_close(self, SDA): + """ + This function stops bit banging I2C on a pair of GPIO + previously opened with [*bb_i2c_open*]. + + SDA:= 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*] + + Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO. + + ... + pi.bb_i2c_close(SDA) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_BI2CC, SDA, 0)) + + + def bb_i2c_zip(self, SDA, data): + """ + This function executes a sequence of bit banged I2C operations. + The operations to be performed are specified by the contents + of data which contains the concatenated command codes and + associated data. + + SDA:= 0-31 (as used in a prior call to [*bb_i2c_open*]) + data:= the concatenated I2C commands, see below + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (count, data) = pi.bb_i2c_zip( + SDA, [4, 0x53, 2, 7, 1, 0x32, 2, 6, 6, 3, 0]) + ... + + 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. + + Any read I2C data is concatenated in the returned bytearray. + + ... + 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 + ... + """ + # I p1 SDA + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_BI2CZ, SDA, 0, len(data), [data])) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def event_trigger(self, event): + """ + This function signals the occurrence of an event. + + event:= 0-31, the event + + Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + + An event is a signal used to inform one or more consumers + to start an action. Each consumer which has registered an + interest in the event (e.g. by calling [*event_callback*]) will + be informed by a callback. + + One event, EVENT_BSC (31) is predefined. This event is + auto generated on BSC slave activity. + + The meaning of other events is arbitrary. + + Note that other than its id and its tick there is no data associated + with an event. + + ... + pi.event_trigger(23) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_EVT, event, 0)) + + + def bsc_xfer(self, bsc_control, data): + """ + 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 + receive buffer. + + bsc_control:= see below + data:= the data bytes to place in the transmit FIFO. + + The returned value is a tuple of the status (see below), + the number of bytes read, and a bytearray containing the + read bytes. If there was an error the status will be less + than zero (and will contain the error code). + + Note that the control word sets the BSC mode. The BSC will + stay in that mode until a different control word is sent. + + 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. + + bsc_control 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 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 + + ... + (status, count, data) = pi.bsc_xfer(0x330305, "Hello!") + ... + """ + # I p1 control + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + + status = PI_CMD_INTERRUPTED + bytes = 0 + rdata = bytearray(b'') + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_BSCX, bsc_control, 0, len(data), [data])) + if bytes > 0: + rx = self._rxbuf(bytes) + status = struct.unpack('I', rx[0:4])[0] + bytes -= 4 + rdata = rx[4:] + else: + status = bytes + bytes = 0 + return status, bytes, rdata + + def bsc_i2c(self, i2c_address, data=[]): + """ + 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. + + i2c_address:= the I2C slave address. + data:= the data bytes to transmit. + + The returned value is a tuple of the status, the number + of bytes read, and a bytearray containing the read bytes. + + See [*bsc_xfer*] for details of the status value. + + 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 as inputs. + + This example assumes GPIO 2/3 are connected to GPIO 18/19 + (GPIO 10/11 on the BCM2711). + + ... + #!/usr/bin/env python + import time + import pigpio + + I2C_ADDR=0x13 + + def i2c(id, tick): + global pi + + s, b, d = pi.bsc_i2c(I2C_ADDR) + if b: + if d[0] == ord('t'): # 116 send 'HH:MM:SS*' + + print("sent={} FR={} received={} [{}]". + format(s>>16, s&0xfff,b,d)) + + s, b, d = pi.bsc_i2c(I2C_ADDR, + "{}*".format(time.asctime()[11:19])) + + elif d[0] == ord('d'): # 100 send 'Sun Oct 30*' + + print("sent={} FR={} received={} [{}]". + format(s>>16, s&0xfff,b,d)) + + s, b, d = pi.bsc_i2c(I2C_ADDR, + "{}*".format(time.asctime()[:10])) + + pi = pigpio.pi() + + if not pi.connected: + exit() + + # Respond to BSC slave activity + + e = pi.event_callback(pigpio.EVENT_BSC, i2c) + + pi.bsc_i2c(I2C_ADDR) # Configure BSC as I2C slave + + time.sleep(600) + + e.cancel() + + pi.bsc_i2c(0) # Disable BSC peripheral + + pi.stop() + ... + + While running the above. + + . . + $ 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 + 0 + + $ pigs i2cwd 0 116 + $ pigs i2crd 0 9 -a + 9 10:13:58* + + $ pigs i2cwd 0 116 + $ pigs i2crd 0 9 -a + 9 10:14:29* + + $ pigs i2cwd 0 100 + $ pigs i2crd 0 11 -a + 11 Sun Oct 30* + + $ pigs i2cwd 0 100 + $ pigs i2crd 0 11 -a + 11 Sun Oct 30* + + $ pigs i2cwd 0 116 + $ pigs i2crd 0 9 -a + 9 10:23:16* + + $ pigs i2cwd 0 100 + $ pigs i2crd 0 11 -a + 11 Sun Oct 30* + . . + """ + if i2c_address: + control = (i2c_address<<16)|0x305 + else: + control = 0 + return self.bsc_xfer(control, data) + + def spi_open(self, spi_channel, baud, spi_flags=0): + """ + Returns a handle for the SPI device on the channel. Data + will be transferred at baud bits per second. The flags + may be used to modify the default behaviour of 4-wire + operation, mode 0, active low chip select. + + 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 + + spi_channel:= 0-1 (0-2 for the auxiliary SPI). + baud:= 32K-125M (values above 30M are unlikely to work). + spi_flags:= see below. + + spi_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 [*spi_read*], [*spi_write*], and [*spi_xfer*] functions + 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 data should + contain 64 bytes. + + 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. + + ... + # open SPI device on channel 1 in mode 3 at 50000 bits per second + + h = pi.spi_open(1, 50000, 3) + ... + """ + # I p1 spi_channel + # I p2 baud + # I p3 4 + ## extension ## + # I spi_flags + extents = [struct.pack("I", spi_flags)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_SPIO, spi_channel, baud, 4, extents)) + + def spi_close(self, handle): + """ + Closes the SPI device associated with handle. + + handle:= >=0 (as returned by a prior call to [*spi_open*]). + + ... + pi.spi_close(h) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_SPIC, handle, 0)) + + def spi_read(self, handle, count): + """ + Reads count bytes from the SPI device associated with handle. + + handle:= >=0 (as returned by a prior call to [*spi_open*]). + count:= >0, the number of bytes to read. + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (b, d) = pi.spi_read(h, 60) # read 60 bytes from device h + if b == 60: + # process read data + else: + # error path + ... + """ + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_nolock( + self.sl, _PI_CMD_SPIR, handle, count)) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def spi_write(self, handle, data): + """ + Writes the data bytes to the SPI device associated with handle. + + handle:= >=0 (as returned by a prior call to [*spi_open*]). + data:= the bytes to write. + + ... + pi.spi_write(0, b'\\x02\\xc0\\x80') # write 3 bytes to device 0 + + pi.spi_write(0, b'defgh') # write 5 bytes to device 0 + + pi.spi_write(0, "def") # write 3 bytes to device 0 + + pi.spi_write(1, [2, 192, 128]) # write 3 bytes to device 1 + ... + """ + # I p1 handle + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_SPIW, handle, 0, len(data), [data])) + + def spi_xfer(self, handle, data): + """ + Writes the data bytes to the SPI device associated with handle, + returning the data bytes read from the device. + + handle:= >=0 (as returned by a prior call to [*spi_open*]). + data:= the bytes to write. + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (count, rx_data) = pi.spi_xfer(h, b'\\x01\\x80\\x00') + + (count, rx_data) = pi.spi_xfer(h, [1, 128, 0]) + + (count, rx_data) = pi.spi_xfer(h, b"hello") + + (count, rx_data) = pi.spi_xfer(h, "hello") + ... + """ + # I p1 handle + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_SPIX, handle, 0, len(data), [data])) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def serial_open(self, tty, baud, ser_flags=0): + """ + Returns a handle for the serial tty device opened + at baud bits per second. The device name must start + with /dev/tty or /dev/serial. + + tty:= the serial device to open. + baud:= baud rate in bits per second, see below. + ser_flags:= 0, no flags are currently defined. + + Normally you would only use the [*serial_**] functions if + you are or will be connecting to the Pi over a network. If + you will always run on the local Pi use the standard serial + module instead. + + 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. + + ... + h1 = pi.serial_open("/dev/ttyAMA0", 300) + + h2 = pi.serial_open("/dev/ttyUSB1", 19200, 0) + + h3 = pi.serial_open("/dev/serial0", 9600) + ... + """ + # I p1 baud + # I p2 ser_flags + # I p3 len + ## extension ## + # s len data bytes + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_SERO, baud, ser_flags, len(tty), [tty])) + + def serial_close(self, handle): + """ + Closes the serial device associated with handle. + + handle:= >=0 (as returned by a prior call to [*serial_open*]). + + ... + pi.serial_close(h1) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_SERC, handle, 0)) + + def serial_read_byte(self, handle): + """ + Returns a single byte from the device associated with handle. + + handle:= >=0 (as returned by a prior call to [*serial_open*]). + + If no data is ready a negative error code will be returned. + + ... + b = pi.serial_read_byte(h1) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_SERRB, handle, 0)) + + def serial_write_byte(self, handle, byte_val): + """ + Writes a single byte to the device associated with handle. + + handle:= >=0 (as returned by a prior call to [*serial_open*]). + byte_val:= 0-255, the value to write. + + ... + pi.serial_write_byte(h1, 23) + + pi.serial_write_byte(h1, ord('Z')) + ... + """ + return _u2i( + _pigpio_command(self.sl, _PI_CMD_SERWB, handle, byte_val)) + + def serial_read(self, handle, count=1000): + """ + Reads up to count bytes from the device associated with handle. + + handle:= >=0 (as returned by a prior call to [*serial_open*]). + count:= >0, the number of bytes to read (defaults to 1000). + + The returned value is a tuple of the number of bytes read and + a bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + If no data is ready a bytes read of zero is returned. + ... + (b, d) = pi.serial_read(h2, 100) + if b > 0: + # process read data + ... + """ + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i( + _pigpio_command_nolock(self.sl, _PI_CMD_SERR, handle, count)) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def serial_write(self, handle, data): + """ + Writes the data bytes to the device associated with handle. + + handle:= >=0 (as returned by a prior call to [*serial_open*]). + data:= the bytes to write. + + ... + pi.serial_write(h1, b'\\x02\\x03\\x04') + + pi.serial_write(h2, b'help') + + pi.serial_write(h2, "hello") + + pi.serial_write(h1, [2, 3, 4]) + ... + """ + # I p1 handle + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_SERW, handle, 0, len(data), [data])) + + def serial_data_available(self, handle): + """ + Returns the number of bytes available to be read from the + device associated with handle. + + handle:= >=0 (as returned by a prior call to [*serial_open*]). + + ... + rdy = pi.serial_data_available(h1) + + if rdy > 0: + (b, d) = pi.serial_read(h1, rdy) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_SERDA, handle, 0)) + + def gpio_trigger(self, user_gpio, pulse_len=10, level=1): + """ + Send a trigger pulse to a GPIO. The GPIO is set to + level for pulse_len microseconds and then reset to not level. + + user_gpio:= 0-31 + pulse_len:= 1-100 + level:= 0-1 + + ... + pi.gpio_trigger(23, 10, 1) + ... + """ + # pigpio message format + + # I p1 user_gpio + # I p2 pulse_len + # I p3 4 + ## extension ## + # I level + extents = [struct.pack("I", level)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_TRIG, user_gpio, pulse_len, 4, extents)) + + def set_glitch_filter(self, user_gpio, steady): + """ + Sets a glitch filter on a GPIO. + + Level changes on the GPIO are not reported unless the level + has been stable for at least [*steady*] microseconds. The + level is then reported. Level changes of less than [*steady*] + microseconds are ignored. + + user_gpio:= 0-31 + steady:= 0-300000 + + Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + + This filter affects the GPIO samples returned to callbacks set up + with [*callback*] and [*wait_for_edge*]. + + It does not affect levels read by [*read*], + [*read_bank_1*], or [*read_bank_2*]. + + Each (stable) edge will be timestamped [*steady*] + microseconds after it was first detected. + + ... + pi.set_glitch_filter(23, 100) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_FG, user_gpio, steady)) + + def set_noise_filter(self, user_gpio, steady, active): + """ + Sets a noise filter on a GPIO. + + Level changes on the GPIO are ignored until a level which has + been stable for [*steady*] microseconds is detected. Level + changes on the GPIO are then reported for [*active*] + microseconds after which the process repeats. + + user_gpio:= 0-31 + steady:= 0-300000 + active:= 0-1000000 + + Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + + This filter affects the GPIO samples returned to callbacks set up + with [*callback*] and [*wait_for_edge*]. + + It does not affect levels read by [*read*], + [*read_bank_1*], or [*read_bank_2*]. + + Level changes before and after the active period may + be reported. Your software must be designed to cope with + such reports. + + ... + pi.set_noise_filter(23, 1000, 5000) + ... + """ + # pigpio message format + + # I p1 user_gpio + # I p2 steady + # I p3 4 + ## extension ## + # I active + extents = [struct.pack("I", active)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_FN, user_gpio, steady, 4, extents)) + + def store_script(self, script): + """ + Store a script for later execution. + + See [[http://abyz.me.uk/rpi/pigpio/pigs.html#Scripts]] for + details. + + script:= the script text as a series of bytes. + + Returns a >=0 script id if OK. + + ... + sid = pi.store_script( + b'tag 0 w 22 1 mils 100 w 22 0 mils 100 dcr p0 jp 0') + ... + """ + # I p1 0 + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + if len(script): + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_PROC, 0, 0, len(script), [script])) + else: + return 0 + + def run_script(self, script_id, params=None): + """ + Runs a stored script. + + script_id:= id of stored script. + params:= up to 10 parameters required by the script. + + ... + s = pi.run_script(sid, [par1, par2]) + + s = pi.run_script(sid) + + s = pi.run_script(sid, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) + ... + """ + # I p1 script id + # I p2 0 + # I p3 params * 4 (0-10 params) + ## (optional) extension ## + # I[] params + if params is not None: + ext = bytearray() + for p in params: + ext.extend(struct.pack("I", p)) + nump = len(params) + extents = [ext] + else: + nump = 0 + extents = [] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_PROCR, script_id, 0, nump*4, extents)) + + def update_script(self, script_id, params=None): + """ + Sets the parameters of a script. The script may or + may not be running. The first parameters of the script are + overwritten with the new values. + + script_id:= id of stored script. + params:= up to 10 parameters required by the script. + + ... + s = pi.update_script(sid, [par1, par2]) + + s = pi.update_script(sid, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) + ... + """ + # I p1 script id + # I p2 0 + # I p3 params * 4 (0-10 params) + ## (optional) extension ## + # I[] params + if params is not None: + ext = bytearray() + for p in params: + ext.extend(struct.pack("I", p)) + nump = len(params) + extents = [ext] + else: + nump = 0 + extents = [] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_PROCU, script_id, 0, nump*4, extents)) + + def script_status(self, script_id): + """ + Returns the run status of a stored script as well as the + current values of parameters 0 to 9. + + script_id:= id of stored script. + + The run status may be + + . . + PI_SCRIPT_INITING + PI_SCRIPT_HALTED + PI_SCRIPT_RUNNING + PI_SCRIPT_WAITING + PI_SCRIPT_FAILED + . . + + The return value is a tuple of run status and a list of + the 10 parameters. On error the run status will be negative + and the parameter list will be empty. + + ... + (s, pars) = pi.script_status(sid) + ... + """ + status = PI_CMD_INTERRUPTED + params = () + with self.sl.l: + bytes = u2i( + _pigpio_command_nolock(self.sl, _PI_CMD_PROCP, script_id, 0)) + if bytes > 0: + data = self._rxbuf(bytes) + pars = struct.unpack('11i', _str(data)) + status = pars[0] + params = pars[1:] + else: + status = bytes + return status, params + + def stop_script(self, script_id): + """ + Stops a running script. + + script_id:= id of stored script. + + ... + status = pi.stop_script(sid) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PROCS, script_id, 0)) + + def delete_script(self, script_id): + """ + Deletes a stored script. + + script_id:= id of stored script. + + ... + status = pi.delete_script(sid) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PROCD, script_id, 0)) + + def bb_serial_read_open(self, user_gpio, baud, bb_bits=8): + """ + Opens a GPIO for bit bang reading of serial data. + + user_gpio:= 0-31, the GPIO to use. + baud:= 50-250000, the baud rate. + bb_bits:= 1-32, the number of bits per word, default 8. + + The serial data is held in a cyclic buffer and is read using + [*bb_serial_read*]. + + It is the caller's responsibility to read data from the cyclic + buffer in a timely fashion. + + ... + status = pi.bb_serial_read_open(4, 19200) + status = pi.bb_serial_read_open(17, 9600) + ... + """ + # pigpio message format + + # I p1 user_gpio + # I p2 baud + # I p3 4 + ## extension ## + # I bb_bits + extents = [struct.pack("I", bb_bits)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_SLRO, user_gpio, baud, 4, extents)) + + def bb_serial_read(self, user_gpio): + """ + Returns data from the bit bang serial cyclic buffer. + + user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*]) + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + The bytes returned for each character depend upon the number of + data bits [*bb_bits*] specified in the [*bb_serial_read_open*] + command. + + For [*bb_bits*] 1-8 there will be one byte per character. + For [*bb_bits*] 9-16 there will be two bytes per character. + For [*bb_bits*] 17-32 there will be four bytes per character. + + ... + (count, data) = pi.bb_serial_read(4) + ... + """ + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i( + _pigpio_command_nolock(self.sl, _PI_CMD_SLR, user_gpio, 10000)) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + + def bb_serial_read_close(self, user_gpio): + """ + Closes a GPIO for bit bang reading of serial data. + + user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*]) + + ... + status = pi.bb_serial_read_close(17) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_SLRC, user_gpio, 0)) + + def bb_serial_invert(self, user_gpio, invert): + """ + Invert serial logic. + + user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*]) + invert:= 0-1 (1 invert, 0 normal) + + ... + status = pi.bb_serial_invert(17, 1) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_SLRI, user_gpio, invert)) + + + def custom_1(self, arg1=0, arg2=0, argx=[]): + """ + Calls a pigpio function customised by the user. + + arg1:= >=0, default 0. + arg2:= >=0, default 0. + argx:= extra arguments (each 0-255), default empty. + + The returned value is an integer which by convention + should be >=0 for OK and <0 for error. + + ... + value = pi.custom_1() + + value = pi.custom_1(23) + + value = pi.custom_1(0, 55) + + value = pi.custom_1(23, 56, [1, 5, 7]) + + value = pi.custom_1(23, 56, b"hello") + + value = pi.custom_1(23, 56, "hello") + ... + """ + # I p1 arg1 + # I p2 arg2 + # I p3 len + ## extension ## + # s len argx bytes + + return u2i(_pigpio_command_ext( + self.sl, _PI_CMD_CF1, arg1, arg2, len(argx), [argx])) + + def custom_2(self, arg1=0, argx=[], retMax=8192): + """ + Calls a pigpio function customised by the user. + + arg1:= >=0, default 0. + argx:= extra arguments (each 0-255), default empty. + retMax:= >=0, maximum number of bytes to return, default 8192. + + The returned value is a tuple of the number of bytes + returned and a bytearray containing the bytes. If + there was an error the number of bytes read will be + less than zero (and will contain the error code). + + ... + (count, data) = pi.custom_2() + + (count, data) = pi.custom_2(23) + + (count, data) = pi.custom_2(23, [1, 5, 7]) + + (count, data) = pi.custom_2(23, b"hello") + + (count, data) = pi.custom_2(23, "hello", 128) + ... + """ + # I p1 arg1 + # I p2 retMax + # I p3 len + ## extension ## + # s len argx bytes + + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_CF2, arg1, retMax, len(argx), [argx])) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def get_pad_strength(self, pad): + """ + This function returns the pad drive strength in mA. + + pad:= 0-2, the pad to get. + + Returns the pad drive strength if OK, otherwise PI_BAD_PAD. + + Pad @ GPIO + 0 @ 0-27 + 1 @ 28-45 + 2 @ 46-53 + + ... + strength = pi.get_pad_strength(0) # Get pad 0 strength. + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PADG, pad, 0)) + + def set_pad_strength(self, pad, pad_strength): + """ + This function sets the pad drive strength in mA. + + + pad:= 0-2, the pad to set. + pad_strength:= 1-16 mA. + + Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH. + + Pad @ GPIO + 0 @ 0-27 + 1 @ 28-45 + 2 @ 46-53 + + ... + pi.set_pad_strength(2, 14) # Set pad 2 to 14 mA. + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_PADS, pad, pad_strength)) + + + def file_open(self, file_name, file_mode): + """ + This function returns a handle to a file opened in a specified mode. + + file_name:= the file to open. + file_mode:= the file open mode. + + Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, + PI_NO_FILE_ACCESS, PI_BAD_FILE_MODE, + PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR. + + ... + h = pi.file_open("/home/pi/shared/dir_3/file.txt", + pigpio.FILE_WRITE | pigpio.FILE_CREATE) + + pi.file_write(h, "Hello world") + + pi.file_close(h) + ... + + 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: + + Constant @ Value @ Meaning + FILE_READ @ 1 @ open file for reading + FILE_WRITE @ 2 @ open file for writing + FILE_RW @ 3 @ open file for reading and writing + + The following values may be or'd into the mode: + + Name @ Value @ Meaning + FILE_APPEND @ 4 @ All writes append data to the end of the file + FILE_CREATE @ 8 @ The file is created if it doesn't exist + FILE_TRUNC @ 16 @ The file is truncated + + Newly created files are owned by root with permissions owner + read and write. + + ... + #!/usr/bin/env python + + import pigpio + + pi = pigpio.pi() + + if not pi.connected: + exit() + + # Assumes /opt/pigpio/access contains the following line: + # /ram/*.c r + + handle = pi.file_open("/ram/pigpio.c", pigpio.FILE_READ) + + done = False + + while not done: + c, d = pi.file_read(handle, 60000) + if c > 0: + print(d) + else: + done = True + + pi.file_close(handle) + + pi.stop() + ... + """ + # I p1 file_mode + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_FO, file_mode, 0, len(file_name), [file_name])) + + def file_close(self, handle): + """ + Closes the file associated with handle. + + handle:= >=0 (as returned by a prior call to [*file_open*]). + + ... + pi.file_close(handle) + ... + """ + return _u2i(_pigpio_command(self.sl, _PI_CMD_FC, handle, 0)) + + def file_read(self, handle, count): + """ + Reads up to count bytes from the file associated with handle. + + handle:= >=0 (as returned by a prior call to [*file_open*]). + count:= >0, the number of bytes to read. + + The returned value is a tuple of the number of bytes read and a + bytearray containing the bytes. If there was an error the + number of bytes read will be less than zero (and will contain + the error code). + + ... + (b, d) = pi.file_read(h2, 100) + if b > 0: + # process read data + ... + """ + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i( + _pigpio_command_nolock(self.sl, _PI_CMD_FR, handle, count)) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def file_write(self, handle, data): + """ + Writes the data bytes to the file associated with handle. + + handle:= >=0 (as returned by a prior call to [*file_open*]). + data:= the bytes to write. + + ... + pi.file_write(h1, b'\\x02\\x03\\x04') + + pi.file_write(h2, b'help') + + pi.file_write(h2, "hello") + + pi.file_write(h1, [2, 3, 4]) + ... + """ + # I p1 handle + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_FW, handle, 0, len(data), [data])) + + def file_seek(self, handle, seek_offset, seek_from): + """ + Seeks to a position relative to the start, current position, + or end of the file. Returns the new position. + + handle:= >=0 (as returned by a prior call to [*file_open*]). + seek_offset:= byte offset. + seek_from:= FROM_START, FROM_CURRENT, or FROM_END. + + ... + new_pos = pi.file_seek(h, 100, pigpio.FROM_START) + + cur_pos = pi.file_seek(h, 0, pigpio.FROM_CURRENT) + + file_size = pi.file_seek(h, 0, pigpio.FROM_END) + ... + """ + # I p1 handle + # I p2 seek_offset + # I p3 4 + ## extension ## + # I seek_from + extents = [struct.pack("I", seek_from)] + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_FS, handle, seek_offset, 4, extents)) + + def file_list(self, fpattern): + """ + Returns a list of files which match a pattern. + + fpattern:= file pattern to match. + + Returns the number of returned bytes if OK, otherwise + PI_NO_FILE_ACCESS, or PI_NO_FILE_MATCH. + + The pattern must match an entry in /opt/pigpio/access. The + pattern may contain wildcards. See [*file_open*]. + + NOTE + + The returned value is not the number of files, it is the number + of bytes in the buffer. The file names are separated by newline + characters. + + ... + #!/usr/bin/env python + + import pigpio + + pi = pigpio.pi() + + if not pi.connected: + exit() + + # Assumes /opt/pigpio/access contains the following line: + # /ram/*.c r + + c, d = pi.file_list("/ram/p*.c") + if c > 0: + print(d) + + pi.stop() + ... + """ + # I p1 60000 + # I p2 0 + # I p3 len + ## extension ## + # s len data bytes + + bytes = PI_CMD_INTERRUPTED + rdata = "" + with self.sl.l: + bytes = u2i(_pigpio_command_ext_nolock( + self.sl, _PI_CMD_FL, 60000, 0, len(fpattern), [fpattern])) + if bytes > 0: + rdata = self._rxbuf(bytes) + return bytes, rdata + + def shell(self, shellscr, pstring=""): + """ + This function uses the system call to execute a shell script + with the given string as its parameter. + + shellscr:= the name of the script, only alphanumerics, + '-' and '_' are allowed in the name + pstring := the parameter string to pass to the script + + The exit status of the system call is returned if OK, + otherwise PI_BAD_SHELL_STATUS. + + [*shellscr*] 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 + status = pi.shell("scr1", "hello world"); + + // pass three parameters, hello, string with spaces, and world + status = pi.shell("scr1", "hello 'string with spaces' world"); + + // pass one parameter, hello string with spaces world + status = pi.shell("scr1", "\\"hello string with spaces world\\""); + ... + """ + # I p1 len(shellscr) + # I p2 0 + # I p3 len(shellscr)+len(pstring)+1 + ## extension ## + # s len data bytes + + ls = len(shellscr) + lp = len(pstring) + return _u2i(_pigpio_command_ext( + self.sl, _PI_CMD_SHELL, ls, 0, ls+lp+1, [shellscr+'\x00'+pstring])) + + + def callback(self, user_gpio, edge=RISING_EDGE, func=None): + """ + Calls a user supplied function (a callback) whenever the + specified GPIO edge is detected. + + user_gpio:= 0-31. + edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE. + func:= user supplied callback function. + + The user supplied callback receives three parameters, the GPIO, + the level, and the tick. + + . . + Parameter Value Meaning + + GPIO 0-31 The GPIO which has changed state + + level 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (a watchdog timeout) + + tick 32 bit The number of microseconds since boot + WARNING: this wraps around from + 4294967295 to 0 roughly every 72 minutes + . . + + If a user callback is not specified a default tally callback is + provided which simply counts edges. The count may be retrieved + 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 cancel function. + + 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) + + cb1 = pi.callback(22, pigpio.EITHER_EDGE, cbf) + + cb2 = pi.callback(4, pigpio.EITHER_EDGE) + + cb3 = pi.callback(17) + + print(cb3.tally()) + + cb3.reset_tally() + + cb1.cancel() # To cancel callback cb1. + ... + """ + return _callback(self._notify, user_gpio, edge, func) + + def event_callback(self, event, func=None): + """ + Calls a user supplied function (a callback) whenever the + specified event is signalled. + + event:= 0-31. + func:= user supplied callback function. + + The user supplied callback receives two parameters, the event id, + and the tick. + + If a user callback is not specified a default tally callback is + provided which simply counts events. The count may be retrieved + by calling the tally function. The count may be reset to zero + by calling the reset_tally 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). + + ... + def cbf(event, tick): + print(event, tick) + + cb1 = pi.event_callback(22, cbf) + + cb2 = pi.event_callback(4) + + print(cb2.tally()) + + cb2.reset_tally() + + cb1.cancel() # To cancel callback cb1. + ... + """ + + return _event(self._notify, event, func) + + def wait_for_edge(self, user_gpio, edge=RISING_EDGE, wait_timeout=60.0): + """ + Wait for an edge event on a GPIO. + + user_gpio:= 0-31. + edge:= EITHER_EDGE, RISING_EDGE (default), or + FALLING_EDGE. + wait_timeout:= >=0.0 (default 60.0). + + The function returns when the edge is detected or after + the number of seconds specified by timeout has expired. + + Do not use this function for precise timing purposes, + the edge is only checked 20 times a second. Whenever + you need to know the accurate time of GPIO events use + a [*callback*] function. + + The function returns True if the edge is detected, + otherwise False. + + ... + if pi.wait_for_edge(23): + print("Rising edge detected") + else: + print("wait for edge timed out") + + if pi.wait_for_edge(23, pigpio.FALLING_EDGE, 5.0): + print("Falling edge detected") + else: + print("wait for falling edge timed out") + ... + """ + a = _wait_for_edge(self._notify, user_gpio, edge, wait_timeout) + return a.trigger + + def wait_for_event(self, event, wait_timeout=60.0): + """ + Wait for an event. + + event:= 0-31. + wait_timeout:= >=0.0 (default 60.0). + + The function returns when the event is signalled or after + the number of seconds specified by timeout has expired. + + The function returns True if the event is detected, + otherwise False. + + ... + if pi.wait_for_event(23): + print("event detected") + else: + print("wait for event timed out") + ... + """ + a = _wait_for_event(self._notify, event, wait_timeout) + return a.trigger + + def __init__(self, + host = os.getenv("PIGPIO_ADDR", 'localhost'), + port = os.getenv("PIGPIO_PORT", 8888), + show_errors = True): + """ + Grants access to a Pi's GPIO. + + host:= the host name of the Pi on which the pigpio daemon is + running. The default is localhost unless overridden by + the PIGPIO_ADDR environment variable. + + port:= the port number on which the pigpio daemon is listening. + The default is 8888 unless overridden by the PIGPIO_PORT + environment variable. The pigpio daemon must have been + started with the same port number. + + This connects to the pigpio daemon and reserves resources + to be used for sending commands and receiving notifications. + + An instance attribute [*connected*] may be used to check the + success of the connection. If the connection is established + successfully [*connected*] will be True, otherwise False. + + ... + pi = pigio.pi() # use defaults + pi = pigpio.pi('mypi') # specify host, default port + pi = pigpio.pi('mypi', 7777) # specify host and port + + pi = pigpio.pi() # exit script if no connection + if not pi.connected: + exit() + ... + """ + self.connected = True + + self.sl = _socklock() + self._notify = None + + port = int(port) + + if host == '': + host = "localhost" + + self._host = host + self._port = port + + try: + self.sl.s = socket.create_connection((host, port), None) + + # Disable the Nagle algorithm. + self.sl.s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + + self._notify = _callback_thread(self.sl, host, port) + + except socket.error: + exception = 1 + + except struct.error: + exception = 2 + + except error: + # assumed to be no handle available + exception = 3 + + else: + exception = 0 + atexit.register(self.stop) + + if exception != 0: + + self.connected = False + + if self.sl.s is not None: + self.sl.s = None + + if show_errors: + + s = "Can't connect to pigpio at {}({})".format(host, str(port)) + + + print(_except_a.format(s)) + if exception == 1: + print(_except_1) + elif exception == 2: + print(_except_2) + else: + print(_except_3) + print(_except_z) + + def __repr__(self): + return "".format(self._host, self._port) + + def stop(self): + """Release pigpio resources. + + ... + pi.stop() + ... + """ + + self.connected = False + + if self._notify is not None: + self._notify.stop() + self._notify = None + + if self.sl.s is not None: + self.sl.s.close() + self.sl.s = None + +def xref(): + """ + active: 0-1000000 + The number of microseconds level changes are reported for once + a noise filter has been triggered (by [*steady*] microseconds of + a stable level). + + + arg1: + An unsigned argument passed to a user customised function. Its + meaning is defined by the customiser. + + arg2: + An unsigned argument passed to a user customised function. Its + meaning is defined by the customiser. + + argx: + An array of bytes passed to a user customised function. + Its meaning and content is defined by the customiser. + + baud: + The speed of serial communication (I2C, SPI, serial link, waves) + in bits per second. + + bb_bits: 1-32 + The number of data bits to be used when adding serial data to a + waveform. + + bb_stop: 2-8 + The number of (half) stop bits to be used when adding serial data + to a waveform. + + bit: 0-1 + A value of 0 or 1. + + bits: 32 bit number + A mask used to select GPIO to be operated on. If bit n is set + then GPIO n is selected. A convenient way of setting bit n is to + bit or in the value (1<=1 + The length of a pulse in microseconds. + + dutycycle: 0-range_ + A number between 0 and range_. + + The dutycycle sets the proportion of time on versus time off during each + PWM cycle. + + Dutycycle @ On time + 0 @ Off + range_ * 0.25 @ 25% On + range_ * 0.50 @ 50% On + range_ * 0.75 @ 75% On + range_ @ Fully On + + edge: 0-2 + + . . + EITHER_EDGE = 2 + FALLING_EDGE = 1 + RISING_EDGE = 0 + . . + + errnum: <0 + + . . + PI_BAD_USER_GPIO = -2 + PI_BAD_GPIO = -3 + PI_BAD_MODE = -4 + PI_BAD_LEVEL = -5 + PI_BAD_PUD = -6 + PI_BAD_PULSEWIDTH = -7 + PI_BAD_DUTYCYCLE = -8 + PI_BAD_WDOG_TIMEOUT = -15 + PI_BAD_DUTYRANGE = -21 + PI_NO_HANDLE = -24 + PI_BAD_HANDLE = -25 + PI_BAD_WAVE_BAUD = -35 + PI_TOO_MANY_PULSES = -36 + PI_TOO_MANY_CHARS = -37 + PI_NOT_SERIAL_GPIO = -38 + PI_NOT_PERMITTED = -41 + PI_SOME_PERMITTED = -42 + PI_BAD_WVSC_COMMND = -43 + PI_BAD_WVSM_COMMND = -44 + PI_BAD_WVSP_COMMND = -45 + PI_BAD_PULSELEN = -46 + PI_BAD_SCRIPT = -47 + PI_BAD_SCRIPT_ID = -48 + PI_BAD_SER_OFFSET = -49 + PI_GPIO_IN_USE = -50 + PI_BAD_SERIAL_COUNT = -51 + PI_BAD_PARAM_NUM = -52 + PI_DUP_TAG = -53 + PI_TOO_MANY_TAGS = -54 + PI_BAD_SCRIPT_CMD = -55 + PI_BAD_VAR_NUM = -56 + PI_NO_SCRIPT_ROOM = -57 + PI_NO_MEMORY = -58 + PI_SOCK_READ_FAILED = -59 + PI_SOCK_WRIT_FAILED = -60 + PI_TOO_MANY_PARAM = -61 + PI_SCRIPT_NOT_READY = -62 + PI_BAD_TAG = -63 + PI_BAD_MICS_DELAY = -64 + PI_BAD_MILS_DELAY = -65 + PI_BAD_WAVE_ID = -66 + PI_TOO_MANY_CBS = -67 + PI_TOO_MANY_OOL = -68 + PI_EMPTY_WAVEFORM = -69 + PI_NO_WAVEFORM_ID = -70 + PI_I2C_OPEN_FAILED = -71 + PI_SER_OPEN_FAILED = -72 + PI_SPI_OPEN_FAILED = -73 + PI_BAD_I2C_BUS = -74 + PI_BAD_I2C_ADDR = -75 + PI_BAD_SPI_CHANNEL = -76 + PI_BAD_FLAGS = -77 + PI_BAD_SPI_SPEED = -78 + PI_BAD_SER_DEVICE = -79 + PI_BAD_SER_SPEED = -80 + PI_BAD_PARAM = -81 + PI_I2C_WRITE_FAILED = -82 + PI_I2C_READ_FAILED = -83 + PI_BAD_SPI_COUNT = -84 + PI_SER_WRITE_FAILED = -85 + PI_SER_READ_FAILED = -86 + PI_SER_READ_NO_DATA = -87 + PI_UNKNOWN_COMMAND = -88 + PI_SPI_XFER_FAILED = -89 + PI_NO_AUX_SPI = -91 + PI_NOT_PWM_GPIO = -92 + PI_NOT_SERVO_GPIO = -93 + PI_NOT_HCLK_GPIO = -94 + PI_NOT_HPWM_GPIO = -95 + PI_BAD_HPWM_FREQ = -96 + PI_BAD_HPWM_DUTY = -97 + PI_BAD_HCLK_FREQ = -98 + PI_BAD_HCLK_PASS = -99 + PI_HPWM_ILLEGAL = -100 + PI_BAD_DATABITS = -101 + PI_BAD_STOPBITS = -102 + PI_MSG_TOOBIG = -103 + PI_BAD_MALLOC_MODE = -104 + PI_BAD_SMBUS_CMD = -107 + PI_NOT_I2C_GPIO = -108 + PI_BAD_I2C_WLEN = -109 + PI_BAD_I2C_RLEN = -110 + PI_BAD_I2C_CMD = -111 + PI_BAD_I2C_BAUD = -112 + PI_CHAIN_LOOP_CNT = -113 + PI_BAD_CHAIN_LOOP = -114 + PI_CHAIN_COUNTER = -115 + PI_BAD_CHAIN_CMD = -116 + PI_BAD_CHAIN_DELAY = -117 + PI_CHAIN_NESTING = -118 + PI_CHAIN_TOO_BIG = -119 + PI_DEPRECATED = -120 + PI_BAD_SER_INVERT = -121 + PI_BAD_FOREVER = -124 + PI_BAD_FILTER = -125 + PI_BAD_PAD = -126 + PI_BAD_STRENGTH = -127 + PI_FIL_OPEN_FAILED = -128 + PI_BAD_FILE_MODE = -129 + PI_BAD_FILE_FLAG = -130 + PI_BAD_FILE_READ = -131 + PI_BAD_FILE_WRITE = -132 + PI_FILE_NOT_ROPEN = -133 + PI_FILE_NOT_WOPEN = -134 + PI_BAD_FILE_SEEK = -135 + PI_NO_FILE_MATCH = -136 + PI_NO_FILE_ACCESS = -137 + PI_FILE_IS_A_DIR = -138 + PI_BAD_SHELL_STATUS = -139 + PI_BAD_SCRIPT_NAME = -140 + 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 + . . + + event:0-31 + An event is a signal used to inform one or more consumers + to start an action. + + file_mode: + The mode may have the following values + + . . + FILE_READ 1 + FILE_WRITE 2 + FILE_RW 3 + . . + + The following values can be or'd into the file open mode + + . . + FILE_APPEND 4 + FILE_CREATE 8 + FILE_TRUNC 16 + . . + + file_name: + A full file path. To be accessible the path must match + an entry in /opt/pigpio/access. + + fpattern: + A file path which may contain wildcards. To be accessible the path + must match an entry in /opt/pigpio/access. + + frequency: 0-40000 + Defines the frequency to be used for PWM on a GPIO. + The closest permitted frequency will be used. + + func: + A user supplied callback function. + + gpio: 0-53 + A Broadcom numbered GPIO. All the user GPIO are in the range 0-31. + + 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 [*get_hardware_revision*]. + + 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 - - - - + . . + + gpio_off: + A mask used to select GPIO to be operated on. See [*bits*]. + + This mask selects the GPIO to be switched off at the start + of a pulse. + + gpio_on: + A mask used to select GPIO to be operated on. See [*bits*]. + + This mask selects the GPIO to be switched on at the start + of a pulse. + + handle: >=0 + A number referencing an object opened by one of the following + + [*file_open*] + [*i2c_open*] + [*notify_open*] + [*serial_open*] + [*spi_open*] + + host: + The name or IP address of the Pi running the pigpio daemon. + + i2c_address: 0-0x7F + The address of a device on the I2C bus. + + i2c_bus: >=0 + An I2C bus number. + + i2c_flags: 0 + No I2C flags are currently defined. + + invert: 0-1 + A flag used to set normal or inverted bit bang serial data + level logic. + + level: 0-1 (2) + + . . + CLEAR = 0 + HIGH = 1 + LOW = 0 + OFF = 0 + ON = 1 + SET = 1 + TIMEOUT = 2 # only returned for a watchdog timeout + . . + + MISO: + The GPIO used for the MISO signal when bit banging SPI. + + mode: + + 1.The operational mode of a GPIO, normally INPUT or OUTPUT. + + . . + ALT0 = 4 + ALT1 = 5 + ALT2 = 6 + ALT3 = 7 + ALT4 = 3 + ALT5 = 2 + INPUT = 0 + OUTPUT = 1 + . . + + 2. The mode of waveform transmission. + + . . + WAVE_MODE_ONE_SHOT = 0 + WAVE_MODE_REPEAT = 1 + WAVE_MODE_ONE_SHOT_SYNC = 2 + WAVE_MODE_REPEAT_SYNC = 3 + . . + + MOSI: + The GPIO used for the MOSI signal when bit banging SPI. + + offset: >=0 + The offset wave data starts from the beginning of the waveform + being currently defined. + + pad: 0-2 + A set of GPIO which share common drivers. + + Pad @ GPIO + 0 @ 0-27 + 1 @ 28-45 + 2 @ 46-53 + + pad_strength: 1-16 + The mA which may be drawn from each GPIO whilst still guaranteeing the + high and low levels. + + params: 32 bit number + 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. + + pstring: + The string to be passed to a [*shell*] script to be executed. + + pud: 0-2 + . . + PUD_DOWN = 1 + PUD_OFF = 0 + PUD_UP = 2 + . . + + pulse_len: 1-100 + The length of the trigger pulse in microseconds. + + pulses: + A list of class pulse objects defining the characteristics of a + waveform. + + pulsewidth: + The servo pulsewidth in microseconds. 0 switches pulses off. + + PWMduty: 0-1000000 (1M) + The hardware PWM dutycycle. + + PWMfreq: 1-125M (1-187.5M for the BCM2711) + The hardware PWM frequency. + + range_: 25-40000 + Defines the limits for the [*dutycycle*] parameter. + + range_ defaults to 255. + + reg: 0-255 + An I2C device register. The usable registers depend on the + actual device. + + retMax: >=0 + The maximum number of bytes a user customised function + should return, default 8192. + + SCL: + The user GPIO to use for the clock when bit banging I2C. + + SCLK:: + The GPIO used for the SCLK signal when bit banging SPI. + + script: + The text of a script to store on the pigpio daemon. + + script_id: >=0 + A number referencing a script created by [*store_script*]. + + SDA: + The user GPIO to use for data when bit banging I2C. + + seek_from: 0-2 + Direction to seek for [*file_seek*]. + + . . + FROM_START=0 + FROM_CURRENT=1 + FROM_END=2 + . . + + seek_offset: + The number of bytes to move forward (positive) or backwards + (negative) from the seek position (start, current, or end of file). + + ser_flags: 32 bit + No serial flags are currently defined. + + serial_*: + One of the serial_ functions. + + shellscr: + The name of a shell script. The script must exist + in /opt/pigpio/cgi and must be executable. + + show_errors: + Controls the display of pigpio daemon connection failures. + The default of True prints the probable failure reasons to + standard output. + + spi_channel: 0-2 + A SPI channel. + + spi_flags: 32 bit + See [*spi_open*]. + + steady: 0-300000 + + The number of microseconds level changes must be stable for + before reporting the level changed ([*set_glitch_filter*]) + or triggering the active part of a noise filter + ([*set_noise_filter*]). + + t1: + A tick (earlier). + + t2: + A tick (later). + + tty: + A Pi serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0 + + uint32: + An unsigned 32 bit number. + + user_gpio: 0-31 + A Broadcom numbered GPIO. + + All the user GPIO are in the range 0-31. + + Not all the GPIO within this range are usable, some are reserved + for system use. + + See [*gpio*]. + + wait_timeout: 0.0 - + The number of seconds to wait in [*wait_for_edge*] before timing out. + + wave_add_*: + One of the following + + [*wave_add_new*] + [*wave_add_generic*] + [*wave_add_serial*] + + wave_id: >=0 + A number referencing a wave created by [*wave_create*]. + + wave_send_*: + One of the following + + [*wave_send_once*] + [*wave_send_repeat*] + + wdog_timeout: 0-60000 + Defines a GPIO watchdog timeout in milliseconds. If no level + change is detected on the GPIO for timeout millisecond a watchdog + timeout report is issued (with level TIMEOUT). + + word_val: 0-65535 + A whole number. + """ + pass + diff --git a/pigpiod.1 b/pigpiod.1 new file mode 100644 index 0000000..29f8326 --- /dev/null +++ b/pigpiod.1 @@ -0,0 +1,273 @@ + +." 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. + +.SH SYNOPSIS + +sudo pigpiod [OPTION]... +.SH DESCRIPTION + + +.ad l + +.nh +pigpiod is a utility which launches the pigpio library as a daemon. +.br + +.br +Once launched the pigpio library runs in the background accepting commands from the pipe and socket interfaces. +.br + +.br +The pigpiod utility requires sudo privileges to launch the library but thereafter the pipe and socket commands may be issued by normal users. +.br + +.br +pigpiod accepts the following configuration options +.br + +.br +.SH OPTIONS + +.IP "\fB-a value\fP" +DMA memory allocation mode. +0=AUTO, 1=PMAP, 2=MBOX. +Default AUTO +. +.IP "\fB-b value\fP" +GPIO sample buffer size in milliseconds. +100-10000. +Default 120 +. +.IP "\fB-c value\fP" +Library internal settings. +. +Default 0 +. +.IP "\fB-d value\fP" +Primary DMA channel. +0-14. +Default 14 +. +.IP "\fB-e value\fP" +Secondary DMA channel. +0-14. +Default 6. Preferably use one of DMA channels 0 to 6 for the secondary channel +. +.IP "\fB-f\fP" +Disable fifo interface. +. +Default enabled +. +.IP "\fB-g\fP" +Run in foreground (do not fork). +. +Default disabled +. +.IP "\fB-k\fP" +Disable local and remote socket interface. +. +Default enabled +. +.IP "\fB-l\fP" +Disable remote socket interface. +. +Default enabled +. +.IP "\fB-m\fP" +Disable alerts (sampling). +. +Default enabled +. +.IP "\fB-n IP address\fP" +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 +. +.IP "\fB-p value\fP" +Socket port. +1024-32000. +Default 8888 +. +.IP "\fB-s value\fP" +Sample rate. +1, 2, 4, 5, 8, or 10 microseconds. +Default 5 +. +.IP "\fB-t value\fP" +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. +. +.IP "\fB-v -V\fP" +Display pigpio version and exit. +. + +. +.IP "\fB-x mask\fP" +GPIO which may be updated. +A 54 bit mask with (1< +*/ + +/* +This version is for pigpio version 69+ +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pigpio.h" + +/* +This program starts the pigpio library as a daemon. +*/ + +static unsigned bufferSizeMilliseconds = PI_DEFAULT_BUFFER_MILLIS; +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_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; + +static uint32_t cfgInternals = PI_DEFAULT_CFG_INTERNALS; + +static int updateMaskSet = 0; + +static FILE * errFifo; + +static uint32_t sockNetAddr[MAX_CONNECT_ADDRESSES]; + +static int numSockNetAddr = 0; + +void fatal(char *fmt, ...) +{ + char buf[128]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + fprintf(stderr, "%s\n", buf); + + fflush(stderr); + + exit(EXIT_FAILURE); +} + +void usage() +{ + fprintf(stderr, "\n" \ + "pigpio V%d\n" \ + "Usage: sudo pigpiod [OPTION] ...\n" \ + " -a value, DMA mode, 0=AUTO, 1=PMAP, 2=MBOX, default AUTO\n" \ + " -b value, sample buffer size in ms, default 120\n" \ + " -c value, library internal settings, default 0\n" \ + " -d value, primary DMA channel, 0-14, default 14\n" \ + " -e value, secondary DMA channel, 0-14, default 6\n" \ + " -f, disable fifo interface, default enabled\n" \ + " -g, run in foreground (do not fork), default disabled\n" \ + " -k, disable socket interface, default enabled\n" \ + " -l, localhost socket only default local+remote\n" \ + " -m, disable alerts default enabled\n" \ + " -n IP addr, allow address, name or dotted, default allow all\n" \ + " -p value, socket port, 1024-32000, default 8888\n" \ + " -s value, sample rate, 1, 2, 4, 5, 8, or 10, default 5\n" \ + " -t value, clock peripheral, 0=PWM 1=PCM, default PCM\n" \ + " -v, -V, display pigpio version and exit\n" \ + " -x mask, GPIO which may be updated, default board GPIO\n" \ + "EXAMPLE\n" \ + "sudo pigpiod -s 2 -b 200 -f\n" \ + " Set a sample rate of 2 microseconds with a 200 millisecond\n" \ + " buffer. Disable the fifo interface.\n" \ + "\n", PIGPIO_VERSION); +} + +static uint64_t getNum(char *str, int *err) +{ + uint64_t val; + char *endptr; + + *err = 0; + val = strtoll(str, &endptr, 0); + if (*endptr) {*err = 1; val = -1;} + return val; +} + +static uint32_t checkAddr(char *addrStr) +{ + int err; + struct addrinfo hints, *res; + struct sockaddr_in *sin; + const char *portStr; + uint32_t addr; + + portStr = getenv(PI_ENVPORT); + + if (!portStr) portStr = PI_DEFAULT_SOCKET_PORT_STR; + + memset (&hints, 0, sizeof (hints)); + + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags |= AI_CANONNAME; + + err = getaddrinfo(addrStr, portStr, &hints, &res); + + if (err) return 0; + + sin = (struct sockaddr_in *)res->ai_addr; + addr = sin->sin_addr.s_addr; + + freeaddrinfo(res); + + return addr; +} + +static void initOpts(int argc, char *argv[]) +{ + int opt, err, i; + uint32_t addr; + int64_t mask; + + while ((opt = getopt(argc, argv, "a:b:c:d:e:fgkln:mp:s:t:x:vV")) != -1) + { + switch (opt) + { + case 'a': + i = getNum(optarg, &err); + if ((i >= PI_MEM_ALLOC_AUTO) && (i <= PI_MEM_ALLOC_MAILBOX)) + memAllocMode = i; + else fatal("invalid -a option (%d)", i); + break; + + case 'b': + i = getNum(optarg, &err); + if ((i >= PI_BUF_MILLIS_MIN) && (i <= PI_BUF_MILLIS_MAX)) + bufferSizeMilliseconds = i; + else fatal("invalid -b option (%d)", i); + break; + + case 'c': + i = getNum(optarg, &err); + if ((i >= 0) && (i < PI_CFG_ILLEGAL_VAL)) + cfgInternals = i; + else fatal("invalid -c option (%x)", i); + break; + + case 'd': + i = getNum(optarg, &err); + if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_DMA_CHANNEL)) + DMAprimaryChannel = i; + else fatal("invalid -d option (%d)", i); + break; + + case 'e': + i = getNum(optarg, &err); + if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_DMA_CHANNEL)) + DMAsecondaryChannel = i; + else fatal("invalid -e option (%d)", i); + break; + + case 'f': + ifFlags |= PI_DISABLE_FIFO_IF; + break; + + case 'g': + foreground = 1; + break; + + case 'k': + ifFlags |= PI_DISABLE_SOCK_IF; + break; + + case 'l': + ifFlags |= PI_LOCALHOST_SOCK_IF; + break; + + case 'm': + ifFlags |= PI_DISABLE_ALERT; + break; + + case 'n': + addr = checkAddr(optarg); + if (addr && (numSockNetAddr= PI_MIN_SOCKET_PORT) && (i <= PI_MAX_SOCKET_PORT)) + socketPort = i; + else fatal("invalid -p option (%d)", i); + break; + + case 's': + i = getNum(optarg, &err); + + switch(i) + { + case 1: + case 2: + case 4: + case 5: + case 8: + case 10: + clockMicros = i; + break; + + default: + fatal("invalid -s option (%d)", i); + break; + } + break; + + case 't': + i = getNum(optarg, &err); + if ((i >= PI_CLOCK_PWM) && (i <= PI_CLOCK_PCM)) + clockPeripheral = i; + else fatal("invalid -t option (%d)", i); + break; + + case 'v': + case 'V': + printf("%d\n", PIGPIO_VERSION); + exit(EXIT_SUCCESS); + break; + + case 'x': + mask = getNum(optarg, &err); + if (!err) + { + updateMask = mask; + updateMaskSet = 1; + } + else fatal("invalid -x option (%s)", optarg); + break; + + default: /* '?' */ + usage(); + exit(EXIT_FAILURE); + } + } +} + +void terminate(int signum) +{ + /* only registered for SIGHUP/SIGTERM */ + + gpioTerminate(); + + fprintf(errFifo, "SIGHUP/SIGTERM received\n"); + + fflush(NULL); + + fclose(errFifo); + + unlink(PI_ERRFIFO); + + exit(0); +} + + +int main(int argc, char **argv) +{ + pid_t pid; + int flags; + + /* check command line parameters */ + + initOpts(argc, argv); + + if (!foreground) { + /* Fork off the parent process */ + + pid = fork(); + + if (pid < 0) { exit(EXIT_FAILURE); } + + /* If we got a good PID, then we can exit the parent process. */ + + if (pid > 0) { exit(EXIT_SUCCESS); } + + /* Change the file mode mask */ + + umask(0); + + /* Open any logs here */ + + /* NONE */ + + /* Create a new SID for the child process */ + + if (setsid() < 0) fatal("setsid failed (%m)"); + + /* Change the current working directory */ + + if ((chdir("/")) < 0) fatal("chdir failed (%m)"); + + /* Close out the standard file descriptors */ + + fclose(stdin); + fclose(stdout); + } + + /* configure library */ + + gpioCfgBufferSize(bufferSizeMilliseconds); + + gpioCfgClock(clockMicros, clockPeripheral, 0); + + gpioCfgInterfaces(ifFlags); + + gpioCfgDMAchannels(DMAprimaryChannel, DMAsecondaryChannel); + + gpioCfgSocketPort(socketPort); + + gpioCfgMemAlloc(memAllocMode); + + if (updateMaskSet) gpioCfgPermissions(updateMask); + + gpioCfgNetAddr(numSockNetAddr, sockNetAddr); + + gpioCfgSetInternals(cfgInternals); + + /* start library */ + + if (gpioInitialise()< 0) fatal("Can't initialise pigpio library"); + + /* create pipe for error reporting */ + + unlink(PI_ERRFIFO); + + mkfifo(PI_ERRFIFO, 0664); + + if (chmod(PI_ERRFIFO, 0664) < 0) + fatal("chmod %s failed (%m)", PI_ERRFIFO); + + errFifo = freopen(PI_ERRFIFO, "w+", stderr); + + if (errFifo) + { + /* set stderr non-blocking */ + + flags = fcntl(fileno(errFifo), F_GETFL, 0); + fcntl(fileno(errFifo), F_SETFL, flags | O_NONBLOCK); + + /* request SIGHUP/SIGTERM from libarary for termination */ + + gpioSetSignalFunc(SIGHUP, terminate); + gpioSetSignalFunc(SIGTERM, terminate); + + /* sleep forever */ + + while (1) + { + /* cat /dev/pigerr to view daemon errors */ + + sleep(5); + + fflush(errFifo); + } + } + else + { + fprintf(stderr, "freopen failed (%m)"); + + gpioTerminate(); + } + + return 0; +} + + diff --git a/pigpiod_if.3 b/pigpiod_if.3 new file mode 100644 index 0000000..a0ec196 --- /dev/null +++ b/pigpiod_if.3 @@ -0,0 +1,5339 @@ + +." 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. + +.SH SYNOPSIS + +#include + + +gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt + + ./prog +.SH DESCRIPTION + + +.ad l + +.nh + +.br + +.br +THIS LIBRARY IS DEPRECATED. NEW CODE SHOULD BE WRITTEN TO +USE THE MORE VERSATILE pigpiod_if2 LIBRARY. + +.br + +.br +pigpiod_if is a C library for the Raspberry which allows control +of the GPIO via the socket interface to the pigpio daemon. +.br + +.br + +.br +.SS Features +.br + +.br +o hardware timed PWM on any of GPIO 0-31 + +.br + +.br +o hardware timed servo pulses on any of GPIO 0-31 + +.br + +.br +o callbacks when any of GPIO 0-31 change state + +.br + +.br +o callbacks at timed intervals + +.br + +.br +o reading/writing all of the GPIO in a bank as one operation + +.br + +.br +o individually setting GPIO modes, reading and writing + +.br + +.br +o notifications when any of GPIO 0-31 change state + +.br + +.br +o the construction of output waveforms with microsecond timing + +.br + +.br +o rudimentary permission control over GPIO + +.br + +.br +o a simple interface to start and stop new threads + +.br + +.br +o I2C, SPI, and serial link wrappers + +.br + +.br +o creating and running scripts on the pigpio daemon + +.br + +.br +.SS GPIO +.br + +.br +ALL GPIO are identified by their Broadcom number. + +.br + +.br +.SS Notes +.br + +.br +The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals. + +.br + +.br +.SS Usage +.br + +.br +Include in your source files. + +.br + +.br +Assuming your source is in prog.c use the following command to build + +.br + +.br + +.EX +gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt +.br + +.EE + +.br + +.br +to run make sure the pigpio daemon is running + +.br + +.br + +.EX +sudo pigpiod +.br + +.br + ./prog # sudo is not required to run programs linked to pigpiod_if +.br + +.EE + +.br + +.br +For examples see x_pigpiod_if.c within the pigpio archive file. + +.br + +.br +.SS Notes +.br + +.br +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" +.IP "" 4 +Return the current time in seconds since the Epoch. + +.IP "\fBvoid time_sleep(double seconds)\fP" +.IP "" 4 +Delay execution for a given number of seconds. + +.br + +.br + +.EX +seconds: the number of seconds to delay. +.br + +.EE + +.IP "\fBchar *pigpio_error(int errnum)\fP" +.IP "" 4 +Return a text description for an error code. + +.br + +.br + +.EX +errnum: the error code. +.br + +.EE + +.IP "\fBunsigned pigpiod_if_version(void)\fP" +.IP "" 4 +Return the pigpiod_if version. + +.IP "\fBpthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata)\fP" +.IP "" 4 +Starts a new thread of execution with thread_func as the main routine. + +.br + +.br + +.EX +thread_func: the main function for the new thread. +.br + userdata: a pointer to an arbitrary argument. +.br + +.EE + +.br + +.br +Returns a pointer to pthread_t if OK, otherwise NULL. + +.br + +.br +The function is passed the single argument userdata. + +.br + +.br +The thread can be cancelled by passing the pointer to pthread_t to +\fBstop_thread\fP. + +.IP "\fBvoid stop_thread(pthread_t *pth)\fP" +.IP "" 4 +Cancels the thread pointed at by pth. + +.br + +.br + +.EX +pth: the thread to be stopped. +.br + +.EE + +.br + +.br +No value is returned. + +.br + +.br +The thread to be stopped should have been started with \fBstart_thread\fP. + +.IP "\fBint pigpio_start(char *addrStr, char *portStr)\fP" +.IP "" 4 +Connect to the pigpio daemon. Reserving command and +notification streams. + +.br + +.br + +.EX +addrStr: specifies the host or IP address of the Pi running the +.br + pigpio daemon. It may be NULL in which case localhost +.br + is used unless overridden by the PIGPIO_ADDR environment +.br + variable. +.br + +.br +portStr: specifies the port address used by the Pi running the +.br + pigpio daemon. It may be NULL in which case "8888" +.br + is used unless overridden by the PIGPIO_PORT environment +.br + variable. +.br + +.EE + +.IP "\fBvoid pigpio_stop(void)\fP" +.IP "" 4 +Terminates the connection to the pigpio daemon and releases +resources used by the library. + +.IP "\fBint set_mode(unsigned gpio, unsigned mode)\fP" +.IP "" 4 +Set the GPIO mode. + +.br + +.br + +.EX +gpio: 0-53. +.br +mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1, +.br + PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE, +or PI_NOT_PERMITTED. + +.IP "\fBint get_mode(unsigned gpio)\fP" +.IP "" 4 +Get the GPIO mode. + +.br + +.br + +.EX +gpio: 0-53. +.br + +.EE + +.br + +.br +Returns the GPIO mode if OK, otherwise PI_BAD_GPIO. + +.IP "\fBint set_pull_up_down(unsigned gpio, unsigned pud)\fP" +.IP "" 4 +Set or clear the GPIO pull-up/down resistor. + +.br + +.br + +.EX +gpio: 0-53. +.br + pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_PUD, +or PI_NOT_PERMITTED. + +.IP "\fBint gpio_read(unsigned gpio)\fP" +.IP "" 4 +Read the GPIO level. + +.br + +.br + +.EX +gpio:0-53. +.br + +.EE + +.br + +.br +Returns the GPIO level if OK, otherwise PI_BAD_GPIO. + +.IP "\fBint gpio_write(unsigned gpio, unsigned level)\fP" +.IP "" 4 +Write the GPIO level. + +.br + +.br + +.EX + gpio: 0-53. +.br +level: 0, 1. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_LEVEL, +or PI_NOT_PERMITTED. + +.br + +.br +Notes + +.br + +.br +If PWM or servo pulses are active on the GPIO they are switched off. + +.IP "\fBint set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle)\fP" +.IP "" 4 +Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31. +.br +dutycycle: 0-range (range defaults to 255). +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYCYCLE, +or PI_NOT_PERMITTED. +Notes + +.br + +.br +The \fBset_PWM_range\fP function may be used to change the +default range of 255. + +.IP "\fBint get_PWM_dutycycle(unsigned user_gpio)\fP" +.IP "" 4 +Return the PWM dutycycle in use on a GPIO. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. + +.br + +.br +For normal PWM the dutycycle will be out of the defined range +for the GPIO (see \fBget_PWM_range\fP). + +.br + +.br +If a hardware clock is active on the GPIO the reported dutycycle +will be 500000 (500k) out of 1000000 (1M). + +.br + +.br +If hardware PWM is active on the GPIO the reported dutycycle +will be out of a 1000000 (1M). + +.IP "\fBint set_PWM_range(unsigned user_gpio, unsigned range)\fP" +.IP "" 4 +Set the range of PWM values to be used on the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + range: 25-40000. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE, +or PI_NOT_PERMITTED. + +.br + +.br +Notes + +.br + +.br +If PWM is currently active on the GPIO its dutycycle will be +scaled to reflect the new range. + +.br + +.br +The real range, the number of steps between fully off and fully on +for each of the 18 available GPIO frequencies is + +.br + +.br + +.EX + 25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6), +.br + 400(#7), 500(#8), 625(#9), 800(#10), 1000(#11), 1250(#12), +.br +2000(#13), 2500(#14), 4000(#15), 5000(#16), 10000(#17), 20000(#18) +.br + +.EE + +.br + +.br +The real value set by set_PWM_range is (dutycycle * real range) / range. + +.IP "\fBint get_PWM_range(unsigned user_gpio)\fP" +.IP "" 4 +Get the range of PWM values being used on the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + +.EE + +.br + +.br +Returns the dutycycle range used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +.br + +.br +If a hardware clock or hardware PWM is active on the GPIO the +reported range will be 1000000 (1M). + +.IP "\fBint get_PWM_real_range(unsigned user_gpio)\fP" +.IP "" 4 +Get the real underlying range of PWM values being used on the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + +.EE + +.br + +.br +Returns the real range used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +.br + +.br +If a hardware clock is active on the GPIO the reported +real range will be 1000000 (1M). + +.br + +.br +If hardware PWM is active on the GPIO the reported real range +will be approximately 250M divided by the set PWM frequency. + +.br + +.br + +.IP "\fBint set_PWM_frequency(unsigned user_gpio, unsigned frequency)\fP" +.IP "" 4 +Set the frequency (in Hz) of the PWM to be used on the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31. +.br +frequency: >=0 (Hz). +.br + +.EE + +.br + +.br +Returns the numerically closest frequency if OK, otherwise +PI_BAD_USER_GPIO or PI_NOT_PERMITTED. + +.br + +.br +If PWM is currently active on the GPIO it will be switched +off and then back on at the new frequency. + +.br + +.br +Each GPIO can be independently set to one of 18 different +PWM frequencies. + +.br + +.br +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. + +.br + +.br +The frequencies for each sample rate are: + +.br + +.br + +.EX + Hertz +.br + +.br + 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600 +.br + 1250 1000 800 500 400 250 200 100 50 +.br + +.br + 2: 20000 10000 5000 4000 2500 2000 1250 1000 800 +.br + 625 500 400 250 200 125 100 50 25 +.br + +.br + 4: 10000 5000 2500 2000 1250 1000 625 500 400 +.br + 313 250 200 125 100 63 50 25 13 +.br +sample +.br + rate +.br + (us) 5: 8000 4000 2000 1600 1000 800 500 400 320 +.br + 250 200 160 100 80 50 40 20 10 +.br + +.br + 8: 5000 2500 1250 1000 625 500 313 250 200 +.br + 156 125 100 63 50 31 25 13 6 +.br + +.br + 10: 4000 2000 1000 800 500 400 250 200 160 +.br + 125 100 80 50 40 25 20 10 5 +.br + +.EE + +.IP "\fBint get_PWM_frequency(unsigned user_gpio)\fP" +.IP "" 4 +Get the frequency of PWM being used on the GPIO. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + +.EE + +.br + +.br +For normal PWM the frequency will be that defined for the GPIO by +\fBset_PWM_frequency\fP. + +.br + +.br +If a hardware clock is active on the GPIO the reported frequency +will be that set by \fBhardware_clock\fP. + +.br + +.br +If hardware PWM is active on the GPIO the reported frequency +will be that set by \fBhardware_PWM\fP. + +.br + +.br +Returns the frequency (in hertz) used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +.IP "\fBint set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth)\fP" +.IP "" 4 +Start (500-2500) or stop (0) servo pulses on the GPIO. + +.br + +.br + +.EX + user_gpio: 0-31. +.br +pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise). +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_PULSEWIDTH or +PI_NOT_PERMITTED. + +.br + +.br +The selected pulsewidth will continue to be transmitted until +changed by a subsequent call to set_servo_pulsewidth. + +.br + +.br +The pulsewidths supported by servos varies and should probably be +determined by experiment. A value of 1500 should always be safe and +represents the mid-point of rotation. + +.br + +.br +You can DAMAGE a servo if you command it to move beyond its limits. + +.br + +.br +OTHER UPDATE RATES: + +.br + +.br +This function updates servos at 50Hz. If you wish to use a different +update frequency you will have to use the PWM functions. + +.br + +.br + +.EX +Update Rate (Hz) 50 100 200 400 500 +.br +1E6/Hz 20000 10000 5000 2500 2000 +.br + +.EE + +.br + +.br +Firstly set the desired PWM frequency using \fBset_PWM_frequency\fP. + +.br + +.br +Then set the PWM range using \fBset_PWM_range\fP to 1E6/Hz. +Doing this allows you to use units of microseconds when setting +the servo pulsewidth. + +.br + +.br +E.g. If you want to update a servo connected to GPIO 25 at 400Hz + +.br + +.br + +.EX +set_PWM_frequency(25, 400); +.br +set_PWM_range(25, 2500); +.br + +.EE + +.br + +.br +Thereafter use the \fBset_PWM_dutycycle\fP function to move the servo, +e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse. +.br + +.IP "\fBint get_servo_pulsewidth(unsigned user_gpio)\fP" +.IP "" 4 +Return the servo pulsewidth in use on a GPIO. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO. + +.IP "\fBint notify_open(void)\fP" +.IP "" 4 +Get a free notification handle. + +.br + +.br +Returns a handle greater than or equal to zero if OK, +otherwise PI_NO_HANDLE. + +.br + +.br +A notification is a method for being notified of GPIO state +changes via a pipe. + +.br + +.br +Pipes are only accessible from the local machine so this function +serves no purpose if you are using the library from a remote machine. +The in-built (socket) notifications provided by \fBcallback\fP +should be used instead. + +.br + +.br +Notifications for handle x will be available at the pipe +named /dev/pigpiox (where x is the handle number). +E.g. if the function returns 15 then the notifications must be +read from /dev/pigpio15. + +.IP "\fBint notify_begin(unsigned handle, uint32_t bits)\fP" +.IP "" 4 +Start notifications on a previously opened handle. + +.br + +.br + +.EX +handle: 0-31 (as returned by \fBnotify_open\fP) +.br + bits: a mask indicating the GPIO to be notified. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +The notification sends state changes for each GPIO whose +corresponding bit in bits is set. + +.br + +.br +Each notification occupies 12 bytes in the fifo as follows: + +.br + +.br + +.EX +typedef struct +.br +{ +.br + uint16_t seqno; +.br + uint16_t flags; +.br + uint32_t tick; +.br + uint32_t level; +.br +} gpioReport_t; +.br + +.EE + +.br + +.br +seqno: starts at 0 each time the handle is opened and then increments +by one for each report. + +.br + +.br +flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE. + +.br + +.br +PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags +indicate a GPIO which has had a watchdog timeout. + +.br + +.br +PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive +signal on the pipe/socket and is sent once a minute in the absence +of other notification activity. + +.br + +.br +tick: the number of microseconds since system boot. It wraps around +after 1h12m. + +.br + +.br +level: indicates the level of each GPIO. If bit 1<=0 +.br + numBytes: >=1 +.br + str: an array of chars. +.br + +.EE + +.br + +.br +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS, +PI_BAD_STOP_BITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET, +or PI_TOO_MANY_PULSES. + +.br + +.br +NOTES: + +.br + +.br +The serial data is formatted as one start bit, \fBdata_bits\fP data bits, +and \fBstop_bits\fP/2 stop bits. + +.br + +.br +It is legal to add serial data streams with different baud rates to +the same waveform. + +.br + +.br +\fBnumBytes\fP is the number of bytes of data in str. + +.br + +.br +The bytes required for each character depend upon \fBdata_bits\fP. + +.br + +.br +For \fBdata_bits\fP 1-8 there will be one byte per character. +.br +For \fBdata_bits\fP 9-16 there will be two bytes per character. +.br +For \fBdata_bits\fP 17-32 there will be four bytes per character. + +.IP "\fBint wave_create(void)\fP" +.IP "" 4 +This function creates a waveform from the data provided by the prior +calls to the \fBwave_add_*\fP functions. 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 +The data provided by the \fBwave_add_*\fP functions is 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 +Normal usage would be + +.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\fP to create the waveform and get a unique id + +.br + +.br +Repeat steps 2 and 3 as needed. + +.br + +.br +Step 4. \fBwave_send_*\fP with the id of the waveform to transmit. + +.br + +.br +A waveform comprises one or more pulses. Each pulse consists of a +\fBgpioPulse_t\fP structure. + +.br + +.br + +.EX +typedef struct +.br +{ +.br + uint32_t gpioOn; +.br + uint32_t gpioOff; +.br + uint32_t usDelay; +.br +} gpioPulse_t; +.br + +.EE + +.br + +.br +The fields specify + +.br + +.br +1) the GPIO to be switched on at the start of the pulse. +.br +2) the GPIO to be switched off at the start of the pulse. +.br +3) the delay in microseconds before the next pulse. +.br + +.br + +.br +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). + +.br + +.br +When a waveform is started each pulse is executed in order with the +specified delay between the pulse and the next. + +.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(unsigned wave_id)\fP" +.IP "" 4 +This function deletes the waveform with id wave_id. + +.br + +.br + +.EX +wave_id: >=0, as returned by \fBwave_create\fP. +.br + +.EE + +.br + +.br +Wave ids are allocated in order, 0, 1, 2, etc. + +.br + +.br +The wave is flagged for deletion. The resources used by the wave +will only be reused when either of the following apply. + +.br + +.br +- all waves with higher numbered wave ids have been deleted or have +been flagged for deletion. + +.br + +.br +- a new wave is created which uses exactly the same resources as +the current wave (see the C source for gpioWaveCreate for details). + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_WAVE_ID. + +.IP "\fBint wave_send_once(unsigned wave_id)\fP" +.IP "" 4 +This function transmits the waveform with id wave_id. The waveform +is sent once. + +.br + +.br +NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled. + +.br + +.br + +.EX +wave_id: >=0, as returned by \fBwave_create\fP. +.br + +.EE + +.br + +.br +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. + +.IP "\fBint wave_send_repeat(unsigned wave_id)\fP" +.IP "" 4 +This function transmits the waveform with id wave_id. The waveform +cycles until cancelled (either by the sending of a new waveform or +by \fBwave_tx_stop\fP). + +.br + +.br +NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled. + +.br + +.br + +.EX +wave_id: >=0, as returned by \fBwave_create\fP. +.br + +.EE + +.br + +.br +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. + +.IP "\fBint wave_chain(char *buf, unsigned bufSize)\fP" +.IP "" 4 +This function transmits a chain of waveforms. + +.br + +.br +NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled. + +.br + +.br +The waves to be transmitted are specified by the contents of buf +which contains an ordered list of \fBwave_id\fPs and optional command +codes and related data. + +.br + +.br + +.EX + buf: pointer to the wave_ids and optional command codes +.br +bufSize: the number of bytes in buf +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER, +PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID. + +.br + +.br +Each wave is transmitted in the order specified. A wave may +occur multiple times per chain. + +.br + +.br +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. + +.br + +.br +Delays between waves may be added with the delay command. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +Loop Start 255 0 Identify start of a wave block +.br +Loop Repeat 255 1 x y loop x + y*256 times +.br +Delay 255 2 x y delay x + y*256 microseconds +.br +Loop Forever 255 3 loop forever +.br + +.br + +.br +If present Loop Forever must be the last entry in the chain. + +.br + +.br +The code is currently dimensioned to support a chain with roughly +600 entries and 20 loop counters. + +.br + +.br +\fBExample\fP +.br + +.EX +#include +.br +#include +.br + +.br +#define WAVES 5 +.br +#define GPIO 4 +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int i, wid[WAVES]; +.br + +.br + if (pigpio_start(0, 0)<0) return -1; +.br + +.br + set_mode(GPIO, PI_OUTPUT); +.br + +.br + for (i=0; i=0, as returned by \fBstore_script\fP. +.br + numPar: 0-10, the number of parameters. +.br + param: an array of parameters. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM + +.br + +.br +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. + +.IP "\fBint script_status(unsigned script_id, uint32_t *param)\fP" +.IP "" 4 +This function returns the run status of a stored script as well +as the current values of parameters 0 to 9. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBstore_script\fP. +.br + param: an array to hold the returned 10 parameters. +.br + +.EE + +.br + +.br +The function returns greater than or equal to 0 if OK, +otherwise PI_BAD_SCRIPT_ID. + +.br + +.br +The run status may be + +.br + +.br + +.EX +PI_SCRIPT_INITING +.br +PI_SCRIPT_HALTED +.br +PI_SCRIPT_RUNNING +.br +PI_SCRIPT_WAITING +.br +PI_SCRIPT_FAILED +.br + +.EE + +.br + +.br +The current value of script parameters 0 to 9 are returned in param. + +.IP "\fBint stop_script(unsigned script_id)\fP" +.IP "" 4 +This function stops a running script. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBstore_script\fP. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. + +.IP "\fBint delete_script(unsigned script_id)\fP" +.IP "" 4 +This function deletes a stored script. + +.br + +.br + +.EX +script_id: >=0, as returned by \fBstore_script\fP. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. + +.IP "\fBint bb_serial_read_open(unsigned user_gpio, unsigned baud, unsigned data_bits)\fP" +.IP "" 4 +This function opens a GPIO for bit bang reading of serial data. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + baud: 50-250000 +.br +data_bits: 1-32 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, +or PI_GPIO_IN_USE. + +.br + +.br +The serial data is returned in a cyclic buffer and is read using +bb_serial_read. + +.br + +.br +It is the caller's responsibility to read data from the cyclic buffer +in a timely fashion. + +.IP "\fBint bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize)\fP" +.IP "" 4 +This function copies up to bufSize bytes of data read from the +bit bang serial cyclic buffer to the buffer starting at buf. + +.br + +.br + +.EX +user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP. +.br + buf: an array to receive the read bytes. +.br + bufSize: >=0 +.br + +.EE + +.br + +.br +Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO +or PI_NOT_SERIAL_GPIO. + +.br + +.br +The bytes returned for each character depend upon the number of +data bits \fBdata_bits\fP specified in the \fBbb_serial_read_open\fP command. + +.br + +.br +For \fBdata_bits\fP 1-8 there will be one byte per character. +.br +For \fBdata_bits\fP 9-16 there will be two bytes per character. +.br +For \fBdata_bits\fP 17-32 there will be four bytes per character. + +.IP "\fBint bb_serial_read_close(unsigned user_gpio)\fP" +.IP "" 4 +This function closes a GPIO for bit bang reading of serial data. + +.br + +.br + +.EX +user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO. + +.IP "\fBint bb_serial_invert(unsigned user_gpio, unsigned invert)\fP" +.IP "" 4 +This function inverts serial logic for big bang serial reads. + +.br + +.br + +.EX +user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP. +.br + invert: 0-1, 1 invert, 0 normal. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT. + +.IP "\fBint i2c_open(unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags)\fP" +.IP "" 4 +This returns a handle for the device at address i2c_addr on bus i2c_bus. + +.br + +.br + +.EX + i2c_bus: >=0. +.br + i2c_addr: 0-0x7F. +.br +i2c_flags: 0. +.br + +.EE + +.br + +.br +No flags are currently defined. This parameter should be set to zero. + +.br + +.br +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. + +.br + +.br +The GPIO used are given in the following table. + +.br + +.br + SDA SCL +.br +I2C 0 0 1 +.br +I2C 1 2 3 +.br + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR, +PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED. + +.br + +.br +For the SMBus commands the low level transactions are shown at the end +of the function description. The following abbreviations are used. + +.br + +.br + +.EX +S (1 bit) : Start bit +.br +P (1 bit) : Stop bit +.br +Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. +.br +A, NA (1 bit) : Accept and not accept bit. +.br +.br +.br +Addr (7 bits): I2C 7 bit address. +.br +Comm (8 bits): Command byte, a data byte which often selects a register. +.br +Data (8 bits): A data byte. +.br +Count (8 bits): A data byte containing the length of a block operation. +.br + +.br +[..]: Data sent by the device. +.br + +.EE + +.IP "\fBint i2c_close(unsigned handle)\fP" +.IP "" 4 +This closes the I2C device associated with the handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint i2c_write_quick(unsigned handle, unsigned bit)\fP" +.IP "" 4 +This sends a single bit (in the Rd/Wr bit) to the device associated +with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + bit: 0-1, the value to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Quick command. SMBus 2.0 5.5.1 + +.EX +S Addr Rd/Wr [A] P +.br + +.EE + +.IP "\fBint i2c_write_byte(unsigned handle, unsigned bVal)\fP" +.IP "" 4 +This sends a single byte to the device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + bVal: 0-0xFF, the value to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Send byte. SMBus 2.0 5.5.2 + +.EX +S Addr Wr [A] Data [A] P +.br + +.EE + +.IP "\fBint i2c_read_byte(unsigned handle)\fP" +.IP "" 4 +This reads a single byte from the device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + +.EE + +.br + +.br +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +or PI_I2C_READ_FAILED. + +.br + +.br +Receive byte. SMBus 2.0 5.5.3 + +.EX +S Addr Rd [A] [Data] NA P +.br + +.EE + +.IP "\fBint i2c_write_byte_data(unsigned handle, unsigned i2c_reg, unsigned bVal)\fP" +.IP "" 4 +This writes a single byte to the specified register of the device +associated with handle. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write. +.br + bVal: 0-0xFF, the value to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Write byte. SMBus 2.0 5.5.4 + +.EX +S Addr Wr [A] Comm [A] Data [A] P +.br + +.EE + +.IP "\fBint i2c_write_word_data(unsigned handle, unsigned i2c_reg, unsigned wVal)\fP" +.IP "" 4 +This writes a single 16 bit word to the specified register of the device +associated with handle. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write. +.br + wVal: 0-0xFFFF, the value to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Write word. SMBus 2.0 5.5.4 + +.EX +S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P +.br + +.EE + +.IP "\fBint i2c_read_byte_data(unsigned handle, unsigned i2c_reg)\fP" +.IP "" 4 +This reads a single byte from the specified register of the device +associated with handle. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to read. +.br + +.EE + +.br + +.br +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Read byte. SMBus 2.0 5.5.5 + +.EX +S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P +.br + +.EE + +.IP "\fBint i2c_read_word_data(unsigned handle, unsigned i2c_reg)\fP" +.IP "" 4 +This reads a single 16 bit word from the specified register of the device +associated with handle. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to read. +.br + +.EE + +.br + +.br +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Read word. SMBus 2.0 5.5.5 + +.EX +S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P +.br + +.EE + +.IP "\fBint i2c_process_call(unsigned handle, unsigned i2c_reg, unsigned wVal)\fP" +.IP "" 4 +This writes 16 bits of data to the specified register of the device +associated with handle and and reads 16 bits of data in return. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write/read. +.br + wVal: 0-0xFFFF, the value to write. +.br + +.EE + +.br + +.br +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Process call. SMBus 2.0 5.5.6 + +.EX +S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] +.br + S Addr Rd [A] [DataLow] A [DataHigh] NA P +.br + +.EE + +.IP "\fBint i2c_write_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes up to 32 bytes to the specified register of the device +associated with handle. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write. +.br + buf: an array with the data to send. +.br + count: 1-32, the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Block write. SMBus 2.0 5.5.7 + +.EX +S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P +.br + +.EE + +.IP "\fBint i2c_read_block_data(unsigned handle, unsigned i2c_reg, char *buf)\fP" +.IP "" 4 +This reads a block of up to 32 bytes from the specified register of +the device associated with handle. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to read. +.br + buf: an array to receive the read data. +.br + +.EE + +.br + +.br +The amount of returned data is set by the device. + +.br + +.br +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Block read. SMBus 2.0 5.5.7 + +.EX +S Addr Wr [A] Comm [A] +.br + S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P +.br + +.EE + +.IP "\fBint i2c_block_process_call(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes data bytes to the specified register of the device +associated with handle and reads a device specified number +of bytes of data in return. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write/read. +.br + buf: an array with the data to send and to receive the read data. +.br + count: 1-32, the number of bytes to write. +.br + +.EE + +.br + +.br + +.br + +.br +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +The smbus 2.0 documentation states that a minimum of 1 byte may be +sent and a minimum of 1 byte may be received. The total number of +bytes sent/received must be 32 or less. + +.br + +.br +Block write-block read. SMBus 2.0 5.5.8 + +.EX +S Addr Wr [A] Comm [A] Count [A] Data [A] ... +.br + S Addr Rd [A] [Count] A [Data] ... A P +.br + +.EE + +.IP "\fBint i2c_read_i2c_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP" +.IP "" 4 +This reads count bytes from the specified register of the device +associated with handle . The count may be 1-32. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to read. +.br + buf: an array to receive the read data. +.br + count: 1-32, the number of bytes to read. +.br + +.EE + +.br + +.br +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br + +.EX +S Addr Wr [A] Comm [A] +.br + S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P +.br + +.EE + +.IP "\fBint i2c_write_i2c_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes 1 to 32 bytes to the specified register of the device +associated with handle. + +.br + +.br + +.EX + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write. +.br + buf: the data to write. +.br + count: 1-32, the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br + +.EX +S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P +.br + +.EE + +.IP "\fBint i2c_read_device(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This reads count bytes from the raw device into buf. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + buf: an array to receive the read data bytes. +.br + count: >0, the number of bytes to read. +.br + +.EE + +.br + +.br +Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_READ_FAILED. + +.IP "\fBint i2c_write_device(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This writes count bytes from buf to the raw device. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + buf: an array containing the data bytes to write. +.br + count: >0, the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.IP "\fBint i2c_zip(unsigned handle, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP" +.IP "" 4 +This function executes a sequence of I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + inBuf: pointer to the concatenated I2C commands, see below +.br + inLen: size of command buffer +.br +outBuf: pointer to buffer to hold returned data +.br +outLen: size of output buffer +.br + +.EE + +.br + +.br +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN. +PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +End 0 No more commands +.br +Escape 1 Next P is two bytes +.br +On 2 Switch combined flag on +.br +Off 3 Switch combined flag off +.br +Address 4 P Set I2C address to P +.br +Flags 5 lsb msb Set I2C flags to lsb + (msb << 8) +.br +Read 6 P Read P bytes of data +.br +Write 7 P ... Write P bytes of data +.br + +.br + +.br +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). + +.br + +.br +The address defaults to that associated with the handle. +The flags default to 0. The address and flags maintain their +previous value until updated. + +.br + +.br +The returned I2C data is stored in consecutive locations of outBuf. + +.br + +.br +\fBExample\fP +.br + +.EX +Set address 0x53, write 0x32, read 6 bytes +.br +Set address 0x1E, write 0x03, read 6 bytes +.br +Set address 0x68, write 0x1B, read 8 bytes +.br +End +.br + +.br +0x04 0x53 0x07 0x01 0x32 0x06 0x06 +.br +0x04 0x1E 0x07 0x01 0x03 0x06 0x06 +.br +0x04 0x68 0x07 0x01 0x1B 0x06 0x08 +.br +0x00 +.br + +.EE + +.br + +.br + +.IP "\fBint bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud)\fP" +.IP "" 4 +This function selects a pair of GPIO for bit banging I2C at a +specified baud rate. + +.br + +.br +Bit banging I2C allows for certain operations which are not possible +with the standard I2C driver. + +.br + +.br +o baud rates as low as 50 +.br +o repeated starts +.br +o clock stretching +.br +o I2C on any pair of spare GPIO + +.br + +.br + +.EX + SDA: 0-31 +.br + SCL: 0-31 +.br +baud: 50-500000 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or +PI_GPIO_IN_USE. + +.br + +.br +NOTE: + +.br + +.br +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. + +.IP "\fBint bb_i2c_close(unsigned SDA)\fP" +.IP "" 4 +This function stops bit banging I2C on a pair of GPIO previously +opened with \fBbb_i2c_open\fP. + +.br + +.br + +.EX +SDA: 0-31, the SDA GPIO used in a prior call to \fBbb_i2c_open\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO. + +.IP "\fBint bb_i2c_zip(unsigned SDA, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP" +.IP "" 4 +This function executes a sequence of bit banged I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +.br + +.br + +.EX + SDA: 0-31 (as used in a prior call to \fBbb_i2c_open\fP) +.br + inBuf: pointer to the concatenated I2C commands, see below +.br + inLen: size of command buffer +.br +outBuf: pointer to buffer to hold returned data +.br +outLen: size of output buffer +.br + +.EE + +.br + +.br +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER, +PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN, +PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +End 0 No more commands +.br +Escape 1 Next P is two bytes +.br +Start 2 Start condition +.br +Stop 3 Stop condition +.br +Address 4 P Set I2C address to P +.br +Flags 5 lsb msb Set I2C flags to lsb + (msb << 8) +.br +Read 6 P Read P bytes of data +.br +Write 7 P ... Write P bytes of data +.br + +.br + +.br +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). + +.br + +.br +The address and flags default to 0. The address and flags maintain +their previous value until updated. + +.br + +.br +No flags are currently defined. + +.br + +.br +The returned I2C data is stored in consecutive locations of outBuf. + +.br + +.br +\fBExample\fP +.br + +.EX +Set address 0x53 +.br +start, write 0x32, (re)start, read 6 bytes, stop +.br +Set address 0x1E +.br +start, write 0x03, (re)start, read 6 bytes, stop +.br +Set address 0x68 +.br +start, write 0x1B, (re)start, read 8 bytes, stop +.br +End +.br + +.br +0x04 0x53 +.br +0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03 +.br + +.br +0x04 0x1E +.br +0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03 +.br + +.br +0x04 0x68 +.br +0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03 +.br + +.br +0x00 +.br + +.EE + +.IP "\fBint spi_open(unsigned spi_channel, unsigned baud, unsigned spi_flags)\fP" +.IP "" 4 +This function returns a handle for the SPI device on the channel. +Data will be transferred at baud bits per second. The flags may +be used to modify the default behaviour of 4-wire operation, mode 0, +active low chip select. + +.br + +.br +The Pi has two SPI peripherals: main and auxiliary. + +.br + +.br +The main SPI has two chip selects (channels), the auxiliary has +three. + +.br + +.br +The auxiliary SPI is available on all models but the A and B. + +.br + +.br +The GPIO used are given in the following table. + +.br + +.br + MISO MOSI SCLK CE0 CE1 CE2 +.br +Main SPI 9 10 11 8 7 - +.br +Aux SPI 19 20 21 18 17 16 +.br + +.br + +.br + +.EX +spi_channel: 0-1 (0-2 for the auxiliary SPI). +.br + baud: 32K-125M (values above 30M are unlikely to work). +.br + spi_flags: see below. +.br + +.EE + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL, +PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED. + +.br + +.br +spi_flags consists of the least significant 22 bits. + +.br + +.br + +.EX +21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m +.br + +.EE + +.br + +.br +mm defines the SPI mode. + +.br + +.br +Warning: modes 1 and 3 do not appear to work on the auxiliary SPI. + +.br + +.br + +.EX +Mode POL PHA +.br + 0 0 0 +.br + 1 0 1 +.br + 2 1 0 +.br + 3 1 1 +.br + +.EE + +.br + +.br +px is 0 if CEx is active low (default) and 1 for active high. + +.br + +.br +ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise. + +.br + +.br +A is 0 for the main SPI, 1 for the auxiliary SPI. + +.br + +.br +W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Main +SPI only. + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +bbbbbb defines the word size in bits (0-32). The default (0) +sets 8 bits per word. Auxiliary SPI only. + +.br + +.br +The \fBspi_read\fP, \fBspi_write\fP, and \fBspi_xfer\fP functions +transfer data packed into 1, 2, or 4 bytes according to +the word size in bits. + +.br + +.br +For bits 1-8 there will be one byte per word. +.br +For bits 9-16 there will be two bytes per word. +.br +For bits 17-32 there will be four bytes per word. + +.br + +.br +Multi-byte transfers are made in least significant byte first order. + +.br + +.br +E.g. to transfer 32 11-bit words buf should contain 64 bytes +and count should be 64. + +.br + +.br +E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed +by 0x1A. + +.br + +.br +The other bits in flags should be set to zero. + +.IP "\fBint spi_close(unsigned handle)\fP" +.IP "" 4 +This functions closes the SPI device identified by the handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBspi_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint spi_read(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function reads count bytes of data from the SPI +device associated with the handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBspi_open\fP. +.br + buf: an array to receive the read data bytes. +.br + count: the number of bytes to read. +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint spi_write(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function writes count bytes of data from buf to the SPI +device associated with the handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBspi_open\fP. +.br + buf: the data bytes to write. +.br + count: the number of bytes to write. +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint spi_xfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count)\fP" +.IP "" 4 +This function transfers count bytes of data from txBuf to the SPI +device associated with the handle. Simultaneously count bytes of +data are read from the device and placed in rxBuf. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBspi_open\fP. +.br + txBuf: the data bytes to write. +.br + rxBuf: the received data bytes. +.br + count: the number of bytes to transfer. +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint serial_open(char *ser_tty, unsigned baud, unsigned ser_flags)\fP" +.IP "" 4 +This function opens a serial device at a specified baud rate +with specified flags. The device name must start with +/dev/tty or /dev/serial. + +.br + +.br + +.EX + ser_tty: the serial device to open. +.br + baud: the baud rate in bits per second, see below. +.br +ser_flags: 0. +.br + +.EE + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or +PI_SER_OPEN_FAILED. + +.br + +.br +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. + +.br + +.br +No flags are currently defined. This parameter should be set to zero. + +.IP "\fBint serial_close(unsigned handle)\fP" +.IP "" 4 +This function closes the serial device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint serial_write_byte(unsigned handle, unsigned bVal)\fP" +.IP "" 4 +This function writes bVal to the serial port associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. + +.IP "\fBint serial_read_byte(unsigned handle)\fP" +.IP "" 4 +This function reads a byte from the serial port associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + +.EE + +.br + +.br +Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED. + +.br + +.br +If no data is ready PI_SER_READ_NO_DATA is returned. + +.IP "\fBint serial_write(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function writes count bytes from buf to the the serial port +associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + buf: the array of bytes to write. +.br + count: the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. + +.IP "\fBint serial_read(unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function reads up to count bytes from the the serial port +associated with handle and writes them to buf. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + buf: an array to receive the read data. +.br + count: the maximum number of bytes to read. +.br + +.EE + +.br + +.br +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED. + +.br + +.br +If no data is ready zero is returned. + +.IP "\fBint serial_data_available(unsigned handle)\fP" +.IP "" 4 +Returns the number of bytes available to be read from the +device associated with handle. + +.br + +.br + +.EX +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + +.EE + +.br + +.br +Returns the number of bytes of data available (>=0) if OK, +otherwise PI_BAD_HANDLE. + +.IP "\fBint custom_1(unsigned arg1, unsigned arg2, char *argx, unsigned argc)\fP" +.IP "" 4 +This function is available for user customisation. + +.br + +.br +It returns a single integer value. + +.br + +.br + +.EX +arg1: >=0 +.br +arg2: >=0 +.br +argx: extra (byte) arguments +.br +argc: number of extra arguments +.br + +.EE + +.br + +.br +Returns >= 0 if OK, less than 0 indicates a user defined error. + +.IP "\fBint custom_2(unsigned arg1, char *argx, unsigned argc, char *retBuf, unsigned retMax)\fP" +.IP "" 4 +This function is available for user customisation. + +.br + +.br +It differs from custom_1 in that it returns an array of bytes +rather than just an integer. + +.br + +.br +The return value is an integer indicating the number of returned bytes. + +.EX + arg1: >=0 +.br + argc: extra (byte) arguments +.br + count: number of extra arguments +.br +retBuf: buffer for returned data +.br +retMax: maximum number of bytes to return +.br + +.EE + +.br + +.br +Returns >= 0 if OK, less than 0 indicates a user defined error. + +.br + +.br +Note, the number of returned bytes will be retMax or less. + +.IP "\fBint callback(unsigned user_gpio, unsigned edge, CBFunc_t f)\fP" +.IP "" 4 +This function initialises a new callback. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. +.br + f: the callback function. +.br + +.EE + +.br + +.br +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +.br + +.br +The callback is called with the GPIO, edge, and tick, whenever the +GPIO has the identified edge. + +.br + +.br + +.EX +Parameter Value Meaning +.br + +.br +GPIO 0-31 The GPIO which has changed state +.br + +.br +edge 0-2 0 = change to low (a falling edge) +.br + 1 = change to high (a rising edge) +.br + 2 = no level change (a watchdog timeout) +.br + +.br +tick 32 bit The number of microseconds since boot +.br + WARNING: this wraps around from +.br + 4294967295 to 0 roughly every 72 minutes +.br + +.EE + +.IP "\fBint callback_ex(unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP" +.IP "" 4 +This function initialises a new callback. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. +.br + f: the callback function. +.br + userdata: a pointer to arbitrary user data. +.br + +.EE + +.br + +.br +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +.br + +.br +The callback is called with the GPIO, edge, tick, and user, whenever +the GPIO has the identified edge. + +.br + +.br + +.EX +Parameter Value Meaning +.br + +.br +GPIO 0-31 The GPIO which has changed state +.br + +.br +edge 0-2 0 = change to low (a falling edge) +.br + 1 = change to high (a rising edge) +.br + 2 = no level change (a watchdog timeout) +.br + +.br +tick 32 bit The number of microseconds since boot +.br + WARNING: this wraps around from +.br + 4294967295 to 0 roughly every 72 minutes +.br + +.br +userdata pointer Pointer to an arbitrary object +.br + +.EE + +.IP "\fBint callback_cancel(unsigned callback_id)\fP" +.IP "" 4 +This function cancels a callback identified by its id. + +.br + +.br + +.EX +callback_id: >=0, as returned by a call to \fBcallback\fP or \fBcallback_ex\fP. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise pigif_callback_not_found. + +.IP "\fBint wait_for_edge(unsigned user_gpio, unsigned edge, double timeout)\fP" +.IP "" 4 +This function waits for edge on the GPIO for up to timeout +seconds. + +.br + +.br + +.EX +user_gpio: 0-31. +.br + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. +.br + timeout: >=0. +.br + +.EE + +.br + +.br +The function returns 1 if the edge occurred, otherwise 0. + +.br + +.br +The function returns when the edge occurs or after the timeout. +.SH PARAMETERS + +.br + +.br + +.IP "\fBactive\fP: 0-1000000" 0 + +.br + +.br +The number of microseconds level changes are reported for once +a noise filter has been triggered (by \fBsteady\fP microseconds of +a stable level). + +.br + +.br + +.IP "\fB*addrStr\fP" 0 +A string specifying the host or IP address of the Pi running +the pigpio daemon. It may be NULL in which case localhost +is used unless overridden by the PIGPIO_ADDR environment +variable. + +.br + +.br + +.IP "\fBarg1\fP" 0 +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +.br + +.br + +.IP "\fBarg2\fP" 0 +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +.br + +.br + +.IP "\fBargc\fP" 0 +The count of bytes passed to a user customised function. + +.br + +.br + +.IP "\fB*argx\fP" 0 +A pointer to an array of bytes passed to a user customised function. +Its meaning and content is defined by the customiser. + +.br + +.br + +.IP "\fBbaud\fP" 0 +The speed of serial communication (I2C, SPI, serial link, waves) in +bits per second. + +.br + +.br + +.IP "\fBbit\fP" 0 +A value of 0 or 1. + +.br + +.br + +.IP "\fBbits\fP" 0 +A value used to select GPIO. If bit n of bits is set then GPIO n is +selected. + +.br + +.br +A convenient way to set bit n is to or in (1<=0, as returned by a call to \fBcallback\fP or \fBcallback_ex\fP. This is +passed to \fBcallback_cancel\fP to cancel the callback. + +.br + +.br + +.IP "\fBCBFunc_t\fP" 0 + +.EX +typedef void (*CBFunc_t) +.br + (unsigned user_gpio, unsigned level, uint32_t tick); +.br + +.EE + +.br + +.br + +.IP "\fBCBFuncEx_t\fP" 0 + +.EX +typedef void (*CBFuncEx_t) +.br + (unsigned user_gpio, unsigned level, uint32_t tick, void * user); +.br + +.EE + +.br + +.br + +.IP "\fBchar\fP" 0 +A single character, an 8 bit quantity able to store 0-255. + +.br + +.br + +.IP "\fBclkfreq\fP: 4689-250000000 (250M)" 0 +The hardware clock frequency. + +.br + +.br + +.IP "\fBcount\fP" 0 +The number of bytes to be transferred in an I2C, SPI, or Serial +command. + +.br + +.br + +.IP "\fBdata_bits\fP: 1-32" 0 +The number of data bits in each character of serial data. + +.br + +.br + +.EX +#define PI_MIN_WAVE_DATABITS 1 +.br +#define PI_MAX_WAVE_DATABITS 32 +.br + +.EE + +.br + +.br + +.IP "\fBdouble\fP" 0 +A floating point number. + +.br + +.br + +.IP "\fBdutycycle\fP: 0-range" 0 +A number representing the ratio of on time to off time for PWM. + +.br + +.br +The number may vary between 0 and range (default 255) where +0 is off and range is fully on. + +.br + +.br + +.IP "\fBedge\fP" 0 +Used to identify a GPIO level transition of interest. A rising edge is +a level change from 0 to 1. A falling edge is a level change from 1 to 0. + +.br + +.br + +.EX +RISING_EDGE 0 +.br +FALLING_EDGE 1 +.br +EITHER_EDGE. 2 +.br + +.EE + +.br + +.br + +.IP "\fBerrnum\fP" 0 +A negative number indicating a function call failed and the nature +of the error. + +.br + +.br + +.IP "\fBf\fP" 0 +A function. + +.br + +.br + +.IP "\fBfrequency\fP: >=0" 0 +The number of times a GPIO is swiched on and off per second. This +can be set per GPIO and may be as little as 5Hz or as much as +40KHz. The GPIO will be on for a proportion of the time as defined +by its dutycycle. + +.br + +.br + +.br + +.br + +.IP "\fBgpio\fP" 0 +A Broadcom numbered GPIO, in the range 0-53. + +.br + +.br +There are 54 General Purpose Input Outputs (GPIO) named gpio0 through +gpio53. + +.br + +.br +They are split into two banks. Bank 1 consists of gpio0 through +gpio31. Bank 2 consists of gpio32 through gpio53. + +.br + +.br +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. + +.br + +.br +See \fBget_hardware_revision\fP. + +.br + +.br +The user GPIO are marked with an X in the following table. + +.br + +.br + +.EX + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +.br +Type 1 X X - - X - - X X X X X - - X X +.br +Type 2 - - X X X - - X X X X X - - X X +.br +Type 3 X X X X X X X X X X X X X X +.br + +.br + 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +.br +Type 1 - X X - - X X X X X - - - - - - +.br +Type 2 - X X - - - X X X X - X X X X X +.br +Type 3 X X X X X X X X X X X X - - - - +.br + +.EE + +.br + +.br + +.IP "\fBgpioPulse_t\fP" 0 + +.EX +typedef struct +.br +{ +.br +uint32_t gpioOn; +.br +uint32_t gpioOff; +.br +uint32_t usDelay; +.br +} gpioPulse_t; +.br + +.EE + +.br + +.br + +.IP "\fBgpioThreadFunc_t\fP" 0 + +.EX +typedef void *(gpioThreadFunc_t) (void *); +.br + +.EE + +.br + +.br + +.IP "\fBhandle\fP: >=0" 0 +A number referencing an object opened by one of \fBi2c_open\fP, \fBnotify_open\fP, +\fBserial_open\fP, and \fBspi_open\fP. + +.br + +.br + +.IP "\fBi2c_addr\fP: 0-0x7F" 0 +The address of a device on the I2C bus. + +.br + +.br + +.IP "\fBi2c_bus\fP: >=0" 0 +An I2C bus number. + +.br + +.br + +.IP "\fBi2c_flags\fP: 0" 0 +Flags which modify an I2C open command. None are currently defined. + +.br + +.br + +.IP "\fBi2c_reg\fP: 0-255" 0 +A register of an I2C device. + +.br + +.br + +.IP "\fB*inBuf\fP" 0 +A buffer used to pass data to a function. + +.br + +.br + +.IP "\fBinLen\fP" 0 +The number of bytes of data in a buffer. + +.br + +.br + +.IP "\fBint\fP" 0 +A whole number, negative or positive. + +.br + +.br + +.IP "\fBinvert\fP" 0 +A flag used to set normal or inverted bit bang serial data level logic. + +.br + +.br + +.IP "\fBlevel\fP" 0 +The level of a GPIO. Low or High. + +.br + +.br + +.EX +PI_OFF 0 +.br +PI_ON 1 +.br + +.br +PI_CLEAR 0 +.br +PI_SET 1 +.br + +.br +PI_LOW 0 +.br +PI_HIGH 1 +.br + +.EE + +.br + +.br +There is one exception. If a watchdog expires on a GPIO the level will be +reported as PI_TIMEOUT. See \fBset_watchdog\fP. + +.br + +.br + +.EX +PI_TIMEOUT 2 +.br + +.EE + +.br + +.br + +.IP "\fBmode\fP: 0-7" 0 +The operational mode of a GPIO, normally INPUT or OUTPUT. + +.br + +.br + +.EX +PI_INPUT 0 +.br +PI_OUTPUT 1 +.br +PI_ALT0 4 +.br +PI_ALT1 5 +.br +PI_ALT2 6 +.br +PI_ALT3 7 +.br +PI_ALT4 3 +.br +PI_ALT5 2 +.br + +.EE + +.br + +.br + +.IP "\fBnumBytes\fP" 0 +The number of bytes used to store characters in a string. Depending +on the number of bits per character there may be 1, 2, or 4 bytes +per character. + +.br + +.br + +.IP "\fBnumPar\fP: 0-10" 0 +The number of parameters passed to a script. + +.br + +.br + +.IP "\fBnumPulses\fP" 0 +The number of pulses to be added to a waveform. + +.br + +.br + +.IP "\fBoffset\fP" 0 +The associated data starts this number of microseconds from the start of +the waveform. + +.br + +.br + +.IP "\fB*outBuf\fP" 0 +A buffer used to return data from a function. + +.br + +.br + +.IP "\fBoutLen\fP" 0 +The size in bytes of an output buffer. + +.br + +.br + +.IP "\fB*param\fP" 0 +An array of script parameters. + +.br + +.br + +.IP "\fB*portStr\fP" 0 +A string specifying the port address used by the Pi running +the pigpio daemon. It may be NULL in which case "8888" +is used unless overridden by the PIGPIO_PORT environment +variable. + +.br + +.br + +.IP "\fB*pth\fP" 0 +A thread identifier, returned by \fBstart_thread\fP. + +.br + +.br + +.br + +.br + +.IP "\fBpthread_t\fP" 0 +A thread identifier. + +.br + +.br + +.IP "\fBpud\fP: 0-2" 0 +The setting of the pull up/down resistor for a GPIO, which may be off, +pull-up, or pull-down. + +.EX +PI_PUD_OFF 0 +.br +PI_PUD_DOWN 1 +.br +PI_PUD_UP 2 +.br + +.EE + +.br + +.br + +.IP "\fBpulseLen\fP" 0 +1-100, the length of a trigger pulse in microseconds. + +.br + +.br + +.IP "\fB*pulses\fP" 0 +An array of pulses to be added to a waveform. + +.br + +.br + +.IP "\fBpulsewidth\fP: 0, 500-2500" 0 + +.EX +PI_SERVO_OFF 0 +.br +PI_MIN_SERVO_PULSEWIDTH 500 +.br +PI_MAX_SERVO_PULSEWIDTH 2500 +.br + +.EE + +.br + +.br + +.IP "\fBPWMduty\fP: 0-1000000 (1M)" 0 +The hardware PWM dutycycle. + +.br + +.br + +.EX +#define PI_HW_PWM_RANGE 1000000 +.br + +.EE + +.br + +.br + +.IP "\fBPWMfreq\fP: 1-125000000 (125M)" 0 +The hardware PWM frequency. + +.br + +.br + +.EX +#define PI_HW_PWM_MIN_FREQ 1 +.br +#define PI_HW_PWM_MAX_FREQ 125000000 +.br + +.EE + +.br + +.br + +.IP "\fBrange\fP: 25-40000" 0 +The permissible dutycycle values are 0-range. + +.EX +PI_MIN_DUTYCYCLE_RANGE 25 +.br +PI_MAX_DUTYCYCLE_RANGE 40000 +.br + +.EE + +.br + +.br + +.IP "\fB*retBuf\fP" 0 +A buffer to hold a number of bytes returned to a used customised function, + +.br + +.br + +.IP "\fBretMax\fP" 0 +The maximum number of bytes a user customised function should return. + +.br + +.br + +.br + +.br + +.IP "\fB*rxBuf\fP" 0 +A pointer to a buffer to receive data. + +.br + +.br + +.IP "\fBSCL\fP" 0 +The user GPIO to use for the clock when bit banging I2C. + +.br + +.br + +.IP "\fB*script\fP" 0 +A pointer to the text of a script. + +.br + +.br + +.IP "\fBscript_id\fP" 0 +An id of a stored script as returned by \fBstore_script\fP. + +.br + +.br + +.IP "\fBSDA\fP" 0 +The user GPIO to use for data when bit banging I2C. + +.br + +.br + +.IP "\fBseconds\fP" 0 +The number of seconds. + +.br + +.br + +.IP "\fBser_flags\fP" 0 +Flags which modify a serial open command. None are currently defined. + +.br + +.br + +.IP "\fB*ser_tty\fP" 0 +The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1. + +.br + +.br + +.IP "\fBsize_t\fP" 0 +A standard type used to indicate the size of an object in bytes. + +.br + +.br + +.IP "\fBspi_channel\fP" 0 +A SPI channel, 0-2. + +.br + +.br + +.IP "\fBspi_flags\fP" 0 +See \fBspi_open\fP. + +.br + +.br + +.IP "\fBsteady\fP: 0-300000" 0 + +.br + +.br +The number of microseconds level changes must be stable for +before reporting the level changed (\fBset_glitch_filter\fP) or triggering +the active part of a noise filter (\fBset_noise_filter\fP). + +.br + +.br + +.IP "\fBstop_bits\fP: 2-8" 0 +The number of (half) stop bits to be used when adding serial data +to a waveform. + +.br + +.br + +.EX +#define PI_MIN_WAVE_HALFSTOPBITS 2 +.br +#define PI_MAX_WAVE_HALFSTOPBITS 8 +.br + +.EE + +.br + +.br + +.IP "\fB*str\fP" 0 + An array of characters. + +.br + +.br + +.IP "\fBthread_func\fP" 0 +A function of type gpioThreadFunc_t used as the main function of a +thread. + +.br + +.br + +.IP "\fBtimeout\fP" 0 +A GPIO watchdog timeout in milliseconds. + +.EX +PI_MIN_WDOG_TIMEOUT 0 +.br +PI_MAX_WDOG_TIMEOUT 60000 +.br + +.EE + +.br + +.br + +.IP "\fB*txBuf\fP" 0 +An array of bytes to transmit. + +.br + +.br + +.IP "\fBuint32_t\fP: 0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)" 0 +A 32-bit unsigned value. + +.br + +.br + +.IP "\fBunsigned\fP" 0 +A whole number >= 0. + +.br + +.br + +.IP "\fBuser_gpio\fP" 0 +0-31, a Broadcom numbered GPIO. + +.br + +.br +See \fBgpio\fP. + +.br + +.br + +.IP "\fB*userdata\fP" 0 +A pointer to arbitrary user data. This may be used to identify the instance. + +.br + +.br + +.IP "\fBvoid\fP" 0 +Denoting no parameter is required + +.br + +.br + +.IP "\fBwave_add_*\fP" 0 +One of \fBwave_add_new\fP, \fBwave_add_generic\fP, \fBwave_add_serial\fP. + +.br + +.br + +.IP "\fBwave_id\fP" 0 +A number representing a waveform created by \fBwave_create\fP. + +.br + +.br + +.IP "\fBwave_send_*\fP" 0 +One of \fBwave_send_once\fP, \fBwave_send_repeat\fP. + +.br + +.br + +.IP "\fBwVal\fP: 0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777)" 0 +A 16-bit word value. + +.br + +.br +.SH pigpiod_if Error Codes + +.EX + +.br +typedef enum +.br +{ +.br + pigif_bad_send = -2000, +.br + pigif_bad_recv = -2001, +.br + pigif_bad_getaddrinfo = -2002, +.br + pigif_bad_connect = -2003, +.br + pigif_bad_socket = -2004, +.br + pigif_bad_noib = -2005, +.br + pigif_duplicate_callback = -2006, +.br + pigif_bad_malloc = -2007, +.br + pigif_bad_callback = -2008, +.br + pigif_notify_failed = -2009, +.br + pigif_callback_not_found = -2010, +.br +} pigifError_t; +.br + +.br + +.EE + +.SH SEE ALSO + +pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if2(3) +.SH AUTHOR + +joan@abyz.me.uk diff --git a/pigpiod_if.c b/pigpiod_if.c new file mode 100644 index 0000000..c62b3e8 --- /dev/null +++ b/pigpiod_if.c @@ -0,0 +1,1572 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +/* PIGPIOD_IF_VERSION 27 */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "pigpio.h" +#include "command.h" + +#include "pigpiod_if.h" + +#define PISCOPE_MAX_REPORTS_PER_READ 4096 + +#define STACK_SIZE (256*1024) + +typedef void (*CBF_t) (); + +struct callback_s +{ + + int id; + int gpio; + int edge; + CBF_t f; + void * user; + int ex; + callback_t *prev; + callback_t *next; +}; + +/* GLOBALS ---------------------------------------------------------------- */ + +static gpioReport_t gReport[PISCOPE_MAX_REPORTS_PER_READ]; + +static int gPigCommand = -1; +static int gPigHandle = -1; +static int gPigNotify = -1; + +static uint32_t gNotifyBits; +static uint32_t gLastLevel; + +callback_t *gCallBackFirst = 0; +callback_t *gCallBackLast = 0; + +static int gPigStarted = 0; + +static pthread_t *pthNotify; + +static pthread_mutex_t command_mutex = PTHREAD_MUTEX_INITIALIZER; + +/* PRIVATE ---------------------------------------------------------------- */ + +static int pigpio_command(int fd, int command, int p1, int p2, int rl) +{ + cmdCmd_t cmd; + + cmd.cmd = command; + cmd.p1 = p1; + cmd.p2 = p2; + cmd.res = 0; + + pthread_mutex_lock(&command_mutex); + + if (send(fd, &cmd, sizeof(cmd), 0) != sizeof(cmd)) + { + pthread_mutex_unlock(&command_mutex); + return pigif_bad_send; + } + + if (recv(fd, &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd)) + { + pthread_mutex_unlock(&command_mutex); + return pigif_bad_recv; + } + + if (rl) pthread_mutex_unlock(&command_mutex); + + return cmd.res; +} + +static int pigpio_command_ext + (int fd, int command, int p1, int p2, int p3, + int extents, gpioExtent_t *ext, int rl) +{ + int i; + cmdCmd_t cmd; + + cmd.cmd = command; + cmd.p1 = p1; + cmd.p2 = p2; + cmd.p3 = p3; + + pthread_mutex_lock(&command_mutex); + + if (send(fd, &cmd, sizeof(cmd), 0) != sizeof(cmd)) + { + pthread_mutex_unlock(&command_mutex); + return pigif_bad_send; + } + + for (i=0; iai_next) + { + sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); + + if (sock == -1) continue; + + /* Disable the Nagle algorithm. */ + opt = 1; + setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(int)); + + if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) break; + } + + freeaddrinfo(res); + + if (rp == NULL) return pigif_bad_connect; + + return sock; +} + +static void dispatch_notification(gpioReport_t *r) +{ + callback_t *p; + uint32_t changed; + int l, g; + + /* + printf("s=%d f=%d l=%8X, t=%10u\n", + r->seqno, r->flags, r->level, r->tick); + */ + + if (r->flags == 0) + { + changed = (r->level ^ gLastLevel) & gNotifyBits; + + gLastLevel = r->level; + + p = gCallBackFirst; + + while (p) + { + if (changed & (1<<(p->gpio))) + { + if ((r->level) & (1<<(p->gpio))) l = 1; else l = 0; + if ((p->edge) ^ l) + { + if (p->ex) (p->f)(p->gpio, l, r->tick, p->user); + else (p->f)(p->gpio, l, r->tick); + } + } + p = p->next; + } + } + else + { + g = (r->flags) & 31; + + p = gCallBackFirst; + + while (p) + { + if ((p->gpio) == g) + { + if (p->ex) (p->f)(g, PI_TIMEOUT, r->tick, p->user); + else (p->f)(g, PI_TIMEOUT, r->tick); + } + p = p->next; + } + } +} + +static void *pthNotifyThread(void *x) +{ + static int got = 0; + + int bytes, r; + + while (1) + { + bytes = read(gPigNotify, (char*)&gReport+got, sizeof(gReport)-got); + + if (bytes > 0) got += bytes; + else break; + + r = 0; + + while (got >= sizeof(gpioReport_t)) + { + dispatch_notification(&gReport[r]); + + r++; + + got -= sizeof(gpioReport_t); + } + + /* copy any partial report to start of array */ + + if (got && r) gReport[0] = gReport[r]; + } + return 0; +} + +static void findNotifyBits(void) +{ + callback_t *p; + uint32_t bits = 0; + + p = gCallBackFirst; + + while (p) + { + bits |= (1<<(p->gpio)); + p = p->next; + } + + if (bits != gNotifyBits) + { + gNotifyBits = bits; + pigpio_command(gPigCommand, PI_CMD_NB, gPigHandle, gNotifyBits, 1); + } +} + +static void _wfe(unsigned user_gpio, unsigned level, uint32_t tick, void *user) +{ + *(int *)user = 1; +} + +static int intCallback(unsigned user_gpio, unsigned edge, void *f, void *user, int ex) +{ + static int id = 0; + callback_t *p; + + if ((user_gpio >=0) && (user_gpio < 32) && (edge >=0) && (edge <= 2) && f) + { + /* prevent duplicates */ + + p = gCallBackFirst; + + while (p) + { + if ((p->gpio == user_gpio) && (p->edge == edge) && (p->f == f)) + { + return pigif_duplicate_callback; + } + p = p->next; + } + + p = malloc(sizeof(callback_t)); + + if (p) + { + if (!gCallBackFirst) gCallBackFirst = p; + + p->id = id++; + p->gpio = user_gpio; + p->edge = edge; + p->f = f; + p->user = user; + p->ex = ex; + p->next = 0; + p->prev = gCallBackLast; + + if (p->prev) (p->prev)->next = p; + gCallBackLast = p; + + findNotifyBits(); + + return p->id; + } + + return pigif_bad_malloc; + } + + return pigif_bad_callback; +} + +/* PUBLIC ----------------------------------------------------------------- */ + +double time_time(void) +{ + struct timeval tv; + double t; + + gettimeofday(&tv, 0); + + t = (double)tv.tv_sec + ((double)tv.tv_usec / 1E6); + + return t; +} + +void time_sleep(double seconds) +{ + struct timespec ts, rem; + + if (seconds > 0.0) + { + ts.tv_sec = seconds; + ts.tv_nsec = (seconds-(double)ts.tv_sec) * 1E9; + + while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem)) + { + /* copy remaining time to ts */ + ts.tv_sec = rem.tv_sec; + ts.tv_nsec = rem.tv_nsec; + } + } +} + +char *pigpio_error(int errnum) +{ + if (errnum > -1000) return cmdErrStr(errnum); + else + { + switch(errnum) + { + case pigif_bad_send: + return "failed to send to pigpiod"; + case pigif_bad_recv: + return "failed to receive from pigpiod"; + case pigif_bad_getaddrinfo: + return "failed to find address of pigpiod"; + case pigif_bad_connect: + return "failed to connect to pigpiod"; + case pigif_bad_socket: + return "failed to create socket"; + case pigif_bad_noib: + return "failed to open noib"; + case pigif_duplicate_callback: + return "identical callback exists"; + case pigif_bad_malloc: + return "failed to malloc"; + case pigif_bad_callback: + return "bad callback parameter"; + case pigif_notify_failed: + return "failed to create notification thread"; + case pigif_callback_not_found: + return "callback not found"; + default: + return "unknown error"; + } + } +} + +unsigned pigpiod_if_version(void) +{ + return PIGPIOD_IF_VERSION; +} + +pthread_t *start_thread(gpioThreadFunc_t thread_func, void *arg) +{ + pthread_t *pth; + pthread_attr_t pthAttr; + + pth = malloc(sizeof(pthread_t)); + + if (pth) + { + if (pthread_attr_init(&pthAttr)) + { + perror("pthread_attr_init failed"); + free(pth); + return NULL; + } + + if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE)) + { + perror("pthread_attr_setstacksize failed"); + free(pth); + return NULL; + } + + if (pthread_create(pth, &pthAttr, thread_func, arg)) + { + perror("pthread_create socket failed"); + free(pth); + return NULL; + } + } + return pth; +} + +void stop_thread(pthread_t *pth) +{ + if (pth) + { + pthread_cancel(*pth); + pthread_join(*pth, NULL); + free(pth); + } +} + +int pigpio_start(char *addrStr, char *portStr) +{ + if ((!addrStr) || (strlen(addrStr) == 0)) + { + addrStr = "localhost"; + } + + if (!gPigStarted) + { + gPigCommand = pigpioOpenSocket(addrStr, portStr); + + if (gPigCommand >= 0) + { + gPigNotify = pigpioOpenSocket(addrStr, portStr); + + if (gPigNotify >= 0) + { + gPigHandle = pigpio_command(gPigNotify, PI_CMD_NOIB, 0, 0, 1); + + if (gPigHandle < 0) return pigif_bad_noib; + else + { + gLastLevel = read_bank_1(); + + pthNotify = start_thread(pthNotifyThread, 0); + if (pthNotify) + { + gPigStarted = 1; + return 0; + } + else return pigif_notify_failed; + } + } + else return gPigNotify; + } + else return gPigCommand; + } + return 0; +} + +void pigpio_stop(void) +{ + gPigStarted = 0; + + if (pthNotify) + { + stop_thread(pthNotify); + pthNotify = 0; + } + + if (gPigNotify >= 0) + { + if (gPigHandle >= 0) + { + pigpio_command(gPigNotify, PI_CMD_NC, gPigHandle, 0, 1); + gPigHandle = -1; + } + + close(gPigNotify); + gPigNotify = -1; + } + + if (gPigCommand >= 0) + { + if (gPigHandle >= 0) + { + pigpio_command(gPigCommand, PI_CMD_NC, gPigHandle, 0, 1); + gPigHandle = -1; + } + + close(gPigCommand); + gPigCommand = -1; + } +} + +int set_mode(unsigned gpio, unsigned mode) + {return pigpio_command(gPigCommand, PI_CMD_MODES, gpio, mode, 1);} + +int get_mode(unsigned gpio) + {return pigpio_command(gPigCommand, PI_CMD_MODEG, gpio, 0, 1);} + +int set_pull_up_down(unsigned gpio, unsigned pud) + {return pigpio_command(gPigCommand, PI_CMD_PUD, gpio, pud, 1);} + +int gpio_read(unsigned gpio) + {return pigpio_command(gPigCommand, PI_CMD_READ, gpio, 0, 1);} + +int gpio_write(unsigned gpio, unsigned level) + {return pigpio_command(gPigCommand, PI_CMD_WRITE, gpio, level, 1);} + +int set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle) + {return pigpio_command(gPigCommand, PI_CMD_PWM, user_gpio, dutycycle, 1);} + +int get_PWM_dutycycle(unsigned user_gpio) + {return pigpio_command(gPigCommand, PI_CMD_GDC, user_gpio, 0, 1);} + +int set_PWM_range(unsigned user_gpio, unsigned range) + {return pigpio_command(gPigCommand, PI_CMD_PRS, user_gpio, range, 1);} + +int get_PWM_range(unsigned user_gpio) + {return pigpio_command(gPigCommand, PI_CMD_PRG, user_gpio, 0, 1);} + +int get_PWM_real_range(unsigned user_gpio) + {return pigpio_command(gPigCommand, PI_CMD_PRRG, user_gpio, 0, 1);} + +int set_PWM_frequency(unsigned user_gpio, unsigned frequency) + {return pigpio_command(gPigCommand, PI_CMD_PFS, user_gpio, frequency, 1);} + +int get_PWM_frequency(unsigned user_gpio) + {return pigpio_command(gPigCommand, PI_CMD_PFG, user_gpio, 0, 1);} + +int set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth) + {return pigpio_command(gPigCommand, PI_CMD_SERVO, user_gpio, pulsewidth, 1);} + +int get_servo_pulsewidth(unsigned user_gpio) + {return pigpio_command(gPigCommand, PI_CMD_GPW, user_gpio, 0, 1);} + +int notify_open(void) + {return pigpio_command(gPigCommand, PI_CMD_NO, 0, 0, 1);} + +int notify_begin(unsigned handle, uint32_t bits) + {return pigpio_command(gPigCommand, PI_CMD_NB, handle, bits, 1);} + +int notify_pause(unsigned handle) + {return pigpio_command(gPigCommand, PI_CMD_NB, handle, 0, 1);} + +int notify_close(unsigned handle) + {return pigpio_command(gPigCommand, PI_CMD_NC, handle, 0, 1);} + +int set_watchdog(unsigned user_gpio, unsigned timeout) + {return pigpio_command(gPigCommand, PI_CMD_WDOG, user_gpio, timeout, 1);} + +uint32_t read_bank_1(void) + {return pigpio_command(gPigCommand, PI_CMD_BR1, 0, 0, 1);} + +uint32_t read_bank_2(void) + {return pigpio_command(gPigCommand, PI_CMD_BR2, 0, 0, 1);} + +int clear_bank_1(uint32_t levels) + {return pigpio_command(gPigCommand, PI_CMD_BC1, levels, 0, 1);} + +int clear_bank_2(uint32_t levels) + {return pigpio_command(gPigCommand, PI_CMD_BC2, levels, 0, 1);} + +int set_bank_1(uint32_t levels) + {return pigpio_command(gPigCommand, PI_CMD_BS1, levels, 0, 1);} + +int set_bank_2(uint32_t levels) + {return pigpio_command(gPigCommand, PI_CMD_BS2, levels, 0, 1);} + +int hardware_clock(unsigned gpio, unsigned frequency) + {return pigpio_command(gPigCommand, PI_CMD_HC, gpio, frequency, 1);} + +int hardware_PWM(unsigned gpio, unsigned frequency, uint32_t dutycycle) +{ + gpioExtent_t ext[1]; + + /* + p1=gpio + p2=frequency + p3=4 + ## extension ## + uint32_t dutycycle + */ + + ext[0].size = sizeof(dutycycle); + ext[0].ptr = &dutycycle; + + return pigpio_command_ext( + gPigCommand, PI_CMD_HP, gpio, frequency, sizeof(dutycycle), 1, ext, 1); +} + +uint32_t get_current_tick(void) + {return pigpio_command(gPigCommand, PI_CMD_TICK, 0, 0, 1);} + +uint32_t get_hardware_revision(void) + {return pigpio_command(gPigCommand, PI_CMD_HWVER, 0, 0, 1);} + +uint32_t get_pigpio_version(void) + {return pigpio_command(gPigCommand, PI_CMD_PIGPV, 0, 0, 1);} + +int wave_clear(void) + {return pigpio_command(gPigCommand, PI_CMD_WVCLR, 0, 0, 1);} + +int wave_add_new(void) + {return pigpio_command(gPigCommand, PI_CMD_WVNEW, 0, 0, 1);} + +int wave_add_generic(unsigned numPulses, gpioPulse_t *pulses) +{ + gpioExtent_t ext[1]; + + /* + p1=0 + p2=0 + p3=pulses*sizeof(gpioPulse_t) + ## extension ## + gpioPulse_t[] pulses + */ + + if (!numPulses) return 0; + + ext[0].size = numPulses * sizeof(gpioPulse_t); + ext[0].ptr = pulses; + + return pigpio_command_ext( + gPigCommand, PI_CMD_WVAG, 0, 0, ext[0].size, 1, ext, 1); +} + +int wave_add_serial( + unsigned user_gpio, unsigned baud, uint32_t databits, + uint32_t stophalfbits, uint32_t offset, unsigned numChar, char *str) +{ + uint8_t buf[12]; + gpioExtent_t ext[2]; + + /* + p1=user_gpio + p2=baud + p3=len+12 + ## extension ## + uint32_t databits + uint32_t stophalfbits + uint32_t offset + char[len] str + */ + + if (!numChar) return 0; + + memcpy(buf, &databits, 4); + memcpy(buf+4, &stophalfbits, 4); + memcpy(buf+8, &offset, 4); + + ext[0].size = sizeof(buf); + ext[0].ptr = buf; + + ext[1].size = numChar; + ext[1].ptr = str; + + return pigpio_command_ext(gPigCommand, PI_CMD_WVAS, + user_gpio, baud, numChar+sizeof(buf), 2, ext, 1); +} + +int wave_create(void) + {return pigpio_command(gPigCommand, PI_CMD_WVCRE, 0, 0, 1);} + +int wave_delete(unsigned wave_id) + {return pigpio_command(gPigCommand, PI_CMD_WVDEL, wave_id, 0, 1);} + +int wave_tx_start(void) /* DEPRECATED */ + {return pigpio_command(gPigCommand, PI_CMD_WVGO, 0, 0, 1);} + +int wave_tx_repeat(void) /* DEPRECATED */ + {return pigpio_command(gPigCommand, PI_CMD_WVGOR, 0, 0, 1);} + +int wave_send_once(unsigned wave_id) + {return pigpio_command(gPigCommand, PI_CMD_WVTX, wave_id, 0, 1);} + +int wave_send_repeat(unsigned wave_id) + {return pigpio_command(gPigCommand, PI_CMD_WVTXR, wave_id, 0, 1);} + +int wave_chain(char *buf, unsigned bufSize) +{ + gpioExtent_t ext[1]; + + /* + p1=0 + p2=0 + p3=bufSize + ## extension ## + char buf[bufSize] + */ + + ext[0].size = bufSize; + ext[0].ptr = buf; + + return pigpio_command_ext + (gPigCommand, PI_CMD_WVCHA, 0, 0, bufSize, 1, ext, 1); +} + +int wave_tx_busy(void) + {return pigpio_command(gPigCommand, PI_CMD_WVBSY, 0, 0, 1);} + +int wave_tx_stop(void) + {return pigpio_command(gPigCommand, PI_CMD_WVHLT, 0, 0, 1);} + +int wave_get_micros(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSM, 0, 0, 1);} + +int wave_get_high_micros(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSM, 1, 0, 1);} + +int wave_get_max_micros(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSM, 2, 0, 1);} + +int wave_get_pulses(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSP, 0, 0, 1);} + +int wave_get_high_pulses(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSP, 1, 0, 1);} + +int wave_get_max_pulses(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSP, 2, 0, 1);} + +int wave_get_cbs(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSC, 0, 0, 1);} + +int wave_get_high_cbs(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSC, 1, 0, 1);} + +int wave_get_max_cbs(void) + {return pigpio_command(gPigCommand, PI_CMD_WVSC, 2, 0, 1);} + +int gpio_trigger(unsigned user_gpio, unsigned pulseLen, uint32_t level) +{ + gpioExtent_t ext[1]; + + /* + p1=user_gpio + p2=pulseLen + p3=4 + ## extension ## + unsigned level + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &level; + + return pigpio_command_ext( + gPigCommand, PI_CMD_TRIG, user_gpio, pulseLen, 4, 1, ext, 1); +} + +int set_glitch_filter(unsigned user_gpio, unsigned steady) + {return pigpio_command(gPigCommand, PI_CMD_FG, user_gpio, steady, 1);} + +int set_noise_filter(unsigned user_gpio, unsigned steady, unsigned active) +{ + gpioExtent_t ext[1]; + + /* + p1=user_gpio + p2=steady + p3=4 + ## extension ## + unsigned active + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &active; + + return pigpio_command_ext( + gPigCommand, PI_CMD_FN, user_gpio, steady, 4, 1, ext, 1); +} + +int store_script(char *script) +{ + unsigned len; + gpioExtent_t ext[1]; + + /* + p1=0 + p2=0 + p3=len + ## extension ## + char[len] script + */ + + len = strlen(script); + + if (!len) return 0; + + ext[0].size = len; + ext[0].ptr = script; + + return pigpio_command_ext(gPigCommand, PI_CMD_PROC, 0, 0, len, 1, ext, 1); +} + +int run_script(unsigned script_id, unsigned numPar, uint32_t *param) +{ + gpioExtent_t ext[1]; + + /* + p1=script id + p2=0 + p3=numPar * 4 + ## extension ## + uint32_t[numPar] pars + */ + + ext[0].size = 4 * numPar; + ext[0].ptr = param; + + return pigpio_command_ext + (gPigCommand, PI_CMD_PROCR, script_id, 0, numPar*4, 1, ext, 1); +} + +int recvMax(void *buf, int bufsize, int sent) +{ + uint8_t scratch[4096]; + int remaining, fetch, count; + + if (sent < bufsize) count = sent; else count = bufsize; + + if (count) recv(gPigCommand, buf, count, MSG_WAITALL); + + remaining = sent - count; + + while (remaining) + { + fetch = remaining; + if (fetch > sizeof(scratch)) fetch = sizeof(scratch); + recv(gPigCommand, scratch, fetch, MSG_WAITALL); + remaining -= fetch; + } + + return count; +} + +int script_status(unsigned script_id, uint32_t *param) +{ + int status; + uint32_t p[PI_MAX_SCRIPT_PARAMS+1]; /* space for script status */ + + status = pigpio_command(gPigCommand, PI_CMD_PROCP, script_id, 0, 0); + + if (status > 0) + { + recvMax(p, sizeof(p), status); + status = p[0]; + if (param) memcpy(param, p+1, sizeof(p)-4); + } + + pthread_mutex_unlock(&command_mutex); + + return status; +} + +int stop_script(unsigned script_id) + {return pigpio_command(gPigCommand, PI_CMD_PROCS, script_id, 0, 1);} + +int delete_script(unsigned script_id) + {return pigpio_command(gPigCommand, PI_CMD_PROCD, script_id, 0, 1);} + +int bb_serial_read_open(unsigned user_gpio, unsigned baud, uint32_t bbBits) +{ + gpioExtent_t ext[1]; + + /* + p1=user_gpio + p2=baud + p3=4 + ## extension ## + unsigned bbBits + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &bbBits; + + return pigpio_command_ext( + gPigCommand, PI_CMD_SLRO, user_gpio, baud, 4, 1, ext, 1); +} + +int bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize) +{ + int bytes; + + bytes = pigpio_command(gPigCommand, PI_CMD_SLR, user_gpio, bufSize, 0); + + if (bytes > 0) + { + bytes = recvMax(buf, bufSize, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int bb_serial_read_close(unsigned user_gpio) + {return pigpio_command(gPigCommand, PI_CMD_SLRC, user_gpio, 0, 1);} + +int bb_serial_invert(unsigned user_gpio, unsigned invert) + {return pigpio_command(gPigCommand, PI_CMD_SLRI, user_gpio, invert, 1);} + +int i2c_open(unsigned i2c_bus, unsigned i2c_addr, uint32_t i2c_flags) +{ + gpioExtent_t ext[1]; + + /* + p1=i2c_bus + p2=i2c_addr + p3=4 + ## extension ## + uint32_t i2c_flags + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &i2c_flags; + + return pigpio_command_ext + (gPigCommand, PI_CMD_I2CO, i2c_bus, i2c_addr, 4, 1, ext, 1); +} + +int i2c_close(unsigned handle) + {return pigpio_command(gPigCommand, PI_CMD_I2CC, handle, 0, 1);} + +int i2c_write_quick(unsigned handle, unsigned bit) + {return pigpio_command(gPigCommand, PI_CMD_I2CWQ, handle, bit, 1);} + +int i2c_write_byte(unsigned handle, unsigned val) + {return pigpio_command(gPigCommand, PI_CMD_I2CWS, handle, val, 1);} + +int i2c_read_byte(unsigned handle) + {return pigpio_command(gPigCommand, PI_CMD_I2CRS, handle, 0, 1);} + +int i2c_write_byte_data(unsigned handle, unsigned reg, uint32_t val) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=4 + ## extension ## + uint32_t val + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &val; + + return pigpio_command_ext + (gPigCommand, PI_CMD_I2CWB, handle, reg, 4, 1, ext, 1); +} + +int i2c_write_word_data(unsigned handle, unsigned reg, uint32_t val) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=4 + ## extension ## + uint32_t val + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &val; + + return pigpio_command_ext + (gPigCommand, PI_CMD_I2CWW, handle, reg, 4, 1, ext, 1); +} + +int i2c_read_byte_data(unsigned handle, unsigned reg) + {return pigpio_command(gPigCommand, PI_CMD_I2CRB, handle, reg, 1);} + +int i2c_read_word_data(unsigned handle, unsigned reg) + {return pigpio_command(gPigCommand, PI_CMD_I2CRW, handle, reg, 1);} + +int i2c_process_call(unsigned handle, unsigned reg, uint32_t val) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=4 + ## extension ## + uint32_t val + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &val; + + return pigpio_command_ext + (gPigCommand, PI_CMD_I2CPC, handle, reg, 4, 1, ext, 1); +} + +int i2c_write_block_data( + unsigned handle, unsigned reg, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (gPigCommand, PI_CMD_I2CWK, handle, reg, count, 1, ext, 1); +} + +int i2c_read_block_data(unsigned handle, unsigned reg, char *buf) +{ + int bytes; + + bytes = pigpio_command(gPigCommand, PI_CMD_I2CRK, handle, reg, 0); + + if (bytes > 0) + { + bytes = recvMax(buf, 32, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int i2c_block_process_call( + unsigned handle, unsigned reg, char *buf, unsigned count) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + bytes = pigpio_command_ext + (gPigCommand, PI_CMD_I2CPK, handle, reg, count, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(buf, 32, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int i2c_read_i2c_block_data( + unsigned handle, unsigned reg, char *buf, uint32_t count) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=4 + ## extension ## + uint32_t count + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &count; + + bytes = pigpio_command_ext + (gPigCommand, PI_CMD_I2CRI, handle, reg, 4, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(buf, count, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + + +int i2c_write_i2c_block_data( + unsigned handle, unsigned reg, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (gPigCommand, PI_CMD_I2CWI, handle, reg, count, 1, ext, 1); +} + +int i2c_read_device(unsigned handle, char *buf, unsigned count) +{ + int bytes; + + bytes = pigpio_command(gPigCommand, PI_CMD_I2CRD, handle, count, 0); + + if (bytes > 0) + { + bytes = recvMax(buf, count, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int i2c_write_device(unsigned handle, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (gPigCommand, PI_CMD_I2CWD, handle, 0, count, 1, ext, 1); +} + +int i2c_zip( + unsigned handle, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=inLen + ## extension ## + char inBuf[inLen] + */ + + ext[0].size = inLen; + ext[0].ptr = inBuf; + + bytes = pigpio_command_ext + (gPigCommand, PI_CMD_I2CZ, handle, 0, inLen, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(outBuf, outLen, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud) +{ + gpioExtent_t ext[1]; + + /* + p1=SDA + p2=SCL + p3=4 + ## extension ## + uint32_t baud + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &baud; + + return pigpio_command_ext + (gPigCommand, PI_CMD_BI2CO, SDA, SCL, 4, 1, ext, 1); +} + +int bb_i2c_close(unsigned SDA) + {return pigpio_command(gPigCommand, PI_CMD_BI2CC, SDA, 0, 1);} + +int bb_i2c_zip( + unsigned SDA, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=SDA + p2=0 + p3=inLen + ## extension ## + char inBuf[inLen] + */ + + ext[0].size = inLen; + ext[0].ptr = inBuf; + + bytes = pigpio_command_ext + (gPigCommand, PI_CMD_BI2CZ, SDA, 0, inLen, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(outBuf, outLen, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int spi_open(unsigned channel, unsigned speed, uint32_t flags) +{ + gpioExtent_t ext[1]; + + /* + p1=channel + p2=speed + p3=4 + ## extension ## + uint32_t flags + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &flags; + + return pigpio_command_ext + (gPigCommand, PI_CMD_SPIO, channel, speed, 4, 1, ext, 1); +} + +int spi_close(unsigned handle) + {return pigpio_command(gPigCommand, PI_CMD_SPIC, handle, 0, 1);} + +int spi_read(unsigned handle, char *buf, unsigned count) +{ + int bytes; + + bytes = pigpio_command + (gPigCommand, PI_CMD_SPIR, handle, count, 0); + + if (bytes > 0) + { + bytes = recvMax(buf, count, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int spi_write(unsigned handle, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (gPigCommand, PI_CMD_SPIW, handle, 0, count, 1, ext, 1); +} + +int spi_xfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = txBuf; + + bytes = pigpio_command_ext + (gPigCommand, PI_CMD_SPIX, handle, 0, count, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(rxBuf, count, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int serial_open(char *dev, unsigned baud, unsigned flags) +{ + int len; + gpioExtent_t ext[1]; + + len = strlen(dev); + + /* + p1=baud + p2=flags + p3=len + ## extension ## + char dev[len] + */ + + ext[0].size = len; + ext[0].ptr = dev; + + return pigpio_command_ext + (gPigCommand, PI_CMD_SERO, baud, flags, len, 1, ext, 1); +} + +int serial_close(unsigned handle) + {return pigpio_command(gPigCommand, PI_CMD_SERC, handle, 0, 1);} + +int serial_write_byte(unsigned handle, unsigned val) + {return pigpio_command(gPigCommand, PI_CMD_SERWB, handle, val, 1);} + +int serial_read_byte(unsigned handle) + {return pigpio_command(gPigCommand, PI_CMD_SERRB, handle, 0, 1);} + +int serial_write(unsigned handle, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (gPigCommand, PI_CMD_SERW, handle, 0, count, 1, ext, 1); +} + +int serial_read(unsigned handle, char *buf, unsigned count) +{ + int bytes; + + bytes = pigpio_command + (gPigCommand, PI_CMD_SERR, handle, count, 0); + + if (bytes > 0) + { + bytes = recvMax(buf, count, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + +int serial_data_available(unsigned handle) + {return pigpio_command(gPigCommand, PI_CMD_SERDA, handle, 0, 1);} + +int custom_1(unsigned arg1, unsigned arg2, char *argx, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=arg1 + p2=arg2 + p3=count + ## extension ## + char argx[count] + */ + + ext[0].size = count; + ext[0].ptr = argx; + + return pigpio_command_ext( + gPigCommand, PI_CMD_CF1, arg1, arg2, count, 1, ext, 1); +} + + +int custom_2(unsigned arg1, char *argx, unsigned count, + char *retBuf, uint32_t retMax) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=arg1 + p2=retMax + p3=count + ## extension ## + char argx[count] + */ + + ext[0].size = count; + ext[0].ptr = argx; + + bytes = pigpio_command_ext + (gPigCommand, PI_CMD_CF2, arg1, retMax, count, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(retBuf, retMax, bytes); + } + + pthread_mutex_unlock(&command_mutex); + + return bytes; +} + + +int callback(unsigned user_gpio, unsigned edge, CBFunc_t f) + {return intCallback(user_gpio, edge, f, 0, 0);} + +int callback_ex(unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *user) + {return intCallback(user_gpio, edge, f, user, 1);} + +int callback_cancel(unsigned id) +{ + callback_t *p; + + p = gCallBackFirst; + + while (p) + { + if (p->id == id) + { + if (p->prev) p->prev->next = p->next; + else gCallBackFirst = p->next; + + if (p->next) p->next->prev = p->prev; + else gCallBackLast = p->prev; + + free(p); + + findNotifyBits(); + + return 0; + } + p = p->next; + } + return pigif_callback_not_found; +} + +int wait_for_edge(unsigned user_gpio, unsigned edge, double timeout) +{ + int triggered = 0; + int id; + double due; + + if (timeout <= 0.0) return 0; + + due = time_time() + timeout; + + id = callback_ex(user_gpio, edge, _wfe, &triggered); + + while (!triggered && (time_time() < due)) time_sleep(0.1); + + callback_cancel(id); + + return triggered; +} + + diff --git a/pigpiod_if.h b/pigpiod_if.h new file mode 100644 index 0000000..e2b52b4 --- /dev/null +++ b/pigpiod_if.h @@ -0,0 +1,2996 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +#ifndef PIGPIOD_IF_H +#define PIGPIOD_IF_H + +#include "pigpio.h" + +#define PIGPIOD_IF_VERSION 28 + +/*TEXT + +THIS LIBRARY IS DEPRECATED. NEW CODE SHOULD BE WRITTEN TO +USE THE MORE VERSATILE pigpiod_if2 LIBRARY. + +pigpiod_if is a C library for the Raspberry which allows control +of the GPIO via the socket interface to the pigpio daemon. + +*Features* + +o hardware timed PWM on any of GPIO 0-31 + +o hardware timed servo pulses on any of GPIO 0-31 + +o callbacks when any of GPIO 0-31 change state + +o callbacks at timed intervals + +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 rudimentary permission control over GPIO + +o a simple interface to start and stop new threads + +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. + +*Notes* + +The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals. + +*Usage* + +Include in your source files. + +Assuming your source is in prog.c use the following command to build + +. . +gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt +. . + +to run make sure the pigpio daemon is running + +. . +sudo pigpiod + + ./prog # sudo is not required to run programs linked to pigpiod_if +. . + +For examples see x_pigpiod_if.c within the pigpio archive file. + +*Notes* + +All the functions which return an int return < 0 on error + +TEXT*/ + +/*OVERVIEW + +ESSENTIAL + +pigpio_start Connects to the pigpio daemon +pigpio_stop Disconnects from the pigpio daemon + +BEGINNER + +set_mode Set a GPIO mode +get_mode Get a GPIO mode + +set_pull_up_down Set/clear GPIO pull up/down resistor + +gpio_read Read a GPIO +gpio_write Write a GPIO + +set_PWM_dutycycle Start/stop PWM pulses on a GPIO +get_PWM_dutycycle Get the PWM dutycycle in use on a 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 +callback_cancel Cancel a callback +wait_for_edge Wait for GPIO level change + +INTERMEDIATE + +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 + +clear_bank_1 Clear selected GPIO in bank 1 +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 + +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 + +SCRIPTS + +store_script Store a script +run_script Run a stored script +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 one or more waveforms + +wave_send_once Transmits a waveform once +wave_send_repeat Transmits a waveform repeatedly + +wave_chain Transmits a chain of waveforms + +wave_tx_busy Checks to see if the waveform has ended +wave_tx_stop Aborts the current waveform + +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 + +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 + +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 + +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_read_byte_data smbus read 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_read_block_data smbus read block data +i2c_block_process_call smbus block process call + +i2c_write_i2c_block_data smbus write I2C block data +i2c_read_i2c_block_data smbus read I2C block data + +i2c_read_device Reads the raw I2C device +i2c_write_device Writes the raw I2C device + +i2c_zip Performs multiple I2C transactions + +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 + +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_read Reads bytes from a serial device + +serial_data_available Returns number of bytes ready to be read + +CUSTOM + +custom_1 User custom function 1 +custom_2 User custom function 2 + +UTILITIES + +get_current_tick Get current tick (microseconds) + +get_hardware_revision Get hardware revision +get_pigpio_version Get the pigpio version +pigpiod_if_version Get the pigpiod_if version + +pigpio_error Get a text description of an error code. + +time_sleep Sleeps for a float number of seconds +time_time Float number of seconds since the epoch + +OVERVIEW*/ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*CBFunc_t) (unsigned user_gpio, unsigned level, uint32_t tick); + +typedef void (*CBFuncEx_t) + (unsigned user_gpio, unsigned level, uint32_t tick, void * user); + +typedef struct callback_s callback_t; + +/*F*/ +double time_time(void); +/*D +Return the current time in seconds since the Epoch. +D*/ + +/*F*/ +void time_sleep(double seconds); +/*D +Delay execution for a given number of seconds. + +. . +seconds: the number of seconds to delay. +. . +D*/ + +/*F*/ +char *pigpio_error(int errnum); +/*D +Return a text description for an error code. + +. . +errnum: the error code. +. . +D*/ + +/*F*/ +unsigned pigpiod_if_version(void); +/*D +Return the pigpiod_if version. +D*/ + +/*F*/ +pthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata); +/*D +Starts a new thread of execution with thread_func as the main routine. + +. . +thread_func: the main function for the new thread. + userdata: a pointer to an arbitrary argument. +. . + +Returns a pointer to pthread_t if OK, otherwise NULL. + +The function is passed the single argument userdata. + +The thread can be cancelled by passing the pointer to pthread_t to +[*stop_thread*]. +D*/ + +/*F*/ +void stop_thread(pthread_t *pth); +/*D +Cancels the thread pointed at by pth. + +. . +pth: the thread to be stopped. +. . + +No value is returned. + +The thread to be stopped should have been started with [*start_thread*]. +D*/ + +/*F*/ +int pigpio_start(char *addrStr, char *portStr); +/*D +Connect to the pigpio daemon. Reserving command and +notification streams. + +. . +addrStr: specifies the host or IP address of the Pi running the + pigpio daemon. It may be NULL in which case localhost + is used unless overridden by the PIGPIO_ADDR environment + variable. + +portStr: specifies the port address used by the Pi running the + pigpio daemon. It may be NULL in which case "8888" + is used unless overridden by the PIGPIO_PORT environment + variable. +. . +D*/ + +/*F*/ +void pigpio_stop(void); +/*D +Terminates the connection to the pigpio daemon and releases +resources used by the library. +D*/ + +/*F*/ +int set_mode(unsigned gpio, unsigned mode); +/*D +Set the GPIO mode. + +. . +gpio: 0-53. +mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1, + PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5. +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE, +or PI_NOT_PERMITTED. +D*/ + +/*F*/ +int get_mode(unsigned gpio); +/*D +Get the GPIO mode. + +. . +gpio: 0-53. +. . + +Returns the GPIO mode if OK, otherwise PI_BAD_GPIO. +D*/ + +/*F*/ +int set_pull_up_down(unsigned gpio, unsigned pud); +/*D +Set or clear the GPIO pull-up/down resistor. + +. . +gpio: 0-53. + pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF. +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_PUD, +or PI_NOT_PERMITTED. +D*/ + +/*F*/ +int gpio_read(unsigned gpio); +/*D +Read the GPIO level. + +. . +gpio:0-53. +. . + +Returns the GPIO level if OK, otherwise PI_BAD_GPIO. +D*/ + +/*F*/ +int gpio_write(unsigned gpio, unsigned level); +/*D +Write the GPIO level. + +. . + gpio: 0-53. +level: 0, 1. +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_LEVEL, +or PI_NOT_PERMITTED. + +Notes + +If PWM or servo pulses are active on the GPIO they are switched off. +D*/ + +/*F*/ +int set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle); +/*D +Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO. + +. . +user_gpio: 0-31. +dutycycle: 0-range (range defaults to 255). +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYCYCLE, +or PI_NOT_PERMITTED. +Notes + +The [*set_PWM_range*] function may be used to change the +default range of 255. +D*/ + +/*F*/ +int get_PWM_dutycycle(unsigned user_gpio); +/*D +Return the PWM dutycycle in use on a GPIO. + +. . +user_gpio: 0-31. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. + +For normal PWM the dutycycle will be out of the defined range +for the GPIO (see [*get_PWM_range*]). + +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). +D*/ + +/*F*/ +int set_PWM_range(unsigned user_gpio, unsigned range); +/*D +Set the range of PWM values to be used on the GPIO. + +. . +user_gpio: 0-31. + range: 25-40000. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE, +or PI_NOT_PERMITTED. + +Notes + +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 of the 18 available GPIO frequencies is + +. . + 25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6), + 400(#7), 500(#8), 625(#9), 800(#10), 1000(#11), 1250(#12), +2000(#13), 2500(#14), 4000(#15), 5000(#16), 10000(#17), 20000(#18) +. . + +The real value set by set_PWM_range is (dutycycle * real range) / range. +D*/ + +/*F*/ +int get_PWM_range(unsigned user_gpio); +/*D +Get the range of PWM values being used on the GPIO. + +. . +user_gpio: 0-31. +. . + +Returns the dutycycle range used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +If a hardware clock or hardware PWM is active on the GPIO the +reported range will be 1000000 (1M). +D*/ + +/*F*/ +int get_PWM_real_range(unsigned user_gpio); +/*D +Get the real underlying range of PWM values being used on the GPIO. + +. . +user_gpio: 0-31. +. . + +Returns the real range used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +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. + +D*/ + +/*F*/ +int set_PWM_frequency(unsigned user_gpio, unsigned frequency); +/*D +Set the frequency (in Hz) of the PWM to be used on the GPIO. + +. . +user_gpio: 0-31. +frequency: >=0 (Hz). +. . + +Returns the numerically closest frequency if OK, otherwise +PI_BAD_USER_GPIO or PI_NOT_PERMITTED. + +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 +. . +D*/ + +/*F*/ +int get_PWM_frequency(unsigned user_gpio); +/*D +Get the frequency of PWM being used on the GPIO. + +. . +user_gpio: 0-31. +. . + +For normal PWM the frequency will be that defined for the GPIO by +[*set_PWM_frequency*]. + +If a hardware clock is active on the GPIO the reported frequency +will be that set by [*hardware_clock*]. + +If hardware PWM is active on the GPIO the reported frequency +will be that set by [*hardware_PWM*]. + +Returns the frequency (in hertz) used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. +D*/ + +/*F*/ +int set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth); +/*D +Start (500-2500) or stop (0) servo pulses on the GPIO. + +. . + user_gpio: 0-31. +pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise). +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_PULSEWIDTH or +PI_NOT_PERMITTED. + +The selected pulsewidth will continue to be transmitted until +changed by a subsequent call to set_servo_pulsewidth. + +The pulsewidths supported by servos varies and should probably be +determined by experiment. 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. + +OTHER UPDATE RATES: + +This function updates servos at 50Hz. If you wish to use a different +update frequency you will have to use the PWM functions. + +. . +Update Rate (Hz) 50 100 200 400 500 +1E6/Hz 20000 10000 5000 2500 2000 +. . + +Firstly set the desired PWM frequency using [*set_PWM_frequency*]. + +Then set the PWM range using [*set_PWM_range*] to 1E6/Hz. +Doing this allows you to use units of microseconds when setting +the servo pulsewidth. + +E.g. If you want to update a servo connected to GPIO 25 at 400Hz + +. . +set_PWM_frequency(25, 400); +set_PWM_range(25, 2500); +. . + +Thereafter use the [*set_PWM_dutycycle*] function to move the servo, +e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse. +D*/ + +/*F*/ +int get_servo_pulsewidth(unsigned user_gpio); +/*D +Return the servo pulsewidth in use on a GPIO. + +. . +user_gpio: 0-31. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO. +D*/ + +/*F*/ +int notify_open(void); +/*D +Get a free notification handle. + +Returns a handle greater than or equal to zero if OK, +otherwise PI_NO_HANDLE. + +A notification is a method for being notified of GPIO state +changes via a pipe. + +Pipes are only accessible from the local machine so this function +serves no purpose if you are using the library from a remote machine. +The in-built (socket) notifications provided by [*callback*] +should be used instead. + +Notifications for handle x will be available at the pipe +named /dev/pigpiox (where x is the handle number). +E.g. if the function returns 15 then the notifications must be +read from /dev/pigpio15. +D*/ + +/*F*/ +int notify_begin(unsigned handle, uint32_t bits); +/*D +Start notifications on a previously opened handle. + +. . +handle: 0-31 (as returned by [*notify_open*]) + bits: a mask indicating the GPIO to be notified. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +The notification sends state changes for each GPIO whose +corresponding bit in bits is set. + +Each notification occupies 12 bytes in the fifo as follows: + +. . +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. + +PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags +indicate a GPIO which has had a watchdog timeout. + +PI_NTFY_FLAGS_ALIVE, if bit 6 is set 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<=0 + numBytes: >=1 + str: an array of chars. +. . + +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS, +PI_BAD_STOP_BITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET, +or PI_TOO_MANY_PULSES. + +NOTES: + +The serial data is formatted as one start bit, [*data_bits*] data bits, +and [*stop_bits*]/2 stop bits. + +It is legal to add serial data streams with different baud rates to +the same waveform. + +[*numBytes*] is the number of bytes of data in str. + +The bytes required for each character depend upon [*data_bits*]. + +For [*data_bits*] 1-8 there will be one byte per character. +For [*data_bits*] 9-16 there will be two bytes per character. +For [*data_bits*] 17-32 there will be four bytes per character. +D*/ + +/*F*/ +int wave_create(void); +/*D +This function creates a waveform from the data provided by the prior +calls to the [*wave_add_**] functions. 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. + +The data provided by the [*wave_add_**] functions is 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. + +Normal usage would be + +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*] to create the waveform and get a unique id + +Repeat steps 2 and 3 as needed. + +Step 4. [*wave_send_**] with the id of the waveform to transmit. + +A waveform comprises one or more pulses. Each pulse consists of a +[*gpioPulse_t*] structure. + +. . +typedef struct +{ + uint32_t gpioOn; + uint32_t gpioOff; + uint32_t usDelay; +} gpioPulse_t; +. . + +The fields specify + +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. + +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(unsigned wave_id); +/*D +This function deletes the waveform with id wave_id. + +. . +wave_id: >=0, as returned by [*wave_create*]. +. . + +Wave ids are allocated in order, 0, 1, 2, etc. + +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). + +Returns 0 if OK, otherwise PI_BAD_WAVE_ID. +D*/ + +/*F*/ +int wave_send_once(unsigned wave_id); +/*D +This function transmits the waveform with id wave_id. The waveform +is sent once. + +NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled. + +. . +wave_id: >=0, as returned by [*wave_create*]. +. . + +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. +D*/ + +/*F*/ +int wave_send_repeat(unsigned wave_id); +/*D +This function transmits the waveform with id wave_id. The waveform +cycles until cancelled (either by the sending of a new waveform or +by [*wave_tx_stop*]). + +NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled. + +. . +wave_id: >=0, as returned by [*wave_create*]. +. . + +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. +D*/ + +/*F*/ +int wave_chain(char *buf, unsigned bufSize); +/*D +This function transmits a chain of waveforms. + +NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled. + +The waves to be transmitted are specified by the contents of buf +which contains an ordered list of [*wave_id*]s and optional command +codes and related data. + +. . + buf: pointer to the wave_ids and optional command codes +bufSize: the number of bytes in buf +. . + +Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER, +PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID. + +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. + +... +#include +#include + +#define WAVES 5 +#define GPIO 4 + +int main(int argc, char *argv[]) +{ + int i, wid[WAVES]; + + if (pigpio_start(0, 0)<0) return -1; + + set_mode(GPIO, PI_OUTPUT); + + for (i=0; i=0, as returned by [*store_script*]. + numPar: 0-10, the number of parameters. + param: an array of parameters. +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM + +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. +D*/ + +/*F*/ +int script_status(unsigned script_id, uint32_t *param); +/*D +This function returns the run status of a stored script as well +as the current values of parameters 0 to 9. + +. . +script_id: >=0, as returned by [*store_script*]. + param: an array to hold the returned 10 parameters. +. . + +The function returns greater than or equal to 0 if OK, +otherwise PI_BAD_SCRIPT_ID. + +The run status may be + +. . +PI_SCRIPT_INITING +PI_SCRIPT_HALTED +PI_SCRIPT_RUNNING +PI_SCRIPT_WAITING +PI_SCRIPT_FAILED +. . + +The current value of script parameters 0 to 9 are returned in param. +D*/ + +/*F*/ +int stop_script(unsigned script_id); +/*D +This function stops a running script. + +. . +script_id: >=0, as returned by [*store_script*]. +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. +D*/ + +/*F*/ +int delete_script(unsigned script_id); +/*D +This function deletes a stored script. + +. . +script_id: >=0, as returned by [*store_script*]. +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. +D*/ + +/*F*/ +int bb_serial_read_open(unsigned user_gpio, unsigned baud, unsigned data_bits); +/*D +This function opens a GPIO for bit bang reading of serial data. + +. . +user_gpio: 0-31. + baud: 50-250000 +data_bits: 1-32 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, +or PI_GPIO_IN_USE. + +The serial data is returned in a cyclic buffer and is read using +bb_serial_read. + +It is the caller's responsibility to read data from the cyclic buffer +in a timely fashion. +D*/ + +/*F*/ +int bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize); +/*D +This function copies up to bufSize bytes of data read from the +bit bang serial cyclic buffer to the buffer starting at buf. + +. . +user_gpio: 0-31, previously opened with [*bb_serial_read_open*]. + buf: an array to receive the read bytes. + bufSize: >=0 +. . + +Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO +or PI_NOT_SERIAL_GPIO. + +The bytes returned for each character depend upon the number of +data bits [*data_bits*] specified in the [*bb_serial_read_open*] command. + +For [*data_bits*] 1-8 there will be one byte per character. +For [*data_bits*] 9-16 there will be two bytes per character. +For [*data_bits*] 17-32 there will be four bytes per character. +D*/ + +/*F*/ +int bb_serial_read_close(unsigned user_gpio); +/*D +This function closes a GPIO for bit bang reading of serial data. + +. . +user_gpio: 0-31, previously opened with [*bb_serial_read_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO. +D*/ + +/*F*/ +int bb_serial_invert(unsigned user_gpio, unsigned invert); +/*D +This function inverts serial logic for big bang serial reads. + +. . +user_gpio: 0-31, previously opened with [*bb_serial_read_open*]. + invert: 0-1, 1 invert, 0 normal. +. . + +Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT. +D*/ + +/*F*/ +int i2c_open(unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags); +/*D +This returns a handle for the device at address i2c_addr on bus i2c_bus. + +. . + i2c_bus: >=0. + i2c_addr: 0-0x7F. +i2c_flags: 0. +. . + +No flags are currently defined. This parameter should be set to zero. + +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 + +Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR, +PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED. + +For the SMBus commands the low level transactions are shown at the end +of the function description. The following abbreviations are used. + +. . +S (1 bit) : Start bit +P (1 bit) : Stop bit +Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. +A, NA (1 bit) : Accept and not accept bit. +Addr (7 bits): I2C 7 bit address. +Comm (8 bits): Command byte, a data byte which often selects a register. +Data (8 bits): A data byte. +Count (8 bits): A data byte containing the length of a block operation. + +[..]: Data sent by the device. +. . +D*/ + +/*F*/ +int i2c_close(unsigned handle); +/*D +This closes the I2C device associated with the handle. + +. . +handle: >=0, as returned by a call to [*i2c_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int i2c_write_quick(unsigned handle, unsigned bit); +/*D +This sends a single bit (in the Rd/Wr bit) to the device associated +with handle. + +. . +handle: >=0, as returned by a call to [*i2c_open*]. + bit: 0-1, the value to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Quick command. SMBus 2.0 5.5.1 +. . +S Addr Rd/Wr [A] P +. . +D*/ + +/*F*/ +int i2c_write_byte(unsigned handle, unsigned bVal); +/*D +This sends a single byte to the device associated with handle. + +. . +handle: >=0, as returned by a call to [*i2c_open*]. + bVal: 0-0xFF, the value to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Send byte. SMBus 2.0 5.5.2 +. . +S Addr Wr [A] Data [A] P +. . +D*/ + +/*F*/ +int i2c_read_byte(unsigned handle); +/*D +This reads a single byte from the device associated with handle. + +. . +handle: >=0, as returned by a call to [*i2c_open*]. +. . + +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +or PI_I2C_READ_FAILED. + +Receive byte. SMBus 2.0 5.5.3 +. . +S Addr Rd [A] [Data] NA P +. . +D*/ + +/*F*/ +int i2c_write_byte_data(unsigned handle, unsigned i2c_reg, unsigned bVal); +/*D +This writes a single byte to the specified register of the device +associated with handle. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write. + bVal: 0-0xFF, the value to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Write byte. SMBus 2.0 5.5.4 +. . +S Addr Wr [A] Comm [A] Data [A] P +. . +D*/ + +/*F*/ +int i2c_write_word_data(unsigned handle, unsigned i2c_reg, unsigned wVal); +/*D +This writes a single 16 bit word to the specified register of the device +associated with handle. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write. + wVal: 0-0xFFFF, the value to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Write word. SMBus 2.0 5.5.4 +. . +S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P +. . +D*/ + +/*F*/ +int i2c_read_byte_data(unsigned handle, unsigned i2c_reg); +/*D +This reads a single byte from the specified register of the device +associated with handle. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to read. +. . + +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Read byte. SMBus 2.0 5.5.5 +. . +S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P +. . +D*/ + +/*F*/ +int i2c_read_word_data(unsigned handle, unsigned i2c_reg); +/*D +This reads a single 16 bit word from the specified register of the device +associated with handle. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to read. +. . + +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Read word. SMBus 2.0 5.5.5 +. . +S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P +. . +D*/ + +/*F*/ +int i2c_process_call(unsigned handle, unsigned i2c_reg, unsigned wVal); +/*D +This writes 16 bits of data to the specified register of the device +associated with handle and and reads 16 bits of data in return. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write/read. + wVal: 0-0xFFFF, the value to write. +. . + +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Process call. SMBus 2.0 5.5.6 +. . +S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] + S Addr Rd [A] [DataLow] A [DataHigh] NA P +. . +D*/ + +/*F*/ +int i2c_write_block_data( +unsigned handle, unsigned i2c_reg, char *buf, unsigned count); +/*D +This writes up to 32 bytes to the specified register of the device +associated with handle. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write. + buf: an array with the data to send. + count: 1-32, the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Block write. SMBus 2.0 5.5.7 +. . +S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P +. . +D*/ + +/*F*/ +int i2c_read_block_data(unsigned handle, unsigned i2c_reg, char *buf); +/*D +This reads a block of up to 32 bytes from the specified register of +the device associated with handle. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to read. + buf: an array to receive the read data. +. . + +The amount of returned data is set by the device. + +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Block read. SMBus 2.0 5.5.7 +. . +S Addr Wr [A] Comm [A] + S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P +. . +D*/ + +/*F*/ +int i2c_block_process_call( +unsigned handle, unsigned i2c_reg, char *buf, unsigned count); +/*D +This writes data bytes to the specified register of the device +associated with handle and reads a device specified number +of bytes of data in return. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write/read. + buf: an array with the data to send and to receive the read data. + count: 1-32, the number of bytes to write. +. . + + +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +The smbus 2.0 documentation states that a minimum of 1 byte may be +sent and a minimum of 1 byte may be received. The total number of +bytes sent/received must be 32 or less. + +Block write-block read. SMBus 2.0 5.5.8 +. . +S Addr Wr [A] Comm [A] Count [A] Data [A] ... + S Addr Rd [A] [Count] A [Data] ... A P +. . +D*/ + +/*F*/ +int i2c_read_i2c_block_data( +unsigned handle, unsigned i2c_reg, char *buf, unsigned count); +/*D +This reads count bytes from the specified register of the device +associated with handle . The count may be 1-32. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to read. + buf: an array to receive the read data. + count: 1-32, the number of bytes to read. +. . + +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +. . +S Addr Wr [A] Comm [A] + S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P +. . +D*/ + + +/*F*/ +int i2c_write_i2c_block_data( +unsigned handle, unsigned i2c_reg, char *buf, unsigned count); +/*D +This writes 1 to 32 bytes to the specified register of the device +associated with handle. + +. . + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write. + buf: the data to write. + count: 1-32, the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +. . +S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P +. . +D*/ + +/*F*/ +int i2c_read_device(unsigned handle, char *buf, unsigned count); +/*D +This reads count bytes from the raw device into buf. + +. . +handle: >=0, as returned by a call to [*i2c_open*]. + buf: an array to receive the read data bytes. + count: >0, the number of bytes to read. +. . + +Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_READ_FAILED. +D*/ + +/*F*/ +int i2c_write_device(unsigned handle, char *buf, unsigned count); +/*D +This writes count bytes from buf to the raw device. + +. . +handle: >=0, as returned by a call to [*i2c_open*]. + buf: an array containing the data bytes to write. + count: >0, the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. +D*/ + +/*F*/ +int i2c_zip( + unsigned handle, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen); +/*D +This function executes a sequence of I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +. . +handle: >=0, as returned by a call to [*i2cOpen*] + inBuf: pointer to the concatenated I2C commands, see below + inLen: size of command buffer +outBuf: pointer to buffer to hold returned data +outLen: size of output buffer +. . + +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN. +PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG. + +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. +The flags default to 0. The address and flags maintain their +previous value until updated. + +The returned I2C data is stored in consecutive locations of outBuf. + +... +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 +... + +D*/ + +/*F*/ +int bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud); +/*D +This function selects a pair of GPIO for bit banging I2C at a +specified baud rate. + +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 + +. . + SDA: 0-31 + SCL: 0-31 +baud: 50-500000 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or +PI_GPIO_IN_USE. + +NOTE: + +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. +D*/ + +/*F*/ +int bb_i2c_close(unsigned SDA); +/*D +This function stops bit banging I2C on a pair of GPIO previously +opened with [*bb_i2c_open*]. + +. . +SDA: 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*] +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO. +D*/ + +/*F*/ +int bb_i2c_zip( + unsigned SDA, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen); +/*D +This function executes a sequence of bit banged I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +. . + SDA: 0-31 (as used in a prior call to [*bb_i2c_open*]) + inBuf: pointer to the concatenated I2C commands, see below + inLen: size of command buffer +outBuf: pointer to buffer to hold returned data +outLen: size of output buffer +. . + +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER, +PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN, +PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED. + +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. + +The returned I2C data is stored in consecutive locations of outBuf. + +... +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 +... +D*/ + +/*F*/ +int spi_open(unsigned spi_channel, unsigned baud, unsigned spi_flags); +/*D +This function returns a handle for the SPI device on the channel. +Data will be transferred at baud bits per second. The flags may +be used to modify the default behaviour of 4-wire operation, mode 0, +active low chip select. + +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 + +. . +spi_channel: 0-1 (0-2 for the auxiliary SPI). + baud: 32K-125M (values above 30M are unlikely to work). + spi_flags: see below. +. . + +Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL, +PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED. + +spi_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 [*spi_read*], [*spi_write*], and [*spi_xfer*] functions +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 word. +For bits 9-16 there will be two bytes per word. +For bits 17-32 there will be four bytes per word. + +Multi-byte transfers are made in least significant byte first order. + +E.g. to transfer 32 11-bit words buf should contain 64 bytes +and count should be 64. + +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. +D*/ + +/*F*/ +int spi_close(unsigned handle); +/*D +This functions closes the SPI device identified by the handle. + +. . +handle: >=0, as returned by a call to [*spi_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int spi_read(unsigned handle, char *buf, unsigned count); +/*D +This function reads count bytes of data from the SPI +device associated with the handle. + +. . +handle: >=0, as returned by a call to [*spi_open*]. + buf: an array to receive the read data bytes. + count: the number of bytes to read. +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + +/*F*/ +int spi_write(unsigned handle, char *buf, unsigned count); +/*D +This function writes count bytes of data from buf to the SPI +device associated with the handle. + +. . +handle: >=0, as returned by a call to [*spi_open*]. + buf: the data bytes to write. + count: the number of bytes to write. +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + +/*F*/ +int spi_xfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count); +/*D +This function transfers count bytes of data from txBuf to the SPI +device associated with the handle. Simultaneously count bytes of +data are read from the device and placed in rxBuf. + +. . +handle: >=0, as returned by a call to [*spi_open*]. + txBuf: the data bytes to write. + rxBuf: the received data bytes. + count: the number of bytes to transfer. +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + +/*F*/ +int serial_open(char *ser_tty, unsigned baud, unsigned ser_flags); +/*D +This function opens a serial device at a specified baud rate +with specified flags. The device name must start with +/dev/tty or /dev/serial. + +. . + ser_tty: the serial device to open. + baud: the baud rate in bits per second, see below. +ser_flags: 0. +. . + +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or +PI_SER_OPEN_FAILED. + +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. + +No flags are currently defined. This parameter should be set to zero. +D*/ + +/*F*/ +int serial_close(unsigned handle); +/*D +This function closes the serial device associated with handle. + +. . +handle: >=0, as returned by a call to [*serial_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int serial_write_byte(unsigned handle, unsigned bVal); +/*D +This function writes bVal to the serial port associated with handle. + +. . +handle: >=0, as returned by a call to [*serial_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. +D*/ + +/*F*/ +int serial_read_byte(unsigned handle); +/*D +This function reads a byte from the serial port associated with handle. + +. . +handle: >=0, as returned by a call to [*serial_open*]. +. . + +Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED. + +If no data is ready PI_SER_READ_NO_DATA is returned. +D*/ + +/*F*/ +int serial_write(unsigned handle, char *buf, unsigned count); +/*D +This function writes count bytes from buf to the the serial port +associated with handle. + +. . +handle: >=0, as returned by a call to [*serial_open*]. + buf: the array of bytes to write. + count: the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. +D*/ + +/*F*/ +int serial_read(unsigned handle, char *buf, unsigned count); +/*D +This function reads up to count bytes from the the serial port +associated with handle and writes them to buf. + +. . +handle: >=0, as returned by a call to [*serial_open*]. + buf: an array to receive the read data. + count: the maximum number of bytes to read. +. . + +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED. + +If no data is ready zero is returned. +D*/ + +/*F*/ +int serial_data_available(unsigned handle); +/*D +Returns the number of bytes available to be read from the +device associated with handle. + +. . +handle: >=0, as returned by a call to [*serial_open*]. +. . + +Returns the number of bytes of data available (>=0) if OK, +otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int custom_1(unsigned arg1, unsigned arg2, char *argx, unsigned argc); +/*D +This function is available for user customisation. + +It returns a single integer value. + +. . +arg1: >=0 +arg2: >=0 +argx: extra (byte) arguments +argc: number of extra arguments +. . + +Returns >= 0 if OK, less than 0 indicates a user defined error. +D*/ + + +/*F*/ +int custom_2(unsigned arg1, char *argx, unsigned argc, + char *retBuf, unsigned retMax); +/*D +This function is available for user customisation. + +It differs from custom_1 in that it returns an array of bytes +rather than just an integer. + +The return value is an integer indicating the number of returned bytes. +. . + arg1: >=0 + argc: extra (byte) arguments + count: number of extra arguments +retBuf: buffer for returned data +retMax: maximum number of bytes to return +. . + +Returns >= 0 if OK, less than 0 indicates a user defined error. + +Note, the number of returned bytes will be retMax or less. +D*/ + + +/*F*/ +int callback(unsigned user_gpio, unsigned edge, CBFunc_t f); +/*D +This function initialises a new callback. + +. . +user_gpio: 0-31. + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. + f: the callback function. +. . + +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +The callback is called with the GPIO, edge, and tick, whenever the +GPIO has the identified edge. + +. . +Parameter Value Meaning + +GPIO 0-31 The GPIO which has changed state + +edge 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (a watchdog timeout) + +tick 32 bit The number of microseconds since boot + WARNING: this wraps around from + 4294967295 to 0 roughly every 72 minutes +. . +D*/ + +/*F*/ +int callback_ex + (unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata); +/*D +This function initialises a new callback. + +. . +user_gpio: 0-31. + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. + f: the callback function. + userdata: a pointer to arbitrary user data. +. . + +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +The callback is called with the GPIO, edge, tick, and user, whenever +the GPIO has the identified edge. + +. . +Parameter Value Meaning + +GPIO 0-31 The GPIO which has changed state + +edge 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (a watchdog timeout) + +tick 32 bit The number of microseconds since boot + WARNING: this wraps around from + 4294967295 to 0 roughly every 72 minutes + +userdata pointer Pointer to an arbitrary object +. . +D*/ + +/*F*/ +int callback_cancel(unsigned callback_id); +/*D +This function cancels a callback identified by its id. + +. . +callback_id: >=0, as returned by a call to [*callback*] or [*callback_ex*]. +. . + +The function returns 0 if OK, otherwise pigif_callback_not_found. +D*/ + +/*F*/ +int wait_for_edge(unsigned user_gpio, unsigned edge, double timeout); +/*D +This function waits for edge on the GPIO for up to timeout +seconds. + +. . +user_gpio: 0-31. + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. + timeout: >=0. +. . + +The function returns 1 if the edge occurred, otherwise 0. + +The function returns when the edge occurs or after the timeout. +D*/ + +/*PARAMS + +active :: 0-1000000 + +The number of microseconds level changes are reported for once +a noise filter has been triggered (by [*steady*] microseconds of +a stable level). + +*addrStr:: +A string specifying the host or IP address of the Pi running +the pigpio daemon. It may be NULL in which case localhost +is used unless overridden by the PIGPIO_ADDR environment +variable. + +arg1:: +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +arg2:: +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +argc:: +The count of bytes passed to a user customised function. + +*argx:: +A pointer to an array of bytes passed to a user customised function. +Its meaning and content is defined by the customiser. + +baud:: +The speed of serial communication (I2C, SPI, serial link, waves) in +bits per second. + +bit:: +A value of 0 or 1. + +bits:: +A value used to select GPIO. If bit n of bits is set then GPIO n is +selected. + +A convenient way to set bit n is to or in (1<=0, as returned by a call to [*callback*] or [*callback_ex*]. This is +passed to [*callback_cancel*] to cancel the callback. + +CBFunc_t:: +. . +typedef void (*CBFunc_t) + (unsigned user_gpio, unsigned level, uint32_t tick); +. . + +CBFuncEx_t:: +. . +typedef void (*CBFuncEx_t) + (unsigned user_gpio, unsigned level, uint32_t tick, void * user); +. . + +char:: +A single character, an 8 bit quantity able to store 0-255. + +clkfreq::4689-250000000 (250M) +The hardware clock frequency. + +count:: +The number of bytes to be transferred in an I2C, SPI, or Serial +command. + +data_bits::1-32 +The number of data bits in each character of serial data. + +. . +#define PI_MIN_WAVE_DATABITS 1 +#define PI_MAX_WAVE_DATABITS 32 +. . + +double:: +A floating point number. + +dutycycle::0-range +A number representing the ratio of on time to off time for PWM. + +The number may vary between 0 and range (default 255) where +0 is off and range is fully on. + +edge:: +Used to identify a GPIO level transition of interest. A rising edge is +a level change from 0 to 1. A falling edge is a level change from 1 to 0. + +. . +RISING_EDGE 0 +FALLING_EDGE 1 +EITHER_EDGE. 2 +. . + +errnum:: +A negative number indicating a function call failed and the nature +of the error. + +f:: +A function. + +frequency::>=0 +The number of times a GPIO is swiched on and off per second. This +can be set per GPIO and may be as little as 5Hz or as much as +40KHz. The GPIO will be on for a proportion of the time as defined +by its dutycycle. + + +gpio:: +A Broadcom numbered GPIO, in the range 0-53. + +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 [*get_hardware_revision*]. + +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 - - - - +. . + +gpioPulse_t:: +. . +typedef struct +{ +uint32_t gpioOn; +uint32_t gpioOff; +uint32_t usDelay; +} gpioPulse_t; +. . + +gpioThreadFunc_t:: +. . +typedef void *(gpioThreadFunc_t) (void *); +. . + +handle::>=0 +A number referencing an object opened by one of [*i2c_open*], [*notify_open*], +[*serial_open*], and [*spi_open*]. + +i2c_addr:: 0-0x7F +The address of a device on the I2C bus. + +i2c_bus::>=0 +An I2C bus number. + +i2c_flags::0 +Flags which modify an I2C open command. None are currently defined. + +i2c_reg:: 0-255 +A register of an I2C device. + +*inBuf:: +A buffer used to pass data to a function. + +inLen:: +The number of bytes of data in a buffer. + +int:: +A whole number, negative or positive. + +invert:: +A flag used to set normal or inverted bit bang serial data level logic. + +level:: +The level of a GPIO. Low or High. + +. . +PI_OFF 0 +PI_ON 1 + +PI_CLEAR 0 +PI_SET 1 + +PI_LOW 0 +PI_HIGH 1 +. . + +There is one exception. If a watchdog expires on a GPIO the level will be +reported as PI_TIMEOUT. See [*set_watchdog*]. + +. . +PI_TIMEOUT 2 +. . + +mode::0-7 +The operational mode of a GPIO, normally INPUT or OUTPUT. + +. . +PI_INPUT 0 +PI_OUTPUT 1 +PI_ALT0 4 +PI_ALT1 5 +PI_ALT2 6 +PI_ALT3 7 +PI_ALT4 3 +PI_ALT5 2 +. . + +numBytes:: +The number of bytes used to store characters in a string. Depending +on the number of bits per character there may be 1, 2, or 4 bytes +per character. + +numPar:: 0-10 +The number of parameters passed to a script. + +numPulses:: +The number of pulses to be added to a waveform. + +offset:: +The associated data starts this number of microseconds from the start of +the waveform. + +*outBuf:: +A buffer used to return data from a function. + +outLen:: +The size in bytes of an output buffer. + +*param:: +An array of script parameters. + +*portStr:: +A string specifying the port address used by the Pi running +the pigpio daemon. It may be NULL in which case "8888" +is used unless overridden by the PIGPIO_PORT environment +variable. + +*pth:: +A thread identifier, returned by [*start_thread*]. + + +pthread_t:: +A thread identifier. + +pud::0-2 +The setting of the pull up/down resistor for a GPIO, which may be off, +pull-up, or pull-down. +. . +PI_PUD_OFF 0 +PI_PUD_DOWN 1 +PI_PUD_UP 2 +. . + +pulseLen:: +1-100, the length of a trigger pulse in microseconds. + +*pulses:: +An array of pulses to be added to a waveform. + +pulsewidth::0, 500-2500 +. . +PI_SERVO_OFF 0 +PI_MIN_SERVO_PULSEWIDTH 500 +PI_MAX_SERVO_PULSEWIDTH 2500 +. . + +PWMduty::0-1000000 (1M) +The hardware PWM dutycycle. + +. . +#define PI_HW_PWM_RANGE 1000000 +. . + +PWMfreq::1-125000000 (125M) +The hardware PWM frequency. + +. . +#define PI_HW_PWM_MIN_FREQ 1 +#define PI_HW_PWM_MAX_FREQ 125000000 +. . + +range::25-40000 +The permissible dutycycle values are 0-range. +. . +PI_MIN_DUTYCYCLE_RANGE 25 +PI_MAX_DUTYCYCLE_RANGE 40000 +. . + +*retBuf:: +A buffer to hold a number of bytes returned to a used customised function, + +retMax:: +The maximum number of bytes a user customised function should return. + + +*rxBuf:: +A pointer to a buffer to receive data. + +SCL:: +The user GPIO to use for the clock when bit banging I2C. + +*script:: +A pointer to the text of a script. + +script_id:: +An id of a stored script as returned by [*store_script*]. + +SDA:: +The user GPIO to use for data when bit banging I2C. + +seconds:: +The number of seconds. + +ser_flags:: +Flags which modify a serial open command. None are currently defined. + +*ser_tty:: +The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1. + +size_t:: +A standard type used to indicate the size of an object in bytes. + +spi_channel:: +A SPI channel, 0-2. + +spi_flags:: +See [*spi_open*]. + +steady :: 0-300000 + +The number of microseconds level changes must be stable for +before reporting the level changed ([*set_glitch_filter*]) or triggering +the active part of a noise filter ([*set_noise_filter*]). + +stop_bits::2-8 +The number of (half) stop bits to be used when adding serial data +to a waveform. + +. . +#define PI_MIN_WAVE_HALFSTOPBITS 2 +#define PI_MAX_WAVE_HALFSTOPBITS 8 +. . + +*str:: + An array of characters. + +thread_func:: +A function of type gpioThreadFunc_t used as the main function of a +thread. + +timeout:: +A GPIO watchdog timeout in milliseconds. +. . +PI_MIN_WDOG_TIMEOUT 0 +PI_MAX_WDOG_TIMEOUT 60000 +. . + +*txBuf:: +An array of bytes to transmit. + +uint32_t::0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF) +A 32-bit unsigned value. + +unsigned:: +A whole number >= 0. + +user_gpio:: +0-31, a Broadcom numbered GPIO. + +See [*gpio*]. + +*userdata:: +A pointer to arbitrary user data. This may be used to identify the instance. + +void:: +Denoting no parameter is required + +wave_add_*:: +One of [*wave_add_new*], [*wave_add_generic*], [*wave_add_serial*]. + +wave_id:: +A number representing a waveform created by [*wave_create*]. + +wave_send_*:: +One of [*wave_send_once*], [*wave_send_repeat*]. + +wVal::0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777) +A 16-bit word value. + +PARAMS*/ + +/*DEF_S pigpiod_if Error Codes*/ + +typedef enum +{ + pigif_bad_send = -2000, + pigif_bad_recv = -2001, + pigif_bad_getaddrinfo = -2002, + pigif_bad_connect = -2003, + pigif_bad_socket = -2004, + pigif_bad_noib = -2005, + pigif_duplicate_callback = -2006, + pigif_bad_malloc = -2007, + pigif_bad_callback = -2008, + pigif_notify_failed = -2009, + pigif_callback_not_found = -2010, +} pigifError_t; + +/*DEF_E*/ + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/pigpiod_if2.3 b/pigpiod_if2.3 new file mode 100644 index 0000000..e5c79e8 --- /dev/null +++ b/pigpiod_if2.3 @@ -0,0 +1,8057 @@ + +." 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. + +.SH SYNOPSIS + +#include + + +gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt + + ./prog +.SH DESCRIPTION + + +.ad l + +.nh + +.br + +.br +pigpiod_if2 is a C library for the Raspberry which allows control +of the GPIO via the socket interface to the pigpio daemon. +.br + +.br + +.br +.SS Features +.br + +.br +o hardware timed PWM on any of GPIO 0-31 + +.br + +.br +o hardware timed servo pulses on any of GPIO 0-31 + +.br + +.br +o callbacks when any of GPIO 0-31 change state + +.br + +.br +o callbacks at timed intervals + +.br + +.br +o reading/writing all of the GPIO in a bank as one operation + +.br + +.br +o individually setting GPIO modes, reading and writing + +.br + +.br +o notifications when any of GPIO 0-31 change state + +.br + +.br +o the construction of output waveforms with microsecond timing + +.br + +.br +o rudimentary permission control over GPIO + +.br + +.br +o a simple interface to start and stop new threads + +.br + +.br +o I2C, SPI, and serial link wrappers + +.br + +.br +o creating and running scripts on the pigpio daemon + +.br + +.br +.SS GPIO +.br + +.br +ALL GPIO are identified by their Broadcom number. + +.br + +.br +.SS Notes +.br + +.br +The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals. + +.br + +.br +.SS Usage +.br + +.br +Include in your source files. + +.br + +.br +Assuming your source is in prog.c use the following command to build + +.br + +.br + +.EX +gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt +.br + +.EE + +.br + +.br +to run make sure the pigpio daemon is running + +.br + +.br + +.EX +sudo pigpiod +.br + +.br + ./prog # sudo is not required to run programs linked to pigpiod_if2 +.br + +.EE + +.br + +.br +For examples see x_pigpiod_if2.c within the pigpio archive file. + +.br + +.br +.SS Notes +.br + +.br +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" +.IP "" 4 +Return the current time in seconds since the Epoch. + +.IP "\fBvoid time_sleep(double seconds)\fP" +.IP "" 4 +Delay execution for a given number of seconds. + +.br + +.br + +.EX +seconds: the number of seconds to delay. +.br + +.EE + +.IP "\fBchar *pigpio_error(int errnum)\fP" +.IP "" 4 +Return a text description for an error code. + +.br + +.br + +.EX +errnum: the error code. +.br + +.EE + +.IP "\fBunsigned pigpiod_if_version(void)\fP" +.IP "" 4 +Return the pigpiod_if2 version. + +.IP "\fBpthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata)\fP" +.IP "" 4 +Starts a new thread of execution with thread_func as the main routine. + +.br + +.br + +.EX +thread_func: the main function for the new thread. +.br + userdata: a pointer to an arbitrary argument. +.br + +.EE + +.br + +.br +Returns a pointer to pthread_t if OK, otherwise NULL. + +.br + +.br +The function is passed the single argument userdata. + +.br + +.br +The thread can be cancelled by passing the pointer to pthread_t to +\fBstop_thread\fP. + +.IP "\fBvoid stop_thread(pthread_t *pth)\fP" +.IP "" 4 +Cancels the thread pointed at by pth. + +.br + +.br + +.EX +pth: the thread to be stopped. +.br + +.EE + +.br + +.br +No value is returned. + +.br + +.br +The thread to be stopped should have been started with \fBstart_thread\fP. + +.IP "\fBint pigpio_start(char *addrStr, char *portStr)\fP" +.IP "" 4 +Connect to the pigpio daemon. Reserving command and +notification streams. + +.br + +.br + +.EX +addrStr: specifies the host or IP address of the Pi running the +.br + pigpio daemon. It may be NULL in which case localhost +.br + is used unless overridden by the PIGPIO_ADDR environment +.br + variable. +.br + +.br +portStr: specifies the port address used by the Pi running the +.br + pigpio daemon. It may be NULL in which case "8888" +.br + is used unless overridden by the PIGPIO_PORT environment +.br + variable. +.br + +.EE + +.br + +.br +Returns an integer value greater than or equal to zero if OK. + +.br + +.br +This value is passed to the GPIO routines to specify the Pi +to be operated on. + +.IP "\fBvoid pigpio_stop(int pi)\fP" +.IP "" 4 +Terminates the connection to a pigpio daemon and releases +resources used by the library. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint set_mode(int pi, unsigned gpio, unsigned mode)\fP" +.IP "" 4 +Set the GPIO mode. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +gpio: 0-53. +.br +mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1, +.br + PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE, +or PI_NOT_PERMITTED. + +.IP "\fBint get_mode(int pi, unsigned gpio)\fP" +.IP "" 4 +Get the GPIO mode. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +gpio: 0-53. +.br + +.EE + +.br + +.br +Returns the GPIO mode if OK, otherwise PI_BAD_GPIO. + +.IP "\fBint set_pull_up_down(int pi, unsigned gpio, unsigned pud)\fP" +.IP "" 4 +Set or clear the GPIO pull-up/down resistor. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +gpio: 0-53. +.br + pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_PUD, +or PI_NOT_PERMITTED. + +.IP "\fBint gpio_read(int pi, unsigned gpio)\fP" +.IP "" 4 +Read the GPIO level. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +gpio:0-53. +.br + +.EE + +.br + +.br +Returns the GPIO level if OK, otherwise PI_BAD_GPIO. + +.IP "\fBint gpio_write(int pi, unsigned gpio, unsigned level)\fP" +.IP "" 4 +Write the GPIO level. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + gpio: 0-53. +.br +level: 0, 1. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_LEVEL, +or PI_NOT_PERMITTED. + +.br + +.br +Notes + +.br + +.br +If PWM or servo pulses are active on the GPIO they are switched off. + +.IP "\fBint set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle)\fP" +.IP "" 4 +Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br +dutycycle: 0-range (range defaults to 255). +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYCYCLE, +or PI_NOT_PERMITTED. +Notes + +.br + +.br +The \fBset_PWM_range\fP function may be used to change the +default range of 255. + +.IP "\fBint get_PWM_dutycycle(int pi, unsigned user_gpio)\fP" +.IP "" 4 +Return the PWM dutycycle in use on a GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. + +.br + +.br +For normal PWM the dutycycle will be out of the defined range +for the GPIO (see \fBget_PWM_range\fP). + +.br + +.br +If a hardware clock is active on the GPIO the reported dutycycle +will be 500000 (500k) out of 1000000 (1M). + +.br + +.br +If hardware PWM is active on the GPIO the reported dutycycle +will be out of a 1000000 (1M). + +.IP "\fBint set_PWM_range(int pi, unsigned user_gpio, unsigned range)\fP" +.IP "" 4 +Set the range of PWM values to be used on the GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + range: 25-40000. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE, +or PI_NOT_PERMITTED. + +.br + +.br +Notes + +.br + +.br +If PWM is currently active on the GPIO its dutycycle will be +scaled to reflect the new range. + +.br + +.br +The real range, the number of steps between fully off and fully on +for each of the 18 available GPIO frequencies is + +.br + +.br + +.EX + 25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6), +.br + 400(#7), 500(#8), 625(#9), 800(#10), 1000(#11), 1250(#12), +.br +2000(#13), 2500(#14), 4000(#15), 5000(#16), 10000(#17), 20000(#18) +.br + +.EE + +.br + +.br +The real value set by set_PWM_range is (dutycycle * real range) / range. + +.IP "\fBint get_PWM_range(int pi, unsigned user_gpio)\fP" +.IP "" 4 +Get the range of PWM values being used on the GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + +.EE + +.br + +.br +Returns the dutycycle range used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +.br + +.br +If a hardware clock or hardware PWM is active on the GPIO the +reported range will be 1000000 (1M). + +.IP "\fBint get_PWM_real_range(int pi, unsigned user_gpio)\fP" +.IP "" 4 +Get the real underlying range of PWM values being used on the GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + +.EE + +.br + +.br +Returns the real range used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +.br + +.br +If a hardware clock is active on the GPIO the reported +real range will be 1000000 (1M). + +.br + +.br +If hardware PWM is active on the GPIO the reported real range +will be approximately 250M divided by the set PWM frequency. + +.br + +.br + +.IP "\fBint set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency)\fP" +.IP "" 4 +Set the frequency (in Hz) of the PWM to be used on the GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br +frequency: >=0 (Hz). +.br + +.EE + +.br + +.br +Returns the numerically closest frequency if OK, otherwise +PI_BAD_USER_GPIO or PI_NOT_PERMITTED. + +.br + +.br +If PWM is currently active on the GPIO it will be switched +off and then back on at the new frequency. + +.br + +.br +Each GPIO can be independently set to one of 18 different +PWM frequencies. + +.br + +.br +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. + +.br + +.br +The frequencies for each sample rate are: + +.br + +.br + +.EX + Hertz +.br + +.br + 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600 +.br + 1250 1000 800 500 400 250 200 100 50 +.br + +.br + 2: 20000 10000 5000 4000 2500 2000 1250 1000 800 +.br + 625 500 400 250 200 125 100 50 25 +.br + +.br + 4: 10000 5000 2500 2000 1250 1000 625 500 400 +.br + 313 250 200 125 100 63 50 25 13 +.br +sample +.br + rate +.br + (us) 5: 8000 4000 2000 1600 1000 800 500 400 320 +.br + 250 200 160 100 80 50 40 20 10 +.br + +.br + 8: 5000 2500 1250 1000 625 500 313 250 200 +.br + 156 125 100 63 50 31 25 13 6 +.br + +.br + 10: 4000 2000 1000 800 500 400 250 200 160 +.br + 125 100 80 50 40 25 20 10 5 +.br + +.EE + +.IP "\fBint get_PWM_frequency(int pi, unsigned user_gpio)\fP" +.IP "" 4 +Get the frequency of PWM being used on the GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + +.EE + +.br + +.br +For normal PWM the frequency will be that defined for the GPIO by +\fBset_PWM_frequency\fP. + +.br + +.br +If a hardware clock is active on the GPIO the reported frequency +will be that set by \fBhardware_clock\fP. + +.br + +.br +If hardware PWM is active on the GPIO the reported frequency +will be that set by \fBhardware_PWM\fP. + +.br + +.br +Returns the frequency (in hertz) used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +.IP "\fBint set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth)\fP" +.IP "" 4 +Start (500-2500) or stop (0) servo pulses on the GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + user_gpio: 0-31. +.br +pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise). +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_PULSEWIDTH or +PI_NOT_PERMITTED. + +.br + +.br +The selected pulsewidth will continue to be transmitted until +changed by a subsequent call to set_servo_pulsewidth. + +.br + +.br +The pulsewidths supported by servos varies and should probably be +determined by experiment. A value of 1500 should always be safe and +represents the mid-point of rotation. + +.br + +.br +You can DAMAGE a servo if you command it to move beyond its limits. + +.br + +.br +OTHER UPDATE RATES: + +.br + +.br +This function updates servos at 50Hz. If you wish to use a different +update frequency you will have to use the PWM functions. + +.br + +.br + +.EX +Update Rate (Hz) 50 100 200 400 500 +.br +1E6/Hz 20000 10000 5000 2500 2000 +.br + +.EE + +.br + +.br +Firstly set the desired PWM frequency using \fBset_PWM_frequency\fP. + +.br + +.br +Then set the PWM range using \fBset_PWM_range\fP to 1E6/Hz. +Doing this allows you to use units of microseconds when setting +the servo pulsewidth. + +.br + +.br +E.g. If you want to update a servo connected to GPIO 25 at 400Hz + +.br + +.br + +.EX +set_PWM_frequency(25, 400); +.br +set_PWM_range(25, 2500); +.br + +.EE + +.br + +.br +Thereafter use the \fBset_PWM_dutycycle\fP function to move the servo, +e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse. +.br + +.IP "\fBint get_servo_pulsewidth(int pi, unsigned user_gpio)\fP" +.IP "" 4 +Return the servo pulsewidth in use on a GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO. + +.IP "\fBint notify_open(int pi)\fP" +.IP "" 4 +Get a free notification handle. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +Returns a handle greater than or equal to zero if OK, +otherwise PI_NO_HANDLE. + +.br + +.br +A notification is a method for being notified of GPIO state +changes via a pipe. + +.br + +.br +Pipes are only accessible from the local machine so this function +serves no purpose if you are using the library from a remote machine. +The in-built (socket) notifications provided by \fBcallback\fP +should be used instead. + +.br + +.br +Notifications for handle x will be available at the pipe +named /dev/pigpiox (where x is the handle number). +E.g. if the function returns 15 then the notifications must be +read from /dev/pigpio15. + +.IP "\fBint notify_begin(int pi, unsigned handle, uint32_t bits)\fP" +.IP "" 4 +Start notifications on a previously opened handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: 0-31 (as returned by \fBnotify_open\fP) +.br + bits: a mask indicating the GPIO to be notified. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +The notification sends state changes for each GPIO whose +corresponding bit in bits is set. + +.br + +.br +Each notification occupies 12 bytes in the fifo as follows: + +.br + +.br + +.EX +typedef struct +.br +{ +.br + uint16_t seqno; +.br + uint16_t flags; +.br + uint32_t tick; +.br + uint32_t level; +.br +} gpioReport_t; +.br + +.EE + +.br + +.br +seqno: starts at 0 each time the handle is opened and then increments +by one for each report. + +.br + +.br +flags: three flags are defined, PI_NTFY_FLAGS_WDOG, +PI_NTFY_FLAGS_ALIVE, and PI_NTFY_FLAGS_EVENT. + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +If bit 7 is set (PI_NTFY_FLAGS_EVENT) then bits 0-4 of the flags +indicate an event which has been triggered. + +.br + +.br +tick: the number of microseconds since system boot. It wraps around +after 1h12m. + +.br + +.br +level: indicates the level of each GPIO. If bit 1<=0 (as returned by \fBpigpio_start\fP). +.br +handle: 0-31 (as returned by \fBnotify_open\fP) +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +Notifications for the handle are suspended until +\fBnotify_begin\fP is called again. + +.IP "\fBint notify_close(int pi, unsigned handle)\fP" +.IP "" 4 +Stop notifications on a previously opened handle and +release the handle for reuse. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: 0-31 (as returned by \fBnotify_open\fP) +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint set_watchdog(int pi, unsigned user_gpio, unsigned timeout)\fP" +.IP "" 4 +Sets a watchdog for a GPIO. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + timeout: 0-60000. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO +or PI_BAD_WDOG_TIMEOUT. + +.br + +.br +The watchdog is nominally in milliseconds. + +.br + +.br +Only one watchdog may be registered per GPIO. + +.br + +.br +The watchdog may be cancelled by setting timeout to 0. + +.br + +.br +Once a watchdog has been started callbacks for the GPIO will be +triggered every timeout interval after the last GPIO activity. + +.br + +.br +The callback will receive the special level PI_TIMEOUT. + +.IP "\fBint set_glitch_filter(int pi, unsigned user_gpio, unsigned steady)\fP" +.IP "" 4 +Sets a glitch filter on a GPIO. + +.br + +.br +Level changes on the GPIO are not reported unless the level +has been stable for at least \fBsteady\fP microseconds. The +level is then reported. Level changes of less than +\fBsteady\fP microseconds are ignored. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31 +.br + steady: 0-300000 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + +.br + +.br +This filter affects the GPIO samples returned to callbacks set up +with \fBcallback\fP, \fBcallback_ex\fP and \fBwait_for_edge\fP. + +.br + +.br +It does not affect levels read by \fBgpio_read\fP, +\fBread_bank_1\fP, or \fBread_bank_2\fP. + +.br + +.br +Each (stable) edge will be timestamped \fBsteady\fP microseconds +after it was first detected. + +.IP "\fBint set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)\fP" +.IP "" 4 +Sets a noise filter on a GPIO. + +.br + +.br +Level changes on the GPIO are ignored until a level which has +been stable for \fBsteady\fP microseconds is detected. Level changes +on the GPIO are then reported for \fBactive\fP microseconds after +which the process repeats. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31 +.br + steady: 0-300000 +.br + active: 0-1000000 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + +.br + +.br +This filter affects the GPIO samples returned to callbacks set up +with \fBcallback\fP, \fBcallback_ex\fP and \fBwait_for_edge\fP. + +.br + +.br +It does not affect levels read by \fBgpio_read\fP, +\fBread_bank_1\fP, or \fBread_bank_2\fP. + +.br + +.br +Level changes before and after the active period may +be reported. Your software must be designed to cope with +such reports. + +.IP "\fBuint32_t read_bank_1(int pi)\fP" +.IP "" 4 +Read the levels of the bank 1 GPIO (GPIO 0-31). + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +The returned 32 bit integer has a bit set if the corresponding +GPIO is logic 1. GPIO n has bit value (1<=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +The returned 32 bit integer has a bit set if the corresponding +GPIO is logic 1. GPIO n has bit value (1<<(n-32)). + +.IP "\fBint clear_bank_1(int pi, uint32_t bits)\fP" +.IP "" 4 +Clears GPIO 0-31 if the corresponding bit in bits is set. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +bits: a bit mask with 1 set if the corresponding GPIO is +.br + to be cleared. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_SOME_PERMITTED. + +.br + +.br +A status of PI_SOME_PERMITTED indicates that the user is not +allowed to write to one or more of the GPIO. + +.IP "\fBint clear_bank_2(int pi, uint32_t bits)\fP" +.IP "" 4 +Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +bits: a bit mask with 1 set if the corresponding GPIO is +.br + to be cleared. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_SOME_PERMITTED. + +.br + +.br +A status of PI_SOME_PERMITTED indicates that the user is not +allowed to write to one or more of the GPIO. + +.IP "\fBint set_bank_1(int pi, uint32_t bits)\fP" +.IP "" 4 +Sets GPIO 0-31 if the corresponding bit in bits is set. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +bits: a bit mask with 1 set if the corresponding GPIO is +.br + to be set. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_SOME_PERMITTED. + +.br + +.br +A status of PI_SOME_PERMITTED indicates that the user is not +allowed to write to one or more of the GPIO. + +.IP "\fBint set_bank_2(int pi, uint32_t bits)\fP" +.IP "" 4 +Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +bits: a bit mask with 1 set if the corresponding GPIO is +.br + to be set. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_SOME_PERMITTED. + +.br + +.br +A status of PI_SOME_PERMITTED indicates that the user is not +allowed to write to one or more of the GPIO. + +.IP "\fBint hardware_clock(int pi, unsigned gpio, unsigned clkfreq)\fP" +.IP "" 4 +Starts a hardware clock on a GPIO at the specified frequency. +Frequencies above 30MHz are unlikely to work. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + gpio: see description +.br +frequency: 0 (off) or 4689-250M (13184-375M for the BCM2711) +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO, +PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS. + +.br + +.br +The same clock is available on multiple GPIO. The latest +frequency setting will be used by all GPIO which share a clock. + +.br + +.br +The GPIO must be one of the following. + +.br + +.br + +.EX +4 clock 0 All models +.br +5 clock 1 All models but A and B (reserved for system use) +.br +6 clock 2 All models but A and B +.br +20 clock 0 All models but A and B +.br +21 clock 1 All models but A and Rev.2 B (reserved for system use) +.br + +.br +32 clock 0 Compute module only +.br +34 clock 0 Compute module only +.br +42 clock 1 Compute module only (reserved for system use) +.br +43 clock 2 Compute module only +.br +44 clock 1 Compute module only (reserved for system use) +.br + +.EE + +.br + +.br +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. + +.IP "\fBint hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)\fP" +.IP "" 4 +Starts hardware PWM on a GPIO at the specified frequency and dutycycle. +Frequencies above 30MHz are unlikely to work. + +.br + +.br +NOTE: Any waveform started by \fBwave_send_*\fP or \fBwave_chain\fP +will be cancelled. + +.br + +.br +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). + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + gpio: see descripton +.br +PWMfreq: 0 (off) or 1-125M (1-187.5M for the BCM2711) +.br +PWMduty: 0 (off) to 1000000 (1M)(fully on) +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO, +PI_NOT_HPWM_GPIO, PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, +or PI_HPWM_ILLEGAL. + +.br + +.br +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. + +.br + +.br +The GPIO must be one of the following. + +.br + +.br + +.EX +12 PWM channel 0 All models but A and B +.br +13 PWM channel 1 All models but A and B +.br +18 PWM channel 0 All models +.br +19 PWM channel 1 All models but A and B +.br + +.br +40 PWM channel 0 Compute module only +.br +41 PWM channel 1 Compute module only +.br +45 PWM channel 1 Compute module only +.br +52 PWM channel 0 Compute module only +.br +53 PWM channel 1 Compute module only +.br + +.EE + +.br + +.br +The actual number of steps beween off and fully on is the +integral part of 250M/PWMfreq (375M/PWMfreq for the BCM2711). + +.br + +.br +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 (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. + +.IP "\fBuint32_t get_current_tick(int pi)\fP" +.IP "" 4 +Gets the current system tick. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +Tick is the number of microseconds since system boot. + +.br + +.br +As tick is an unsigned 32 bit quantity it wraps around after +2**32 microseconds, which is approximately 1 hour 12 minutes. + +.br + +.br + +.IP "\fBuint32_t get_hardware_revision(int pi)\fP" +.IP "" 4 +Get the Pi's hardware revision number. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +The hardware revision is the last few characters on the Revision line +of /proc/cpuinfo. + +.br + +.br +If the hardware revision can not be found or is not a valid +hexadecimal number the function returns 0. + +.br + +.br +The revision number can be used to determine the assignment of GPIO +to pins (see \fBgpio\fP). + +.br + +.br +There are at least three types of board. + +.br + +.br +Type 1 boards have hardware revision numbers of 2 and 3. + +.br + +.br +Type 2 boards have hardware revision numbers of 4, 5, 6, and 15. + +.br + +.br +Type 3 boards have hardware revision numbers of 16 or greater. + +.IP "\fBuint32_t get_pigpio_version(int pi)\fP" +.IP "" 4 +Returns the pigpio version. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_clear(int pi)\fP" +.IP "" 4 +This function clears all waveforms and any data added by calls to the +\fBwave_add_*\fP functions. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.IP "\fBint wave_add_new(int pi)\fP" +.IP "" 4 +This function starts a new empty waveform. You wouldn't normally need +to call this function as it is automatically called after a waveform is +created with the \fBwave_create\fP function. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.IP "\fBint wave_add_generic(int pi, unsigned numPulses, gpioPulse_t *pulses)\fP" +.IP "" 4 +This function adds a number of pulses to the current waveform. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +numPulses: the number of pulses. +.br + pulses: an array of pulses. +.br + +.EE + +.br + +.br +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_TOO_MANY_PULSES. + +.br + +.br +The pulses are interleaved in time order within the existing waveform +(if any). + +.br + +.br +Merging allows the waveform to be built in parts, that is the settings +for GPIO#1 can be added, and then GPIO#2 etc. + +.br + +.br +If the added waveform is intended to start after or within the existing +waveform then the first pulse should consist solely of a delay. + +.IP "\fBint wave_add_serial(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits, unsigned stop_bits, unsigned offset, unsigned numBytes, char *str)\fP" +.IP "" 4 +This function adds a waveform representing serial data to the +existing waveform (if any). The serial data starts offset +microseconds from the start of the waveform. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + baud: 50-1000000 +.br +data_bits: number of data bits (1-32) +.br +stop_bits: number of stop half bits (2-8) +.br + offset: >=0 +.br + numBytes: >=1 +.br + str: an array of chars. +.br + +.EE + +.br + +.br +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS, +PI_BAD_STOP_BITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET, +or PI_TOO_MANY_PULSES. + +.br + +.br +NOTES: + +.br + +.br +The serial data is formatted as one start bit, \fBdata_bits\fP data bits, +and \fBstop_bits\fP/2 stop bits. + +.br + +.br +It is legal to add serial data streams with different baud rates to +the same waveform. + +.br + +.br +\fBnumBytes\fP is the number of bytes of data in str. + +.br + +.br +The bytes required for each character depend upon \fBdata_bits\fP. + +.br + +.br +For \fBdata_bits\fP 1-8 there will be one byte per character. +.br +For \fBdata_bits\fP 9-16 there will be two bytes per character. +.br +For \fBdata_bits\fP 17-32 there will be four bytes per character. + +.IP "\fBint wave_create(int pi)\fP" +.IP "" 4 +This function creates a waveform from the data provided by the prior +calls to the \fBwave_add_*\fP functions. 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 + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +The data provided by the \fBwave_add_*\fP functions is 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 +Normal usage would be + +.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\fP to create the waveform and get a unique id + +.br + +.br +Repeat steps 2 and 3 as needed. + +.br + +.br +Step 4. \fBwave_send_*\fP with the id of the waveform to transmit. + +.br + +.br +A waveform comprises one or more pulses. Each pulse consists of a +\fBgpioPulse_t\fP structure. + +.br + +.br + +.EX +typedef struct +.br +{ +.br + uint32_t gpioOn; +.br + uint32_t gpioOff; +.br + uint32_t usDelay; +.br +} gpioPulse_t; +.br + +.EE + +.br + +.br +The fields specify + +.br + +.br +1) the GPIO to be switched on at the start of the pulse. +.br +2) the GPIO to be switched off at the start of the pulse. +.br +3) the delay in microseconds before the next pulse. +.br + +.br + +.br +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). + +.br + +.br +When a waveform is started each pulse is executed in order with the +specified delay between the pulse and the next. + +.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_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. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +wave_id: >=0, as returned by \fBwave_create\fP. +.br + +.EE + +.br + +.br +Wave ids are allocated in order, 0, 1, 2, etc. + +.br + +.br +The wave is flagged for deletion. The resources used by the wave +will only be reused when either of the following apply. + +.br + +.br +- all waves with higher numbered wave ids have been deleted or have +been flagged for deletion. + +.br + +.br +- a new wave is created which uses exactly the same resources as +the current wave (see the C source for gpioWaveCreate for details). + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_WAVE_ID. + +.IP "\fBint wave_send_once(int pi, unsigned wave_id)\fP" +.IP "" 4 +This function transmits the waveform with id wave_id. The waveform +is sent once. + +.br + +.br +NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +wave_id: >=0, as returned by \fBwave_create\fP. +.br + +.EE + +.br + +.br +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. + +.IP "\fBint wave_send_repeat(int pi, unsigned wave_id)\fP" +.IP "" 4 +This function transmits the waveform with id wave_id. The waveform +cycles until cancelled (either by the sending of a new waveform or +by \fBwave_tx_stop\fP). + +.br + +.br +NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +wave_id: >=0, as returned by \fBwave_create\fP. +.br + +.EE + +.br + +.br +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. + +.IP "\fBint wave_send_using_mode(int pi, unsigned wave_id, unsigned mode)\fP" +.IP "" 4 +Transmits the waveform with id wave_id using mode mode. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +wave_id: >=0, as returned by \fBwave_create\fP. +.br + mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT, +.br + PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC. +.br + +.EE + +.br + +.br +PI_WAVE_MODE_ONE_SHOT: same as \fBwave_send_once\fP. + +.br + +.br +PI_WAVE_MODE_REPEAT same as \fBwave_send_repeat\fP. + +.br + +.br +PI_WAVE_MODE_ONE_SHOT_SYNC same as \fBwave_send_once\fP but tries +to sync with the previous waveform. + +.br + +.br +PI_WAVE_MODE_REPEAT_SYNC same as \fBwave_send_repeat\fP but tries +to sync with the previous waveform. + +.br + +.br +WARNING: bad things may happen if you delete the previous +waveform before it has been synced to the new waveform. + +.br + +.br +NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled. + +.br + +.br +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. + +.IP "\fBint wave_chain(int pi, char *buf, unsigned bufSize)\fP" +.IP "" 4 +This function transmits a chain of waveforms. + +.br + +.br +NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled. + +.br + +.br +The waves to be transmitted are specified by the contents of buf +which contains an ordered list of \fBwave_id\fPs and optional command +codes and related data. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + buf: pointer to the wave_ids and optional command codes +.br +bufSize: the number of bytes in buf +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER, +PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID. + +.br + +.br +Each wave is transmitted in the order specified. A wave may +occur multiple times per chain. + +.br + +.br +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. + +.br + +.br +Delays between waves may be added with the delay command. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +Loop Start 255 0 Identify start of a wave block +.br +Loop Repeat 255 1 x y loop x + y*256 times +.br +Delay 255 2 x y delay x + y*256 microseconds +.br +Loop Forever 255 3 loop forever +.br + +.br + +.br +If present Loop Forever must be the last entry in the chain. + +.br + +.br +The code is currently dimensioned to support a chain with roughly +600 entries and 20 loop counters. + +.br + +.br +\fBExample\fP +.br + +.EX +#include +.br +#include +.br + +.br +#define WAVES 5 +.br +#define GPIO 4 +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int i, pi, wid[WAVES]; +.br + +.br + pi = pigpio_start(0, 0); +.br + if (pi<0) return -1; +.br + +.br + set_mode(pi, GPIO, PI_OUTPUT); +.br + +.br + for (i=0; i=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +Returns the waveform id or one of the following special values: + +.br + +.br +PI_WAVE_NOT_FOUND (9998) - transmitted wave not found. +.br +PI_NO_TX_WAVE (9999) - no wave being transmitted. + +.IP "\fBint wave_tx_busy(int pi)\fP" +.IP "" 4 +This function checks to see if a waveform is currently being +transmitted. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +Returns 1 if a waveform is currently being transmitted, otherwise 0. + +.IP "\fBint wave_tx_stop(int pi)\fP" +.IP "" 4 +This function stops the transmission of the current waveform. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.br + +.br +Returns 0 if OK. + +.br + +.br +This function is intended to stop a waveform started with the repeat mode. + +.IP "\fBint wave_get_micros(int pi)\fP" +.IP "" 4 +This function returns the length in microseconds of the current +waveform. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_get_high_micros(int pi)\fP" +.IP "" 4 +This function returns the length in microseconds of the longest waveform +created since the pigpio daemon was started. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_get_max_micros(int pi)\fP" +.IP "" 4 +This function returns the maximum possible size of a waveform in +.br +microseconds. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_get_pulses(int pi)\fP" +.IP "" 4 +This function returns the length in pulses of the current waveform. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_get_high_pulses(int pi)\fP" +.IP "" 4 +This function returns the length in pulses of the longest waveform +created since the pigpio daemon was started. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_get_max_pulses(int pi)\fP" +.IP "" 4 +This function returns the maximum possible size of a waveform in pulses. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_get_cbs(int pi)\fP" +.IP "" 4 +This function returns the length in DMA control blocks of the current +waveform. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_get_high_cbs(int pi)\fP" +.IP "" 4 +This function returns the length in DMA control blocks of the longest +waveform created since the pigpio daemon was started. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint wave_get_max_cbs(int pi)\fP" +.IP "" 4 +This function returns the maximum possible size of a waveform in DMA +control blocks. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br + +.EE + +.IP "\fBint gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)\fP" +.IP "" 4 +This function sends a trigger pulse to a GPIO. The GPIO is set to +level for pulseLen microseconds and then reset to not level. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + pulseLen: 1-100. +.br + level: 0,1. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL, +PI_BAD_PULSELEN, or PI_NOT_PERMITTED. + +.IP "\fBint store_script(int pi, char *script)\fP" +.IP "" 4 +This function stores a script for later execution. + +.br + +.br +See \fBhttp://abyz.me.uk/rpi/pigpio/pigs.html#Scripts\fP for details. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +script: the text of the script. +.br + +.EE + +.br + +.br +The function returns a script id if the script is valid, +otherwise PI_BAD_SCRIPT. + +.IP "\fBint run_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param)\fP" +.IP "" 4 +This function runs a stored script. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +script_id: >=0, as returned by \fBstore_script\fP. +.br + numPar: 0-10, the number of parameters. +.br + param: an array of parameters. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM + +.br + +.br +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. + +.IP "\fBint update_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param)\fP" +.IP "" 4 +This function sets the parameters of a script. The script may or +may not be running. The first numPar parameters of the script are +overwritten with the new values. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +script_id: >=0, as returned by \fBstore_script\fP. +.br + numPar: 0-10, the number of parameters. +.br + param: an array of parameters. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM. + +.br + +.br +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. + +.IP "\fBint script_status(int pi, unsigned script_id, uint32_t *param)\fP" +.IP "" 4 +This function returns the run status of a stored script as well +as the current values of parameters 0 to 9. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +script_id: >=0, as returned by \fBstore_script\fP. +.br + param: an array to hold the returned 10 parameters. +.br + +.EE + +.br + +.br +The function returns greater than or equal to 0 if OK, +otherwise PI_BAD_SCRIPT_ID. + +.br + +.br +The run status may be + +.br + +.br + +.EX +PI_SCRIPT_INITING +.br +PI_SCRIPT_HALTED +.br +PI_SCRIPT_RUNNING +.br +PI_SCRIPT_WAITING +.br +PI_SCRIPT_FAILED +.br + +.EE + +.br + +.br +The current value of script parameters 0 to 9 are returned in param. + +.IP "\fBint stop_script(int pi, unsigned script_id)\fP" +.IP "" 4 +This function stops a running script. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +script_id: >=0, as returned by \fBstore_script\fP. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. + +.IP "\fBint delete_script(int pi, unsigned script_id)\fP" +.IP "" 4 +This function deletes a stored script. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +script_id: >=0, as returned by \fBstore_script\fP. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. + +.IP "\fBint bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits)\fP" +.IP "" 4 +This function opens a GPIO for bit bang reading of serial data. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + baud: 50-250000 +.br +data_bits: 1-32 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, +or PI_GPIO_IN_USE. + +.br + +.br +The serial data is returned in a cyclic buffer and is read using +bb_serial_read. + +.br + +.br +It is the caller's responsibility to read data from the cyclic buffer +in a timely fashion. + +.IP "\fBint bb_serial_read(int pi, unsigned user_gpio, void *buf, size_t bufSize)\fP" +.IP "" 4 +This function copies up to bufSize bytes of data read from the +bit bang serial cyclic buffer to the buffer starting at buf. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP. +.br + buf: an array to receive the read bytes. +.br + bufSize: >=0 +.br + +.EE + +.br + +.br +Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO +or PI_NOT_SERIAL_GPIO. + +.br + +.br +The bytes returned for each character depend upon the number of +data bits \fBdata_bits\fP specified in the \fBbb_serial_read_open\fP command. + +.br + +.br +For \fBdata_bits\fP 1-8 there will be one byte per character. +.br +For \fBdata_bits\fP 9-16 there will be two bytes per character. +.br +For \fBdata_bits\fP 17-32 there will be four bytes per character. + +.IP "\fBint bb_serial_read_close(int pi, unsigned user_gpio)\fP" +.IP "" 4 +This function closes a GPIO for bit bang reading of serial data. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO. + +.IP "\fBint bb_serial_invert(int pi, unsigned user_gpio, unsigned invert)\fP" +.IP "" 4 +This function inverts serial logic for big bang serial reads. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP. +.br + invert: 0-1, 1 invert, 0 normal. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT. + +.IP "\fBint i2c_open(int pi, unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags)\fP" +.IP "" 4 +This returns a handle for the device at address i2c_addr on bus i2c_bus. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + i2c_bus: >=0. +.br + i2c_addr: 0-0x7F. +.br +i2c_flags: 0. +.br + +.EE + +.br + +.br +No flags are currently defined. This parameter should be set to zero. + +.br + +.br +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. + +.br + +.br +The GPIO used are given in the following table. + +.br + +.br + SDA SCL +.br +I2C 0 0 1 +.br +I2C 1 2 3 +.br + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR, +PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED. + +.br + +.br +For the SMBus commands the low level transactions are shown at the end +of the function description. The following abbreviations are used. + +.br + +.br + +.EX +S (1 bit) : Start bit +.br +P (1 bit) : Stop bit +.br +Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. +.br +A, NA (1 bit) : Accept and not accept bit. +.br +.br +.br +Addr (7 bits): I2C 7 bit address. +.br +i2c_reg (8 bits): A byte which often selects a register. +.br +Data (8 bits): A data byte. +.br +Count (8 bits): A byte defining the length of a block operation. +.br + +.br +[..]: Data sent by the device. +.br + +.EE + +.IP "\fBint i2c_close(int pi, unsigned handle)\fP" +.IP "" 4 +This closes the I2C device associated with the handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint i2c_write_quick(int pi, unsigned handle, unsigned bit)\fP" +.IP "" 4 +This sends a single bit (in the Rd/Wr bit) to the device associated +with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + bit: 0-1, the value to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Quick command. SMBus 2.0 5.5.1 + +.EX +S Addr bit [A] P +.br + +.EE + +.IP "\fBint i2c_write_byte(int pi, unsigned handle, unsigned bVal)\fP" +.IP "" 4 +This sends a single byte to the device associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + bVal: 0-0xFF, the value to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Send byte. SMBus 2.0 5.5.2 + +.EX +S Addr Wr [A] bVal [A] P +.br + +.EE + +.IP "\fBint i2c_read_byte(int pi, unsigned handle)\fP" +.IP "" 4 +This reads a single byte from the device associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + +.EE + +.br + +.br +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +or PI_I2C_READ_FAILED. + +.br + +.br +Receive byte. SMBus 2.0 5.5.3 + +.EX +S Addr Rd [A] [Data] NA P +.br + +.EE + +.IP "\fBint i2c_write_byte_data(int pi, unsigned handle, unsigned i2c_reg, unsigned bVal)\fP" +.IP "" 4 +This writes a single byte to the specified register of the device +associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write. +.br + bVal: 0-0xFF, the value to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Write byte. SMBus 2.0 5.5.4 + +.EX +S Addr Wr [A] i2c_reg [A] bVal [A] P +.br + +.EE + +.IP "\fBint i2c_write_word_data(int pi, unsigned handle, unsigned i2c_reg, unsigned wVal)\fP" +.IP "" 4 +This writes a single 16 bit word to the specified register of the device +associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write. +.br + wVal: 0-0xFFFF, the value to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Write word. SMBus 2.0 5.5.4 + +.EX +S Addr Wr [A] i2c_reg [A] wval_Low [A] wVal_High [A] P +.br + +.EE + +.IP "\fBint i2c_read_byte_data(int pi, unsigned handle, unsigned i2c_reg)\fP" +.IP "" 4 +This reads a single byte from the specified register of the device +associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to read. +.br + +.EE + +.br + +.br +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Read byte. SMBus 2.0 5.5.5 + +.EX +S Addr Wr [A] i2c_reg [A] S Addr Rd [A] [Data] NA P +.br + +.EE + +.IP "\fBint i2c_read_word_data(int pi, unsigned handle, unsigned i2c_reg)\fP" +.IP "" 4 +This reads a single 16 bit word from the specified register of the device +associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to read. +.br + +.EE + +.br + +.br +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Read word. SMBus 2.0 5.5.5 + +.EX +S Addr Wr [A] i2c_reg [A] +.br + S Addr Rd [A] [DataLow] A [DataHigh] NA P +.br + +.EE + +.IP "\fBint i2c_process_call(int pi, unsigned handle, unsigned i2c_reg, unsigned wVal)\fP" +.IP "" 4 +This writes 16 bits of data to the specified register of the device +associated with handle and and reads 16 bits of data in return. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write/read. +.br + wVal: 0-0xFFFF, the value to write. +.br + +.EE + +.br + +.br +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Process call. SMBus 2.0 5.5.6 + +.EX +S Addr Wr [A] i2c_reg [A] wVal_Low [A] wVal_High [A] +.br + S Addr Rd [A] [DataLow] A [DataHigh] NA P +.br + +.EE + +.IP "\fBint i2c_write_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes up to 32 bytes to the specified register of the device +associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write. +.br + buf: an array with the data to send. +.br + count: 1-32, the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br +Block write. SMBus 2.0 5.5.7 + +.EX +S Addr Wr [A] i2c_reg [A] count [A] buf0 [A] buf1 [A] ... +.br + [A] bufn [A] P +.br + +.EE + +.IP "\fBint i2c_read_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf)\fP" +.IP "" 4 +This reads a block of up to 32 bytes from the specified register of +the device associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to read. +.br + buf: an array to receive the read data. +.br + +.EE + +.br + +.br +The amount of returned data is set by the device. + +.br + +.br +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +Block read. SMBus 2.0 5.5.7 + +.EX +S Addr Wr [A] i2c_reg [A] +.br + S Addr Rd [A] [Count] A [buf0] A [buf1] A ... A [bufn] NA P +.br + +.EE + +.IP "\fBint i2c_block_process_call(int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes data bytes to the specified register of the device +associated with handle and reads a device specified number +of bytes of data in return. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write/read. +.br + buf: an array with the data to send and to receive the read data. +.br + count: 1-32, the number of bytes to write. +.br + +.EE + +.br + +.br + +.br + +.br +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br +The smbus 2.0 documentation states that a minimum of 1 byte may be +sent and a minimum of 1 byte may be received. The total number of +bytes sent/received must be 32 or less. + +.br + +.br +Block write-block read. SMBus 2.0 5.5.8 + +.EX +S Addr Wr [A] i2c_reg [A] count [A] buf0 [A] ... +.br + S Addr Rd [A] [Count] A [Data] ... A P +.br + +.EE + +.IP "\fBint i2c_read_i2c_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP" +.IP "" 4 +This reads count bytes from the specified register of the device +associated with handle . The count may be 1-32. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to read. +.br + buf: an array to receive the read data. +.br + count: 1-32, the number of bytes to read. +.br + +.EE + +.br + +.br +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +.br + +.br + +.EX +S Addr Wr [A] i2c_reg [A] +.br + S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P +.br + +.EE + +.IP "\fBint i2c_write_i2c_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP" +.IP "" 4 +This writes 1 to 32 bytes to the specified register of the device +associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0, as returned by a call to \fBi2c_open\fP. +.br +i2c_reg: 0-255, the register to write. +.br + buf: the data to write. +.br + count: 1-32, the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br + +.EX +S Addr Wr [A] i2c_reg [A] buf0 [A] buf1 [A] ... [A] bufn [A] P +.br + +.EE + +.IP "\fBint i2c_read_device(int pi, unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This reads count bytes from the raw device into buf. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + buf: an array to receive the read data bytes. +.br + count: >0, the number of bytes to read. +.br + +.EE + +.br + +.br +Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_READ_FAILED. + +.br + +.br + +.EX +S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P +.br + +.EE + +.IP "\fBint i2c_write_device(int pi, unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This writes count bytes from buf to the raw device. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBi2c_open\fP. +.br + buf: an array containing the data bytes to write. +.br + count: >0, the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +.br + +.br + +.EX +S Addr Wr [A] buf0 [A] buf1 [A] ... [A] bufn [A] P +.br + +.EE + +.IP "\fBint i2c_zip(int pi, unsigned handle, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP" +.IP "" 4 +This function executes a sequence of I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBi2cOpen\fP +.br + inBuf: pointer to the concatenated I2C commands, see below +.br + inLen: size of command buffer +.br +outBuf: pointer to buffer to hold returned data +.br +outLen: size of output buffer +.br + +.EE + +.br + +.br +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN. +PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +End 0 No more commands +.br +Escape 1 Next P is two bytes +.br +On 2 Switch combined flag on +.br +Off 3 Switch combined flag off +.br +Address 4 P Set I2C address to P +.br +Flags 5 lsb msb Set I2C flags to lsb + (msb << 8) +.br +Read 6 P Read P bytes of data +.br +Write 7 P ... Write P bytes of data +.br + +.br + +.br +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). + +.br + +.br +The address defaults to that associated with the handle. +The flags default to 0. The address and flags maintain their +previous value until updated. + +.br + +.br +The returned I2C data is stored in consecutive locations of outBuf. + +.br + +.br +\fBExample\fP +.br + +.EX +Set address 0x53, write 0x32, read 6 bytes +.br +Set address 0x1E, write 0x03, read 6 bytes +.br +Set address 0x68, write 0x1B, read 8 bytes +.br +End +.br + +.br +0x04 0x53 0x07 0x01 0x32 0x06 0x06 +.br +0x04 0x1E 0x07 0x01 0x03 0x06 0x06 +.br +0x04 0x68 0x07 0x01 0x1B 0x06 0x08 +.br +0x00 +.br + +.EE + +.br + +.br + +.IP "\fBint bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud)\fP" +.IP "" 4 +This function selects a pair of GPIO for bit banging I2C at a +specified baud rate. + +.br + +.br +Bit banging I2C allows for certain operations which are not possible +with the standard I2C driver. + +.br + +.br +o baud rates as low as 50 +.br +o repeated starts +.br +o clock stretching +.br +o I2C on any pair of spare GPIO + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + SDA: 0-31 +.br + SCL: 0-31 +.br +baud: 50-500000 +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or +PI_GPIO_IN_USE. + +.br + +.br +NOTE: + +.br + +.br +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. + +.IP "\fBint bb_i2c_close(int pi, unsigned SDA)\fP" +.IP "" 4 +This function stops bit banging I2C on a pair of GPIO previously +opened with \fBbb_i2c_open\fP. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +SDA: 0-31, the SDA GPIO used in a prior call to \fBbb_i2c_open\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO. + +.IP "\fBint bb_i2c_zip(int pi, unsigned SDA, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP" +.IP "" 4 +This function executes a sequence of bit banged I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + SDA: 0-31 (as used in a prior call to \fBbb_i2c_open\fP) +.br + inBuf: pointer to the concatenated I2C commands, see below +.br + inLen: size of command buffer +.br +outBuf: pointer to buffer to hold returned data +.br +outLen: size of output buffer +.br + +.EE + +.br + +.br +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER, +PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN, +PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED. + +.br + +.br +The following command codes are supported: + +.br + +.br +Name Cmd & Data Meaning +.br +End 0 No more commands +.br +Escape 1 Next P is two bytes +.br +Start 2 Start condition +.br +Stop 3 Stop condition +.br +Address 4 P Set I2C address to P +.br +Flags 5 lsb msb Set I2C flags to lsb + (msb << 8) +.br +Read 6 P Read P bytes of data +.br +Write 7 P ... Write P bytes of data +.br + +.br + +.br +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). + +.br + +.br +The address and flags default to 0. The address and flags maintain +their previous value until updated. + +.br + +.br +No flags are currently defined. + +.br + +.br +The returned I2C data is stored in consecutive locations of outBuf. + +.br + +.br +\fBExample\fP +.br + +.EX +Set address 0x53 +.br +start, write 0x32, (re)start, read 6 bytes, stop +.br +Set address 0x1E +.br +start, write 0x03, (re)start, read 6 bytes, stop +.br +Set address 0x68 +.br +start, write 0x1B, (re)start, read 8 bytes, stop +.br +End +.br + +.br +0x04 0x53 +.br +0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03 +.br + +.br +0x04 0x1E +.br +0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03 +.br + +.br +0x04 0x68 +.br +0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03 +.br + +.br +0x00 +.br + +.EE + +.IP "\fBint bb_spi_open(int pi, unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, unsigned baud, unsigned spi_flags)\fP" +.IP "" 4 +This function selects a set of GPIO for bit banging SPI at a +specified baud rate. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + CS: 0-31 +.br + MISO: 0-31 +.br + MOSI: 0-31 +.br + SCLK: 0-31 +.br + baud: 50-250000 +.br +spi_flags: see below +.br + +.EE + +.br + +.br +spi_flags consists of the least significant 22 bits. + +.br + +.br + +.EX +21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m +.br + +.EE + +.br + +.br +mm defines the SPI mode, defaults to 0 + +.br + +.br + +.EX +Mode CPOL CPHA +.br + 0 0 0 +.br + 1 0 1 +.br + 2 1 0 +.br + 3 1 1 +.br + +.EE + +.br + +.br +p is 0 if CS is active low (default) and 1 for active high. + +.br + +.br +T is 1 if the least significant bit is transmitted on MOSI first, the +default (0) shifts the most significant bit out first. + +.br + +.br +R is 1 if the least significant bit is received on MISO first, the +default (0) receives the most significant bit first. + +.br + +.br +The other bits in flags should be set to zero. + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or +PI_GPIO_IN_USE. + +.br + +.br +If more than one device is connected to the SPI bus (defined by +SCLK, MOSI, and MISO) each must have its own CS. + +.br + +.br +\fBExample\fP +.br + +.EX +bb_spi_open(pi,10, MISO, MOSI, SCLK, 10000, 0); // device 1 +.br +bb_spi_open(pi,11, MISO, MOSI, SCLK, 20000, 3); // device 2 +.br + +.EE + +.IP "\fBint bb_spi_close(int pi, unsigned CS)\fP" +.IP "" 4 +This function stops bit banging SPI on a set of GPIO +opened with \fBbbSPIOpen\fP. + +.br + +.br + +.EX +pi: >=0 (as returned by \fBpigpio_start\fP). +.br +CS: 0-31, the CS GPIO used in a prior call to \fBbb_spi_open\fP +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO. + +.IP "\fBint bb_spi_xfer(int pi, unsigned CS, char *txBuf, char *rxBuf, unsigned count)\fP" +.IP "" 4 +This function executes a bit banged SPI transfer. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + CS: 0-31 (as used in a prior call to \fBbb_spi_open\fP) +.br +txBuf: pointer to buffer to hold data to be sent +.br +rxBuf: pointer to buffer to hold returned data +.br +count: size of data transfer +.br + +.EE + +.br + +.br +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_SPI_GPIO or PI_BAD_POINTER. + +.br + +.br +\fBExample\fP +.br + +.EX +// gcc -Wall -pthread -o bb_spi_x_test bb_spi_x_test.c -lpigpiod_if2 +.br +// ./bb_spi_x_test +.br + +.br +#include +.br + +.br +#include "pigpiod_if2.h" +.br + +.br +#define CE0 5 +.br +#define CE1 6 +.br +#define MISO 13 +.br +#define MOSI 19 +.br +#define SCLK 12 +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int i, pi, count, set_val, read_val; +.br + unsigned char inBuf[3]; +.br + char cmd1[] = {0, 0}; +.br + char cmd2[] = {12, 0}; +.br + char cmd3[] = {1, 128, 0}; +.br + +.br + if ((pi = pigpio_start(0, 0)) < 0) +.br + { +.br + fprintf(stderr, "pigpio initialisation failed (%d).\n", pi); +.br + return 1; +.br + } +.br + +.br + bb_spi_open(pi, CE0, MISO, MOSI, SCLK, 10000, 0); // MCP4251 DAC +.br + bb_spi_open(pi, CE1, MISO, MOSI, SCLK, 20000, 3); // MCP3008 ADC +.br + +.br + for (i=0; i<256; i++) +.br + { +.br + cmd1[1] = i; +.br + +.br + count = bb_spi_xfer(pi, CE0, cmd1, (char *)inBuf, 2); // > DAC +.br + +.br + if (count == 2) +.br + { +.br + count = bb_spi_xfer(pi, CE0, cmd2, (char *)inBuf, 2); // < DAC +.br + +.br + if (count == 2) +.br + { +.br + set_val = inBuf[1]; +.br + +.br + count = bb_spi_xfer(pi, CE1, cmd3, (char *)inBuf, 3); // < ADC +.br + +.br + if (count == 3) +.br + { +.br + read_val = ((inBuf[1]&3)<<8) | inBuf[2]; +.br + printf("%d %d\n", set_val, read_val); +.br + } +.br + } +.br + } +.br + } +.br + +.br + bb_spi_close(pi, CE0); +.br + bb_spi_close(pi, CE1); +.br + +.br + pigpio_stop(pi); +.br +} +.br + +.EE + +.IP "\fBint spi_open(int pi, unsigned spi_channel, unsigned baud, unsigned spi_flags)\fP" +.IP "" 4 +This function returns a handle for the SPI device on the channel. +Data will be transferred at baud bits per second. The flags may +be used to modify the default behaviour of 4-wire operation, mode 0, +active low chip select. + +.br + +.br +The Pi has two SPI peripherals: main and auxiliary. + +.br + +.br +The main SPI has two chip selects (channels), the auxiliary has +three. + +.br + +.br +The auxiliary SPI is available on all models but the A and B. + +.br + +.br +The GPIO used are given in the following table. + +.br + +.br + MISO MOSI SCLK CE0 CE1 CE2 +.br +Main SPI 9 10 11 8 7 - +.br +Aux SPI 19 20 21 18 17 16 +.br + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +spi_channel: 0-1 (0-2 for the auxiliary SPI). +.br + baud: 32K-125M (values above 30M are unlikely to work). +.br + spi_flags: see below. +.br + +.EE + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL, +PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED. + +.br + +.br +spi_flags consists of the least significant 22 bits. + +.br + +.br + +.EX +21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m +.br + +.EE + +.br + +.br +mm defines the SPI mode. + +.br + +.br +Warning: modes 1 and 3 do not appear to work on the auxiliary SPI. + +.br + +.br + +.EX +Mode POL PHA +.br + 0 0 0 +.br + 1 0 1 +.br + 2 1 0 +.br + 3 1 1 +.br + +.EE + +.br + +.br +px is 0 if CEx is active low (default) and 1 for active high. + +.br + +.br +ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise. + +.br + +.br +A is 0 for the main SPI, 1 for the auxiliary SPI. + +.br + +.br +W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Main +SPI only. + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +bbbbbb defines the word size in bits (0-32). The default (0) +sets 8 bits per word. Auxiliary SPI only. + +.br + +.br +The \fBspi_read\fP, \fBspi_write\fP, and \fBspi_xfer\fP functions +transfer data packed into 1, 2, or 4 bytes according to +the word size in bits. + +.br + +.br +For bits 1-8 there will be one byte per character. +.br +For bits 9-16 there will be two bytes per character. +.br +For bits 17-32 there will be four bytes per character. + +.br + +.br +Multi-byte transfers are made in least significant byte first order. + +.br + +.br +E.g. to transfer 32 11-bit words buf should contain 64 bytes +and count should be 64. + +.br + +.br +E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed +by 0x1A. + +.br + +.br +The other bits in flags should be set to zero. + +.IP "\fBint spi_close(int pi, unsigned handle)\fP" +.IP "" 4 +This functions closes the SPI device identified by the handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBspi_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint spi_read(int pi, unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function reads count bytes of data from the SPI +device associated with the handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBspi_open\fP. +.br + buf: an array to receive the read data bytes. +.br + count: the number of bytes to read. +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint spi_write(int pi, unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function writes count bytes of data from buf to the SPI +device associated with the handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBspi_open\fP. +.br + buf: the data bytes to write. +.br + count: the number of bytes to write. +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint spi_xfer(int pi, unsigned handle, char *txBuf, char *rxBuf, unsigned count)\fP" +.IP "" 4 +This function transfers count bytes of data from txBuf to the SPI +device associated with the handle. Simultaneously count bytes of +data are read from the device and placed in rxBuf. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBspi_open\fP. +.br + txBuf: the data bytes to write. +.br + rxBuf: the received data bytes. +.br + count: the number of bytes to transfer. +.br + +.EE + +.br + +.br +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. + +.IP "\fBint serial_open(int pi, char *ser_tty, unsigned baud, unsigned ser_flags)\fP" +.IP "" 4 +This function opens a serial device at a specified baud rate +with specified flags. The device name must start with +/dev/tty or /dev/serial. + +.br + +.br + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + ser_tty: the serial device to open. +.br + baud: the baud rate in bits per second, see below. +.br +ser_flags: 0. +.br + +.EE + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or +PI_SER_OPEN_FAILED. + +.br + +.br +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. + +.br + +.br +No flags are currently defined. This parameter should be set to zero. + +.IP "\fBint serial_close(int pi, unsigned handle)\fP" +.IP "" 4 +This function closes the serial device associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.IP "\fBint serial_write_byte(int pi, unsigned handle, unsigned bVal)\fP" +.IP "" 4 +This function writes bVal to the serial port associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. + +.IP "\fBint serial_read_byte(int pi, unsigned handle)\fP" +.IP "" 4 +This function reads a byte from the serial port associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + +.EE + +.br + +.br +Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED. + +.br + +.br +If no data is ready PI_SER_READ_NO_DATA is returned. + +.IP "\fBint serial_write(int pi, unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function writes count bytes from buf to the the serial port +associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + buf: the array of bytes to write. +.br + count: the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. + +.IP "\fBint serial_read(int pi, unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function reads up to count bytes from the the serial port +associated with handle and writes them to buf. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + buf: an array to receive the read data. +.br + count: the maximum number of bytes to read. +.br + +.EE + +.br + +.br +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED. + +.br + +.br +If no data is ready zero is returned. + +.IP "\fBint serial_data_available(int pi, unsigned handle)\fP" +.IP "" 4 +Returns the number of bytes available to be read from the +device associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0, as returned by a call to \fBserial_open\fP. +.br + +.EE + +.br + +.br +Returns the number of bytes of data available (>=0) if OK, +otherwise PI_BAD_HANDLE. + +.IP "\fBint custom_1(int pi, unsigned arg1, unsigned arg2, char *argx, unsigned argc)\fP" +.IP "" 4 +This function is available for user customisation. + +.br + +.br +It returns a single integer value. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +arg1: >=0 +.br +arg2: >=0 +.br +argx: extra (byte) arguments +.br +argc: number of extra arguments +.br + +.EE + +.br + +.br +Returns >= 0 if OK, less than 0 indicates a user defined error. + +.IP "\fBint custom_2(int pi, unsigned arg1, char *argx, unsigned argc, char *retBuf, unsigned retMax)\fP" +.IP "" 4 +This function is available for user customisation. + +.br + +.br +It differs from custom_1 in that it returns an array of bytes +rather than just an integer. + +.br + +.br +The return value is an integer indicating the number of returned bytes. + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + arg1: >=0 +.br + argc: extra (byte) arguments +.br + count: number of extra arguments +.br +retBuf: buffer for returned data +.br +retMax: maximum number of bytes to return +.br + +.EE + +.br + +.br +Returns >= 0 if OK, less than 0 indicates a user defined error. + +.br + +.br +Note, the number of returned bytes will be retMax or less. + +.IP "\fBint get_pad_strength(int pi, unsigned pad)\fP" +.IP "" 4 +This function returns the pad drive strength in mA. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +pad: 0-2, the pad to get. +.br + +.EE + +.br + +.br +Returns the pad drive strength if OK, otherwise PI_BAD_PAD. + +.br + +.br +Pad GPIO +.br +0 0-27 +.br +1 28-45 +.br +2 46-53 +.br + +.br + +.br +\fBExample\fP +.br + +.EX +strength = get_pad_strength(pi, 0); // get pad 0 strength +.br + +.EE + +.IP "\fBint set_pad_strength(int pi, unsigned pad, unsigned padStrength)\fP" +.IP "" 4 +This function sets the pad drive strength in mA. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + pad: 0-2, the pad to set. +.br +padStrength: 1-16 mA. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH. + +.br + +.br +Pad GPIO +.br +0 0-27 +.br +1 28-45 +.br +2 46-53 +.br + +.br + +.br +\fBExample\fP +.br + +.EX +set_pad_strength(pi, 0, 10); // set pad 0 strength to 10 mA +.br + +.EE + +.IP "\fBint shell_(int pi, char *scriptName, char *scriptString)\fP" +.IP "" 4 +This function uses the system call to execute a shell script +with the given string as its parameter. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + scriptName: the name of the script, only alphanumeric characters, +.br + '-' and '_' are allowed in the name. +.br +scriptString: the string to pass to the script. +.br + +.EE + +.br + +.br +The exit status of the system call is returned if OK, otherwise +PI_BAD_SHELL_STATUS. + +.br + +.br +scriptName must exist in /opt/pigpio/cgi and must be executable. + +.br + +.br +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. + +.br + +.br +The following table gives some example returned statuses. + +.br + +.br +Script exit status Returned system call status +.br +1 256 +.br +5 1280 +.br +10 2560 +.br +200 51200 +.br +script not found 32512 +.br + +.br + +.br +\fBExample\fP +.br + +.EX +// pass two parameters, hello and world +.br +status = shell_(pi, "scr1", "hello world"); +.br + +.br +// pass three parameters, hello, string with spaces, and world +.br +status = shell_(pi, "scr1", "hello 'string with spaces' world"); +.br + +.br +// pass one parameter, hello string with spaces world +.br +status = shell_(pi, "scr1", "\"hello string with spaces world\""); +.br + +.EE + +.IP "\fBint file_open(int pi, char *file, unsigned mode)\fP" +.IP "" 4 +This function returns a handle to a file opened in a specified mode. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +file: the file to open. +.br +mode: the file open mode. +.br + +.EE + +.br + +.br +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS, +PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR. + +.br + +.br +File + +.br + +.br +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. + +.br + +.br +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. + +.br + +.br +Where more than one entry matches a file the most specific rule +applies. If no entry matches a file then access is denied. + +.br + +.br +Suppose /opt/pigpio/access contains the following entries + +.br + +.br + +.EX +/home/* n +.br +/home/pi/shared/dir_1/* w +.br +/home/pi/shared/dir_2/* r +.br +/home/pi/shared/dir_3/* u +.br +/home/pi/shared/dir_1/file.txt n +.br + +.EE + +.br + +.br +Files may be written in directory dir_1 with the exception +of file.txt. + +.br + +.br +Files may be read in directory dir_2. + +.br + +.br +Files may be read and written in directory dir_3. + +.br + +.br +If a directory allows read, write, or read/write access then files may +be created in that directory. + +.br + +.br +In an attempt to prevent risky permissions the following paths are +ignored in /opt/pigpio/access. + +.br + +.br + +.EX +a path containing .. +.br +a path containing only wildcards (*?) +.br +a path containing less than two non-wildcard parts +.br + +.EE + +.br + +.br +Mode + +.br + +.br +The mode may have the following values. + +.br + +.br +Macro Value Meaning +.br +PI_FILE_READ 1 open file for reading +.br +PI_FILE_WRITE 2 open file for writing +.br +PI_FILE_RW 3 open file for reading and writing +.br + +.br + +.br +The following values may be or'd into the mode. + +.br + +.br +Macro Value Meaning +.br +PI_FILE_APPEND 4 Writes append data to the end of the file +.br +PI_FILE_CREATE 8 The file is created if it doesn't exist +.br +PI_FILE_TRUNC 16 The file is truncated +.br + +.br + +.br +Newly created files are owned by root with permissions owner read and write. + +.br + +.br +\fBExample\fP +.br + +.EX +#include +.br +#include +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int pi, handle, c; +.br + char buf[60000]; +.br + +.br + pi = pigpio_start(NULL, NULL); +.br + +.br + if (pi < 0) return 1; +.br + +.br + // assumes /opt/pigpio/access contains the following line +.br + // /ram/*.c r +.br + +.br + handle = file_open(pi, "/ram/pigpio.c", PI_FILE_READ); +.br + +.br + if (handle >= 0) +.br + { +.br + while ((c=file_read(pi, handle, buf, sizeof(buf)-1))) +.br + { +.br + buf[c] = 0; +.br + printf("%s", buf); +.br + } +.br + +.br + file_close(pi, handle); +.br + } +.br + +.br + pigpio_stop(pi); +.br +} +.br + +.EE + +.IP "\fBint file_close(int pi, unsigned handle)\fP" +.IP "" 4 +This function closes the file associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0 (as returned by \fBfile_open\fP). +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +.br + +.br +\fBExample\fP +.br + +.EX +file_close(pi, handle); +.br + +.EE + +.IP "\fBint file_write(int pi, unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function writes count bytes from buf to the the file +associated with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0 (as returned by \fBfile_open\fP). +.br + buf: the array of bytes to write. +.br + count: the number of bytes to write. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, +PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE. + +.br + +.br +\fBExample\fP +.br + +.EX +if (file_write(pi, handle, buf, 100) == 0) +.br +{ +.br + // file written okay +.br +} +.br +else +.br +{ +.br + // error +.br +} +.br + +.EE + +.IP "\fBint file_read(int pi, unsigned handle, char *buf, unsigned count)\fP" +.IP "" 4 +This function reads up to count bytes from the the file +associated with handle and writes them to buf. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +handle: >=0 (as returned by \fBfile_open\fP). +.br + buf: an array to receive the read data. +.br + count: the maximum number of bytes to read. +.br + +.EE + +.br + +.br +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE. + +.br + +.br +\fBExample\fP +.br + +.EX + bytes = file_read(pi, handle, buf, sizeof(buf)); +.br + +.br + if (bytes >= 0) +.br + { +.br + // process read data +.br + } +.br + +.EE + +.IP "\fBint file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom)\fP" +.IP "" 4 +This function seeks to a position within the file associated +with handle. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + handle: >=0 (as returned by \fBfile_open\fP). +.br +seekOffset: the number of bytes to move. Positive offsets +.br + move forward, negative offsets backwards. +.br + seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1), +.br + or PI_FROM_END (2). +.br + +.EE + +.br + +.br +Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK. + +.br + +.br +\fBExample\fP +.br + +.EX +file_seek(pi, handle, 123, PI_FROM_START); // Start plus 123 +.br + +.br +size = file_seek(pi, handle, 0, PI_FROM_END); // End, return size +.br + +.br +pos = file_seek(pi, handle, 0, PI_FROM_CURRENT); // Current position +.br + +.EE + +.IP "\fBint file_list(int pi, char *fpat, char *buf, unsigned count)\fP" +.IP "" 4 +This function returns a list of files which match a pattern. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + fpat: file pattern to match. +.br + buf: an array to receive the matching file names. +.br +count: the maximum number of bytes to read. +.br + +.EE + +.br + +.br +Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS, +or PI_NO_FILE_MATCH. + +.br + +.br +The pattern must match an entry in /opt/pigpio/access. The pattern +may contain wildcards. See \fBfile_open\fP. + +.br + +.br +NOTE + +.br + +.br +The returned value is not the number of files, it is the number +of bytes in the buffer. The file names are separated by newline +characters. + +.br + +.br +\fBExample\fP +.br + +.EX +#include +.br +#include +.br + +.br +int main(int argc, char *argv[]) +.br +{ +.br + int pi, handle, c; +.br + char buf[60000]; +.br + +.br + pi = pigpio_start(NULL, NULL); +.br + +.br + if (pi < 0) return 1; +.br + +.br + // assumes /opt/pigpio/access contains the following line +.br + // /ram/*.c r +.br + +.br + c = file_list(pi, "/ram/p*.c", buf, sizeof(buf)); +.br + +.br + if (c >= 0) +.br + { +.br + buf[c] = 0; +.br + printf("%s", buf); +.br + } +.br + +.br + pigpio_stop(pi); +.br +} +.br + +.EE + +.IP "\fBint callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f)\fP" +.IP "" 4 +This function initialises a new callback. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. +.br + f: the callback function. +.br + +.EE + +.br + +.br +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +.br + +.br +The callback is called with the GPIO, edge, and tick, whenever the +GPIO has the identified edge. + +.br + +.br + +.EX +Parameter Value Meaning +.br + +.br +GPIO 0-31 The GPIO which has changed state +.br + +.br +edge 0-2 0 = change to low (a falling edge) +.br + 1 = change to high (a rising edge) +.br + 2 = no level change (a watchdog timeout) +.br + +.br +tick 32 bit The number of microseconds since boot +.br + WARNING: this wraps around from +.br + 4294967295 to 0 roughly every 72 minutes +.br + +.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. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. +.br + f: the callback function. +.br + userdata: a pointer to arbitrary user data. +.br + +.EE + +.br + +.br +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +.br + +.br +The callback is called with the GPIO, edge, tick, and the userdata +pointer, whenever the GPIO has the identified edge. + +.br + +.br + +.EX +Parameter Value Meaning +.br + +.br +GPIO 0-31 The GPIO which has changed state +.br + +.br +edge 0-2 0 = change to low (a falling edge) +.br + 1 = change to high (a rising edge) +.br + 2 = no level change (a watchdog timeout) +.br + +.br +tick 32 bit The number of microseconds since boot +.br + WARNING: this wraps around from +.br + 4294967295 to 0 roughly every 72 minutes +.br + +.br +userdata pointer Pointer to an arbitrary object +.br + +.EE + +.IP "\fBint callback_cancel(unsigned callback_id)\fP" +.IP "" 4 +This function cancels a callback identified by its id. + +.br + +.br + +.EX +callback_id: >=0, as returned by a call to \fBcallback\fP or \fBcallback_ex\fP. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise pigif_callback_not_found. + +.IP "\fBint wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout)\fP" +.IP "" 4 +This function waits for an edge on the GPIO for up to timeout +seconds. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +user_gpio: 0-31. +.br + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. +.br + timeout: >=0. +.br + +.EE + +.br + +.br +The function returns when the edge occurs or after the timeout. + +.br + +.br +Do not use this function for precise timing purposes, +the edge is only checked 20 times a second. Whenever +you need to know the accurate time of GPIO events use +a \fBcallback\fP function. + +.br + +.br +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 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 + +.br +I can't get SPI to work properly. I tried with a +control word of 0x303 and swapped MISO and MOSI. + +.br + +.br +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 +receive buffer. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +bscxfer: a structure defining the transfer. +.br + +.br +typedef struct +.br +{ +.br + uint32_t control; // Write +.br + int rxCnt; // Read only +.br + char rxBuf[BSC_FIFO_SIZE]; // Read only +.br + int txCnt; // Write +.br + char txBuf[BSC_FIFO_SIZE]; // Write +.br +} bsc_xfer_t; +.br + +.EE + +.br + +.br +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 + +.br +Upon return rxCnt will be set to the number of received bytes placed +in rxBuf. + +.br + +.br +The returned function value is the status of the transfer (see below). + +.br + +.br +If there was an error the status will be less than zero +(and will contain the error code). + +.br + +.br +The most significant word of the returned status contains the number +of bytes actually copied from txBuf to the BSC transmit FIFO (may be +less than requested if the FIFO already contained untransmitted data). + +.br + +.br +Note that the control word sets the BSC mode. The BSC will stay in +that mode until a different control word is sent. + +.br + +.br +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 + 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 + +.br +control consists of the following bits. + +.br + +.br + +.EX +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + a a a a a a a - - IT HC TF IR RE TE BK EC ES PL PH I2 SP EN +.br + +.EE + +.br + +.br +Bits 0-13 are copied unchanged to the BSC CR register. See +pages 163-165 of the Broadcom peripherals document for full +details. + +.br + +.br +aaaaaaa defines the I2C slave address (only relevant in I2C mode) +.br +IT invert transmit status flags +.br +HC enable host control +.br +TF enable test FIFO +.br +IR invert receive status flags +.br +RE enable receive +.br +TE enable transmit +.br +BK abort operation and clear FIFOs +.br +EC send control register as first I2C byte +.br +ES send status register as first I2C byte +.br +PL set SPI polarity high +.br +PH set SPI phase high +.br +I2 enable I2C mode +.br +SP enable SPI mode +.br +EN enable BSC peripheral +.br + +.br + +.br +The returned status has the following format + +.br + +.br + +.EX +20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + S S S S S R R R R R T T T T T RB TE RF TF RE TB +.br + +.EE + +.br + +.br +Bits 0-15 are copied unchanged from the BSC FR register. See +pages 165-166 of the Broadcom peripherals document for full +details. + +.br + +.br +SSSSS number of bytes successfully copied to transmit FIFO +.br +RRRRR number of bytes in receieve FIFO +.br +TTTTT number of bytes in transmit FIFO +.br +RB receive busy +.br +TE transmit FIFO empty +.br +RF receive FIFO full +.br +TF transmit FIFO full +.br +RE receive FIFO empty +.br +TB transmit busy +.br + +.br + +.br +The following example shows how to configure the BSC peripheral as +an I2C slave with address 0x13 and send four bytes. + +.br + +.br +\fBExample\fP +.br + +.EX +bsc_xfer_t xfer; +.br + +.br +xfer.control = (0x13<<16) | 0x305; +.br + +.br +memcpy(xfer.txBuf, "ABCD", 4); +.br +xfer.txCnt = 4; +.br + +.br +status = bsc_xfer(pi, &xfer); +.br + +.br +if (status >= 0) +.br +{ +.br + // process transfer +.br +} +.br + +.EE + +.IP "\fBint bsc_i2c(int pi, int i2c_addr, bsc_xfer_t *bscxfer)\fP" +.IP "" 4 +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. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +i2c_addr: 0-0x7F. +.br + bscxfer: a structure defining the transfer. +.br + +.br +typedef struct +.br +{ +.br + uint32_t control; // N/A +.br + int rxCnt; // Read only +.br + char rxBuf[BSC_FIFO_SIZE]; // Read only +.br + int txCnt; // Write +.br + char txBuf[BSC_FIFO_SIZE]; // Write +.br +} bsc_xfer_t; +.br + +.EE + +.br + +.br +txCnt is set to the number of bytes to be transmitted, possibly +zero. The data itself should be copied to txBuf. + +.br + +.br +Any received data will be written to rxBuf with rxCnt set. + +.br + +.br +See \fBbsc_xfer\fP for details of the returned status value. + +.br + +.br +If there was an error the status will be less than zero +(and will contain the error code). + +.br + +.br +Note that an i2c_address of 0 may be used to close +the BSC device and reassign the used GPIO as inputs. + +.IP "\fBint event_callback(int pi, unsigned event, evtCBFunc_t f)\fP" +.IP "" 4 +This function initialises an event callback. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +event: 0-31. +.br + f: the callback function. +.br + +.EE + +.br + +.br +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +.br + +.br +The callback is called with the event id, and tick, whenever the +event occurs. + +.IP "\fBint event_callback_ex(int pi, unsigned event, evtCBFuncEx_t f, void *userdata)\fP" +.IP "" 4 +This function initialises an event callback. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + event: 0-31. +.br + f: the callback function. +.br +userdata: a pointer to arbitrary user data. +.br + +.EE + +.br + +.br +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +.br + +.br +The callback is called with the event id, the tick, and the userdata +pointer whenever the event occurs. + +.IP "\fBint event_callback_cancel(unsigned callback_id)\fP" +.IP "" 4 +This function cancels an event callback identified by its id. + +.br + +.br + +.EX +callback_id: >=0, as returned by a call to \fBevent_callback\fP or +.br +\fBevent_callback_ex\fP. +.br + +.EE + +.br + +.br +The function returns 0 if OK, otherwise pigif_callback_not_found. + +.IP "\fBint wait_for_event(int pi, unsigned event, double timeout)\fP" +.IP "" 4 +This function waits for an event for up to timeout seconds. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br + event: 0-31. +.br +timeout: >=0. +.br + +.EE + +.br + +.br +The function returns when the event occurs or after the timeout. + +.br + +.br +The function returns 1 if the event occurred, otherwise 0. + +.IP "\fBint event_trigger(int pi, unsigned event)\fP" +.IP "" 4 +This function signals the occurrence of an event. + +.br + +.br + +.EX + pi: >=0 (as returned by \fBpigpio_start\fP). +.br +event: 0-31. +.br + +.EE + +.br + +.br +Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + +.br + +.br +An event is a signal used to inform one or more consumers +to start an action. Each consumer which has registered an interest +in the event (e.g. by calling \fBevent_callback\fP) will be informed by +a callback. + +.br + +.br +One event, PI_EVENT_BSC (31) is predefined. This event is +auto generated on BSC slave activity. + +.br + +.br +The meaning of other events is arbitrary. + +.br + +.br +Note that other than its id and its tick there is no data associated +with an event. +.SH PARAMETERS + +.br + +.br + +.IP "\fBactive\fP: 0-1000000" 0 + +.br + +.br +The number of microseconds level changes are reported for once +a noise filter has been triggered (by \fBsteady\fP microseconds of +a stable level). + +.br + +.br + +.IP "\fB*addrStr\fP" 0 +A string specifying the host or IP address of the Pi running +the pigpio daemon. It may be NULL in which case localhost +is used unless overridden by the PIGPIO_ADDR environment +variable. + +.br + +.br + +.IP "\fBarg1\fP" 0 +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +.br + +.br + +.IP "\fBarg2\fP" 0 +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +.br + +.br + +.IP "\fBargc\fP" 0 +The count of bytes passed to a user customised function. + +.br + +.br + +.IP "\fB*argx\fP" 0 +A pointer to an array of bytes passed to a user customised function. +Its meaning and content is defined by the customiser. + +.br + +.br + +.IP "\fBbaud\fP" 0 +The speed of serial communication (I2C, SPI, serial link, waves) in +bits per second. + +.br + +.br + +.IP "\fBbit\fP" 0 +A value of 0 or 1. + +.br + +.br + +.IP "\fBbits\fP" 0 +A value used to select GPIO. If bit n of bits is set then GPIO n is +selected. + +.br + +.br +A convenient way to set bit n is to or in (1<=0, as returned by a call to a callback function, one of + +.br + +.br +\fBcallback\fP +.br +\fBcallback_ex\fP +.br +\fBevent_callback\fP +.br +\fBevent_callback_ex\fP + +.br + +.br +The id is passed to \fBcallback_cancel\fP or \fBevent_callback_cancel\fP +to cancel the callback. + +.br + +.br + +.IP "\fBCBFunc_t\fP" 0 + +.EX +typedef void (*CBFunc_t) +.br + (int pi, unsigned user_gpio, unsigned level, uint32_t tick); +.br + +.EE + +.br + +.br + +.IP "\fBCBFuncEx_t\fP" 0 + +.EX +typedef void (*CBFuncEx_t) +.br + (int pi, unsigned user_gpio, unsigned level, uint32_t tick, void * userdata); +.br + +.EE + +.br + +.br + +.IP "\fBchar\fP" 0 +A single character, an 8 bit quantity able to store 0-255. + +.br + +.br + +.IP "\fBclkfreq\fP: 4689-250M (13184-375M for the BCM2711)" 0 +The hardware clock frequency. + +.br + +.br + +.IP "\fBcount\fP" 0 +The number of bytes to be transferred in a file, I2C, SPI, or serial +command. + +.br + +.br + +.IP "\fBCS\fP" 0 +The GPIO used for the slave select signal when bit banging SPI. + +.br + +.br + +.IP "\fBdata_bits\fP: 1-32" 0 +The number of data bits in each character of serial data. + +.br + +.br + +.EX +#define PI_MIN_WAVE_DATABITS 1 +.br +#define PI_MAX_WAVE_DATABITS 32 +.br + +.EE + +.br + +.br + +.IP "\fBdouble\fP" 0 +A floating point number. + +.br + +.br + +.IP "\fBdutycycle\fP: 0-range" 0 +A number representing the ratio of on time to off time for PWM. + +.br + +.br +The number may vary between 0 and range (default 255) where +0 is off and range is fully on. + +.br + +.br + +.IP "\fBedge\fP" 0 +Used to identify a GPIO level transition of interest. A rising edge is +a level change from 0 to 1. A falling edge is a level change from 1 to 0. + +.br + +.br + +.EX +RISING_EDGE 0 +.br +FALLING_EDGE 1 +.br +EITHER_EDGE. 2 +.br + +.EE + +.br + +.br + +.IP "\fBerrnum\fP" 0 +A negative number indicating a function call failed and the nature +of the error. + +.br + +.br + +.IP "\fBevent\fP: 0-31" 0 +An event is a signal used to inform one or more consumers +to start an action. + +.br + +.br + +.IP "\fBevtCBFunc_t\fP" 0 + +.br + +.br + +.EX +typedef void (*evtCBFunc_t) +.br + (int pi, unsigned event, uint32_t tick); +.br + +.EE + +.br + +.br + +.IP "\fBevtCBFuncEx_t\fP" 0 + +.br + +.br + +.EX +typedef void (*evtCBFuncEx_t) +.br + (int pi, unsigned event, uint32_t tick, void *userdata); +.br + +.EE + +.br + +.br + +.IP "\fBf\fP" 0 +A function. + +.br + +.br + +.IP "\fB*file\fP" 0 +A full file path. To be accessible the path must match an entry in +/opt/pigpio/access. + +.br + +.br + +.IP "\fB*fpat\fP" 0 +A file path which may contain wildcards. To be accessible the path +must match an entry in /opt/pigpio/access. + +.br + +.br + +.IP "\fBfrequency\fP: >=0" 0 +The number of times a GPIO is swiched on and off per second. This +can be set per GPIO and may be as little as 5Hz or as much as +40KHz. The GPIO will be on for a proportion of the time as defined +by its dutycycle. + +.br + +.br + +.IP "\fBgpio\fP" 0 +A Broadcom numbered GPIO, in the range 0-53. + +.br + +.br +There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through +GPIO53. + +.br + +.br +They are split into two banks. Bank 1 consists of GPIO0 through +GPIO31. Bank 2 consists of GPIO32 through GPIO53. + +.br + +.br +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. + +.br + +.br +See \fBget_hardware_revision\fP. + +.br + +.br +The user GPIO are marked with an X in the following table. + +.br + +.br + +.EX + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +.br +Type 1 X X - - X - - X X X X X - - X X +.br +Type 2 - - X X X - - X X X X X - - X X +.br +Type 3 X X X X X X X X X X X X X X +.br + +.br + 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +.br +Type 1 - X X - - X X X X X - - - - - - +.br +Type 2 - X X - - - X X X X - X X X X X +.br +Type 3 X X X X X X X X X X X X - - - - +.br + +.EE + +.br + +.br + +.IP "\fBgpioPulse_t\fP" 0 + +.EX +typedef struct +.br +{ +.br + uint32_t gpioOn; +.br + uint32_t gpioOff; +.br + uint32_t usDelay; +.br +} gpioPulse_t; +.br + +.EE + +.br + +.br + +.IP "\fBgpioThreadFunc_t\fP" 0 + +.EX +typedef void *(gpioThreadFunc_t) (void *); +.br + +.EE + +.br + +.br + +.IP "\fBhandle\fP: >=0" 0 +A number referencing an object opened by one of + +.br + +.br +\fBfile_open\fP +.br +\fBi2c_open\fP +.br +\fBnotify_open\fP +.br +\fBserial_open\fP +.br +\fBspi_open\fP + +.br + +.br + +.IP "\fBi2c_addr\fP: 0-0x7F" 0 +The address of a device on the I2C bus. + +.br + +.br + +.IP "\fBi2c_bus\fP: >=0" 0 +An I2C bus number. + +.br + +.br + +.IP "\fBi2c_flags\fP: 0" 0 +Flags which modify an I2C open command. None are currently defined. + +.br + +.br + +.IP "\fBi2c_reg\fP: 0-255" 0 +A register of an I2C device. + +.br + +.br + +.IP "\fB*inBuf\fP" 0 +A buffer used to pass data to a function. + +.br + +.br + +.IP "\fBinLen\fP" 0 +The number of bytes of data in a buffer. + +.br + +.br + +.IP "\fBint\fP" 0 +A whole number, negative or positive. + +.br + +.br + +.IP "\fBint32_t\fP" 0 +A 32-bit signed value. + +.br + +.br + +.IP "\fBinvert\fP" 0 +A flag used to set normal or inverted bit bang serial data level logic. + +.br + +.br + +.IP "\fBlevel\fP" 0 +The level of a GPIO. Low or High. + +.br + +.br + +.EX +PI_OFF 0 +.br +PI_ON 1 +.br + +.br +PI_CLEAR 0 +.br +PI_SET 1 +.br + +.br +PI_LOW 0 +.br +PI_HIGH 1 +.br + +.EE + +.br + +.br +There is one exception. If a watchdog expires on a GPIO the level will be +reported as PI_TIMEOUT. See \fBset_watchdog\fP. + +.br + +.br + +.EX +PI_TIMEOUT 2 +.br + +.EE + +.br + +.br + +.IP "\fBMISO\fP" 0 +The GPIO used for the MISO signal when bit banging SPI. + +.br + +.br + +.IP "\fBmode\fP" 0 +1. The operational mode of a GPIO, normally INPUT or OUTPUT. + +.br + +.br + +.EX +PI_INPUT 0 +.br +PI_OUTPUT 1 +.br +PI_ALT0 4 +.br +PI_ALT1 5 +.br +PI_ALT2 6 +.br +PI_ALT3 7 +.br +PI_ALT4 3 +.br +PI_ALT5 2 +.br + +.EE + +.br + +.br +2. The mode of waveform transmission. + +.br + +.br + +.EX +PI_WAVE_MODE_ONE_SHOT 0 +.br +PI_WAVE_MODE_REPEAT 1 +.br +PI_WAVE_MODE_ONE_SHOT_SYNC 2 +.br +PI_WAVE_MODE_REPEAT_SYNC 3 +.br + +.EE + +.br + +.br +3. A file open mode. + +.br + +.br + +.EX +PI_FILE_READ 1 +.br +PI_FILE_WRITE 2 +.br +PI_FILE_RW 3 +.br + +.EE + +.br + +.br +The following values can be or'd into the mode. + +.br + +.br + +.EX +PI_FILE_APPEND 4 +.br +PI_FILE_CREATE 8 +.br +PI_FILE_TRUNC 16 +.br + +.EE + +.br + +.br + +.IP "\fBMOSI\fP" 0 +The GPIO used for the MOSI signal when bit banging SPI. + +.br + +.br + +.IP "\fBnumBytes\fP" 0 +The number of bytes used to store characters in a string. Depending +on the number of bits per character there may be 1, 2, or 4 bytes +per character. + +.br + +.br + +.IP "\fBnumPar\fP: 0-10" 0 +The number of parameters passed to a script. + +.br + +.br + +.IP "\fBnumPulses\fP" 0 +The number of pulses to be added to a waveform. + +.br + +.br + +.IP "\fBoffset\fP" 0 +The associated data starts this number of microseconds from the start of +the waveform. + +.br + +.br + +.IP "\fB*outBuf\fP" 0 +A buffer used to return data from a function. + +.br + +.br + +.IP "\fBoutLen\fP" 0 +The size in bytes of an output buffer. + +.br + +.br + +.IP "\fBpad\fP: 0-2" 0 +A set of GPIO which share common drivers. + +.br + +.br +Pad GPIO +.br +0 0-27 +.br +1 28-45 +.br +2 46-53 +.br + +.br + +.br + +.IP "\fBpadStrength\fP: 1-16" 0 +The mA which may be drawn from each GPIO whilst still guaranteeing the +high and low levels. + +.br + +.br + +.IP "\fB*param\fP" 0 +An array of script parameters. + +.br + +.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. + +.br + +.br + +.IP "\fB*portStr\fP" 0 +A string specifying the port address used by the Pi running +the pigpio daemon. It may be NULL in which case "8888" +is used unless overridden by the PIGPIO_PORT environment +variable. + +.br + +.br + +.IP "\fB*pth\fP" 0 +A thread identifier, returned by \fBstart_thread\fP. + +.br + +.br + +.br + +.br + +.IP "\fBpthread_t\fP" 0 +A thread identifier. + +.br + +.br + +.IP "\fBpud\fP: 0-2" 0 +The setting of the pull up/down resistor for a GPIO, which may be off, +pull-up, or pull-down. + +.EX +PI_PUD_OFF 0 +.br +PI_PUD_DOWN 1 +.br +PI_PUD_UP 2 +.br + +.EE + +.br + +.br + +.IP "\fBpulseLen\fP" 0 +1-100, the length of a trigger pulse in microseconds. + +.br + +.br + +.IP "\fB*pulses\fP" 0 +An array of pulses to be added to a waveform. + +.br + +.br + +.IP "\fBpulsewidth\fP: 0, 500-2500" 0 + +.EX +PI_SERVO_OFF 0 +.br +PI_MIN_SERVO_PULSEWIDTH 500 +.br +PI_MAX_SERVO_PULSEWIDTH 2500 +.br + +.EE + +.br + +.br + +.IP "\fBPWMduty\fP: 0-1000000 (1M)" 0 +The hardware PWM dutycycle. + +.br + +.br + +.EX +#define PI_HW_PWM_RANGE 1000000 +.br + +.EE + +.br + +.br + +.IP "\fBPWMfreq\fP: 1-125M (1-187.5M for the BCM2711)" 0 +The hardware PWM frequency. + +.br + +.br + +.EX +#define PI_HW_PWM_MIN_FREQ 1 +.br +#define PI_HW_PWM_MAX_FREQ 125000000 +.br +#define PI_HW_PWM_MAX_FREQ_2711 187500000 +.br + +.EE + +.br + +.br + +.IP "\fBrange\fP: 25-40000" 0 +The permissible dutycycle values are 0-range. + +.br + +.br + +.EX +PI_MIN_DUTYCYCLE_RANGE 25 +.br +PI_MAX_DUTYCYCLE_RANGE 40000 +.br + +.EE + +.br + +.br + +.IP "\fB*retBuf\fP" 0 +A buffer to hold a number of bytes returned to a used customised function, + +.br + +.br + +.IP "\fBretMax\fP" 0 +The maximum number of bytes a user customised function should return. + +.br + +.br + +.br + +.br + +.IP "\fB*rxBuf\fP" 0 +A pointer to a buffer to receive data. + +.br + +.br + +.IP "\fBSCL\fP" 0 +The user GPIO to use for the clock when bit banging I2C. + +.br + +.br + +.IP "\fBSCLK\fP" 0 +The GPIO used for the SCLK signal when bit banging SPI. + +.br + +.br + +.IP "\fB*script\fP" 0 +A pointer to the text of a script. + +.br + +.br + +.IP "\fBscript_id\fP" 0 +An id of a stored script as returned by \fBstore_script\fP. + +.br + +.br + +.IP "\fB*scriptName\fP" 0 +The name of a \fBshell_\fP script to be executed. The script must be present in +/opt/pigpio/cgi and must have execute permission. + +.br + +.br + +.IP "\fB*scriptString\fP" 0 +The string to be passed to a \fBshell_\fP script to be executed. + +.br + +.br + +.IP "\fBSDA\fP" 0 +The user GPIO to use for data when bit banging I2C. + +.br + +.br + +.IP "\fBseconds\fP" 0 +The number of seconds. + +.br + +.br + +.IP "\fBseekFrom\fP" 0 + +.br + +.br + +.EX +PI_FROM_START 0 +.br +PI_FROM_CURRENT 1 +.br +PI_FROM_END 2 +.br + +.EE + +.br + +.br + +.IP "\fBseekOffset\fP" 0 +The number of bytes to move forward (positive) or backwards (negative) +from the seek position (start, current, or end of file). + +.br + +.br + +.IP "\fBser_flags\fP" 0 +Flags which modify a serial open command. None are currently defined. + +.br + +.br + +.IP "\fB*ser_tty\fP" 0 +The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1. + +.br + +.br + +.IP "\fBsize_t\fP" 0 +A standard type used to indicate the size of an object in bytes. + +.br + +.br + +.IP "\fBspi_channel\fP" 0 +A SPI channel, 0-2. + +.br + +.br + +.IP "\fBspi_flags\fP" 0 +See \fBspi_open\fP and \fBbb_spi_open\fP. + +.br + +.br + +.IP "\fBsteady\fP: 0-300000" 0 + +.br + +.br +The number of microseconds level changes must be stable for +before reporting the level changed (\fBset_glitch_filter\fP) or triggering +the active part of a noise filter (\fBset_noise_filter\fP). + +.br + +.br + +.IP "\fBstop_bits\fP: 2-8" 0 +The number of (half) stop bits to be used when adding serial data +to a waveform. + +.br + +.br + +.EX +#define PI_MIN_WAVE_HALFSTOPBITS 2 +.br +#define PI_MAX_WAVE_HALFSTOPBITS 8 +.br + +.EE + +.br + +.br + +.IP "\fB*str\fP" 0 + An array of characters. + +.br + +.br + +.IP "\fBthread_func\fP" 0 +A function of type gpioThreadFunc_t used as the main function of a +thread. + +.br + +.br + +.IP "\fBtimeout\fP" 0 +A GPIO watchdog timeout in milliseconds. + +.br + +.br + +.EX +PI_MIN_WDOG_TIMEOUT 0 +.br +PI_MAX_WDOG_TIMEOUT 60000 +.br + +.EE + +.br + +.br + +.IP "\fB*txBuf\fP" 0 +An array of bytes to transmit. + +.br + +.br + +.IP "\fBuint32_t\fP: 0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)" 0 +A 32-bit unsigned value. + +.br + +.br + +.IP "\fBunsigned\fP" 0 +A whole number >= 0. + +.br + +.br + +.IP "\fBuser_gpio\fP" 0 +0-31, a Broadcom numbered GPIO. + +.br + +.br +See \fBgpio\fP. + +.br + +.br + +.IP "\fB*userdata\fP" 0 + +.br + +.br +A pointer to arbitrary user data. This may be used to identify the instance. + +.br + +.br +You must ensure that the pointer is in scope at the time it is processed. If +it is a pointer to a global this is automatic. Do not pass the address of a +local variable. If you want to pass a transient object then use the +following technique. + +.br + +.br +In the calling function: + +.br + +.br + +.EX +user_type *userdata; +.br +.br +.br +user_type my_userdata; +.br + +.br +userdata = malloc(sizeof(user_type)); +.br +.br +.br +*userdata = my_userdata; +.br + +.EE + +.br + +.br +In the receiving function: + +.br + +.br + +.EX +user_type my_userdata = *(user_type*)userdata; +.br + +.br +free(userdata); +.br + +.EE + +.br + +.br + +.IP "\fBvoid\fP" 0 +Denoting no parameter is required + +.br + +.br + +.IP "\fBwave_add_*\fP" 0 +One of + +.br + +.br +\fBwave_add_new\fP +.br +\fBwave_add_generic\fP +.br +\fBwave_add_serial\fP + +.br + +.br + +.IP "\fBwave_id\fP" 0 +A number representing a waveform created by \fBwave_create\fP. + +.br + +.br + +.IP "\fBwave_send_*\fP" 0 +One of + +.br + +.br +\fBwave_send_once\fP +.br +\fBwave_send_repeat\fP + +.br + +.br + +.IP "\fBwVal\fP: 0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777)" 0 +A 16-bit word value. + +.br + +.br +.SH pigpiod_if2 Error Codes + +.EX + +.br +typedef enum +.br +{ +.br + pigif_bad_send = -2000, +.br + pigif_bad_recv = -2001, +.br + pigif_bad_getaddrinfo = -2002, +.br + pigif_bad_connect = -2003, +.br + pigif_bad_socket = -2004, +.br + pigif_bad_noib = -2005, +.br + pigif_duplicate_callback = -2006, +.br + pigif_bad_malloc = -2007, +.br + pigif_bad_callback = -2008, +.br + pigif_notify_failed = -2009, +.br + pigif_callback_not_found = -2010, +.br + pigif_unconnected_pi = -2011, +.br + pigif_too_many_pis = -2012, +.br +} pigifError_t; +.br + +.br + +.EE + +.SH SEE ALSO + +pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3) +.SH AUTHOR + +joan@abyz.me.uk diff --git a/pigpiod_if2.c b/pigpiod_if2.c new file mode 100644 index 0000000..ab2ef10 --- /dev/null +++ b/pigpiod_if2.c @@ -0,0 +1,2126 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +/* PIGPIOD_IF2_VERSION 17 */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include "pigpio.h" +#include "command.h" + +#include "pigpiod_if2.h" + +#define PI_MAX_REPORTS_PER_READ 4096 + +#define STACK_SIZE (256*1024) + +#define MAX_PI 32 + +typedef void (*CBF_t) (); + +struct callback_s +{ + + int id; + int pi; + int gpio; + int edge; + CBF_t f; + void * user; + int ex; + callback_t *prev; + callback_t *next; +}; + +struct evtCallback_s +{ + + int id; + int pi; + int event; + CBF_t f; + void * user; + int ex; + evtCallback_t *prev; + evtCallback_t *next; +}; + +/* GLOBALS ---------------------------------------------------------------- */ + +static int gPiInUse [MAX_PI]; + +static int gPigCommand [MAX_PI]; +static int gPigHandle [MAX_PI]; +static int gPigNotify [MAX_PI]; + +static uint32_t gEventBits [MAX_PI]; +static uint32_t gNotifyBits [MAX_PI]; +static uint32_t gLastLevel [MAX_PI]; + +static pthread_t *gPthNotify [MAX_PI]; + +static pthread_mutex_t gCmdMutex [MAX_PI]; +static int gCancelState [MAX_PI]; + +static callback_t *gCallBackFirst = 0; +static callback_t *gCallBackLast = 0; + +static evtCallback_t *geCallBackFirst = 0; +static evtCallback_t *geCallBackLast = 0; + +/* PRIVATE ---------------------------------------------------------------- */ + +static void _pml(int pi) +{ + int cancelState; + + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancelState); + pthread_mutex_lock(&gCmdMutex[pi]); + gCancelState[pi] = cancelState; +} + +static void _pmu(int pi) +{ + int cancelState; + + cancelState = gCancelState[pi]; + pthread_mutex_unlock(&gCmdMutex[pi]); + pthread_setcancelstate(cancelState, NULL); +} + +static int pigpio_command(int pi, int command, int p1, int p2, int rl) +{ + cmdCmd_t cmd; + + if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) + return pigif_unconnected_pi; + + cmd.cmd = command; + cmd.p1 = p1; + cmd.p2 = p2; + cmd.res = 0; + + _pml(pi); + + if (send(gPigCommand[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd)) + { + _pmu(pi); + return pigif_bad_send; + } + + if (recv(gPigCommand[pi], &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd)) + { + _pmu(pi); + return pigif_bad_recv; + } + + if (rl) _pmu(pi); + + return cmd.res; +} + +static int pigpio_notify(int pi) +{ + cmdCmd_t cmd; + + if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) + return pigif_unconnected_pi; + + cmd.cmd = PI_CMD_NOIB; + cmd.p1 = 0; + cmd.p2 = 0; + cmd.res = 0; + + _pml(pi); + + if (send(gPigNotify[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd)) + { + _pmu(pi); + return pigif_bad_send; + } + + if (recv(gPigNotify[pi], &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd)) + { + _pmu(pi); + return pigif_bad_recv; + } + + _pmu(pi); + + return cmd.res; +} + +static int pigpio_command_ext + (int pi, int command, int p1, int p2, int p3, + int extents, gpioExtent_t *ext, int rl) +{ + int i; + cmdCmd_t cmd; + + if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) + return pigif_unconnected_pi; + + cmd.cmd = command; + cmd.p1 = p1; + cmd.p2 = p2; + cmd.p3 = p3; + + _pml(pi); + + if (send(gPigCommand[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd)) + { + _pmu(pi); + return pigif_bad_send; + } + + for (i=0; iai_next) + { + sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); + + if (sock == -1) continue; + + /* Disable the Nagle algorithm. */ + opt = 1; + setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(int)); + + if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) break; + } + + freeaddrinfo(res); + + if (rp == NULL) return pigif_bad_connect; + + return sock; +} + +static void dispatch_notification(int pi, gpioReport_t *r) +{ + callback_t *p; + evtCallback_t *ep; + uint32_t changed; + int l, g; + +/* + printf("s=%4x f=%4x t=%10u l=%8x\n", + r->seqno, r->flags, r->tick, r->level); +*/ + + if (r->flags == 0) + { + changed = (r->level ^ gLastLevel[pi]) & gNotifyBits[pi]; + + gLastLevel[pi] = r->level; + + p = gCallBackFirst; + + while (p) + { + if (((p->pi) == pi) && (changed & (1<<(p->gpio)))) + { + if ((r->level) & (1<<(p->gpio))) l = 1; else l = 0; + if ((p->edge) ^ l) + { + if (p->ex) (p->f)(pi, p->gpio, l, r->tick, p->user); + else (p->f)(pi, p->gpio, l, r->tick); + } + } + p = p->next; + } + } + else + { + if ((r->flags) & PI_NTFY_FLAGS_WDOG) + { + g = (r->flags) & 31; + + p = gCallBackFirst; + + while (p) + { + if (((p->pi) == pi) && ((p->gpio) == g)) + { + if (p->ex) (p->f)(pi, g, PI_TIMEOUT, r->tick, p->user); + else (p->f)(pi, g, PI_TIMEOUT, r->tick); + } + p = p->next; + } + } + else if ((r->flags) & PI_NTFY_FLAGS_EVENT) + { + g = (r->flags) & 31; + + ep = geCallBackFirst; + + while (ep) + { + if (((ep->pi) == pi) && ((ep->event) == g)) + { + if (ep->ex) (ep->f)(pi, g, r->tick, ep->user); + else (ep->f)(pi, g, r->tick); + } + ep = ep->next; + } + } + } +} + +static void *pthNotifyThread(void *x) +{ + static int got = 0; + int pi; + int bytes, r; + gpioReport_t report[PI_MAX_REPORTS_PER_READ]; + + pi = *((int*)x); + free(x); /* memory allocated in pigpio_start */ + + while (1) + { + bytes = read(gPigNotify[pi], (char*)&report+got, sizeof(report)-got); + + if (bytes > 0) got += bytes; + else break; + + r = 0; + + while (got >= sizeof(gpioReport_t)) + { + dispatch_notification(pi, &report[r]); + + r++; + + got -= sizeof(gpioReport_t); + } + + /* copy any partial report to start of array */ + + if (got && r) report[0] = report[r]; + } + + fprintf(stderr, "notify thread for pi %d broke with read error %d\n", + pi, bytes); + + while (1) sleep(1); + + return NULL; +} + +static void findNotifyBits(int pi) +{ + callback_t *p; + uint32_t bits = 0; + + p = gCallBackFirst; + + while (p) + { + if (p->pi == pi) bits |= (1<<(p->gpio)); + p = p->next; + } + + if (bits != gNotifyBits[pi]) + { + gNotifyBits[pi] = bits; + pigpio_command(pi, PI_CMD_NB, gPigHandle[pi], gNotifyBits[pi], 1); + } +} + +static void _wfe( + int pi, unsigned user_gpio, unsigned level, uint32_t tick, void *user) +{ + *(int *)user = 1; +} + +static int intCallback( + int pi, unsigned user_gpio, unsigned edge, void *f, void *user, int ex) +{ + static int id = 0; + callback_t *p; + + if ((user_gpio >=0) && (user_gpio < 32) && (edge >=0) && (edge <= 2) && f) + { + /* prevent duplicates */ + + p = gCallBackFirst; + + while (p) + { + if ((p->pi == pi) && + (p->gpio == user_gpio) && + (p->edge == edge) && + (p->f == f)) + { + return pigif_duplicate_callback; + } + p = p->next; + } + + p = malloc(sizeof(callback_t)); + + if (p) + { + if (!gCallBackFirst) gCallBackFirst = p; + + p->id = id++; + p->pi = pi; + p->gpio = user_gpio; + p->edge = edge; + p->f = f; + p->user = user; + p->ex = ex; + p->next = 0; + p->prev = gCallBackLast; + + if (p->prev) (p->prev)->next = p; + gCallBackLast = p; + + findNotifyBits(pi); + + return p->id; + } + + return pigif_bad_malloc; + } + + return pigif_bad_callback; +} + +static void findEventBits(int pi) +{ + evtCallback_t *ep; + uint32_t bits = 0; + + ep = geCallBackFirst; + + while (ep) + { + if (ep->pi == pi) bits |= (1<<(ep->event)); + ep = ep->next; + } + + if (bits != gEventBits[pi]) + { + gEventBits[pi] = bits; + pigpio_command(pi, PI_CMD_EVM, gPigHandle[pi], gEventBits[pi], 1); + } +} + +static void _ewfe( + int pi, unsigned event, uint32_t tick, void *user) +{ + *(int *)user = 1; +} + +static int intEventCallback( + int pi, unsigned event, void *f, void *user, int ex) +{ + static int id = 0; + evtCallback_t *ep; + + if ((event >=0) && (event < 32) && f) + { + /* prevent duplicates */ + + ep = geCallBackFirst; + + while (ep) + { + if ((ep->pi == pi) && + (ep->event == event) && + (ep->f == f)) + { + return pigif_duplicate_callback; + } + ep = ep->next; + } + + ep = malloc(sizeof(evtCallback_t)); + + if (ep) + { + if (!geCallBackFirst) geCallBackFirst = ep; + + ep->id = id++; + ep->pi = pi; + ep->event = event; + ep->f = f; + ep->user = user; + ep->ex = ex; + ep->next = 0; + ep->prev = geCallBackLast; + + if (ep->prev) (ep->prev)->next = ep; + geCallBackLast = ep; + + findEventBits(pi); + + return ep->id; + } + + return pigif_bad_malloc; + } + + return pigif_bad_callback; +} + +static int recvMax(int pi, void *buf, int bufsize, int sent) +{ + /* + Copy at most bufSize bytes from the receieved message to + buf. Discard the rest of the message. + */ + uint8_t scratch[4096]; + int remaining, fetch, count; + + if (sent < bufsize) count = sent; else count = bufsize; + + if (count) recv(gPigCommand[pi], buf, count, MSG_WAITALL); + + remaining = sent - count; + + while (remaining) + { + fetch = remaining; + if (fetch > sizeof(scratch)) fetch = sizeof(scratch); + recv(gPigCommand[pi], scratch, fetch, MSG_WAITALL); + remaining -= fetch; + } + + return count; +} + +/* PUBLIC ----------------------------------------------------------------- */ + +double time_time(void) +{ + struct timeval tv; + double t; + + gettimeofday(&tv, 0); + + t = (double)tv.tv_sec + ((double)tv.tv_usec / 1E6); + + return t; +} + +void time_sleep(double seconds) +{ + struct timespec ts, rem; + + if (seconds > 0.0) + { + ts.tv_sec = seconds; + ts.tv_nsec = (seconds-(double)ts.tv_sec) * 1E9; + + while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem)) + { + /* copy remaining time to ts */ + ts.tv_sec = rem.tv_sec; + ts.tv_nsec = rem.tv_nsec; + } + } +} + +char *pigpio_error(int errnum) +{ + if (errnum > -1000) return cmdErrStr(errnum); + else + { + switch(errnum) + { + case pigif_bad_send: + return "failed to send to pigpiod"; + case pigif_bad_recv: + return "failed to receive from pigpiod"; + case pigif_bad_getaddrinfo: + return "failed to find address of pigpiod"; + case pigif_bad_connect: + return "failed to connect to pigpiod"; + case pigif_bad_socket: + return "failed to create socket"; + case pigif_bad_noib: + return "failed to open notification in band"; + case pigif_duplicate_callback: + return "identical callback exists"; + case pigif_bad_malloc: + return "failed to malloc"; + case pigif_bad_callback: + return "bad callback parameter"; + case pigif_notify_failed: + return "failed to create notification thread"; + case pigif_callback_not_found: + return "callback not found"; + case pigif_unconnected_pi: + return "not connected to Pi"; + case pigif_too_many_pis: + return "too many connected Pis"; + + default: + return "unknown error"; + } + } +} + +unsigned pigpiod_if_version(void) +{ + return PIGPIOD_IF2_VERSION; +} + +pthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata) +{ + pthread_t *pth; + pthread_attr_t pthAttr; + + pth = malloc(sizeof(pthread_t)); + + if (pth) + { + if (pthread_attr_init(&pthAttr)) + { + perror("pthread_attr_init failed"); + free(pth); + return NULL; + } + + if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE)) + { + perror("pthread_attr_setstacksize failed"); + free(pth); + return NULL; + } + + if (pthread_create(pth, &pthAttr, thread_func, userdata)) + { + perror("pthread_create socket failed"); + free(pth); + return NULL; + } + } + return pth; +} + +void stop_thread(pthread_t *pth) +{ + if (pth) + { + pthread_cancel(*pth); + pthread_join(*pth, NULL); + free(pth); + } +} + +int pigpio_start(char *addrStr, char *portStr) +{ + int pi; + int *userdata; + + for (pi=0; pi= MAX_PI) return pigif_too_many_pis; + + 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); + + if (gPigCommand[pi] >= 0) + { + gPigNotify[pi] = pigpioOpenSocket(addrStr, portStr); + + if (gPigNotify[pi] >= 0) + { + gPigHandle[pi] = pigpio_notify(pi); + + if (gPigHandle[pi] < 0) return pigif_bad_noib; + else + { + gLastLevel[pi] = read_bank_1(pi); + + /* must be freed by pthNotifyThread */ + userdata = malloc(sizeof(*userdata)); + *userdata = pi; + + gPthNotify[pi] = start_thread(pthNotifyThread, userdata); + + if (gPthNotify[pi]) return pi; + else return pigif_notify_failed; + + } + } + else return gPigNotify[pi]; + } + else return gPigCommand[pi]; +} + +void pigpio_stop(int pi) +{ + if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) return; + + if (gPthNotify[pi]) + { + stop_thread(gPthNotify[pi]); + gPthNotify[pi] = 0; + } + + if (gPigCommand[pi] >= 0) + { + if (gPigHandle[pi] >= 0) + { + pigpio_command(pi, PI_CMD_NC, gPigHandle[pi], 0, 1); + gPigHandle[pi] = -1; + } + + close(gPigCommand[pi]); + gPigCommand[pi] = -1; + } + + if (gPigNotify[pi] >= 0) + { + close(gPigNotify[pi]); + gPigNotify[pi] = -1; + } + + gPiInUse[pi] = 0; +} + +int set_mode(int pi, unsigned gpio, unsigned mode) + {return pigpio_command(pi, PI_CMD_MODES, gpio, mode, 1);} + +int get_mode(int pi, unsigned gpio) + {return pigpio_command(pi, PI_CMD_MODEG, gpio, 0, 1);} + +int set_pull_up_down(int pi, unsigned gpio, unsigned pud) + {return pigpio_command(pi, PI_CMD_PUD, gpio, pud, 1);} + +int gpio_read(int pi, unsigned gpio) + {return pigpio_command(pi, PI_CMD_READ, gpio, 0, 1);} + +int gpio_write(int pi, unsigned gpio, unsigned level) + {return pigpio_command(pi, PI_CMD_WRITE, gpio, level, 1);} + +int set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle) + {return pigpio_command(pi, PI_CMD_PWM, user_gpio, dutycycle, 1);} + +int get_PWM_dutycycle(int pi, unsigned user_gpio) + {return pigpio_command(pi, PI_CMD_GDC, user_gpio, 0, 1);} + +int set_PWM_range(int pi, unsigned user_gpio, unsigned range) + {return pigpio_command(pi, PI_CMD_PRS, user_gpio, range, 1);} + +int get_PWM_range(int pi, unsigned user_gpio) + {return pigpio_command(pi, PI_CMD_PRG, user_gpio, 0, 1);} + +int get_PWM_real_range(int pi, unsigned user_gpio) + {return pigpio_command(pi, PI_CMD_PRRG, user_gpio, 0, 1);} + +int set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency) + {return pigpio_command(pi, PI_CMD_PFS, user_gpio, frequency, 1);} + +int get_PWM_frequency(int pi, unsigned user_gpio) + {return pigpio_command(pi, PI_CMD_PFG, user_gpio, 0, 1);} + +int set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth) + {return pigpio_command(pi, PI_CMD_SERVO, user_gpio, pulsewidth, 1);} + +int get_servo_pulsewidth(int pi, unsigned user_gpio) + {return pigpio_command(pi, PI_CMD_GPW, user_gpio, 0, 1);} + +int notify_open(int pi) + {return pigpio_command(pi, PI_CMD_NO, 0, 0, 1);} + +int notify_begin(int pi, unsigned handle, uint32_t bits) + {return pigpio_command(pi, PI_CMD_NB, handle, bits, 1);} + +int notify_pause(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_NB, handle, 0, 1);} + +int notify_close(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_NC, handle, 0, 1);} + +int set_watchdog(int pi, unsigned user_gpio, unsigned timeout) + {return pigpio_command(pi, PI_CMD_WDOG, user_gpio, timeout, 1);} + +uint32_t read_bank_1(int pi) + {return pigpio_command(pi, PI_CMD_BR1, 0, 0, 1);} + +uint32_t read_bank_2(int pi) + {return pigpio_command(pi, PI_CMD_BR2, 0, 0, 1);} + +int clear_bank_1(int pi, uint32_t levels) + {return pigpio_command(pi, PI_CMD_BC1, levels, 0, 1);} + +int clear_bank_2(int pi, uint32_t levels) + {return pigpio_command(pi, PI_CMD_BC2, levels, 0, 1);} + +int set_bank_1(int pi, uint32_t levels) + {return pigpio_command(pi, PI_CMD_BS1, levels, 0, 1);} + +int set_bank_2(int pi, uint32_t levels) + {return pigpio_command(pi, PI_CMD_BS2, levels, 0, 1);} + +int hardware_clock(int pi, unsigned gpio, unsigned frequency) + {return pigpio_command(pi, PI_CMD_HC, gpio, frequency, 1);} + +int hardware_PWM(int pi, unsigned gpio, unsigned frequency, uint32_t dutycycle) +{ + gpioExtent_t ext[1]; + + /* + p1=gpio + p2=frequency + p3=4 + ## extension ## + uint32_t dutycycle + */ + + ext[0].size = sizeof(dutycycle); + ext[0].ptr = &dutycycle; + + return pigpio_command_ext( + pi, PI_CMD_HP, gpio, frequency, sizeof(dutycycle), 1, ext, 1); +} + +uint32_t get_current_tick(int pi) + {return pigpio_command(pi, PI_CMD_TICK, 0, 0, 1);} + +uint32_t get_hardware_revision(int pi) + {return pigpio_command(pi, PI_CMD_HWVER, 0, 0, 1);} + +uint32_t get_pigpio_version(int pi) + {return pigpio_command(pi, PI_CMD_PIGPV, 0, 0, 1);} + +int wave_clear(int pi) + {return pigpio_command(pi, PI_CMD_WVCLR, 0, 0, 1);} + +int wave_add_new(int pi) + {return pigpio_command(pi, PI_CMD_WVNEW, 0, 0, 1);} + +int wave_add_generic(int pi, unsigned numPulses, gpioPulse_t *pulses) +{ + gpioExtent_t ext[1]; + + /* + p1=0 + p2=0 + p3=pulses*sizeof(gpioPulse_t) + ## extension ## + gpioPulse_t[] pulses + */ + + if (!numPulses) return 0; + + ext[0].size = numPulses * sizeof(gpioPulse_t); + ext[0].ptr = pulses; + + return pigpio_command_ext( + pi, PI_CMD_WVAG, 0, 0, ext[0].size, 1, ext, 1); +} + +int wave_add_serial( + int pi, unsigned user_gpio, unsigned baud, uint32_t databits, + uint32_t stophalfbits, uint32_t offset, unsigned numChar, char *str) +{ + uint8_t buf[12]; + gpioExtent_t ext[2]; + + /* + p1=user_gpio + p2=baud + p3=len+12 + ## extension ## + uint32_t databits + uint32_t stophalfbits + uint32_t offset + char[len] str + */ + + if (!numChar) return 0; + + memcpy(buf, &databits, 4); + memcpy(buf+4, &stophalfbits, 4); + memcpy(buf+8, &offset, 4); + + ext[0].size = sizeof(buf); + ext[0].ptr = buf; + + ext[1].size = numChar; + ext[1].ptr = str; + + return pigpio_command_ext(pi, PI_CMD_WVAS, + user_gpio, baud, numChar+sizeof(buf), 2, ext, 1); +} + +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);} + +int wave_tx_start(int pi) /* DEPRECATED */ + {return pigpio_command(pi, PI_CMD_WVGO, 0, 0, 1);} + +int wave_tx_repeat(int pi) /* DEPRECATED */ + {return pigpio_command(pi, PI_CMD_WVGOR, 0, 0, 1);} + +int wave_send_once(int pi, unsigned wave_id) + {return pigpio_command(pi, PI_CMD_WVTX, wave_id, 0, 1);} + +int wave_send_repeat(int pi, unsigned wave_id) + {return pigpio_command(pi, PI_CMD_WVTXR, wave_id, 0, 1);} + +int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode) + {return pigpio_command(pi, PI_CMD_WVTXM, wave_id, mode, 1);} + +int wave_chain(int pi, char *buf, unsigned bufSize) +{ + gpioExtent_t ext[1]; + + /* + p1=0 + p2=0 + p3=bufSize + ## extension ## + char buf[bufSize] + */ + + ext[0].size = bufSize; + ext[0].ptr = buf; + + return pigpio_command_ext + (pi, PI_CMD_WVCHA, 0, 0, bufSize, 1, ext, 1); +} + +int wave_tx_at(int pi) + {return pigpio_command(pi, PI_CMD_WVTAT, 0, 0, 1);} + +int wave_tx_busy(int pi) + {return pigpio_command(pi, PI_CMD_WVBSY, 0, 0, 1);} + +int wave_tx_stop(int pi) + {return pigpio_command(pi, PI_CMD_WVHLT, 0, 0, 1);} + +int wave_get_micros(int pi) + {return pigpio_command(pi, PI_CMD_WVSM, 0, 0, 1);} + +int wave_get_high_micros(int pi) + {return pigpio_command(pi, PI_CMD_WVSM, 1, 0, 1);} + +int wave_get_max_micros(int pi) + {return pigpio_command(pi, PI_CMD_WVSM, 2, 0, 1);} + +int wave_get_pulses(int pi) + {return pigpio_command(pi, PI_CMD_WVSP, 0, 0, 1);} + +int wave_get_high_pulses(int pi) + {return pigpio_command(pi, PI_CMD_WVSP, 1, 0, 1);} + +int wave_get_max_pulses(int pi) + {return pigpio_command(pi, PI_CMD_WVSP, 2, 0, 1);} + +int wave_get_cbs(int pi) + {return pigpio_command(pi, PI_CMD_WVSC, 0, 0, 1);} + +int wave_get_high_cbs(int pi) + {return pigpio_command(pi, PI_CMD_WVSC, 1, 0, 1);} + +int wave_get_max_cbs(int pi) + {return pigpio_command(pi, PI_CMD_WVSC, 2, 0, 1);} + +int gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, uint32_t level) +{ + gpioExtent_t ext[1]; + + /* + p1=user_gpio + p2=pulseLen + p3=4 + ## extension ## + unsigned level + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &level; + + return pigpio_command_ext( + pi, PI_CMD_TRIG, user_gpio, pulseLen, 4, 1, ext, 1); +} + +int set_glitch_filter(int pi, unsigned user_gpio, unsigned steady) + {return pigpio_command(pi, PI_CMD_FG, user_gpio, steady, 1);} + +int set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active) +{ + gpioExtent_t ext[1]; + + /* + p1=user_gpio + p2=steady + p3=4 + ## extension ## + unsigned active + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &active; + + return pigpio_command_ext( + pi, PI_CMD_FN, user_gpio, steady, 4, 1, ext, 1); +} + +int store_script(int pi, char *script) +{ + unsigned len; + gpioExtent_t ext[1]; + + /* + p1=0 + p2=0 + p3=len + ## extension ## + char[len] script + */ + + len = strlen(script); + + if (!len) return 0; + + ext[0].size = len; + ext[0].ptr = script; + + return pigpio_command_ext(pi, PI_CMD_PROC, 0, 0, len, 1, ext, 1); +} + +int run_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param) +{ + gpioExtent_t ext[1]; + + /* + p1=script id + p2=0 + p3=numPar * 4 + ## extension ## + uint32_t[numPar] pars + */ + + ext[0].size = 4 * numPar; + ext[0].ptr = param; + + return pigpio_command_ext + (pi, PI_CMD_PROCR, script_id, 0, numPar*4, 1, ext, 1); +} + +int update_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param) +{ + gpioExtent_t ext[1]; + + /* + p1=script id + p2=0 + p3=numPar * 4 + ## extension ## + uint32_t[numPar] pars + */ + + ext[0].size = 4 * numPar; + ext[0].ptr = param; + + return pigpio_command_ext + (pi, PI_CMD_PROCU, script_id, 0, numPar*4, 1, ext, 1); +} + +int script_status(int pi, unsigned script_id, uint32_t *param) +{ + int status; + uint32_t p[PI_MAX_SCRIPT_PARAMS+1]; /* space for script status */ + + status = pigpio_command(pi, PI_CMD_PROCP, script_id, 0, 0); + + if (status > 0) + { + recvMax(pi, p, sizeof(p), status); + status = p[0]; + if (param) memcpy(param, p+1, sizeof(p)-4); + } + + _pmu(pi); + + return status; +} + +int stop_script(int pi, unsigned script_id) + {return pigpio_command(pi, PI_CMD_PROCS, script_id, 0, 1);} + +int delete_script(int pi, unsigned script_id) + {return pigpio_command(pi, PI_CMD_PROCD, script_id, 0, 1);} + +int bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, uint32_t bbBits) +{ + gpioExtent_t ext[1]; + + /* + p1=user_gpio + p2=baud + p3=4 + ## extension ## + unsigned bbBits + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &bbBits; + + return pigpio_command_ext( + pi, PI_CMD_SLRO, user_gpio, baud, 4, 1, ext, 1); +} + +int bb_serial_read(int pi, unsigned user_gpio, void *buf, size_t bufSize) +{ + int bytes; + + bytes = pigpio_command(pi, PI_CMD_SLR, user_gpio, bufSize, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, bufSize, bytes); + } + + _pmu(pi); + + return bytes; +} + +int bb_serial_read_close(int pi, unsigned user_gpio) + {return pigpio_command(pi, PI_CMD_SLRC, user_gpio, 0, 1);} + +int bb_serial_invert(int pi, unsigned user_gpio, unsigned invert) + {return pigpio_command(pi, PI_CMD_SLRI, user_gpio, invert, 1);} + +int i2c_open(int pi, unsigned i2c_bus, unsigned i2c_addr, uint32_t i2c_flags) +{ + gpioExtent_t ext[1]; + + /* + p1=i2c_bus + p2=i2c_addr + p3=4 + ## extension ## + uint32_t i2c_flags + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &i2c_flags; + + return pigpio_command_ext + (pi, PI_CMD_I2CO, i2c_bus, i2c_addr, 4, 1, ext, 1); +} + +int i2c_close(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_I2CC, handle, 0, 1);} + +int i2c_write_quick(int pi, unsigned handle, unsigned bit) + {return pigpio_command(pi, PI_CMD_I2CWQ, handle, bit, 1);} + +int i2c_write_byte(int pi, unsigned handle, unsigned val) + {return pigpio_command(pi, PI_CMD_I2CWS, handle, val, 1);} + +int i2c_read_byte(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_I2CRS, handle, 0, 1);} + +int i2c_write_byte_data(int pi, unsigned handle, unsigned reg, uint32_t val) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=4 + ## extension ## + uint32_t val + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &val; + + return pigpio_command_ext + (pi, PI_CMD_I2CWB, handle, reg, 4, 1, ext, 1); +} + +int i2c_write_word_data(int pi, unsigned handle, unsigned reg, uint32_t val) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=4 + ## extension ## + uint32_t val + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &val; + + return pigpio_command_ext + (pi, PI_CMD_I2CWW, handle, reg, 4, 1, ext, 1); +} + +int i2c_read_byte_data(int pi, unsigned handle, unsigned reg) + {return pigpio_command(pi, PI_CMD_I2CRB, handle, reg, 1);} + +int i2c_read_word_data(int pi, unsigned handle, unsigned reg) + {return pigpio_command(pi, PI_CMD_I2CRW, handle, reg, 1);} + +int i2c_process_call(int pi, unsigned handle, unsigned reg, uint32_t val) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=4 + ## extension ## + uint32_t val + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &val; + + return pigpio_command_ext + (pi, PI_CMD_I2CPC, handle, reg, 4, 1, ext, 1); +} + +int i2c_write_block_data( + int pi, unsigned handle, unsigned reg, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (pi, PI_CMD_I2CWK, handle, reg, count, 1, ext, 1); +} + +int i2c_read_block_data(int pi, unsigned handle, unsigned reg, char *buf) +{ + int bytes; + + bytes = pigpio_command(pi, PI_CMD_I2CRK, handle, reg, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, 32, bytes); + } + + _pmu(pi); + + return bytes; +} + +int i2c_block_process_call( + int pi, unsigned handle, unsigned reg, char *buf, unsigned count) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + bytes = pigpio_command_ext + (pi, PI_CMD_I2CPK, handle, reg, count, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, 32, bytes); + } + + _pmu(pi); + + return bytes; +} + +int i2c_read_i2c_block_data( + int pi, unsigned handle, unsigned reg, char *buf, uint32_t count) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=4 + ## extension ## + uint32_t count + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &count; + + bytes = pigpio_command_ext + (pi, PI_CMD_I2CRI, handle, reg, 4, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, count, bytes); + } + + _pmu(pi); + + return bytes; +} + + +int i2c_write_i2c_block_data( + int pi, unsigned handle, unsigned reg, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=reg + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (pi, PI_CMD_I2CWI, handle, reg, count, 1, ext, 1); +} + +int i2c_read_device(int pi, unsigned handle, char *buf, unsigned count) +{ + int bytes; + + bytes = pigpio_command(pi, PI_CMD_I2CRD, handle, count, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, count, bytes); + } + + _pmu(pi); + + return bytes; +} + +int i2c_write_device(int pi, unsigned handle, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (pi, PI_CMD_I2CWD, handle, 0, count, 1, ext, 1); +} + +int i2c_zip( + int pi, + unsigned handle, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=inLen + ## extension ## + char inBuf[inLen] + */ + + ext[0].size = inLen; + ext[0].ptr = inBuf; + + bytes = pigpio_command_ext + (pi, PI_CMD_I2CZ, handle, 0, inLen, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, outBuf, outLen, bytes); + } + + _pmu(pi); + + return bytes; +} + +int bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud) +{ + gpioExtent_t ext[1]; + + /* + p1=SDA + p2=SCL + p3=4 + ## extension ## + uint32_t baud + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &baud; + + return pigpio_command_ext + (pi, PI_CMD_BI2CO, SDA, SCL, 4, 1, ext, 1); +} + +int bb_i2c_close(int pi, unsigned SDA) + {return pigpio_command(pi, PI_CMD_BI2CC, SDA, 0, 1);} + +int bb_i2c_zip( + int pi, + unsigned SDA, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=SDA + p2=0 + p3=inLen + ## extension ## + char inBuf[inLen] + */ + + ext[0].size = inLen; + ext[0].ptr = inBuf; + + bytes = pigpio_command_ext + (pi, PI_CMD_BI2CZ, SDA, 0, inLen, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, outBuf, outLen, bytes); + } + + _pmu(pi); + + return bytes; +} + +int bb_spi_open( + int pi, + unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, + unsigned baud, unsigned spiFlags) +{ + uint8_t buf[20]; + gpioExtent_t ext[1]; + + /* + p1=CS + p2=0 + p3=20 + ## extension ## + uint32_t MISO + uint32_t MOSI + uint32_t SCLK + uint32_t baud + uint32_t spiFlags + */ + + ext[0].size = 20; + ext[0].ptr = &buf; + + memcpy(buf + 0, &MISO, 4); + memcpy(buf + 4, &MOSI, 4); + memcpy(buf + 8, &SCLK, 4); + memcpy(buf + 12, &baud, 4); + memcpy(buf + 16, &spiFlags, 4); + + return pigpio_command_ext + (pi, PI_CMD_BSPIO, CS, 0, 20, 1, ext, 1); +} + +int bb_spi_close(int pi, unsigned CS) + {return pigpio_command(pi, PI_CMD_BSPIC, CS, 0, 1);} + +int bb_spi_xfer( + int pi, + unsigned CS, + char *txBuf, + char *rxBuf, + unsigned count) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=CS + p2=0 + p3=count + ## extension ## + char txBuf[count] + */ + + ext[0].size = count; + ext[0].ptr = txBuf; + + bytes = pigpio_command_ext + (pi, PI_CMD_BSPIX, CS, 0, count, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, rxBuf, count, bytes); + } + + _pmu(pi); + + return bytes; +} + +int spi_open(int pi, unsigned channel, unsigned speed, uint32_t flags) +{ + gpioExtent_t ext[1]; + + /* + p1=channel + p2=speed + p3=4 + ## extension ## + uint32_t flags + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &flags; + + return pigpio_command_ext + (pi, PI_CMD_SPIO, channel, speed, 4, 1, ext, 1); +} + +int spi_close(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_SPIC, handle, 0, 1);} + +int spi_read(int pi, unsigned handle, char *buf, unsigned count) +{ + int bytes; + + bytes = pigpio_command + (pi, PI_CMD_SPIR, handle, count, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, count, bytes); + } + + _pmu(pi); + + return bytes; +} + +int spi_write(int pi, unsigned handle, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (pi, PI_CMD_SPIW, handle, 0, count, 1, ext, 1); +} + +int spi_xfer(int pi, unsigned handle, char *txBuf, char *rxBuf, unsigned count) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = txBuf; + + bytes = pigpio_command_ext + (pi, PI_CMD_SPIX, handle, 0, count, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, rxBuf, count, bytes); + } + + _pmu(pi); + + return bytes; +} + +int serial_open(int pi, char *dev, unsigned baud, unsigned flags) +{ + int len; + gpioExtent_t ext[1]; + + len = strlen(dev); + + /* + p1=baud + p2=flags + p3=len + ## extension ## + char dev[len] + */ + + ext[0].size = len; + ext[0].ptr = dev; + + return pigpio_command_ext + (pi, PI_CMD_SERO, baud, flags, len, 1, ext, 1); +} + +int serial_close(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_SERC, handle, 0, 1);} + +int serial_write_byte(int pi, unsigned handle, unsigned val) + {return pigpio_command(pi, PI_CMD_SERWB, handle, val, 1);} + +int serial_read_byte(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_SERRB, handle, 0, 1);} + +int serial_write(int pi, unsigned handle, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (pi, PI_CMD_SERW, handle, 0, count, 1, ext, 1); +} + +int serial_read(int pi, unsigned handle, char *buf, unsigned count) +{ + int bytes; + + bytes = pigpio_command + (pi, PI_CMD_SERR, handle, count, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, count, bytes); + } + + _pmu(pi); + + return bytes; +} + +int serial_data_available(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_SERDA, handle, 0, 1);} + +int custom_1(int pi, unsigned arg1, unsigned arg2, char *argx, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=arg1 + p2=arg2 + p3=count + ## extension ## + char argx[count] + */ + + ext[0].size = count; + ext[0].ptr = argx; + + return pigpio_command_ext( + pi, PI_CMD_CF1, arg1, arg2, count, 1, ext, 1); +} + + +int custom_2(int pi, unsigned arg1, char *argx, unsigned count, + char *retBuf, uint32_t retMax) +{ + int bytes; + gpioExtent_t ext[1]; + + /* + p1=arg1 + p2=retMax + p3=count + ## extension ## + char argx[count] + */ + + ext[0].size = count; + ext[0].ptr = argx; + + bytes = pigpio_command_ext + (pi, PI_CMD_CF2, arg1, retMax, count, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, retBuf, retMax, bytes); + } + + _pmu(pi); + + return bytes; +} + +int get_pad_strength(int pi, unsigned pad) + {return pigpio_command(pi, PI_CMD_PADG, pad, 0, 1);} + +int set_pad_strength(int pi, unsigned pad, unsigned padStrength) + {return pigpio_command(pi, PI_CMD_PADS, pad, padStrength, 1);} + +int shell_(int pi, char *scriptName, char *scriptString) +{ + int ln, ls; + gpioExtent_t ext[2]; + + ln = strlen(scriptName); + ls = strlen(scriptString); + /* + p1=len(scriptName) + p2=0 + p3=len(scriptName) + len(scriptString) + 1 + ## extension ## + char[] + */ + + ext[0].size = ln + 1; /* include null byte */ + ext[0].ptr = scriptName; + + ext[1].size = ls; + ext[1].ptr = scriptString; + + return pigpio_command_ext + (pi, PI_CMD_SHELL, ln, 0, ln+ls+1, 2, ext, 1); +} + +int file_open(int pi, char *file, unsigned mode) +{ + int len; + gpioExtent_t ext[1]; + + len = strlen(file); + + /* + p1=mode + p2=0 + p3=len + ## extension ## + char file[len] + */ + + ext[0].size = len; + ext[0].ptr = file; + + return pigpio_command_ext + (pi, PI_CMD_FO, mode, 0, len, 1, ext, 1); +} + +int file_close(int pi, unsigned handle) + {return pigpio_command(pi, PI_CMD_FC, handle, 0, 1);} + +int file_write(int pi, unsigned handle, char *buf, unsigned count) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=0 + p3=count + ## extension ## + char buf[count] + */ + + ext[0].size = count; + ext[0].ptr = buf; + + return pigpio_command_ext + (pi, PI_CMD_FW, handle, 0, count, 1, ext, 1); +} + +int file_read(int pi, unsigned handle, char *buf, unsigned count) +{ + int bytes; + + bytes = pigpio_command + (pi, PI_CMD_FR, handle, count, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, count, bytes); + } + + _pmu(pi); + + return bytes; +} + +int file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom) +{ + gpioExtent_t ext[1]; + + /* + p1=handle + p2=seekOffset + p3=4 + ## extension ## + uint32_t seekFrom + */ + + ext[0].size = sizeof(uint32_t); + ext[0].ptr = &seekFrom; + + return pigpio_command_ext + (pi, PI_CMD_FS, handle, seekOffset, 4, 1, ext, 1); +} + +int file_list(int pi, char *fpat, char *buf, unsigned count) +{ + int len; + int bytes; + gpioExtent_t ext[1]; + + len = strlen(fpat); + + /* + p1=60000 + p2=0 + p3=len + ## extension ## + char fpat[len] + */ + + ext[0].size = len; + ext[0].ptr = fpat; + + bytes = pigpio_command_ext(pi, PI_CMD_FL, 60000, 0, len, 1, ext, 0); + + if (bytes > 0) + { + bytes = recvMax(pi, buf, count, bytes); + } + + _pmu(pi); + + return bytes; +} + +int callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f) + {return intCallback(pi, user_gpio, edge, f, 0, 0);} + +int callback_ex( + int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *user) + {return intCallback(pi, user_gpio, edge, f, user, 1);} + +int callback_cancel(unsigned id) +{ + callback_t *p; + int pi; + + p = gCallBackFirst; + + while (p) + { + if (p->id == id) + { + pi = p->pi; + + if (p->prev) {p->prev->next = p->next;} + else {gCallBackFirst = p->next;} + + if (p->next) {p->next->prev = p->prev;} + else {gCallBackLast = p->prev;} + + free(p); + + findNotifyBits(pi); + + return 0; + } + p = p->next; + } + return pigif_callback_not_found; +} + +int wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout) +{ + int triggered = 0; + int id; + double due; + + if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) + return pigif_unconnected_pi; + + if (timeout <= 0.0) return 0; + + due = time_time() + timeout; + + id = callback_ex(pi, user_gpio, edge, _wfe, &triggered); + + while (!triggered && (time_time() < due)) time_sleep(0.05); + + callback_cancel(id); + + return triggered; +} + +int bsc_xfer(int pi, bsc_xfer_t *bscxfer) +{ + int bytes; + int status; + gpioExtent_t ext[1]; + + /* + p1=control + p2=0 + p3=len + ## extension ## + char buf[len] + */ + + ext[0].size = bscxfer->txCnt; + ext[0].ptr = bscxfer->txBuf; + + bytes = pigpio_command_ext + (pi, PI_CMD_BSCX, bscxfer->control, 0, bscxfer->txCnt, 1, ext, 0); + + if (bytes > 0) + { + recvMax(pi, &status, 4, 4); + status = ntohl(status); + bytes -= 4; + bytes = recvMax(pi, bscxfer->rxBuf, sizeof(bscxfer->rxBuf), bytes); + bscxfer->rxCnt = bytes; + } + else + { + status = bytes; + } + + _pmu(pi); + + return status; +} + + +int bsc_i2c(int pi, int i2c_addr, bsc_xfer_t *bscxfer) +{ + int control = 0; + + if (i2c_addr) control = (i2c_addr<<16) | 0x305; + bscxfer->control = control; + return bsc_xfer(pi, bscxfer); +} + + +int event_callback(int pi, unsigned event, evtCBFunc_t f) + {return intEventCallback(pi, event, f, 0, 0);} + +int event_callback_ex( + int pi, unsigned event, evtCBFuncEx_t f, void *user) + {return intEventCallback(pi, event, f, user, 1);} + +int event_callback_cancel(unsigned id) +{ + evtCallback_t *ep; + int pi; + + ep = geCallBackFirst; + + while (ep) + { + if (ep->id == id) + { + pi = ep->pi; + + if (ep->prev) {ep->prev->next = ep->next;} + else {geCallBackFirst = ep->next;} + + if (ep->next) {ep->next->prev = ep->prev;} + else {geCallBackLast = ep->prev;} + + free(ep); + + findEventBits(pi); + + return 0; + } + ep = ep->next; + } + return pigif_callback_not_found; +} + +int wait_for_event(int pi, unsigned event, double timeout) +{ + int triggered = 0; + int id; + double due; + + if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) + return pigif_unconnected_pi; + + if (timeout <= 0.0) return 0; + + due = time_time() + timeout; + + id = event_callback_ex(pi, event, _ewfe, &triggered); + + while (!triggered && (time_time() < due)) time_sleep(0.05); + + event_callback_cancel(id); + + return triggered; +} + +int event_trigger(int pi, unsigned event) + {return pigpio_command(pi, PI_CMD_EVM, event, 0, 1);} + diff --git a/pigpiod_if2.h b/pigpiod_if2.h new file mode 100644 index 0000000..9700cc0 --- /dev/null +++ b/pigpiod_if2.h @@ -0,0 +1,4379 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +#ifndef PIGPIOD_IF2_H +#define PIGPIOD_IF2_H + +#include "pigpio.h" + +#define PIGPIOD_IF2_VERSION 17 + +/*TEXT + +pigpiod_if2 is a C library for the Raspberry which allows control +of the GPIO via the socket interface to the pigpio daemon. + +*Features* + +o hardware timed PWM on any of GPIO 0-31 + +o hardware timed servo pulses on any of GPIO 0-31 + +o callbacks when any of GPIO 0-31 change state + +o callbacks at timed intervals + +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 rudimentary permission control over GPIO + +o a simple interface to start and stop new threads + +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. + +*Notes* + +The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals. + +*Usage* + +Include in your source files. + +Assuming your source is in prog.c use the following command to build + +. . +gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt +. . + +to run make sure the pigpio daemon is running + +. . +sudo pigpiod + + ./prog # sudo is not required to run programs linked to pigpiod_if2 +. . + +For examples see x_pigpiod_if2.c within the pigpio archive file. + +*Notes* + +All the functions which return an int return < 0 on error + +TEXT*/ + +/*OVERVIEW + +ESSENTIAL + +pigpio_start Connects to a pigpio daemon +pigpio_stop Disconnects from a pigpio daemon + +BASIC + +set_mode Set a GPIO mode +get_mode Get a GPIO mode + +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 + +INTERMEDIATE + +gpio_trigger Send a trigger pulse to a GPIO. + +set_watchdog Set a watchdog on a GPIO. + +read_bank_1 Read all GPIO in bank 1 +read_bank_2 Read all GPIO in bank 2 + +clear_bank_1 Clear selected GPIO in bank 1 +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 + +notify_open Request a notification handle +notify_begin Start notifications for selected GPIO +notify_pause Pause notifications +notify_close Close a notification + +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 + +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_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 + +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 + +I2C + +i2c_open Opens an I2C device +i2c_close Closes an I2C device + +i2c_write_quick smbus write quick + +i2c_read_byte smbus read byte +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_write_word_data smbus write word data + +i2c_read_block_data smbus read block data +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 + +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 bit banged I2C transactions + +I2C/SPI_SLAVE + +bsc_xfer I2C/SPI as slave transfer +bsc_i2c I2C as slave transfer + +SERIAL + +serial_open Opens a serial device +serial_close Closes 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_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 + +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_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 + +get_current_tick Get current tick (microseconds) + +get_hardware_revision Get hardware revision +get_pigpio_version Get the pigpio version +pigpiod_if_version Get the pigpiod_if2 version + +pigpio_error Get a text description of an error code. + +time_sleep Sleeps for a float number of seconds +time_time Float number of seconds since the epoch + +OVERVIEW*/ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*CBFunc_t) + (int pi, unsigned user_gpio, unsigned level, uint32_t tick); + +typedef void (*CBFuncEx_t) + (int pi, unsigned user_gpio, unsigned level, uint32_t tick, void *userdata); + +typedef struct callback_s callback_t; + +typedef void (*evtCBFunc_t) + (int pi, unsigned event, uint32_t tick); + +typedef void (*evtCBFuncEx_t) + (int pi, unsigned event, uint32_t tick, void *userdata); + +typedef struct evtCallback_s evtCallback_t; + +/*F*/ +double time_time(void); +/*D +Return the current time in seconds since the Epoch. +D*/ + +/*F*/ +void time_sleep(double seconds); +/*D +Delay execution for a given number of seconds. + +. . +seconds: the number of seconds to delay. +. . +D*/ + +/*F*/ +char *pigpio_error(int errnum); +/*D +Return a text description for an error code. + +. . +errnum: the error code. +. . +D*/ + +/*F*/ +unsigned pigpiod_if_version(void); +/*D +Return the pigpiod_if2 version. +D*/ + +/*F*/ +pthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata); +/*D +Starts a new thread of execution with thread_func as the main routine. + +. . +thread_func: the main function for the new thread. + userdata: a pointer to an arbitrary argument. +. . + +Returns a pointer to pthread_t if OK, otherwise NULL. + +The function is passed the single argument userdata. + +The thread can be cancelled by passing the pointer to pthread_t to +[*stop_thread*]. +D*/ + +/*F*/ +void stop_thread(pthread_t *pth); +/*D +Cancels the thread pointed at by pth. + +. . +pth: the thread to be stopped. +. . + +No value is returned. + +The thread to be stopped should have been started with [*start_thread*]. +D*/ + +/*F*/ +int pigpio_start(char *addrStr, char *portStr); +/*D +Connect to the pigpio daemon. Reserving command and +notification streams. + +. . +addrStr: specifies the host or IP address of the Pi running the + pigpio daemon. It may be NULL in which case localhost + is used unless overridden by the PIGPIO_ADDR environment + variable. + +portStr: specifies the port address used by the Pi running the + pigpio daemon. It may be NULL in which case "8888" + is used unless overridden by the PIGPIO_PORT environment + variable. +. . + +Returns an integer value greater than or equal to zero if OK. + +This value is passed to the GPIO routines to specify the Pi +to be operated on. +D*/ + +/*F*/ +void pigpio_stop(int pi); +/*D +Terminates the connection to a pigpio daemon and releases +resources used by the library. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int set_mode(int pi, unsigned gpio, unsigned mode); +/*D +Set the GPIO mode. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +gpio: 0-53. +mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1, + PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5. +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE, +or PI_NOT_PERMITTED. +D*/ + +/*F*/ +int get_mode(int pi, unsigned gpio); +/*D +Get the GPIO mode. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +gpio: 0-53. +. . + +Returns the GPIO mode if OK, otherwise PI_BAD_GPIO. +D*/ + +/*F*/ +int set_pull_up_down(int pi, unsigned gpio, unsigned pud); +/*D +Set or clear the GPIO pull-up/down resistor. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +gpio: 0-53. + pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF. +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_PUD, +or PI_NOT_PERMITTED. +D*/ + +/*F*/ +int gpio_read(int pi, unsigned gpio); +/*D +Read the GPIO level. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +gpio:0-53. +. . + +Returns the GPIO level if OK, otherwise PI_BAD_GPIO. +D*/ + +/*F*/ +int gpio_write(int pi, unsigned gpio, unsigned level); +/*D +Write the GPIO level. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + gpio: 0-53. +level: 0, 1. +. . + +Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_LEVEL, +or PI_NOT_PERMITTED. + +Notes + +If PWM or servo pulses are active on the GPIO they are switched off. +D*/ + +/*F*/ +int set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle); +/*D +Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. +dutycycle: 0-range (range defaults to 255). +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYCYCLE, +or PI_NOT_PERMITTED. +Notes + +The [*set_PWM_range*] function may be used to change the +default range of 255. +D*/ + +/*F*/ +int get_PWM_dutycycle(int pi, unsigned user_gpio); +/*D +Return the PWM dutycycle in use on a GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. + +For normal PWM the dutycycle will be out of the defined range +for the GPIO (see [*get_PWM_range*]). + +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). +D*/ + +/*F*/ +int set_PWM_range(int pi, unsigned user_gpio, unsigned range); +/*D +Set the range of PWM values to be used on the GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. + range: 25-40000. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE, +or PI_NOT_PERMITTED. + +Notes + +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 of the 18 available GPIO frequencies is + +. . + 25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6), + 400(#7), 500(#8), 625(#9), 800(#10), 1000(#11), 1250(#12), +2000(#13), 2500(#14), 4000(#15), 5000(#16), 10000(#17), 20000(#18) +. . + +The real value set by set_PWM_range is (dutycycle * real range) / range. +D*/ + +/*F*/ +int get_PWM_range(int pi, unsigned user_gpio); +/*D +Get the range of PWM values being used on the GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. +. . + +Returns the dutycycle range used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +If a hardware clock or hardware PWM is active on the GPIO the +reported range will be 1000000 (1M). +D*/ + +/*F*/ +int get_PWM_real_range(int pi, unsigned user_gpio); +/*D +Get the real underlying range of PWM values being used on the GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. +. . + +Returns the real range used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. + +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. + +D*/ + +/*F*/ +int set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency); +/*D +Set the frequency (in Hz) of the PWM to be used on the GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. +frequency: >=0 (Hz). +. . + +Returns the numerically closest frequency if OK, otherwise +PI_BAD_USER_GPIO or PI_NOT_PERMITTED. + +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 +. . +D*/ + +/*F*/ +int get_PWM_frequency(int pi, unsigned user_gpio); +/*D +Get the frequency of PWM being used on the GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. +. . + +For normal PWM the frequency will be that defined for the GPIO by +[*set_PWM_frequency*]. + +If a hardware clock is active on the GPIO the reported frequency +will be that set by [*hardware_clock*]. + +If hardware PWM is active on the GPIO the reported frequency +will be that set by [*hardware_PWM*]. + +Returns the frequency (in hertz) used for the GPIO if OK, +otherwise PI_BAD_USER_GPIO. +D*/ + +/*F*/ +int set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth); +/*D +Start (500-2500) or stop (0) servo pulses on the GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + user_gpio: 0-31. +pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise). +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_PULSEWIDTH or +PI_NOT_PERMITTED. + +The selected pulsewidth will continue to be transmitted until +changed by a subsequent call to set_servo_pulsewidth. + +The pulsewidths supported by servos varies and should probably be +determined by experiment. 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. + +OTHER UPDATE RATES: + +This function updates servos at 50Hz. If you wish to use a different +update frequency you will have to use the PWM functions. + +. . +Update Rate (Hz) 50 100 200 400 500 +1E6/Hz 20000 10000 5000 2500 2000 +. . + +Firstly set the desired PWM frequency using [*set_PWM_frequency*]. + +Then set the PWM range using [*set_PWM_range*] to 1E6/Hz. +Doing this allows you to use units of microseconds when setting +the servo pulsewidth. + +E.g. If you want to update a servo connected to GPIO 25 at 400Hz + +. . +set_PWM_frequency(25, 400); +set_PWM_range(25, 2500); +. . + +Thereafter use the [*set_PWM_dutycycle*] function to move the servo, +e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse. +D*/ + +/*F*/ +int get_servo_pulsewidth(int pi, unsigned user_gpio); +/*D +Return the servo pulsewidth in use on a GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO. +D*/ + +/*F*/ +int notify_open(int pi); +/*D +Get a free notification handle. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +Returns a handle greater than or equal to zero if OK, +otherwise PI_NO_HANDLE. + +A notification is a method for being notified of GPIO state +changes via a pipe. + +Pipes are only accessible from the local machine so this function +serves no purpose if you are using the library from a remote machine. +The in-built (socket) notifications provided by [*callback*] +should be used instead. + +Notifications for handle x will be available at the pipe +named /dev/pigpiox (where x is the handle number). +E.g. if the function returns 15 then the notifications must be +read from /dev/pigpio15. +D*/ + +/*F*/ +int notify_begin(int pi, unsigned handle, uint32_t bits); +/*D +Start notifications on a previously opened handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: 0-31 (as returned by [*notify_open*]) + bits: a mask indicating the GPIO to be notified. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +The notification sends state changes for each GPIO whose +corresponding bit in bits is set. + +Each notification occupies 12 bytes in the fifo as follows: + +. . +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: three flags are defined, PI_NTFY_FLAGS_WDOG, +PI_NTFY_FLAGS_ALIVE, and PI_NTFY_FLAGS_EVENT. + +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. + +If bit 7 is set (PI_NTFY_FLAGS_EVENT) then bits 0-4 of the flags +indicate an event which has been triggered. + +tick: the number of microseconds since system boot. It wraps around +after 1h12m. + +level: indicates the level of each GPIO. If bit 1<=0 (as returned by [*pigpio_start*]). +handle: 0-31 (as returned by [*notify_open*]) +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +Notifications for the handle are suspended until +[*notify_begin*] is called again. +D*/ + +/*F*/ +int notify_close(int pi, unsigned handle); +/*D +Stop notifications on a previously opened handle and +release the handle for reuse. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: 0-31 (as returned by [*notify_open*]) +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int set_watchdog(int pi, unsigned user_gpio, unsigned timeout); +/*D +Sets a watchdog for a GPIO. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. + timeout: 0-60000. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO +or PI_BAD_WDOG_TIMEOUT. + +The watchdog is nominally in milliseconds. + +Only one watchdog may be registered per GPIO. + +The watchdog may be cancelled by setting timeout to 0. + +Once a watchdog has been started callbacks for the GPIO will be +triggered every timeout interval after the last GPIO activity. + +The callback will receive the special level PI_TIMEOUT. +D*/ + +/*F*/ +int set_glitch_filter(int pi, unsigned user_gpio, unsigned steady); +/*D +Sets a glitch filter on a GPIO. + +Level changes on the GPIO are not reported unless the level +has been stable for at least [*steady*] microseconds. The +level is then reported. Level changes of less than +[*steady*] microseconds are ignored. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31 + steady: 0-300000 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + +This filter affects the GPIO samples returned to callbacks set up +with [*callback*], [*callback_ex*] and [*wait_for_edge*]. + +It does not affect levels read by [*gpio_read*], +[*read_bank_1*], or [*read_bank_2*]. + +Each (stable) edge will be timestamped [*steady*] microseconds +after it was first detected. +D*/ + +/*F*/ +int set_noise_filter( + int pi, unsigned user_gpio, unsigned steady, unsigned active); +/*D +Sets a noise filter on a GPIO. + +Level changes on the GPIO are ignored until a level which has +been stable for [*steady*] microseconds is detected. Level changes +on the GPIO are then reported for [*active*] microseconds after +which the process repeats. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31 + steady: 0-300000 + active: 0-1000000 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER. + +This filter affects the GPIO samples returned to callbacks set up +with [*callback*], [*callback_ex*] and [*wait_for_edge*]. + +It does not affect levels read by [*gpio_read*], +[*read_bank_1*], or [*read_bank_2*]. + +Level changes before and after the active period may +be reported. Your software must be designed to cope with +such reports. +D*/ + +/*F*/ +uint32_t read_bank_1(int pi); +/*D +Read the levels of the bank 1 GPIO (GPIO 0-31). + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +The returned 32 bit integer has a bit set if the corresponding +GPIO is logic 1. GPIO n has bit value (1<=0 (as returned by [*pigpio_start*]). +. . + +The returned 32 bit integer has a bit set if the corresponding +GPIO is logic 1. GPIO n has bit value (1<<(n-32)). +D*/ + +/*F*/ +int clear_bank_1(int pi, uint32_t bits); +/*D +Clears GPIO 0-31 if the corresponding bit in bits is set. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +bits: a bit mask with 1 set if the corresponding GPIO is + to be cleared. +. . + +Returns 0 if OK, otherwise PI_SOME_PERMITTED. + +A status of PI_SOME_PERMITTED indicates that the user is not +allowed to write to one or more of the GPIO. +D*/ + +/*F*/ +int clear_bank_2(int pi, uint32_t bits); +/*D +Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +bits: a bit mask with 1 set if the corresponding GPIO is + to be cleared. +. . + +Returns 0 if OK, otherwise PI_SOME_PERMITTED. + +A status of PI_SOME_PERMITTED indicates that the user is not +allowed to write to one or more of the GPIO. +D*/ + +/*F*/ +int set_bank_1(int pi, uint32_t bits); +/*D +Sets GPIO 0-31 if the corresponding bit in bits is set. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +bits: a bit mask with 1 set if the corresponding GPIO is + to be set. +. . + +Returns 0 if OK, otherwise PI_SOME_PERMITTED. + +A status of PI_SOME_PERMITTED indicates that the user is not +allowed to write to one or more of the GPIO. +D*/ + +/*F*/ +int set_bank_2(int pi, uint32_t bits); +/*D +Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +bits: a bit mask with 1 set if the corresponding GPIO is + to be set. +. . + +Returns 0 if OK, otherwise PI_SOME_PERMITTED. + +A status of PI_SOME_PERMITTED indicates that the user is not +allowed to write to one or more of the GPIO. +D*/ + + +/*F*/ +int hardware_clock(int pi, unsigned gpio, unsigned clkfreq); +/*D +Starts a hardware clock on a GPIO at the specified frequency. +Frequencies above 30MHz are unlikely to work. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + gpio: see description +frequency: 0 (off) or 4689-250M (13184-375M for the BCM2711) +. . + +Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO, +PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS. + +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 Rev.2 B (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. +D*/ + + +/*F*/ +int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty); +/*D +Starts hardware PWM on a GPIO at the specified frequency and dutycycle. +Frequencies above 30MHz are unlikely to work. + +NOTE: Any waveform started by [*wave_send_**] or [*wave_chain*] +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). + +. . + pi: >=0 (as returned by [*pigpio_start*]). + gpio: see descripton +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, +PI_NOT_HPWM_GPIO, PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, +or PI_HPWM_ILLEGAL. + +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/PWMfreq (375M/PWMfreq for the BCM2711). + +The actual frequency set is 250M/steps (375M/steps for the BCM2711). + +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*/ + + +/*F*/ +uint32_t get_current_tick(int pi); +/*D +Gets the current system tick. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +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. + +D*/ + +/*F*/ +uint32_t get_hardware_revision(int pi); +/*D +Get the Pi's hardware revision number. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +The hardware revision is the last few characters on the Revision line +of /proc/cpuinfo. + +If the hardware revision can not be found or is not a valid +hexadecimal number the function returns 0. + +The revision number can be used to determine the assignment of GPIO +to pins (see [*gpio*]). + +There are at least 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. +D*/ + +/*F*/ +uint32_t get_pigpio_version(int pi); +/*D +Returns the pigpio version. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + + +/*F*/ +int wave_clear(int pi); +/*D +This function clears all waveforms and any data added by calls to the +[*wave_add_**] functions. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +Returns 0 if OK. +D*/ + +/*F*/ +int wave_add_new(int pi); +/*D +This function starts a new empty waveform. You wouldn't normally need +to call this function as it is automatically called after a waveform is +created with the [*wave_create*] function. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +Returns 0 if OK. +D*/ + +/*F*/ +int wave_add_generic(int pi, unsigned numPulses, gpioPulse_t *pulses); +/*D +This function adds a number of pulses to the current waveform. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +numPulses: the number of pulses. + pulses: an array of pulses. +. . + +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_TOO_MANY_PULSES. + +The pulses are interleaved in time order within the existing waveform +(if any). + +Merging allows the waveform to be built in parts, that is the settings +for GPIO#1 can be added, and then GPIO#2 etc. + +If the added waveform is intended to start after or within the existing +waveform then the first pulse should consist solely of a delay. +D*/ + +/*F*/ +int wave_add_serial + (int pi, unsigned user_gpio, unsigned baud, unsigned data_bits, + unsigned stop_bits, unsigned offset, unsigned numBytes, char *str); +/*D +This function adds a waveform representing serial data to the +existing waveform (if any). The serial data starts offset +microseconds from the start of the waveform. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. + baud: 50-1000000 +data_bits: number of data bits (1-32) +stop_bits: number of stop half bits (2-8) + offset: >=0 + numBytes: >=1 + str: an array of chars. +. . + +Returns the new total number of pulses in the current waveform if OK, +otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS, +PI_BAD_STOP_BITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET, +or PI_TOO_MANY_PULSES. + +NOTES: + +The serial data is formatted as one start bit, [*data_bits*] data bits, +and [*stop_bits*]/2 stop bits. + +It is legal to add serial data streams with different baud rates to +the same waveform. + +[*numBytes*] is the number of bytes of data in str. + +The bytes required for each character depend upon [*data_bits*]. + +For [*data_bits*] 1-8 there will be one byte per character. +For [*data_bits*] 9-16 there will be two bytes per character. +For [*data_bits*] 17-32 there will be four bytes per character. +D*/ + +/*F*/ +int wave_create(int pi); +/*D +This function creates a waveform from the data provided by the prior +calls to the [*wave_add_**] functions. 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. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +The data provided by the [*wave_add_**] functions is 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. + +Normal usage would be + +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*] to create the waveform and get a unique id + +Repeat steps 2 and 3 as needed. + +Step 4. [*wave_send_**] with the id of the waveform to transmit. + +A waveform comprises one or more pulses. Each pulse consists of a +[*gpioPulse_t*] structure. + +. . +typedef struct +{ + uint32_t gpioOn; + uint32_t gpioOff; + uint32_t usDelay; +} gpioPulse_t; +. . + +The fields specify + +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. + +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_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. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +wave_id: >=0, as returned by [*wave_create*]. +. . + +Wave ids are allocated in order, 0, 1, 2, etc. + +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). + +Returns 0 if OK, otherwise PI_BAD_WAVE_ID. +D*/ + + +/*F*/ +int wave_send_once(int pi, unsigned wave_id); +/*D +This function transmits the waveform with id wave_id. The waveform +is sent once. + +NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +wave_id: >=0, as returned by [*wave_create*]. +. . + +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. +D*/ + + +/*F*/ +int wave_send_repeat(int pi, unsigned wave_id); +/*D +This function transmits the waveform with id wave_id. The waveform +cycles until cancelled (either by the sending of a new waveform or +by [*wave_tx_stop*]). + +NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +wave_id: >=0, as returned by [*wave_create*]. +. . + +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. +D*/ + + +/*F*/ +int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode); +/*D +Transmits the waveform with id wave_id using mode mode. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +wave_id: >=0, as returned by [*wave_create*]. + mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT, + PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC. +. . + +PI_WAVE_MODE_ONE_SHOT: same as [*wave_send_once*]. + +PI_WAVE_MODE_REPEAT same as [*wave_send_repeat*]. + +PI_WAVE_MODE_ONE_SHOT_SYNC same as [*wave_send_once*] but tries +to sync with the previous waveform. + +PI_WAVE_MODE_REPEAT_SYNC same as [*wave_send_repeat*] but tries +to sync with the previous waveform. + +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 [*hardware_PWM*] will be cancelled. + +Returns the number of DMA control blocks in the waveform if OK, +otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE. +D*/ + +/*F*/ +int wave_chain(int pi, char *buf, unsigned bufSize); +/*D +This function transmits a chain of waveforms. + +NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled. + +The waves to be transmitted are specified by the contents of buf +which contains an ordered list of [*wave_id*]s and optional command +codes and related data. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + buf: pointer to the wave_ids and optional command codes +bufSize: the number of bytes in buf +. . + +Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER, +PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID. + +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. + +... +#include +#include + +#define WAVES 5 +#define GPIO 4 + +int main(int argc, char *argv[]) +{ + int i, pi, wid[WAVES]; + + pi = pigpio_start(0, 0); + if (pi<0) return -1; + + set_mode(pi, GPIO, PI_OUTPUT); + + for (i=0; i=0 (as returned by [*pigpio_start*]). +. . + +Returns the waveform id or one of the following special values: + +PI_WAVE_NOT_FOUND (9998) - transmitted wave not found. +PI_NO_TX_WAVE (9999) - no wave being transmitted. +D*/ + +/*F*/ +int wave_tx_busy(int pi); +/*D +This function checks to see if a waveform is currently being +transmitted. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +Returns 1 if a waveform is currently being transmitted, otherwise 0. +D*/ + +/*F*/ +int wave_tx_stop(int pi); +/*D +This function stops the transmission of the current waveform. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . + +Returns 0 if OK. + +This function is intended to stop a waveform started with the repeat mode. +D*/ + +/*F*/ +int wave_get_micros(int pi); +/*D +This function returns the length in microseconds of the current +waveform. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int wave_get_high_micros(int pi); +/*D +This function returns the length in microseconds of the longest waveform +created since the pigpio daemon was started. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int wave_get_max_micros(int pi); +/*D +This function returns the maximum possible size of a waveform in +microseconds. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int wave_get_pulses(int pi); +/*D +This function returns the length in pulses of the current waveform. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int wave_get_high_pulses(int pi); +/*D +This function returns the length in pulses of the longest waveform +created since the pigpio daemon was started. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int wave_get_max_pulses(int pi); +/*D +This function returns the maximum possible size of a waveform in pulses. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int wave_get_cbs(int pi); +/*D +This function returns the length in DMA control blocks of the current +waveform. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int wave_get_high_cbs(int pi); +/*D +This function returns the length in DMA control blocks of the longest +waveform created since the pigpio daemon was started. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int wave_get_max_cbs(int pi); +/*D +This function returns the maximum possible size of a waveform in DMA +control blocks. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +. . +D*/ + +/*F*/ +int gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level); +/*D +This function sends a trigger pulse to a GPIO. The GPIO is set to +level for pulseLen microseconds and then reset to not level. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. + pulseLen: 1-100. + level: 0,1. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL, +PI_BAD_PULSELEN, or PI_NOT_PERMITTED. +D*/ + +/*F*/ +int store_script(int pi, char *script); +/*D +This function stores a script for later execution. + +See [[http://abyz.me.uk/rpi/pigpio/pigs.html#Scripts]] for details. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +script: the text of the script. +. . + +The function returns a script id if the script is valid, +otherwise PI_BAD_SCRIPT. +D*/ + +/*F*/ +int run_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param); +/*D +This function runs a stored script. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +script_id: >=0, as returned by [*store_script*]. + numPar: 0-10, the number of parameters. + param: an array of parameters. +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM + +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. +D*/ + +/*F*/ +int update_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param); +/*D +This function sets the parameters of a script. The script may or +may not be running. The first numPar parameters of the script are +overwritten with the new values. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +script_id: >=0, as returned by [*store_script*]. + numPar: 0-10, the number of parameters. + param: an array of parameters. +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or +PI_TOO_MANY_PARAM. + +param is an array of up to 10 parameters which may be referenced in +the script as p0 to p9. +D*/ + +/*F*/ +int script_status(int pi, unsigned script_id, uint32_t *param); +/*D +This function returns the run status of a stored script as well +as the current values of parameters 0 to 9. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +script_id: >=0, as returned by [*store_script*]. + param: an array to hold the returned 10 parameters. +. . + +The function returns greater than or equal to 0 if OK, +otherwise PI_BAD_SCRIPT_ID. + +The run status may be + +. . +PI_SCRIPT_INITING +PI_SCRIPT_HALTED +PI_SCRIPT_RUNNING +PI_SCRIPT_WAITING +PI_SCRIPT_FAILED +. . + +The current value of script parameters 0 to 9 are returned in param. +D*/ + +/*F*/ +int stop_script(int pi, unsigned script_id); +/*D +This function stops a running script. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +script_id: >=0, as returned by [*store_script*]. +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. +D*/ + +/*F*/ +int delete_script(int pi, unsigned script_id); +/*D +This function deletes a stored script. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +script_id: >=0, as returned by [*store_script*]. +. . + +The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID. +D*/ + +/*F*/ +int bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits); +/*D +This function opens a GPIO for bit bang reading of serial data. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. + baud: 50-250000 +data_bits: 1-32 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, +or PI_GPIO_IN_USE. + +The serial data is returned in a cyclic buffer and is read using +bb_serial_read. + +It is the caller's responsibility to read data from the cyclic buffer +in a timely fashion. +D*/ + +/*F*/ +int bb_serial_read(int pi, unsigned user_gpio, void *buf, size_t bufSize); +/*D +This function copies up to bufSize bytes of data read from the +bit bang serial cyclic buffer to the buffer starting at buf. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31, previously opened with [*bb_serial_read_open*]. + buf: an array to receive the read bytes. + bufSize: >=0 +. . + +Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO +or PI_NOT_SERIAL_GPIO. + +The bytes returned for each character depend upon the number of +data bits [*data_bits*] specified in the [*bb_serial_read_open*] command. + +For [*data_bits*] 1-8 there will be one byte per character. +For [*data_bits*] 9-16 there will be two bytes per character. +For [*data_bits*] 17-32 there will be four bytes per character. +D*/ + +/*F*/ +int bb_serial_read_close(int pi, unsigned user_gpio); +/*D +This function closes a GPIO for bit bang reading of serial data. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31, previously opened with [*bb_serial_read_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO. +D*/ + +/*F*/ +int bb_serial_invert(int pi, unsigned user_gpio, unsigned invert); +/*D +This function inverts serial logic for big bang serial reads. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31, previously opened with [*bb_serial_read_open*]. + invert: 0-1, 1 invert, 0 normal. +. . + +Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT. +D*/ + +/*F*/ +int i2c_open(int pi, unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags); +/*D +This returns a handle for the device at address i2c_addr on bus i2c_bus. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + i2c_bus: >=0. + i2c_addr: 0-0x7F. +i2c_flags: 0. +. . + +No flags are currently defined. This parameter should be set to zero. + +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 + +Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR, +PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED. + +For the SMBus commands the low level transactions are shown at the end +of the function description. The following abbreviations are used. + +. . +S (1 bit) : Start bit +P (1 bit) : Stop bit +Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. +A, NA (1 bit) : Accept and not accept bit. +Addr (7 bits): I2C 7 bit address. +i2c_reg (8 bits): A byte which often selects a register. +Data (8 bits): A data byte. +Count (8 bits): A byte defining the length of a block operation. + +[..]: Data sent by the device. +. . +D*/ + +/*F*/ +int i2c_close(int pi, unsigned handle); +/*D +This closes the I2C device associated with the handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*i2c_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int i2c_write_quick(int pi, unsigned handle, unsigned bit); +/*D +This sends a single bit (in the Rd/Wr bit) to the device associated +with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*i2c_open*]. + bit: 0-1, the value to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Quick command. SMBus 2.0 5.5.1 +. . +S Addr bit [A] P +. . +D*/ + +/*F*/ +int i2c_write_byte(int pi, unsigned handle, unsigned bVal); +/*D +This sends a single byte to the device associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*i2c_open*]. + bVal: 0-0xFF, the value to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Send byte. SMBus 2.0 5.5.2 +. . +S Addr Wr [A] bVal [A] P +. . +D*/ + +/*F*/ +int i2c_read_byte(int pi, unsigned handle); +/*D +This reads a single byte from the device associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*i2c_open*]. +. . + +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +or PI_I2C_READ_FAILED. + +Receive byte. SMBus 2.0 5.5.3 +. . +S Addr Rd [A] [Data] NA P +. . +D*/ + +/*F*/ +int i2c_write_byte_data( + int pi, unsigned handle, unsigned i2c_reg, unsigned bVal); +/*D +This writes a single byte to the specified register of the device +associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write. + bVal: 0-0xFF, the value to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Write byte. SMBus 2.0 5.5.4 +. . +S Addr Wr [A] i2c_reg [A] bVal [A] P +. . +D*/ + +/*F*/ +int i2c_write_word_data( + int pi, unsigned handle, unsigned i2c_reg, unsigned wVal); +/*D +This writes a single 16 bit word to the specified register of the device +associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write. + wVal: 0-0xFFFF, the value to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Write word. SMBus 2.0 5.5.4 +. . +S Addr Wr [A] i2c_reg [A] wval_Low [A] wVal_High [A] P +. . +D*/ + +/*F*/ +int i2c_read_byte_data(int pi, unsigned handle, unsigned i2c_reg); +/*D +This reads a single byte from the specified register of the device +associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to read. +. . + +Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Read byte. SMBus 2.0 5.5.5 +. . +S Addr Wr [A] i2c_reg [A] S Addr Rd [A] [Data] NA P +. . +D*/ + +/*F*/ +int i2c_read_word_data(int pi, unsigned handle, unsigned i2c_reg); +/*D +This reads a single 16 bit word from the specified register of the device +associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to read. +. . + +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Read word. SMBus 2.0 5.5.5 +. . +S Addr Wr [A] i2c_reg [A] + S Addr Rd [A] [DataLow] A [DataHigh] NA P +. . +D*/ + +/*F*/ +int i2c_process_call(int pi, unsigned handle, unsigned i2c_reg, unsigned wVal); +/*D +This writes 16 bits of data to the specified register of the device +associated with handle and and reads 16 bits of data in return. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write/read. + wVal: 0-0xFFFF, the value to write. +. . + +Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Process call. SMBus 2.0 5.5.6 +. . +S Addr Wr [A] i2c_reg [A] wVal_Low [A] wVal_High [A] + S Addr Rd [A] [DataLow] A [DataHigh] NA P +. . +D*/ + +/*F*/ +int i2c_write_block_data( + int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count); +/*D +This writes up to 32 bytes to the specified register of the device +associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write. + buf: an array with the data to send. + count: 1-32, the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +Block write. SMBus 2.0 5.5.7 +. . +S Addr Wr [A] i2c_reg [A] count [A] buf0 [A] buf1 [A] ... + [A] bufn [A] P +. . +D*/ + +/*F*/ +int i2c_read_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf); +/*D +This reads a block of up to 32 bytes from the specified register of +the device associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to read. + buf: an array to receive the read data. +. . + +The amount of returned data is set by the device. + +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +Block read. SMBus 2.0 5.5.7 +. . +S Addr Wr [A] i2c_reg [A] + S Addr Rd [A] [Count] A [buf0] A [buf1] A ... A [bufn] NA P +. . +D*/ + +/*F*/ +int i2c_block_process_call( + int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count); +/*D +This writes data bytes to the specified register of the device +associated with handle and reads a device specified number +of bytes of data in return. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write/read. + buf: an array with the data to send and to receive the read data. + count: 1-32, the number of bytes to write. +. . + + +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +The smbus 2.0 documentation states that a minimum of 1 byte may be +sent and a minimum of 1 byte may be received. The total number of +bytes sent/received must be 32 or less. + +Block write-block read. SMBus 2.0 5.5.8 +. . +S Addr Wr [A] i2c_reg [A] count [A] buf0 [A] ... + S Addr Rd [A] [Count] A [Data] ... A P +. . +D*/ + +/*F*/ +int i2c_read_i2c_block_data( + int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count); +/*D +This reads count bytes from the specified register of the device +associated with handle . The count may be 1-32. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to read. + buf: an array to receive the read data. + count: 1-32, the number of bytes to read. +. . + +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, or PI_I2C_READ_FAILED. + +. . +S Addr Wr [A] i2c_reg [A] + S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P +. . +D*/ + + +/*F*/ +int i2c_write_i2c_block_data( + int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count); +/*D +This writes 1 to 32 bytes to the specified register of the device +associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0, as returned by a call to [*i2c_open*]. +i2c_reg: 0-255, the register to write. + buf: the data to write. + count: 1-32, the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +. . +S Addr Wr [A] i2c_reg [A] buf0 [A] buf1 [A] ... [A] bufn [A] P +. . +D*/ + +/*F*/ +int i2c_read_device(int pi, unsigned handle, char *buf, unsigned count); +/*D +This reads count bytes from the raw device into buf. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*i2c_open*]. + buf: an array to receive the read data bytes. + count: >0, the number of bytes to read. +. . + +Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_READ_FAILED. + +. . +S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P +. . +D*/ + +/*F*/ +int i2c_write_device(int pi, unsigned handle, char *buf, unsigned count); +/*D +This writes count bytes from buf to the raw device. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*i2c_open*]. + buf: an array containing the data bytes to write. + count: >0, the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_I2C_WRITE_FAILED. + +. . +S Addr Wr [A] buf0 [A] buf1 [A] ... [A] bufn [A] P +. . +D*/ + +/*F*/ +int i2c_zip( + int pi, + unsigned handle, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen); +/*D +This function executes a sequence of I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*i2cOpen*] + inBuf: pointer to the concatenated I2C commands, see below + inLen: size of command buffer +outBuf: pointer to buffer to hold returned data +outLen: size of output buffer +. . + +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN. +PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG. + +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. +The flags default to 0. The address and flags maintain their +previous value until updated. + +The returned I2C data is stored in consecutive locations of outBuf. + +... +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 +... + +D*/ + +/*F*/ +int bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud); +/*D +This function selects a pair of GPIO for bit banging I2C at a +specified baud rate. + +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 + +. . + pi: >=0 (as returned by [*pigpio_start*]). + SDA: 0-31 + SCL: 0-31 +baud: 50-500000 +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or +PI_GPIO_IN_USE. + +NOTE: + +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. +D*/ + +/*F*/ +int bb_i2c_close(int pi, unsigned SDA); +/*D +This function stops bit banging I2C on a pair of GPIO previously +opened with [*bb_i2c_open*]. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +SDA: 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*] +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO. +D*/ + +/*F*/ +int bb_i2c_zip( + int pi, + unsigned SDA, + char *inBuf, + unsigned inLen, + char *outBuf, + unsigned outLen); +/*D +This function executes a sequence of bit banged I2C operations. The +operations to be performed are specified by the contents of inBuf +which contains the concatenated command codes and associated data. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + SDA: 0-31 (as used in a prior call to [*bb_i2c_open*]) + inBuf: pointer to the concatenated I2C commands, see below + inLen: size of command buffer +outBuf: pointer to buffer to hold returned data +outLen: size of output buffer +. . + +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER, +PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN, +PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED. + +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. + +The returned I2C data is stored in consecutive locations of outBuf. + +... +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 +... +D*/ + +/*F*/ +int bb_spi_open( + int pi, + unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, + unsigned baud, unsigned spi_flags); +/*D +This function selects a set of GPIO for bit banging SPI at a +specified baud rate. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + CS: 0-31 + MISO: 0-31 + MOSI: 0-31 + SCLK: 0-31 + baud: 50-250000 +spi_flags: see below +. . + +spi_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, defaults to 0 + +. . +Mode CPOL CPHA + 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. + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or +PI_GPIO_IN_USE. + +If more than one device is connected to the SPI bus (defined by +SCLK, MOSI, and MISO) each must have its own CS. + +... +bb_spi_open(pi,10, MISO, MOSI, SCLK, 10000, 0); // device 1 +bb_spi_open(pi,11, MISO, MOSI, SCLK, 20000, 3); // device 2 +... +D*/ + +/*F*/ +int bb_spi_close(int pi, unsigned CS); +/*D +This function stops bit banging SPI on a set of GPIO +opened with [*bbSPIOpen*]. + +. . +pi: >=0 (as returned by [*pigpio_start*]). +CS: 0-31, the CS GPIO used in a prior call to [*bb_spi_open*] +. . + +Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO. +D*/ + +/*F*/ +int bb_spi_xfer( + int pi, + unsigned CS, + char *txBuf, + char *rxBuf, + unsigned count); +/*D +This function executes a bit banged SPI transfer. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + CS: 0-31 (as used in a prior call to [*bb_spi_open*]) +txBuf: pointer to buffer to hold data to be sent +rxBuf: pointer to buffer to hold returned data +count: size of data transfer +. . + +Returns >= 0 if OK (the number of bytes read), otherwise +PI_BAD_USER_GPIO, PI_NOT_SPI_GPIO or PI_BAD_POINTER. + +... +// gcc -Wall -pthread -o bb_spi_x_test bb_spi_x_test.c -lpigpiod_if2 +// ./bb_spi_x_test + +#include + +#include "pigpiod_if2.h" + +#define CE0 5 +#define CE1 6 +#define MISO 13 +#define MOSI 19 +#define SCLK 12 + +int main(int argc, char *argv[]) +{ + int i, pi, count, set_val, read_val; + unsigned char inBuf[3]; + char cmd1[] = {0, 0}; + char cmd2[] = {12, 0}; + char cmd3[] = {1, 128, 0}; + + if ((pi = pigpio_start(0, 0)) < 0) + { + fprintf(stderr, "pigpio initialisation failed (%d).\n", pi); + return 1; + } + + bb_spi_open(pi, CE0, MISO, MOSI, SCLK, 10000, 0); // MCP4251 DAC + bb_spi_open(pi, CE1, MISO, MOSI, SCLK, 20000, 3); // MCP3008 ADC + + for (i=0; i<256; i++) + { + cmd1[1] = i; + + count = bb_spi_xfer(pi, CE0, cmd1, (char *)inBuf, 2); // > DAC + + if (count == 2) + { + count = bb_spi_xfer(pi, CE0, cmd2, (char *)inBuf, 2); // < DAC + + if (count == 2) + { + set_val = inBuf[1]; + + count = bb_spi_xfer(pi, CE1, cmd3, (char *)inBuf, 3); // < ADC + + if (count == 3) + { + read_val = ((inBuf[1]&3)<<8) | inBuf[2]; + printf("%d %d\n", set_val, read_val); + } + } + } + } + + bb_spi_close(pi, CE0); + bb_spi_close(pi, CE1); + + pigpio_stop(pi); +} +... +D*/ + +/*F*/ +int spi_open(int pi, unsigned spi_channel, unsigned baud, unsigned spi_flags); +/*D +This function returns a handle for the SPI device on the channel. +Data will be transferred at baud bits per second. The flags may +be used to modify the default behaviour of 4-wire operation, mode 0, +active low chip select. + +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 + +. . + pi: >=0 (as returned by [*pigpio_start*]). +spi_channel: 0-1 (0-2 for the auxiliary SPI). + baud: 32K-125M (values above 30M are unlikely to work). + spi_flags: see below. +. . + +Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL, +PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED. + +spi_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 [*spi_read*], [*spi_write*], and [*spi_xfer*] functions +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 buf should contain 64 bytes +and count should be 64. + +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. +D*/ + +/*F*/ +int spi_close(int pi, unsigned handle); +/*D +This functions closes the SPI device identified by the handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*spi_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int spi_read(int pi, unsigned handle, char *buf, unsigned count); +/*D +This function reads count bytes of data from the SPI +device associated with the handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*spi_open*]. + buf: an array to receive the read data bytes. + count: the number of bytes to read. +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + +/*F*/ +int spi_write(int pi, unsigned handle, char *buf, unsigned count); +/*D +This function writes count bytes of data from buf to the SPI +device associated with the handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*spi_open*]. + buf: the data bytes to write. + count: the number of bytes to write. +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + +/*F*/ +int spi_xfer( + int pi, unsigned handle, char *txBuf, char *rxBuf, unsigned count); +/*D +This function transfers count bytes of data from txBuf to the SPI +device associated with the handle. Simultaneously count bytes of +data are read from the device and placed in rxBuf. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*spi_open*]. + txBuf: the data bytes to write. + rxBuf: the received data bytes. + count: the number of bytes to transfer. +. . + +Returns the number of bytes transferred if OK, otherwise +PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED. +D*/ + +/*F*/ +int serial_open(int pi, char *ser_tty, unsigned baud, unsigned ser_flags); +/*D +This function opens a serial device at a specified baud rate +with specified flags. The device name must start with +/dev/tty or /dev/serial. + + +. . + pi: >=0 (as returned by [*pigpio_start*]). + ser_tty: the serial device to open. + baud: the baud rate in bits per second, see below. +ser_flags: 0. +. . + +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or +PI_SER_OPEN_FAILED. + +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. + +No flags are currently defined. This parameter should be set to zero. +D*/ + +/*F*/ +int serial_close(int pi, unsigned handle); +/*D +This function closes the serial device associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*serial_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int serial_write_byte(int pi, unsigned handle, unsigned bVal); +/*D +This function writes bVal to the serial port associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*serial_open*]. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. +D*/ + +/*F*/ +int serial_read_byte(int pi, unsigned handle); +/*D +This function reads a byte from the serial port associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*serial_open*]. +. . + +Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED. + +If no data is ready PI_SER_READ_NO_DATA is returned. +D*/ + +/*F*/ +int serial_write(int pi, unsigned handle, char *buf, unsigned count); +/*D +This function writes count bytes from buf to the the serial port +associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*serial_open*]. + buf: the array of bytes to write. + count: the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or +PI_SER_WRITE_FAILED. +D*/ + +/*F*/ +int serial_read(int pi, unsigned handle, char *buf, unsigned count); +/*D +This function reads up to count bytes from the the serial port +associated with handle and writes them to buf. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*serial_open*]. + buf: an array to receive the read data. + count: the maximum number of bytes to read. +. . + +Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, +PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED. + +If no data is ready zero is returned. +D*/ + +/*F*/ +int serial_data_available(int pi, unsigned handle); +/*D +Returns the number of bytes available to be read from the +device associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0, as returned by a call to [*serial_open*]. +. . + +Returns the number of bytes of data available (>=0) if OK, +otherwise PI_BAD_HANDLE. +D*/ + +/*F*/ +int custom_1(int pi, unsigned arg1, unsigned arg2, char *argx, unsigned argc); +/*D +This function is available for user customisation. + +It returns a single integer value. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +arg1: >=0 +arg2: >=0 +argx: extra (byte) arguments +argc: number of extra arguments +. . + +Returns >= 0 if OK, less than 0 indicates a user defined error. +D*/ + + +/*F*/ +int custom_2(int pi, unsigned arg1, char *argx, unsigned argc, + char *retBuf, unsigned retMax); +/*D +This function is available for user customisation. + +It differs from custom_1 in that it returns an array of bytes +rather than just an integer. + +The return value is an integer indicating the number of returned bytes. +. . + pi: >=0 (as returned by [*pigpio_start*]). + arg1: >=0 + argc: extra (byte) arguments + count: number of extra arguments +retBuf: buffer for returned data +retMax: maximum number of bytes to return +. . + +Returns >= 0 if OK, less than 0 indicates a user defined error. + +Note, the number of returned bytes will be retMax or less. +D*/ + +/*F*/ +int get_pad_strength(int pi, unsigned pad); +/*D +This function returns the pad drive strength in mA. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +pad: 0-2, the pad to get. +. . + +Returns the pad drive strength if OK, otherwise PI_BAD_PAD. + +Pad @ GPIO +0 @ 0-27 +1 @ 28-45 +2 @ 46-53 + +... +strength = get_pad_strength(pi, 0); // get pad 0 strength +... +D*/ + + +/*F*/ +int set_pad_strength(int pi, unsigned pad, unsigned padStrength); +/*D +This function sets the pad drive strength in mA. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + pad: 0-2, the pad to set. +padStrength: 1-16 mA. +. . + +Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH. + +Pad @ GPIO +0 @ 0-27 +1 @ 28-45 +2 @ 46-53 + +... +set_pad_strength(pi, 0, 10); // set pad 0 strength to 10 mA +... +D*/ + + +/*F*/ +int shell_(int pi, char *scriptName, char *scriptString); +/*D +This function uses the system call to execute a shell script +with the given string as its parameter. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + scriptName: the name of the script, only alphanumeric characters, + '-' and '_' are allowed in the name. +scriptString: the string to pass to the script. +. . + +The exit status of the system call is returned if OK, otherwise +PI_BAD_SHELL_STATUS. + +scriptName 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 +status = shell_(pi, "scr1", "hello world"); + +// pass three parameters, hello, string with spaces, and world +status = shell_(pi, "scr1", "hello 'string with spaces' world"); + +// pass one parameter, hello string with spaces world +status = shell_(pi, "scr1", "\"hello string with spaces world\""); +... +D*/ + +#pragma GCC diagnostic push + +#pragma GCC diagnostic ignored "-Wcomment" + +/*F*/ +int file_open(int pi, char *file, unsigned mode); +/*D +This function returns a handle to a file opened in a specified mode. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +file: the file to open. +mode: the file open mode. +. . + +Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS, +PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR. + +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. + +Macro @ Value @ Meaning +PI_FILE_READ @ 1 @ open file for reading +PI_FILE_WRITE @ 2 @ open file for writing +PI_FILE_RW @ 3 @ open file for reading and writing + +The following values may be or'd into the mode. + +Macro @ Value @ Meaning +PI_FILE_APPEND @ 4 @ Writes append data to the end of the file +PI_FILE_CREATE @ 8 @ The file is created if it doesn't exist +PI_FILE_TRUNC @ 16 @ The file is truncated + +Newly created files are owned by root with permissions owner read and write. + +... +#include +#include + +int main(int argc, char *argv[]) +{ + int pi, handle, c; + char buf[60000]; + + pi = pigpio_start(NULL, NULL); + + if (pi < 0) return 1; + + // assumes /opt/pigpio/access contains the following line + // /ram/*.c r + + handle = file_open(pi, "/ram/pigpio.c", PI_FILE_READ); + + if (handle >= 0) + { + while ((c=file_read(pi, handle, buf, sizeof(buf)-1))) + { + buf[c] = 0; + printf("%s", buf); + } + + file_close(pi, handle); + } + + pigpio_stop(pi); +} +... +D*/ + +#pragma GCC diagnostic pop + +/*F*/ +int file_close(int pi, unsigned handle); +/*D +This function closes the file associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0 (as returned by [*file_open*]). +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE. + +... +file_close(pi, handle); +... +D*/ + + +/*F*/ +int file_write(int pi, unsigned handle, char *buf, unsigned count); +/*D +This function writes count bytes from buf to the the file +associated with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0 (as returned by [*file_open*]). + buf: the array of bytes to write. + count: the number of bytes to write. +. . + +Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, +PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE. + +... +if (file_write(pi, handle, buf, 100) == 0) +{ + // file written okay +} +else +{ + // error +} +... +D*/ + + +/*F*/ +int file_read(int pi, unsigned handle, char *buf, unsigned count); +/*D +This function reads up to count bytes from the the file +associated with handle and writes them to buf. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +handle: >=0 (as returned by [*file_open*]). + buf: an array to receive the read data. + count: the maximum number of bytes to read. +. . + +Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE. + +... + bytes = file_read(pi, handle, buf, sizeof(buf)); + + if (bytes >= 0) + { + // process read data + } +... +D*/ + + +/*F*/ +int file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom); +/*D +This function seeks to a position within the file associated +with handle. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + handle: >=0 (as returned by [*file_open*]). +seekOffset: the number of bytes to move. Positive offsets + move forward, negative offsets backwards. + seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1), + or PI_FROM_END (2). +. . + +Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK. + +... +file_seek(pi, handle, 123, PI_FROM_START); // Start plus 123 + +size = file_seek(pi, handle, 0, PI_FROM_END); // End, return size + +pos = file_seek(pi, handle, 0, PI_FROM_CURRENT); // Current position +... +D*/ + +#pragma GCC diagnostic push + +#pragma GCC diagnostic ignored "-Wcomment" + +/*F*/ +int file_list(int pi, char *fpat, char *buf, unsigned count); +/*D +This function returns a list of files which match a pattern. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + fpat: file pattern to match. + buf: an array to receive the matching file names. +count: the maximum number of bytes to read. +. . + +Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS, +or PI_NO_FILE_MATCH. + +The pattern must match an entry in /opt/pigpio/access. The pattern +may contain wildcards. See [*file_open*]. + +NOTE + +The returned value is not the number of files, it is the number +of bytes in the buffer. The file names are separated by newline +characters. + +... +#include +#include + +int main(int argc, char *argv[]) +{ + int pi, handle, c; + char buf[60000]; + + pi = pigpio_start(NULL, NULL); + + if (pi < 0) return 1; + + // assumes /opt/pigpio/access contains the following line + // /ram/*.c r + + c = file_list(pi, "/ram/p*.c", buf, sizeof(buf)); + + if (c >= 0) + { + buf[c] = 0; + printf("%s", buf); + } + + pigpio_stop(pi); +} +... +D*/ + +#pragma GCC diagnostic pop + + +/*F*/ +int callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f); +/*D +This function initialises a new callback. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. + f: the callback function. +. . + +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +The callback is called with the GPIO, edge, and tick, whenever the +GPIO has the identified edge. + +. . +Parameter Value Meaning + +GPIO 0-31 The GPIO which has changed state + +edge 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (a watchdog timeout) + +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*/ +int callback_ex + (int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata); +/*D +This function initialises a new callback. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. + f: the callback function. + userdata: a pointer to arbitrary user data. +. . + +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +The callback is called with the GPIO, edge, tick, and the userdata +pointer, whenever the GPIO has the identified edge. + +. . +Parameter Value Meaning + +GPIO 0-31 The GPIO which has changed state + +edge 0-2 0 = change to low (a falling edge) + 1 = change to high (a rising edge) + 2 = no level change (a watchdog timeout) + +tick 32 bit The number of microseconds since boot + WARNING: this wraps around from + 4294967295 to 0 roughly every 72 minutes + +userdata pointer Pointer to an arbitrary object +. . +D*/ + +/*F*/ +int callback_cancel(unsigned callback_id); +/*D +This function cancels a callback identified by its id. + +. . +callback_id: >=0, as returned by a call to [*callback*] or [*callback_ex*]. +. . + +The function returns 0 if OK, otherwise pigif_callback_not_found. +D*/ + +/*F*/ +int wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout); +/*D +This function waits for an edge on the GPIO for up to timeout +seconds. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +user_gpio: 0-31. + edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE. + timeout: >=0. +. . + +The function returns when the edge occurs or after the timeout. + +Do not use this function for precise timing purposes, +the edge is only checked 20 times a second. Whenever +you need to know the accurate time of GPIO events use +a [*callback*] function. + +The function returns 1 if the edge occurred, otherwise 0. +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 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 +receive buffer. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +bscxfer: a structure defining the transfer. + +typedef struct +{ + uint32_t control; // Write + int rxCnt; // Read only + char rxBuf[BSC_FIFO_SIZE]; // Read only + int txCnt; // Write + char txBuf[BSC_FIFO_SIZE]; // Write +} bsc_xfer_t; +. . + +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. + +The returned function value is the status of the transfer (see below). + +If there was an error the status will be less than zero +(and will contain the error code). + +The most significant word of the returned status contains the number +of bytes actually copied from txBuf to the BSC transmit FIFO (may be +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. + +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. + +control 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 + +The following example shows how to configure the BSC peripheral as +an I2C slave with address 0x13 and send four bytes. + +... +bsc_xfer_t xfer; + +xfer.control = (0x13<<16) | 0x305; + +memcpy(xfer.txBuf, "ABCD", 4); +xfer.txCnt = 4; + +status = bsc_xfer(pi, &xfer); + +if (status >= 0) +{ + // process transfer +} +... +D*/ + +/*F*/ +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. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +i2c_addr: 0-0x7F. + bscxfer: a structure defining the transfer. + +typedef struct +{ + uint32_t control; // N/A + int rxCnt; // Read only + char rxBuf[BSC_FIFO_SIZE]; // Read only + int txCnt; // Write + char txBuf[BSC_FIFO_SIZE]; // Write +} bsc_xfer_t; +. . + +txCnt is set to the number of bytes to be transmitted, possibly +zero. The data itself should be copied to txBuf. + +Any received data will be written to rxBuf with rxCnt set. + +See [*bsc_xfer*] for details of the returned status value. + +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 as inputs. +D*/ + +/*F*/ +int event_callback(int pi, unsigned event, evtCBFunc_t f); +/*D +This function initialises an event callback. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +event: 0-31. + f: the callback function. +. . + +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +The callback is called with the event id, and tick, whenever the +event occurs. +D*/ + +/*F*/ +int event_callback_ex(int pi, unsigned event, evtCBFuncEx_t f, void *userdata); +/*D +This function initialises an event callback. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + event: 0-31. + f: the callback function. +userdata: a pointer to arbitrary user data. +. . + +The function returns a callback id if OK, otherwise pigif_bad_malloc, +pigif_duplicate_callback, or pigif_bad_callback. + +The callback is called with the event id, the tick, and the userdata +pointer whenever the event occurs. +D*/ + +/*F*/ +int event_callback_cancel(unsigned callback_id); +/*D +This function cancels an event callback identified by its id. + +. . +callback_id: >=0, as returned by a call to [*event_callback*] or +[*event_callback_ex*]. +. . + +The function returns 0 if OK, otherwise pigif_callback_not_found. +D*/ + +/*F*/ +int wait_for_event(int pi, unsigned event, double timeout); +/*D +This function waits for an event for up to timeout seconds. + +. . + pi: >=0 (as returned by [*pigpio_start*]). + event: 0-31. +timeout: >=0. +. . + +The function returns when the event occurs or after the timeout. + +The function returns 1 if the event occurred, otherwise 0. +D*/ + +/*F*/ +int event_trigger(int pi, unsigned event); +/*D +This function signals the occurrence of an event. + +. . + pi: >=0 (as returned by [*pigpio_start*]). +event: 0-31. +. . + +Returns 0 if OK, otherwise PI_BAD_EVENT_ID. + +An event is a signal used to inform one or more consumers +to start an action. Each consumer which has registered an interest +in the event (e.g. by calling [*event_callback*]) will be informed by +a callback. + +One event, PI_EVENT_BSC (31) is predefined. This event is +auto generated on BSC slave activity. + +The meaning of other events is arbitrary. + +Note that other than its id and its tick there is no data associated +with an event. +D*/ + +/*PARAMS + +active :: 0-1000000 + +The number of microseconds level changes are reported for once +a noise filter has been triggered (by [*steady*] microseconds of +a stable level). + +*addrStr:: +A string specifying the host or IP address of the Pi running +the pigpio daemon. It may be NULL in which case localhost +is used unless overridden by the PIGPIO_ADDR environment +variable. + +arg1:: +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +arg2:: +An unsigned argument passed to a user customised function. Its +meaning is defined by the customiser. + +argc:: +The count of bytes passed to a user customised function. + +*argx:: +A pointer to an array of bytes passed to a user customised function. +Its meaning and content is defined by the customiser. + +baud:: +The speed of serial communication (I2C, SPI, serial link, waves) in +bits per second. + +bit:: +A value of 0 or 1. + +bits:: +A value used to select GPIO. If bit n of bits is set then GPIO n is +selected. + +A convenient way to set bit n is to or in (1<=0, as returned by a call to a callback function, one of + +[*callback*] +[*callback_ex*] +[*event_callback*] +[*event_callback_ex*] + +The id is passed to [*callback_cancel*] or [*event_callback_cancel*] +to cancel the callback. + +CBFunc_t:: +. . +typedef void (*CBFunc_t) + (int pi, unsigned user_gpio, unsigned level, uint32_t tick); +. . + +CBFuncEx_t:: +. . +typedef void (*CBFuncEx_t) + (int pi, unsigned user_gpio, unsigned level, uint32_t tick, void * userdata); +. . + +char:: +A single character, an 8 bit quantity able to store 0-255. + +clkfreq::4689-250M (13184-375M for the BCM2711) +The hardware clock frequency. + +count:: +The number of bytes to be transferred in a file, I2C, SPI, or serial +command. + +CS:: +The GPIO used for the slave select signal when bit banging SPI. + +data_bits::1-32 +The number of data bits in each character of serial data. + +. . +#define PI_MIN_WAVE_DATABITS 1 +#define PI_MAX_WAVE_DATABITS 32 +. . + +double:: +A floating point number. + +dutycycle::0-range +A number representing the ratio of on time to off time for PWM. + +The number may vary between 0 and range (default 255) where +0 is off and range is fully on. + +edge:: +Used to identify a GPIO level transition of interest. A rising edge is +a level change from 0 to 1. A falling edge is a level change from 1 to 0. + +. . +RISING_EDGE 0 +FALLING_EDGE 1 +EITHER_EDGE. 2 +. . + +errnum:: +A negative number indicating a function call failed and the nature +of the error. + +event::0-31 +An event is a signal used to inform one or more consumers +to start an action. + +evtCBFunc_t:: + +. . +typedef void (*evtCBFunc_t) + (int pi, unsigned event, uint32_t tick); +. . + +evtCBFuncEx_t:: + +. . +typedef void (*evtCBFuncEx_t) + (int pi, unsigned event, uint32_t tick, void *userdata); +. . + +f:: +A function. + +*file:: +A full file path. To be accessible the path must match an entry in +/opt/pigpio/access. + +*fpat:: +A file path which may contain wildcards. To be accessible the path +must match an entry in /opt/pigpio/access. + +frequency::>=0 +The number of times a GPIO is swiched on and off per second. This +can be set per GPIO and may be as little as 5Hz or as much as +40KHz. The GPIO will be on for a proportion of the time as defined +by its dutycycle. + +gpio:: +A Broadcom numbered GPIO, in the range 0-53. + +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 [*get_hardware_revision*]. + +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 - - - - +. . + +gpioPulse_t:: +. . +typedef struct +{ + uint32_t gpioOn; + uint32_t gpioOff; + uint32_t usDelay; +} gpioPulse_t; +. . + +gpioThreadFunc_t:: +. . +typedef void *(gpioThreadFunc_t) (void *); +. . + +handle::>=0 +A number referencing an object opened by one of + +[*file_open*] +[*i2c_open*] +[*notify_open*] +[*serial_open*] +[*spi_open*] + +i2c_addr::0-0x7F +The address of a device on the I2C bus. + +i2c_bus::>=0 +An I2C bus number. + +i2c_flags::0 +Flags which modify an I2C open command. None are currently defined. + +i2c_reg:: 0-255 +A register of an I2C device. + +*inBuf:: +A buffer used to pass data to a function. + +inLen:: +The number of bytes of data in a buffer. + +int:: +A whole number, negative or positive. + +int32_t:: +A 32-bit signed value. + +invert:: +A flag used to set normal or inverted bit bang serial data level logic. + +level:: +The level of a GPIO. Low or High. + +. . +PI_OFF 0 +PI_ON 1 + +PI_CLEAR 0 +PI_SET 1 + +PI_LOW 0 +PI_HIGH 1 +. . + +There is one exception. If a watchdog expires on a GPIO the level will be +reported as PI_TIMEOUT. See [*set_watchdog*]. + +. . +PI_TIMEOUT 2 +. . + +MISO:: +The GPIO used for the MISO signal when bit banging SPI. + +mode:: +1. The operational mode of a GPIO, normally INPUT or OUTPUT. + +. . +PI_INPUT 0 +PI_OUTPUT 1 +PI_ALT0 4 +PI_ALT1 5 +PI_ALT2 6 +PI_ALT3 7 +PI_ALT4 3 +PI_ALT5 2 +. . + +2. The mode of waveform transmission. + +. . +PI_WAVE_MODE_ONE_SHOT 0 +PI_WAVE_MODE_REPEAT 1 +PI_WAVE_MODE_ONE_SHOT_SYNC 2 +PI_WAVE_MODE_REPEAT_SYNC 3 +. . + +3. A file open mode. + +. . +PI_FILE_READ 1 +PI_FILE_WRITE 2 +PI_FILE_RW 3 +. . + +The following values can be or'd into the mode. + +. . +PI_FILE_APPEND 4 +PI_FILE_CREATE 8 +PI_FILE_TRUNC 16 +. . + +MOSI:: +The GPIO used for the MOSI signal when bit banging SPI. + +numBytes:: +The number of bytes used to store characters in a string. Depending +on the number of bits per character there may be 1, 2, or 4 bytes +per character. + +numPar:: 0-10 +The number of parameters passed to a script. + +numPulses:: +The number of pulses to be added to a waveform. + +offset:: +The associated data starts this number of microseconds from the start of +the waveform. + +*outBuf:: +A buffer used to return data from a function. + +outLen:: +The size in bytes of an output buffer. + +pad:: 0-2 +A set of GPIO which share common drivers. + +Pad @ GPIO +0 @ 0-27 +1 @ 28-45 +2 @ 46-53 + +padStrength:: 1-16 +The mA which may be drawn from each GPIO whilst still guaranteeing the +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. + +*portStr:: +A string specifying the port address used by the Pi running +the pigpio daemon. It may be NULL in which case "8888" +is used unless overridden by the PIGPIO_PORT environment +variable. + +*pth:: +A thread identifier, returned by [*start_thread*]. + + +pthread_t:: +A thread identifier. + +pud::0-2 +The setting of the pull up/down resistor for a GPIO, which may be off, +pull-up, or pull-down. +. . +PI_PUD_OFF 0 +PI_PUD_DOWN 1 +PI_PUD_UP 2 +. . + +pulseLen:: +1-100, the length of a trigger pulse in microseconds. + +*pulses:: +An array of pulses to be added to a waveform. + +pulsewidth::0, 500-2500 +. . +PI_SERVO_OFF 0 +PI_MIN_SERVO_PULSEWIDTH 500 +PI_MAX_SERVO_PULSEWIDTH 2500 +. . + +PWMduty::0-1000000 (1M) +The hardware PWM dutycycle. + +. . +#define PI_HW_PWM_RANGE 1000000 +. . + +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 +The permissible dutycycle values are 0-range. + +. . +PI_MIN_DUTYCYCLE_RANGE 25 +PI_MAX_DUTYCYCLE_RANGE 40000 +. . + +*retBuf:: +A buffer to hold a number of bytes returned to a used customised function, + +retMax:: +The maximum number of bytes a user customised function should return. + + +*rxBuf:: +A pointer to a buffer to receive data. + +SCL:: +The user GPIO to use for the clock when bit banging I2C. + +SCLK:: +The GPIO used for the SCLK signal when bit banging SPI. + +*script:: +A pointer to the text of a script. + +script_id:: +An id of a stored script as returned by [*store_script*]. + +*scriptName:: +The name of a [*shell_*] script to be executed. The script must be present in +/opt/pigpio/cgi and must have execute permission. + +*scriptString:: +The string to be passed to a [*shell_*] script to be executed. + +SDA:: +The user GPIO to use for data when bit banging I2C. + +seconds:: +The number of seconds. + +seekFrom:: + +. . +PI_FROM_START 0 +PI_FROM_CURRENT 1 +PI_FROM_END 2 +. . + +seekOffset:: +The number of bytes to move forward (positive) or backwards (negative) +from the seek position (start, current, or end of file). + +ser_flags:: +Flags which modify a serial open command. None are currently defined. + +*ser_tty:: +The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1. + +size_t:: +A standard type used to indicate the size of an object in bytes. + +spi_channel:: +A SPI channel, 0-2. + +spi_flags:: +See [*spi_open*] and [*bb_spi_open*]. + +steady:: 0-300000 + +The number of microseconds level changes must be stable for +before reporting the level changed ([*set_glitch_filter*]) or triggering +the active part of a noise filter ([*set_noise_filter*]). + +stop_bits::2-8 +The number of (half) stop bits to be used when adding serial data +to a waveform. + +. . +#define PI_MIN_WAVE_HALFSTOPBITS 2 +#define PI_MAX_WAVE_HALFSTOPBITS 8 +. . + +*str:: + An array of characters. + +thread_func:: +A function of type gpioThreadFunc_t used as the main function of a +thread. + +timeout:: +A GPIO watchdog timeout in milliseconds. + +. . +PI_MIN_WDOG_TIMEOUT 0 +PI_MAX_WDOG_TIMEOUT 60000 +. . + +*txBuf:: +An array of bytes to transmit. + +uint32_t::0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF) +A 32-bit unsigned value. + +unsigned:: +A whole number >= 0. + +user_gpio:: +0-31, a Broadcom numbered GPIO. + +See [*gpio*]. + +*userdata:: + +A pointer to arbitrary user data. This may be used to identify the instance. + +You must ensure that the pointer is in scope at the time it is processed. If +it is a pointer to a global this is automatic. Do not pass the address of a +local variable. If you want to pass a transient object then use the +following technique. + +In the calling function: + +. . +user_type *userdata; +user_type my_userdata; + +userdata = malloc(sizeof(user_type)); +*userdata = my_userdata; +. . + +In the receiving function: + +. . +user_type my_userdata = *(user_type*)userdata; + +free(userdata); +. . + +void:: +Denoting no parameter is required + +wave_add_*:: +One of + +[*wave_add_new*] +[*wave_add_generic*] +[*wave_add_serial*] + +wave_id:: +A number representing a waveform created by [*wave_create*]. + +wave_send_*:: +One of + +[*wave_send_once*] +[*wave_send_repeat*] + +wVal::0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777) +A 16-bit word value. + +PARAMS*/ + +/*DEF_S pigpiod_if2 Error Codes*/ + +typedef enum +{ + pigif_bad_send = -2000, + pigif_bad_recv = -2001, + pigif_bad_getaddrinfo = -2002, + pigif_bad_connect = -2003, + pigif_bad_socket = -2004, + pigif_bad_noib = -2005, + pigif_duplicate_callback = -2006, + pigif_bad_malloc = -2007, + pigif_bad_callback = -2008, + pigif_notify_failed = -2009, + pigif_callback_not_found = -2010, + pigif_unconnected_pi = -2011, + pigif_too_many_pis = -2012, +} pigifError_t; + +/*DEF_E*/ + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/pigs.1 b/pigs.1 new file mode 100644 index 0000000..9b53e0e --- /dev/null +++ b/pigs.1 @@ -0,0 +1,6333 @@ + +." 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. + +/dev/pigpio - command line pipe access to the pigpio daemon. + +.SH SYNOPSIS + +.B sudo pigpiod + +then + +.B pigs {command}+ + +or + +.B "echo {command}+ >/dev/pigpio" + +.SH DESCRIPTION + +.ad l + +.nh + + +.br +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. + +.br + +.EX +sudo pigpiod +.br + +.EE + +.br +.SS Features +.br +o hardware timed PWM on any of GPIO 0-31 + +.br +o hardware timed servo pulses on any of GPIO 0-31 + +.br +o reading/writing all of the GPIO in a bank as one operation + +.br +o individually setting GPIO modes, reading and writing + +.br +o notifications when any of GPIO 0-31 change state + +.br +o the construction of output waveforms with microsecond timing + +.br +o I2C, SPI, and serial link wrappers + +.br +o creating and running scripts on the pigpio daemon + +.br +.SS GPIO +.br +ALL GPIO are identified by their Broadcom number. + +.br +.SS Usage +.br +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 +The pigpio library must be running, either by running a program linked +with the library or starting the pigpio daemon (sudo pigpiod). + +.br +pigs {command}+ + +.br +echo "{command}+" >/dev/pigpio + +.br +pigs will show the result of the command on screen. + +.br +The pigs process returns an exit status (which can be displayed with +the command echo $?). + +.br + +.EX +PIGS_OK 0 +.br +PIGS_CONNECT_ERR 255 +.br +PIGS_OPTION_ERR 254 +.br +PIGS_SCRIPT_ERR 253 +.br +.br +.br + +.EE + +.br +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). + +.br +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. + +.br +Several commands may be entered on a line. If present PROC and PARSE must +be the last command on a line. + +.br +E.g. + +.br + +.EX +pigs w 22 1 mils 1000 w 22 0 +.br + +.EE + +.br +is equivalent to + +.br + +.EX +pigs w 22 1 +.br +pigs mils 1000 +.br +pigs w 22 0 +.br + +.EE + +.br +and + +.br + +.EX +echo "m 4 w w 4 0 mils 250 m 4 r r 4" >/dev/pigpio +.br + +.EE + +.br +is equivalent to + +.br + +.EX +echo "m 4 w" >/dev/pigpio +.br +echo "w 4 0" >/dev/pigpio +.br +echo "mils 250" >/dev/pigpio +.br +echo "m 4 r" >/dev/pigpio +.br +echo "r 4" >/dev/pigpio +.br + +.EE + +.br +.SS Notes +.br +The examples from now on will show the pigs interface but the same +commands will also work on the pipe interface. + +.br +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. + +.br +The status/data of each command sent to the pipe interface should +be read from /dev/pigout. + +.br +When a command takes a number as a parameter it may be entered as hex +(precede by 0x), octal (precede by 0), or decimal. + +.br +E.g. 23 is 23 decimal, 0x100 is 256 decimal, 070 is 56 decimal. + +.br +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. + +.br +E.g. assuming the transmitted serial data is the letters ABCDEONM + +.br + +.EX +$ pigs slr 4 100 +.br +8 65 66 67 68 69 79 78 77 +.br + +.br +$ pigs -a slr 4 100 +.br +8 ABCDEONM +.br + +.br +$ pigs -x slr 4 100 +.br +8 41 42 43 44 45 4f 4e 4d +.br + +.EE + +.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 + +.IP "\fBBC1 bits\fP - Clear specified GPIO in bank 1" +.IP "" 4 +This command clears (sets low) the GPIO specified by \fBbits\fP in bank 1. +Bank 1 consists of GPIO 0-31. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs bc1 0x400010 # clear GPIO 4 (1<<4) and 22 (1<<22) +.br + +.br +$ pigs bc1 32 # clear GPIO 5 (1<<5) +.br +-42 +.br +ERROR: no permission to update one or more GPIO +.br + +.EE + +.br + +.IP "\fBBC2 bits\fP - Clear specified GPIO in bank 2" +.IP "" 4 +This command clears (sets low) the GPIO specified by \fBbits\fP in bank 2. +Bank 2 consists of GPIO 32-53. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs bc2 0x8000 # clear GPIO 47 (activity LED on A+/B+/Pi2/Pi3) +.br + +.br +$ pigs bc2 1 # clear GPIO 32 (first in bank 2) +.br +-42 +.br +ERROR: no permission to update one or more GPIO +.br + +.EE + +.br + +.IP "\fBBI2CC sda\fP - Close bit bang I2C" +.IP "" 4 +This command signals that bit banging I2C on \fBsda\fP (and \fBscl\fP) is no +longer required. + +.br + +\fBExample\fP +.br + +.EX +$ pigs bi2cc 5 +.br + +.EE + +.br + +.IP "\fBBI2CO sda scl b\fP - Open bit bang I2C" +.IP "" 4 +This command signals that GPIO \fBsda\fP and \fBscl\fP are to be used +for bit banging I2C at \fBb\fP baud. + +.br +Bit banging I2C allows for certain operations which are not possible +with the standard I2C driver. + +.br +o baud rates as low as 50 +.br +o repeated starts +.br +o clock stretching +.br +o I2C on any pair of spare GPIO + +.br +The baud rate may be between 50 and 500000 bits per second. + +.br +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. + +.br + +.IP "\fBBI2CZ sda bvs\fP - I2C bit bang multiple transactions" +.IP "" 4 +This function executes a sequence of bit banged I2C operations. The +operations to be performed are specified by the contents of \fBbvs\fP +which contains the concatenated command codes and associated data. + +.br +The following command codes are supported: + +.br + +.EX +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 + +.EE + +.br +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). + +.br +The address and flags default to 0. The address and flags maintain +their previous value until updated. + +.br +No flags are currently defined. + +.br + +\fBExample\fP +.br + +.EX +Set address 0x53 +.br +start, write 0x32, (re)start, read 6 bytes, stop +.br +Set address 0x1E +.br +start, write 0x03, (re)start, read 6 bytes, stop +.br +Set address 0x68 +.br +start, write 0x1B, (re)start, read 8 bytes, stop +.br +End +.br + +.br +0x04 0x53 +.br +0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03 +.br + +.br +0x04 0x1E +.br +0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03 +.br + +.br +0x04 0x68 +.br +0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03 +.br + +.br +0x00 +.br + +.EE + +.br + +.IP "\fBBR1 \fP - Read bank 1 GPIO" +.IP "" 4 +This command read GPIO 0-31 (bank 1) and returns the levels as a +32-bit hexadecimal value. + +.br + +\fBExample\fP +.br + +.EX +$ pigs br1 +.br +1001C1CF +.br + +.EE + +.br + +.IP "\fBBR2 \fP - Read bank 2 GPIO" +.IP "" 4 +This command read GPIO 32-53 (bank 2) and returns the levels as a +32-bit hexadecimal value. + +.br + +\fBExample\fP +.br + +.EX +$ pigs br2 +.br +003F0000 +.br + +.EE + +.br + +.IP "\fBBS1 bits\fP - Set specified GPIO in bank 1" +.IP "" 4 +This command sets (sets high) the GPIO specified by \fBbits\fP in bank 1. +Bank 1 consists of GPIO 0-31. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs bs1 16 # set GPIO 4 (1<<4) +.br + +.br +$ pigs bs1 1 # set GPIO 1 (1<<0) +.br +-42 +.br +ERROR: no permission to update one or more GPIO +.br + +.EE + +.br + +.IP "\fBBS2 bits\fP - Set specified GPIO in bank 2" +.IP "" 4 +This command sets (sets high) the GPIO specified by \fBbits\fP in bank 2. +Bank 2 consists of GPIO 32-53. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs bs2 0x40 # set GPIO 38 (enable high current mode A+/B+/Pi2/Pi3) +.br + +.br +$ pigs bs2 1 # set GPIO 32 (first in bank 2) +.br +-42 +.br +ERROR: no permission to update one or more GPIO +.br + +.EE + +.br + +.IP "\fBBSCX bctl bvs\fP - BSC I2C/SPI transfer" +.IP "" 4 + +.br +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. + +.br +The command sets the BSC mode and writes any data \fBbvs\fP +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. + +.br +Note that the control word sets the BSC mode. The BSC will stay in +that mode until a different control word is sent. + +.br +For I2C use a control word of (I2C address << 16) + 0x305. + +.br +E.g. to talk as I2C slave with address 0x13 use 0x130305. + +.br +GPIO used for models other than those based on the BCM2711. + +.br + +.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 +The control word consists of the following bits. + +.br + +.EX +22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + a a a a a a a - - IT HC TF IR RE TE BK EC ES PL PH I2 SP EN +.br + +.EE + +.br +Bits 0-13 are copied unchanged to the BSC CR register. See +pages 163-165 of the Broadcom peripherals document for full +details. + +.br + +.EX +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 + +.EE + +.br +The returned status has the following format + +.br + +.EX +20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + S S S S S R R R R R T T T T T RB TE RF TF RE TB +.br + +.EE + +.br +Bits 0-15 are copied unchanged from the BSC FR register. See +pages 165-166 of the Broadcom peripherals document for full +details. + +.br + +.EX +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 + +.EE + +.br +This example assumes that GPIO 2/3 are connected to GPIO 18/19 +(GPIO 10/11 on the BCM2711). + +.br + +\fBExample\fP +.br + +.EX +$ pigs bscx 0x130305 # start BSC as I2C slave 0x13 +.br +1 18 +.br + +.br +$ i2cdetect -y 1 +.br + 0 1 2 3 4 5 6 7 8 9 a b c d e f +.br +00: -- -- -- -- -- -- -- -- -- -- -- -- -- +.br +10: -- -- -- 13 -- -- -- -- -- -- -- -- -- -- -- -- +.br +20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +.br +30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +.br +40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +.br +50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +.br +60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +.br +70: -- -- -- -- -- -- -- -- +.br + +.br +$ pigs i2co 1 0x13 0 # get handle for device 0x13 on bus 1 +.br +0 +.br + +.br +$ pigs i2cwd 0 90 87 51 9 23 # write 5 bytes +.br + +.br +$ pigs bscx 0x130305 # check for data +.br +6 18 90 87 51 9 23 +.br + +.br +$ pigs bscx 0x130305 11 13 15 17 # check for data and send 4 bytes +.br +1 262338 +.br + +.br +$ pigs i2crd 0 4 # read 4 bytes +.br +4 11 13 15 17 +.br + +.br +$ pigs i2cwd 0 90 87 51 9 23 # write 5 bytes +.br +$ pigs bscx 0x130305 11 13 15 17 # check for data and send 4 bytes +.br +6 262338 90 87 51 9 23 +.br + +.br +$ pigs i2crd 0 4 +.br +4 11 13 15 17 +.br + +.br +$ pigs bscx 0x130305 22 33 44 55 66 +.br +1 327938 +.br +$ pigs i2crd 0 5 +.br +5 22 33 44 55 66 +.br + +.EE + +.br + +.IP "\fBBSPIC cs\fP - Close bit bang SPI" +.IP "" 4 + +.br +This command stops bit banging SPI on a set of GPIO +opened with \fBBSPIO\fP. + +.br +The set of GPIO is specifed by \fBcs\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs bspic 10 +.br + +.br +$ pigs bspic 10 +.br +-142 +.br +ERROR: no bit bang SPI in progress on GPIO +.br + +.EE + +.br + +.IP "\fBBSPIO cs miso mosi sclk b spf\fP - Open bit bang SPI" +.IP "" 4 + +.br +This command starts bit banging SPI on a group of GPIO with slave +select \fBcs\fP, MISO \fBmiso\fP, MOSI \fBmosi\fP, and clock \fBsclk\fP. + +.br +Data will be transferred at baud \fBb\fP bits per second (which may +be set in the range 50-250000). + +.br +The flags \fBspf\fP may be used to modify the default behaviour of +mode 0, active low chip select. + +.br +The flags consists of the least significant 22 bits. + +.br + +.EX +21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m +.br + +.EE + +.br +mm defines the SPI mode. + +.br + +.EX +Mode POL PHA +.br + 0 0 0 +.br + 1 0 1 +.br + 2 1 0 +.br + 3 1 1 +.br + +.EE + +.br +p is 0 if CS is active low (default) and 1 for active high. + +.br +T is 1 if the least significant bit is transmitted on MOSI first, the +default (0) shifts the most significant bit out first. + +.br +R is 1 if the least significant bit is received on MISO first, the +default (0) receives the most significant bit first. + +.br +The other bits in flags should be set to zero. + +.br +Upon success 0 is returned. On error a negative status code +will be returned. + +.br +If more than one device is connected to the SPI bus (defined by +SCLK, MOSI, and MISO) each must have its own CS. + +.br + +\fBExample\fP +.br + +.EX +$ pigs bspio 9 11 12 13 50000 0 +.br + +.br +$ pigs bspio 10 11 12 13 50000 0 +.br + +.br +$ pigs bspio 29 19 20 21 50000 0 # GPIO 29 not avaialble on this Pi +.br +-41 +.br +ERROR: no permission to update GPIO +.br + +.EE + +.br + +.IP "\fBBSPIX cs bvs\fP - SPI bit bang transfer" +.IP "" 4 + +.br +This command writes bytes \fBbvs\fP to the bit bang SPI device +associated with slave select \fBcs\fP. It returns the same +number of bytes read from the device. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs bspio 5 13 19 12 10000 0 # MCP4251 DAC +.br +$ pigs bspio 6 13 19 12 20000 3 # MCP3008 ADC +.br + +.br +$ pigs bspix 5 0 16 # set DAC to 16 +.br +2 255 255 +.br + +.br +$ pigs bspix 5 12 0 # read back DAC +.br +2 254 16 +.br + +.br +$ pigs bspix 6 1 128 0 # read ADC input 0 +.br +3 0 3 184 # 952 +.br + +.br +$ pigs bspix 5 0 240 # set DAC to 240 +.br +2 255 255 +.br + +.br +$ pigs bspix 5 12 0 # read back DAC +.br +2 254 240 +.br + +.br +$ pigs bspix 6 1 128 0 # read ADC input 0 +.br +3 0 0 63 # 63 +.br + +.br +$ pigs bspix 5 0 128 # set DAC to 128 +.br +2 255 255 +.br + +.br +$ pigs bspix 5 12 0 # read back DAC +.br +2 254 128 +.br + +.br +$ pigs bspix 6 1 128 0 # read ADC input 0 +.br +3 0 1 255 # 511 +.br + +.br +$ pigs bspic 5 # close SPI CS 5 +.br +$ pigs bspic 6 # close SPI CS 6 +.br + +.br +$ pigs bspic 5 # try to close SPI CS 5 again +.br +-142 +.br +ERROR: no bit bang SPI in progress on GPIO +.br + +.EE + +.br + +.br + +.IP "\fBCF1 uvs\fP - Custom function 1" +.IP "" 4 + +.br +This command calls a user customised function. The meaning of +any paramaters and the returned value is defined by the +customiser. + +.br + +.IP "\fBCF2 uvs\fP - Custom function 2" +.IP "" 4 + +.br +This command calls a user customised function. The meaning of +any paramaters and the returned value is defined by the +customiser. + +.br + +.IP "\fBCGI \fP - Configuration get internals" +.IP "" 4 +This command returns the value of the internal library +configuration settings. + +.br + +.IP "\fBCSI v\fP - Configuration set internals" +.IP "" 4 +This command sets the value of the internal library +configuration settings to \fBv\fP. + +.br + +.IP "\fBEVM h bits\fP - Set events to monitor" +.IP "" 4 +This command starts event reporting on handle \fBh\fP (returned by +a prior call to \fBNO\fP). + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The notification gets reports for each event specified by \fBbits\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs evm 0 -1 # Shorthand for events 0-31. +.br +$ pigs evm 0 0xf0 # Get notifications for events 4-7. +.br + +.br +$ pigs evm 1 0xf +.br +-25 +.br +ERROR: unknown handle +.br + +.EE + +.br + +.IP "\fBEVT event\fP - Trigger event" +.IP "" 4 +This command triggers event \fBevent\fP. + +.br +One event, number 31, is predefined. This event is +auto generated on BSC slave activity. + +.br + +\fBExample\fP +.br + +.EX +$ pigs evt 12 +.br +$ pigs evt 5 +.br + +.br +$ pigs evt 32 +.br +-143 +.br +ERROR: bad event id +.br + +.EE + +.br + +.IP "\fBFC h\fP - Close file handle" +.IP "" 4 +This command closes a file handle \fBh\fP previously opened with \fBFO\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs fc 0 # First close okay. +.br + +.br +$ pigs fc 0 # Second fails. +.br +-25 +.br +ERROR: unknown handle +.br + +.EE + +.br + +.IP "\fBFG u stdy\fP - Set a glitch filter on a GPIO" +.IP "" 4 + +.br +Level changes on the GPIO \fBu\fP are not reported unless the level +has been stable for at least \fBstdy\fP microseconds. The +level is then reported. Level changes of less than \fBstdy\fP +microseconds are ignored. + +.br +The filter only affects callbacks (including pipe notifications). + +.br +The \fBR/READ\fP, \fBBR1\fP, and \fBBR2\fP commands are not affected. + +.br +Note, each (stable) edge will be timestamped \fBstdy\fP microseconds +after it was first detected. + +.br + +\fBExample\fP +.br + +.EX +$ pigs fg 4 250 +.br + +.br +$ pigs fg 4 1000000 +.br +-125 +.br +ERROR: bad filter parameter +.br + +.EE + +.br + +.IP "\fBFL pat num\fP - List files which match pattern" +.IP "" 4 +This command returns a list of the files matching \fBpat\fP. Up +to \fBnum\fP bytes may be returned. + +.br +Upon success the count of returned bytes followed by the matching +files is returned. On error a negative status code will be returned. + +.br +A newline (0x0a) character separates each file name. + +.br +Only files which have a matching entry in /opt/pigpio/access may +be listed. + +.br +Suppose /opt/pigpio/access contains + +.br +/sys/bus/w1/devices/28*/w1_slave r + +.br + +\fBExample\fP +.br + +.EX +$ pigs -a fl "/sys/bus/w1/devices/28*/w1_slave" 5000 +.br +90 /sys/bus/w1/devices/28-000005d34cd2/w1_slave +.br +/sys/bus/w1/devices/28-001414abbeff/w1_slave +.br + +.br +$ pigs -a fl "/sys/bus/*" 5000 +.br +ERROR: no permission to access file +.br +-137 +.br + +.EE + +.br + +.IP "\fBFN u stdy actv\fP - Set a noise filter on a GPIO" +.IP "" 4 + +.br +Level changes on the GPIO \fBu\fP are ignored until a level which has +been stable for \fBstdy\fP microseconds is detected. Level +changes on the GPIO are then reported for \fBactv\fP microseconds +after which the process repeats. + +.br +The filter only affects callbacks (including pipe notifications). + +.br +The \fBR/READ\fP, \fBBR1\fP, and \fBBR2\fP commands are not affected. + +.br +Note, level changes before and after the active period may +be reported. Your software must be designed to cope with +such reports. + +.br + +\fBExample\fP +.br + +.EX +$ pigs fn 7 250 1000 +.br + +.br +$ pigs fn 7 2500000 1000 +.br +-125 +.br +ERROR: bad filter parameter +.br + +.EE + +.br + +.IP "\fBFO file mode\fP - Open a file in mode" +.IP "" 4 +This function returns a handle to a file \fBfile\fP opened +in a specified mode \fBmode\fP. + +.br +Upon success a handle (>=0) is returned. On error a negative status code +will be returned. + +.br +File + +.br +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. + +.br +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. + +.br +Where more than one entry matches a file the most specific rule +applies. If no entry matches a file then access is denied. + +.br +Suppose /opt/pigpio/access contains the following entries + +.br + +.EX +/home/* n +.br +/home/pi/shared/dir_1/* w +.br +/home/pi/shared/dir_2/* r +.br +/home/pi/shared/dir_3/* u +.br +/home/pi/shared/dir_1/file.txt n +.br + +.EE + +.br +Files may be written in directory dir_1 with the exception +of file.txt. + +.br +Files may be read in directory dir_2. + +.br +Files may be read and written in directory dir_3. + +.br +If a directory allows read, write, or read/write access then files may +be created in that directory. + +.br +In an attempt to prevent risky permissions the following paths are +ignored in /opt/pigpio/access. + +.br + +.EX +a path containing .. +.br +a path containing only wildcards (*?) +.br +a path containing less than two non-wildcard parts +.br + +.EE + +.br +Mode + +.br +The mode may have the following values. + +.br + +.EX + Value Meaning +READ 1 open file for reading +WRITE 2 open file for writing +RW 3 open file for reading and writing + +.EE + +.br +The following values may be or'd into the mode. + +.br + +.EX + 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 + +.EE + +.br +Newly created files are owned by root with permissions owner read and write. + +.br + +\fBExample\fP +.br + +.EX +$ ls /ram/*.c +.br +/ram/command.c /ram/pigpiod.c /ram/pigs.c +.br +/ram/x_pigpiod_if.c /ram/pig2vcd.c /ram/pigpiod_if2.c +.br +/ram/x_pigpio.c /ram/x_repeat.c /ram/pigpio.c +.br +/ram/pigpiod_if.c /ram/x_pigpiod_if2.c +.br + +.br +# assumes /opt/pigpio/access contains the following line +.br +# /ram/*.c r +.br + +.br +$ pigs fo /ram/pigpio.c 1 +.br +0 +.br + +.br +$ pigs fo /ram/new.c 1 +.br +-128 +.br +ERROR: file open failed +.br + +.br +$ pigs fo /ram/new.c 9 +.br +1 +.br + +.br +$ ls /ram/*.c -l +.br +-rw-r--r-- 1 joan joan 42923 Jul 10 11:22 /ram/command.c +.br +-rw------- 1 root root 0 Jul 10 16:54 /ram/new.c +.br +-rw-r--r-- 1 joan joan 2971 Jul 10 11:22 /ram/pig2vcd.c +.br +-rw------- 1 joan joan 296235 Jul 10 11:22 /ram/pigpio.c +.br +-rw-r--r-- 1 joan joan 9266 Jul 10 11:22 /ram/pigpiod.c +.br +-rw-r--r-- 1 joan joan 37331 Jul 10 11:22 /ram/pigpiod_if2.c +.br +-rw-r--r-- 1 joan joan 33088 Jul 10 11:22 /ram/pigpiod_if.c +.br +-rw-r--r-- 1 joan joan 7990 Jul 10 11:22 /ram/pigs.c +.br +-rw-r--r-- 1 joan joan 19970 Jul 10 11:22 /ram/x_pigpio.c +.br +-rw-r--r-- 1 joan joan 20804 Jul 10 11:22 /ram/x_pigpiod_if2.c +.br +-rw-r--r-- 1 joan joan 19844 Jul 10 11:22 /ram/x_pigpiod_if.c +.br +-rw-r--r-- 1 joan joan 19907 Jul 10 11:22 /ram/x_repeat.c +.br + +.EE + +.br + +.IP "\fBFR h num\fP - Read bytes from file handle" +.IP "" 4 +This command returns up to \fBnum\fP bytes of data read from the +file associated with handle \fBh\fP. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs fr 0 10 +.br +5 48 49 128 144 255 +.br + +.br +$ pigs fr 0 10 +.br +0 +.br + +.EE + +.br + +.IP "\fBFS h num from\fP - Seek to file handle position" +.IP "" 4 +This command seeks to a position within the file associated +with handle \fBh\fP. + +.br +The number of bytes to move is \fBnum\fP. Positive offsets +move forward, negative offsets backwards. The move start +position is determined by \fBfrom\fP as follows. + +.br + +.EX + From +0 start +1 current position +2 end + +.EE + +.br +Upon success the new byte position within the file (>=0) is +returned. On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs fs 0 200 0 # Seek to start of file plus 200 +.br +200 +.br + +.br +$ pigs fs 0 0 1 # Return current position +.br +200 +.br + +.br +$ pigs fs 0 0 2 # Seek to end of file, return size +.br +296235 +.br + +.EE + +.br + +.IP "\fBFW h bvs\fP - Write bytes to file handle" +.IP "" 4 +This command writes bytes \fBbvs\fP to the file +associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs fw 0 23 45 67 89 +.br + +.EE + +.br + +.IP "\fBGDC u\fP - Get GPIO PWM dutycycle" +.IP "" 4 + +.br +This command returns the PWM dutycycle in use on GPIO \fBu\fP. + +.br +Upon success the dutycycle is returned. On error a negative +status code will be returned. + +.br +For normal PWM the dutycycle will be out of the defined range +for the GPIO (see \fBPRG\fP). + +.br +If a hardware clock is active on the GPIO the reported +dutycycle will be 500000 (500k) out of 1000000 (1M). + +.br +If hardware PWM is active on the GPIO the reported dutycycle +will be out of a 1000000 (1M). + +.br + +\fBExample\fP +.br + +.EX +$ pigs p 4 129 +.br +$ pigs gdc 4 +.br +129 +.br + +.br +pigs gdc 5 +.br +-92 +.br +ERROR: GPIO is not in use for PWM +.br + +.EE + +.br + +.IP "\fBGPW u\fP - Get GPIO servo pulsewidth" +.IP "" 4 + +.br +This command returns the servo pulsewidth in use on GPIO \fBu\fP. + +.br +Upon success the servo pulsewidth is returned. On error a negative +status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs s 4 1235 +.br +$ pigs gpw 4 +.br +1235 +.br + +.br +$ pigs gpw 9 +.br +-93 +.br +ERROR: GPIO is not in use for servo pulses +.br + +.EE + +.br + +.IP "\fBH/HELP \fP - Display command help" +.IP "" 4 +This command displays a brief list of the commands and their parameters. + +.br + +\fBExample\fP +.br + +.EX +$ pigs h +.br + +.br +$ pigs help +.br + +.EE + +.br + +.IP "\fBHC g cf\fP - Set hardware clock frequency" +.IP "" 4 +This command sets the hardware clock associated with GPIO \fBg\fP to +frequency \fBcf\fP. Frequencies above 30MHz are unlikely to work. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs hc 4 5000 # start a 5 KHz clock on GPIO 4 (clock 0) +.br + +.br +$ pigs hc 5 5000000 # start a 5 MHz clcok on GPIO 5 (clock 1) +.br +-99 +.br +ERROR: need password to use hardware clock 1 +.br + +.EE + +.br +The same clock is available on multiple GPIO. The latest +frequency setting will be used by all GPIO which share a clock. + +.br +The GPIO must be one of the following. + +.br + +.EX +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) + +.EE + +.br + +.EX +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) + +.EE + +.br +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. + +.br + +.IP "\fBHP g pf pdc\fP - Set hardware PWM frequency and dutycycle" +.IP "" 4 +This command sets the hardware PWM associated with GPIO \fBg\fP to +frequency \fBpf\fP with dutycycle \fBpdc\fP. Frequencies above 30MHz +are unlikely to work. + +.br +NOTE: Any waveform started by \fBWVTX\fP, \fBWVTXR\fP, or \fBWVCHA\fP +will be cancelled. + +.br +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). + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +.EX +$ pigs hp 18 100 800000 # 80% dutycycle +.br + +.br +$ pigs hp 19 100 200000 # 20% dutycycle +.br + +.br +$ pigs hp 19 400000000 100000 +.br +-96 +.br +ERROR: invalid hardware PWM frequency +.br + +.EE + +.br +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. + +.br +The GPIO must be one of the following. + +.br + +.EX +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 + +.EE + +.br + +.EX +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 + +.EE + +.br +The actual number of steps beween off and fully on is the +integral part of 250M/\fBpf\fP (375M/\fBpf\fP for the BCM2711). + +.br +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 (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. + +.br + +.IP "\fBHWVER \fP - Get hardware version" +.IP "" 4 +This command returns the hardware revision of the Pi. + +.br +The hardware revision is found in the last 4 characters on the revision +line of /proc/cpuinfo. + +.br +If the hardware revision can not be found or is not a valid hexadecimal +number the command returns 0. + +.br +The revision number can be used to determine the assignment of GPIO +to pins (see \fBg\fP). + +.br +There are currently three types of board. + +.br +Type 1 boards have hardware revision numbers of 2 and 3. + +.br +Type 2 boards have hardware revision numbers of 4, 5, 6, and 15. + +.br +Type 3 boards have hardware revision numbers of 16 or greater. + +.br +for "Revision : 0002" the command returns 2. + +.br +for "Revision : 000f" the command returns 15. + +.br +for "Revision : 000g" the command returns 0. + +.br + +\fBExample\fP +.br + +.EX +$ pigs hwver # On a B+ +.br +16 +.br + +.EE + +.br + +.IP "\fBI2CC h\fP - Close I2C handle" +.IP "" 4 +This command closes an I2C handle \fBh\fP previously opened with \fBI2CO\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cc 0 # First close okay. +.br + +.br +$ pigs i2cc 0 # Second fails. +.br +-25 +.br +ERROR: unknown handle +.br + +.EE + +.br + +.IP "\fBI2CO ib id if\fP - Open I2C bus and device with flags" +.IP "" 4 +This command returns a handle to access device \fBid\fP on I2C bus \fBib\fP. +The device is opened with flags \fBif\fP. + +.br +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. + +.br +The GPIO used are given in the following table. + +.br + +.EX + SDA SCL +I2C 0 0 1 +I2C 1 2 3 + +.EE + +.br +No flags are currently defined. The parameter \fBif\fP should be 0. + +.br +Upon success the next free handle (>=0) is returned. On error a +negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2co 1 0x70 0 # Bus 1, device 0x70, flags 0. +.br +0 +.br + +.br +$ pigs i2co 1 0x53 0 # Bus 1, device 0x53, flags 0. +.br +1 +.br + +.EE + +.br + +.IP "\fBI2CPC h r wv\fP - smb Process Call: exchange register with word" +.IP "" 4 +This command writes \fBwv\fP to register \fBr\fP of the I2C device +associated with handle \fBh\fP and returns a 16-bit word read from the +device. + +.br +Upon success a value between 0 and 65535 will be returned. On error +a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cpc 0 37 43210 +.br +39933 +.br + +.br +$ pigs i2cpc 0 256 43210 +.br +ERROR: bad i2c/spi/ser parameter +.br +-81 +.br + +.EE + +.br + +.IP "\fBI2CPK h r bvs\fP - smb Block Process Call: exchange data bytes with register" +.IP "" 4 + +.br +This command writes the data bytes \fBbvs\fP to register \fBr\fP of the I2C device +associated with handle \fBh\fP and returns a device specific number of bytes. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cpk 0 0 0x11 0x12 +.br +6 0 0 0 0 0 0 +.br + +.EE + +.br + +.IP "\fBI2CRB h r\fP - smb Read Byte Data: read byte from register" +.IP "" 4 + +.br +This command returns a single byte read from register \fBr\fP of the I2C device +associated with handle \fBh\fP. + +.br +Upon success a value between 0 and 255 will be returned. On error +a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2crb 0 0 +.br +6 +.br + +.EE + +.br + +.IP "\fBI2CRD h num\fP - i2c Read device" +.IP "" 4 + +.br +This command returns \fBnum\fP bytes read from the I2C device associated with +handle \fBh\fP. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br +This command operates on the raw I2C device. The maximum value of the +parameter \fBnum\fP is dependent on the I2C drivers and the device +itself. pigs imposes a limit of about 8000 bytes. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2crd 0 16 +.br +16 6 24 0 0 0 0 0 0 0 0 0 0 0 0 32 78 +.br + +.EE + +.br + +.IP "\fBI2CRI h r num\fP - smb Read I2C Block Data: read bytes from register" +.IP "" 4 + +.br +This command returns \fBnum\fP bytes from register \fBr\fP of the I2C device +associated with handle \fBh\fP. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br +The parameter \fBnum\fP may be 1-32. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cri 0 0 16 +.br +16 237 155 155 155 155 155 155 155 155 155 155 155 155 155 155 155 +.br + +.EE + +.br + +.IP "\fBI2CRK h r\fP - smb Read Block Data: read data from register" +.IP "" 4 + +.br +This command returns between 1 and 32 bytes read from register \fBr\fP of +the I2C device associated with handle \fBh\fP. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br +The number of bytes of returned data is specific to the device and +register. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2crk 0 0 +.br +6 0 0 0 0 0 0 +.br + +.br +$ pigs i2crk 0 1 +.br +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 +.br + +.EE + +.br + +.IP "\fBI2CRS h\fP - smb Read Byte: read byte" +.IP "" 4 + +.br +This command returns a single byte read from the I2C device +associated with handle \fBh\fP. + +.br +Upon success a value between 0 and 255 will be returned. On error +a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2crs 0 +.br +0 +.br + +.EE + +.br + +.IP "\fBI2CRW h r\fP - smb Read Word Data: read word from register" +.IP "" 4 + +.br +This command returns a single 16 bit word read from register \fBr\fP of +the I2C device associated with handle \fBh\fP. + +.br +Upon success a value between 0 and 65535 will be returned. On error +a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2crw 0 0 +.br +6150 +.br + +.EE + +.br + +.IP "\fBI2CWB h r bv\fP - smb Write Byte Data: write byte to register" +.IP "" 4 + +.br +This command writes a single byte \fBbv\fP to register \fBr\fP of the +I2C device associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cwb 0 10 0x54 +.br + +.EE + +.br + +.IP "\fBI2CWD h bvs\fP - i2c Write device" +.IP "" 4 + +.br +This command writes a block of bytes \fBbvs\fP to the I2C device +associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +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. + +.br +This command operates on the raw I2C device. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cwd 0 0x01 0x02 0x03 0x04 +.br + +.EE + +.br + +.IP "\fBI2CWI h r bvs\fP - smb Write I2C Block Data" +.IP "" 4 + +.br +This command writes between 1 and 32 bytes \fBbvs\fP to register \fBr\fP of +the I2C device associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cwi 0 4 0x01 0x04 0xc0 +.br + +.EE + +.br + +.IP "\fBI2CWK h r bvs\fP - smb Write Block Data: write data to register" +.IP "" 4 + +.br +This command writes between 1 and 32 bytes \fBbvs\fP to register \fBr\fP of +the I2C device associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +pigs i2cwk 0 4 0x01 0x04 0xc0 +.br + +.EE + +.br + +.IP "\fBI2CWQ h bit\fP - smb Write Quick: write bit" +.IP "" 4 + +.br +This command writes a single \fBbit\fP to the I2C device associated +with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cwq 0 1 +.br + +.EE + +.br + +.IP "\fBI2CWS h bv\fP - smb Write Byte: write byte" +.IP "" 4 + +.br +This command writes a single byte \fBbv\fP to the I2C device associated +with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cws 0 0x12 +.br + +.br +$ pigs i2cws 0 0xff +.br +-82 +.br +ERROR: I2C write failed +.br + +.EE + +.br + +.IP "\fBI2CWW h r wv\fP - smb Write Word Data: write word to register" +.IP "" 4 + +.br +This command writes a single 16 bit word \fBwv\fP to register \fBr\fP of +the I2C device associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs i2cww 0 0 0xffff +.br + +.EE + +.br + +.IP "\fBI2CZ h bvs\fP - Performs multiple I2C transactions" +.IP "" 4 +This command executes a sequence of I2C operations. The +operations to be performed are specified by the contents of \fBbvs\fP +which contains the concatenated command codes and associated data. + +.br +The following command codes are supported: + +.br + +.EX +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 + +.EE + +.br +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). + +.br +The address defaults to that associated with the handle \fBh\fP. +The flags default to 0. The address and flags maintain their +previous value until updated. + +.br + +\fBExample\fP +.br + +.EX +Set address 0x53, write 0x32, read 6 bytes +.br +Set address 0x1E, write 0x03, read 6 bytes +.br +Set address 0x68, write 0x1B, read 8 bytes +.br +End +.br + +.br +0x04 0x53 0x07 0x01 0x32 0x06 0x06 +.br +0x04 0x1E 0x07 0x01 0x03 0x06 0x06 +.br +0x04 0x68 0x07 0x01 0x1B 0x06 0x08 +.br +0x00 +.br + +.EE + +.br + +.br + +.IP "\fBM/MODES g m\fP - Set GPIO mode" +.IP "" 4 + +.br +This command sets GPIO \fBg\fP to mode \fBm\fP, typically input (read) +or output (write). + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +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. + +.br +To set the mode use the code for the mode. + +.br + +.EX +Mode Input Output ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 +Code R W 0 1 2 3 4 5 + +.EE + +.br + +\fBExample\fP +.br + +.EX +$ pigs m 4 r # Input (read) +.br +$ pigs m 4 w # Output (write) +.br +$ pigs m 4 0 # ALT 0 +.br +$ pigs m 4 5 # ALT 5 +.br + +.EE + +.br + +.IP "\fBMG/MODEG g\fP - Get GPIO mode" +.IP "" 4 + +.br +This command returns the current mode of GPIO \fBg\fP. + +.br +Upon success the value of the GPIO mode is returned. +On error a negative status code will be returned. + +.br + +.EX +Value 0 1 2 3 4 5 6 7 +Mode Input Output ALT5 ALT4 ALT0 ALT1 ALT2 ALT3 + +.EE + +.br + +\fBExample\fP +.br + +.EX +$ pigs mg 4 +.br +1 +.br + +.EE + +.br + +.IP "\fBMICS v\fP - Microseconds delay" +.IP "" 4 +This command delays execution for \fBv\fP microseconds. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The main use of this command is expected to be within \fBScripts\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs mics 20 # Delay 20 microseconds. +.br +$ pigs mics 1000000 # Delay 1 second. +.br + +.br +$ pigs mics 2000000 +.br +-64 +.br +ERROR: bad MICS delay (too large) +.br + +.EE + +.br + +.IP "\fBMILS v\fP - Milliseconds delay" +.IP "" 4 + +.br +This command delays execution for \fBv\fP milliseconds. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs mils 2000 # Delay 2 seconds. +.br + +.br +$ pigs mils 61000 +.br +-65 +.br +ERROR: bad MILS delay (too large) +.br + +.EE + +.br + +.IP "\fBNB h bits\fP - Start notification" +.IP "" 4 + +.br +This command starts notifications on handle \fBh\fP returned by +a prior call to \fBNO\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The notification gets state changes for each GPIO specified by \fBbits\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs nb 0 -1 # Shorthand for GPIO 0-31. +.br +$ pigs nb 0 0xf0 # Get notifications for GPIO 4-7. +.br + +.br +$ pigs nb 1 0xf +.br +-25 +.br +ERROR: unknown handle +.br + +.EE + +.br + +.IP "\fBNC h\fP - Close notification" +.IP "" 4 + +.br +This command stops notifications on handle \fBh\fP returned by +a prior call to \fBNO\fP and releases the handle for reuse. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs nc 0 # First call succeeds. +.br + +.br +$ pigs nc 1 # Second call fails. +.br +-25 +.br +ERROR: unknown handle +.br + +.EE + +.br + +.IP "\fBNO \fP - Request a notification" +.IP "" 4 + +.br +This command requests a free notification handle. + +.br +A notification is a method for being notified of GPIO state changes via a pipe. + +.br +Upon success the command returns a handle greater than or equal to zero. +On error a negative status code will be returned. + +.br +Notifications for handle x will be available at the pipe named /dev/pigpiox +(where x is the handle number). + +.br +E.g. if the command returns 15 then the notifications must be read +from /dev/pigpio15. + +.br + +\fBExample\fP +.br + +.EX +$ pigs no +.br +0 +.br + +.EE + +.br + +.IP "\fBNP h\fP - Pause notification" +.IP "" 4 + +.br +This command pauses notifications on handle \fBh\fP returned by +a prior call to \fBNO\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +Notifications for the handle are suspended until a new \fBNB\fP command +is given for the handle. + +.br + +\fBExample\fP +.br + +.EX +$ pigs np 0 +.br + +.EE + +.br + +.IP "\fBP/PWM u v\fP - Set GPIO PWM value" +.IP "" 4 + +.br +This command starts PWM on GPIO \fBu\fP with dutycycle \fBv\fP. The dutycycle +varies from 0 (off) to range (fully on). The range defaults to 255. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +This and the servo functionality use the DMA and PWM or PCM peripherals +to control and schedule the pulsewidths and dutycycles. + +.br +The \fBPRS\fP command may be used to change the default range of 255. + +.br + +\fBExample\fP +.br + +.EX +$ pigs p 4 64 # Start PWM on GPIO 4 with 25% dutycycle +.br +$ pigs p 4 128 # 50% +.br +$ pigs p 4 192 # 75% +.br +$ pigs p 4 255 # 100% +.br + +.EE + +.br + +.IP "\fBPADG pad\fP - Get pad drive strength" +.IP "" 4 + +.br +This command gets the \fBpad\fP drive strength \fBpadma\fP in mA. + +.br +Returns the pad drive strength if OK. On error a negative status code +will be returned. + +.br + +.EX +Pad GPIO +0 0-27 +1 28-45 +2 46-53 + +.EE + +.br + +\fBExample\fP +.br + +.EX +$ pigs padg 0 +.br +8 +.br +$ pigs pads 0 16 +.br +$ pigs padg 0 +.br +16 +.br +pigs padg 3 +.br +-126 +.br +ERROR: bad pad number +.br + +.EE + +.br + +.IP "\fBPADS pad padma\fP - Set pad drive strength" +.IP "" 4 + +.br +This command sets the \fBpad\fP drive strength \fBpadma\fP in mA. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +.EX +Pad GPIO +0 0-27 +1 28-45 +2 46-53 + +.EE + +.br + +\fBExample\fP +.br + +.EX +$ pigs pads 0 16 +.br +$ pigs padg 0 +.br +16 +.br +$ pigs pads 0 17 +.br +-127 +.br +ERROR: bad pad drive strength +.br + +.EE + +.br + +.IP "\fBPARSE t\fP - Validate script" +.IP "" 4 + +.br +Validates the text \fBt\fP of a script without storing the script. + +.br +Upon success nothing is returned. On error a list of detected +script errors will be given. + +.br +See \fBScripts\fP. + +.br +This command may be used to find script syntax faults. + +.br + +\fBExample\fP +.br + +.EX +$ pigs parse tag 100 w 22 1 mils 200 w 22 0 mils 800 jmp 100 +.br + +.br +$ pigs parse tag 0 w 22 1 mills 50 w 22 0 dcr p10 jp 99 +.br +Unknown command: mills +.br +Unknown command: 50 +.br +Bad parameter to dcr +.br +Can't resolve tag 99 +.br + +.EE + +.br + +.IP "\fBPFG u\fP - Get GPIO PWM frequency" +.IP "" 4 + +.br +This command returns the PWM frequency in Hz used for GPIO \fBu\fP. + +.br +Upon success the PWM frequency is returned. On error a negative +status code will be returned. + +.br +For normal PWM the frequency will be that defined for the GPIO +by \fBPFS\fP. + +.br +If a hardware clock is active on the GPIO the reported frequency +will be that set by \fBHC\fP. + +.br +If hardware PWM is active on the GPIO the reported frequency +will be that set by \fBHP\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs pfg 4 +.br +800 +.br + +.br +$ pigs pfg 34 +.br +ERROR: GPIO not 0-31 +.br +-2 +.br + +.EE + +.br + +.IP "\fBPFS u v\fP - Set GPIO PWM frequency" +.IP "" 4 +This command sets the PWM frequency \fBv\fP to be used for GPIO \fBu\fP. + +.br +The numerically closest frequency to \fBv\fP will be selected. + +.br +Upon success the new frequency is returned. On error a negative status code +will be returned. + +.br +If PWM is currently active on the GPIO it will be +switched off and then back on at the new frequency. + +.br +Each GPIO can be independently set to one of 18 different PWM +frequencies. + +.br +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. + +.br +The frequencies for each sample rate are: + +.br + +.EX + Hertz +.br + +.br + 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600 +.br + 1250 1000 800 500 400 250 200 100 50 +.br + +.br + 2: 20000 10000 5000 4000 2500 2000 1250 1000 800 +.br + 625 500 400 250 200 125 100 50 25 +.br + +.br + 4: 10000 5000 2500 2000 1250 1000 625 500 400 +.br + 313 250 200 125 100 63 50 25 13 +.br +sample +.br + rate +.br + (us) 5: 8000 4000 2000 1600 1000 800 500 400 320 +.br + 250 200 160 100 80 50 40 20 10 +.br + +.br + 8: 5000 2500 1250 1000 625 500 313 250 200 +.br + 156 125 100 63 50 31 25 13 6 +.br + +.br + 10: 4000 2000 1000 800 500 400 250 200 160 +.br + 125 100 80 50 40 25 20 10 5 +.br + +.EE + +.br + +\fBExample\fP +.br + +.EX +pigs pfs 4 0 # 0 selects the lowest frequency. +.br +10 +.br + +.br +$ pigs pfs 4 1000 # Set 1000Hz PWM. +.br +1000 +.br + +.br +$ pigs pfs 4 100000 # Very big number selects the highest frequency. +.br +8000 +.br + +.EE + +.br + +.IP "\fBPIGPV \fP - Get pigpio library version" +.IP "" 4 + +.br +This command returns the pigpio library version. + +.br + +\fBExample\fP +.br + +.EX +$ pigs pigpv +.br +17 +.br + +.EE + +.br + +.IP "\fBPRG u\fP - Get GPIO PWM range" +.IP "" 4 + +.br +This command returns the dutycycle range for GPIO \fBu\fP. + +.br +Upon success the range is returned. On error a negative status code +will be returned. + +.br +If a hardware clock or hardware PWM is active on the GPIO the reported +range will be 1000000 (1M). + +.br + +\fBExample\fP +.br + +.EX +$ pigs prg 4 +.br +255 +.br + +.EE + +.br + +.IP "\fBPROC t\fP - Store script" +.IP "" 4 + +.br +This command stores a script \fBt\fP for later execution. + +.br +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. + +.br +See \fBScripts\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs proc tag 123 w 4 0 mils 200 w 4 1 mils 300 dcr p0 jp 123 +.br +0 +.br + +.br +$ pigs proc tag 123 w 4 0 mils 5 w 4 1 mils 5 jmp 12 +.br +ERROR: script has unresolved tag +.br +-63 +.br + +.EE + +.br + +.IP "\fBPROCD sid\fP - Delete script" +.IP "" 4 + +.br +This command deletes script \fBsid\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +See \fBScripts\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs procd 1 +.br + +.br +$ pigs procd 1 +.br +ERROR: unknown script id +.br +-48 +.br + +.EE + +.br + +.IP "\fBPROCP sid\fP - Get script status and parameters" +.IP "" 4 + +.br +This command returns the status of script \fBsid\fP as well as the +current value of its 10 parameters. + +.br +Upon success the script status and parameters are returned. +On error a negative status code will be returned. + +.br +The script status may be one of + +.br + +.EX +0 being initialised +1 halted +2 running +3 waiting +4 failed + +.EE + +.br +See \fBScripts\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs procp 0 +.br +1 0 0 0 0 0 0 0 0 0 0 +.br + +.EE + +.br + +.IP "\fBPROCR sid pars\fP - Run script" +.IP "" 4 + +.br +This command runs stored script \fBsid\fP passing it up to 10 optional +parameters. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +See \fBScripts\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs proc tag 123 w 4 0 mils 200 w 4 1 mils 300 dcr p0 jp 123 +.br +0 +.br + +.br +$ pigs procr 0 50 # Run script 0 with parameter 0 of 50. +.br + +.br +$ pigs procp 0 +.br +2 44 0 0 0 0 0 0 0 0 0 +.br +$ pigs procp 0 +.br +2 37 0 0 0 0 0 0 0 0 0 +.br +$ pigs procp 0 +.br +2 10 0 0 0 0 0 0 0 0 0 +.br +$ pigs procp 0 +.br +2 5 0 0 0 0 0 0 0 0 0 +.br +$ pigs procp 0 +.br +2 2 0 0 0 0 0 0 0 0 0 +.br +$ pigs procp 0 +.br +1 -1 0 0 0 0 0 0 0 0 0 +.br + +.EE + +.br + +.IP "\fBPROCS sid\fP - Stop script" +.IP "" 4 + +.br +This command stops a running script \fBsid\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +See \fBScripts\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs procs 0 +.br + +.br +$ pigs procs 1 +.br +-48 +.br +ERROR: unknown script id +.br + +.EE + +.br + +.IP "\fBPROCU sid pars\fP - Set script parameters" +.IP "" 4 + +.br +This command sets the parameters of a stored script \fBsid\fP passing +it up to 10 parameters. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +See \fBScripts\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs proc tag 0 hp 18 p0 p1 mils 1000 jmp 0 +.br +0 +.br +$ pigs procu 0 50 500000 +.br +$ pigs procr 0 +.br +$ pigs procu 0 100 +.br +$ pigs procu 0 200 +.br +$ pigs procu 0 200 100000 +.br + +.EE + +.br + +.IP "\fBPRRG u\fP - Get GPIO PWM real range" +.IP "" 4 + +.br +This command returns the real underlying range used by GPIO \fBu\fP. + +.br +If a hardware clock is active on the GPIO the reported +real range will be 1000000 (1M). + +.br +If hardware PWM is active on the GPIO the reported real range +will be approximately 250M divided by the set PWM frequency. + +.br +On error a negative status code will be returned. + +.br +See \fBPRS\fP. + +.br + +\fBExample\fP +.br + +.EX +$ pigs prrg 17 +.br +250 +.br + +.br +$ pigs pfs 17 0 +.br +10 +.br +$ pigs prrg 17 +.br +20000 +.br + +.br +$ pigs pfs 17 100000 +.br +8000 +.br +$ pigs prrg 17 +.br +25 +.br + +.EE + +.br + +.IP "\fBPRS u v\fP - Set GPIO PWM range" +.IP "" 4 + +.br +This command sets the dutycycle range \fBv\fP to be used for GPIO \fBu\fP. +Subsequent uses of command \fBP/PWM\fP will use a dutycycle between 0 (off) +and \fBv\fP (fully on). + +.br +Upon success the real underlying range used by the GPIO is returned. +On error a negative status code will be returned. + +.br +If PWM is currently active on the GPIO its dutycycle will be scaled to +reflect the new range. + +.br +The real range, the number of steps between fully off and fully on +for each frequency, is given in the following table. + +.br + +.EX + #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 + +.EE + +.br +The real value set by \fBPRS\fP is (dutycycle * real range) / range. + +.br +See \fBPRRG\fP + +.br + +\fBExample\fP +.br + +.EX +$ pigs prs 18 1000 +.br +250 +.br + +.EE + +.br + +.IP "\fBPUD g p\fP - Set GPIO pull up/down" +.IP "" 4 + +.br +This command sets the internal pull/up down for GPIO \fBg\fP to mode \fBp\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The mode may be pull-down (D), pull-up (U), or off (O). + +.br + +\fBExample\fP +.br + +.EX +$ pigs pud 4 d # Set pull-down on GPIO 4. +.br +$ pigs pud 4 u # Set pull-up on GPIO 4. +.br +$ pigs pud 4 o # No pull-up/down on GPIO 4. +.br + +.EE + +.br + +.IP "\fBR/READ g\fP - Read GPIO level" +.IP "" 4 + +.br +This reads the current level of GPIO \fBg\fP. + +.br +Upon success the current level is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs r 17 # Get level of GPIO 17. +.br +0 +.br + +.br +$ pigs r 4 # Get level of GPIO 4. +.br +1 +.br + +.EE + +.br + +.IP "\fBS/SERVO u v\fP - Set GPIO servo pulsewidth" +.IP "" 4 + +.br +This command starts servo pulses of \fBv\fP microseconds on GPIO \fBu\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The servo pulsewidth may be 0 (off), 500 (most anti-clockwise) +to 2500 (most clockwise). + +.br +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. + +.br +You can DAMAGE a servo if you command it to move beyond its limits. + +.br + +\fBExample\fP +.br + +.EX +$ pigs SERVO 17 1500 +.br + +.EE + +.br +This example causes an on pulse of 1500 microseconds duration to be +transmitted on GPIO 17 at a rate of 50 times per second. + +.br +This will command a servo connected to GPIO 17 to rotate to its mid-point. + +.br + +\fBExample\fP +.br + +.EX +pigs s 17 0 # Switch servo pulses off. +.br + +.EE + +.br + +.IP "\fBSERC h\fP - Close serial handle" +.IP "" 4 + +.br +This command closes a serial handle \fBh\fP previously opened with \fBSERO\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs serc 0 # First close okay. +.br + +.br +$ pigs serc 0 # Second close gives error. +.br +-25 +.br +ERROR: unknown handle +.br + +.EE + +.br + +.IP "\fBSERDA h\fP - Check for serial data ready to read" +.IP "" 4 + +.br +This command returns the number of bytes of data available +to be read from the serial device associated with handle \fBh\fP. + +.br +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. + +.br + +\fBExample\fP +.br + +.EX +$ pigs serda 0 +.br +0 +.br + +.EE + +.br + +.IP "\fBSERO dev b sef\fP - Open serial device dev at baud b with flags" +.IP "" 4 + +.br +This command opens the serial \fBdev\fP at \fBb\fP bits per second. + +.br +No flags are currently defined. \fBsef\fP should be set to zero. + +.br +Upon success a handle (>=0) is returned. On error a negative status code +will be returned. + +.br +The device name must start with /dev/tty or /dev/serial. + +.br + +.br +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. + +.br + +\fBExample\fP +.br + +.EX +$ pigs sero /dev/ttyAMA0 9600 0 +.br +0 +.br + +.br +$ pigs sero /dev/tty1 38400 0 +.br +1 +.br + +.EE + +.br + +.IP "\fBSERR h num\fP - Read bytes from serial handle" +.IP "" 4 + +.br +This command returns up to \fBnum\fP bytes of data read from the +serial device associated with handle \fBh\fP. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs serr 0 10 +.br +5 48 49 128 144 255 +.br + +.br +$ pigs serr 0 10 +.br +0 +.br + +.EE + +.br + +.IP "\fBSERRB \fP - Read byte from serial handle" +.IP "" 4 + +.br +This command returns a byte of data read from the serial +device associated with handle \fBh\fP. + +.br +Upon success a number between 0 and 255 is returned. +On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs serrb 0 +.br +23 +.br +$ pigs serrb 0 +.br +45 +.br + +.EE + +.br + +.IP "\fBSERW h bvs\fP - Write bytes to serial handle" +.IP "" 4 + +.br +This command writes bytes \fBbvs\fP to the serial device +associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs serw 0 23 45 67 89 +.br + +.EE + +.br + +.IP "\fBSERWB h bv\fP - Write byte to serial handle" +.IP "" 4 + +.br +This command writes a single byte \fBbv\fP to the serial device +associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs serwb 0 23 +.br +$ pigs serwb 0 0xf0 +.br + +.EE + +.br + +.IP "\fBSHELL name str\fP - Execute a shell command" +.IP "" 4 + +.br +This command uses the system call to execute a shell script \fBname\fP +with the given string \fBstr\fP as its parameter. + +.br +The exit status of the system call is returned if OK, otherwise +PI_BAD_SHELL_STATUS. + +.br +\fBname\fP must exist in /opt/pigpio/cgi and must be executable. + +.br +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. + +.br +The following table gives some example returned statuses. + +.br + +.EX +Script exit status Returned system call status +1 256 +5 1280 +10 2560 +200 51200 +script not found 32512 + +.EE + +.br + +\fBExample\fP +.br + +.EX +# pass two parameters, hello and world +.br +$ pigs shell scr1 hello world +.br +256 +.br + +.br +# pass three parameters, hello, string with spaces, and world +.br +$ pigs shell scr1 "hello 'string with spaces' world" +.br +256 +.br + +.br +# pass one parameter, hello string with spaces world +.br +$ pigs shell scr1 "\"hello string with spaces world\"" +.br +256 +.br + +.br +# non-existent script +.br +$ pigs shell scr78 par1 +.br +32512 +.br + +.EE + +.br + +.IP "\fBSLR u num\fP - Read bit bang serial data from GPIO" +.IP "" 4 + +.br +This command returns up to \fBnum\fP bytes of bit bang serial data +read from GPIO \fBu\fP. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br +The GPIO \fBu\fP should have been initialised with the \fBSLRO\fP command. + +.br +The bytes returned for each character depend upon the number of +data bits \fBdb\fP specified in the \fBSLRO\fP command. + +.br +For \fBdb\fP 1-8 there will be one byte per character. +.br +For \fBdb\fP 9-16 there will be two bytes per character. +.br +For \fBdb\fP 17-32 there will be four bytes per character. + +.br + +\fBExample\fP +.br + +.EX +$ pigs slr 15 20 +.br +6 1 0 23 45 89 0 +.br + +.EE + +.br + +.IP "\fBSLRC u\fP - Close GPIO for bit bang serial data" +.IP "" 4 + +.br +This command closes GPIO \fBu\fP for reading bit bang serial data. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs slrc 23 +.br + +.br +$ pigs slrc 23 +.br +-38 +.br +ERROR: no serial read in progress on GPIO +.br + +.EE + +.br + +.IP "\fBSLRI u v\fP - Sets bit bang serial data logic levels" +.IP "" 4 + +.br +This command sets the logic level for reading bit bang serial data +on GPIO \fBu\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The invert parameter \fBv\fP is 1 for inverted signal, 0 for normal. + +.br + +\fBExample\fP +.br + +.EX +$ pigs slri 17 1 # invert logic on GPIO 17 +.br + +.br +$ pigs slri 23 0 # use normal logic on GPIO 23 +.br + +.EE + +.br + +.IP "\fBSLRO u b db\fP - Open GPIO for bit bang serial data" +.IP "" 4 + +.br +This command opens GPIO \fBu\fP for reading bit bang serial data +at \fBb\fP baud and \fBdb\fP data bits. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The baud rate may be between 50 and 250000 bits per second. + +.br +The received data is held in a cyclic buffer. + +.br +It is the user's responsibility to read the data (with \fBSLR\fP) +in a timely fashion. + +.br + +\fBExample\fP +.br + +.EX +$ pigs slro 23 19200 8 +.br + +.br +$ pigs slro 23 19200 8 +.br +-50 +.br +ERROR: GPIO already in use +.br + +.EE + +.br + +.IP "\fBSPIC h\fP - SPI close handle" +.IP "" 4 + +.br +This command closes the SPI handle \fBh\fP returned by a prior +call to \fBSPIO\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs spic 1 +.br + +.br +$ pigs spic 1 +.br +-25 +.br +ERROR: unknown handle +.br + +.EE + +.br + +.IP "\fBSPIO c b spf\fP - SPI open channel at baud b with flags" +.IP "" 4 + +.br +This command returns a handle to a SPI device on channel \fBc\fP. + +.br +Data will be transferred at \fBb\fP bits per second. The flags \fBspf\fP +may be used to modify the default behaviour of 4-wire operation, +mode 0, active low chip select. + +.br +Speeds between 32kbps and 125Mbps are allowed. Speeds above 30Mbps +are unlikely to work. + +.br +The Pi has two SPI peripherals: main and auxiliary. + +.br +The main SPI has two chip selects (channels), the auxiliary has +three. + +.br +The auxiliary SPI is available on all models but the A and B. + +.br +The GPIO used are given in the following table. + +.br + +.EX + MISO MOSI SCLK CE0 CE1 CE2 +Main SPI 9 10 11 8 7 - +Aux SPI 19 20 21 18 17 16 + +.EE + +.br +The flags consists of the least significant 22 bits. + +.br + +.EX +21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 +.br + b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m +.br + +.EE + +.br +mm defines the SPI mode. + +.br +Warning: modes 1 and 3 do not appear to work on the auxiliary SPI. + +.br + +.EX +Mode POL PHA +.br + 0 0 0 +.br + 1 0 1 +.br + 2 1 0 +.br + 3 1 1 +.br + +.EE + +.br +px is 0 if CEx is active low (default) and 1 for active high. + +.br +ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise. + +.br +A is 0 for the main SPI, 1 for the auxiliary SPI. + +.br +W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Main +SPI only. + +.br +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. + +.br +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. + +.br +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. + +.br +bbbbbb defines the word size in bits (0-32). The default (0) +sets 8 bits per word. Auxiliary SPI only. + +.br +The \fBSPIR\fP, \fBSPIW\fP, and \fBSPIX\fP commands transfer data +packed into 1, 2, or 4 bytes according to the word size in bits. + +.br +For bits 1-8 there will be one byte per character. +.br +For bits 9-16 there will be two bytes per character. +.br +For bits 17-32 there will be four bytes per character. + +.br +Multi-byte transfers are made in least significant byte first order. + +.br +E.g. to transfer 32 11-bit words 64 bytes need to be sent. + +.br +E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed +by 0x1A. + +.br +The other bits in flags should be set to zero. + +.br +Upon success a handle (>=0) is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs spio 0 100000 3 # Open channel 0 at 100kbps in mode 3. +.br +0 +.br + +.br +$ pigs spio 0 32000 256 # Open channel 0 of auxiliary spi at 32kbps. +.br +1 +.br + +.EE + +.br + +.IP "\fBSPIR h num\fP - SPI read bytes from handle" +.IP "" 4 + +.br +This command returns \fBnum\fP bytes read from the SPI device +associated with handle \fBh\fP. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs spir 0 10 # Read 10 bytes from the SPI device. +.br +10 0 0 0 0 0 0 0 0 0 0 +.br + +.EE + +.br + +.IP "\fBSPIW h bvs\fP - SPI write bytes to handle" +.IP "" 4 + +.br +This command writes bytes \fBbvs\fP to the SPI device +associated with handle \fBh\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs spiw 0 0x22 0x33 0xcc 0xff +.br + +.EE + +.br + +.IP "\fBSPIX h bvs\fP - SPI transfer bytes to handle" +.IP "" 4 + +.br +This command writes bytes \fBbvs\fP to the SPI device +associated with handle \fBh\fP. It returns the same +number of bytes read from the device. + +.br +Upon success the count of returned bytes followed by the bytes themselves +is returned. On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs spix 0 0x22 0x33 0xcc 0xff +.br +4 0 0 0 0 +.br + +.EE + +.br + +.IP "\fBT/TICK \fP - Get current tick" +.IP "" 4 + +.br +This command returns the current system tick. + +.br +Tick is the number of microseconds since system boot. + +.br +As tick is an unsigned 32 bit quantity it wraps around after 2^32 microseconds, +which is approximately 1 hour 12 minutes. + +.br + +\fBExample\fP +.br + +.EX +$ pigs t mils 1000 t +.br +3691823946 +.br +3692833987 +.br + +.EE + +.br + +.IP "\fBTRIG u pl L\fP - Send a trigger pulse" +.IP "" 4 + +.br +This command sends a trigger pulse of \fBpl\fP microseconds at level \fBL\fP +to GPIO \fBu\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The GPIO is set to not level at the end of the pulse. + +.br + +\fBExample\fP +.br + +.EX +$ pigs trig 4 10 1 +.br + +.br +$ pigs trig 4 51 1 +.br +-46 +.br +ERROR: trigger pulse > 50 microseconds +.br + +.EE + +.br + +.IP "\fBW/WRITE g L\fP - Write GPIO level" +.IP "" 4 + +.br +This command sets GPIO \fBg\fP to level \fBL\fP. The level may be 0 +(low, off, clear) or 1 (high, on, set). + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs w 23 0 +.br +$ pigs w 23 1 +.br + +.br +$ pigs w 23 2 +.br +-5 +.br +ERROR: level not 0-1 +.br + +.EE + +.br + +.IP "\fBWDOG u v\fP - Set GPIO watchdog" +.IP "" 4 + +.br +This command sets a watchdog of \fBv\fP milliseconds on GPIO \fBu\fP. + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br +The watchdog is nominally in milliseconds. + +.br +One watchdog may be registered per GPIO. + +.br +The watchdog may be cancelled by setting timeout to 0. + +.br +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. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wdog 23 90000 +.br +-15 +.br +ERROR: timeout not 0-60000 +.br + +.br +$ pigs wdog 23 9000 +.br + +.EE + +.br +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. + +.br + +.IP "\fBWVAG trips\fP - Add generic pulses to waveform" +.IP "" 4 + +.br +This command adds 1 one or more triplets \fBtrips\fP of GPIO on, GPIO off, +delay to the existing waveform (if any). + +.br +Upon success the total number of pulses in the waveform so far is +returned. On error a negative status code will be returned. + +.br +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. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvag 0x10 0x80 1000 0x80 0x10 9000 +.br +2 +.br + +.br +$ pigs wvag 0 0 10000 0x10 0x80 1000 0x80 0x10 9000 +.br +4 +.br + +.EE + +.br + +.IP "\fBWVAS u b db sb o bvs\fP - Add serial data to waveform" +.IP "" 4 + +.br +This command adds a waveform representing serial data \fBbvs\fP to +GPIO \fBu\fP at \fBb\fP baud to the existing waveform (if any). +The serial data starts \fBo\fP microseconds from the start of the +waveform. + +.br +Upon success the total number of pulses in the waveform so far is +returned. On error a negative status code will be returned. + +.br +The serial data is formatted as one start bit, \fBdb\fP data bits, and +\fBsb\fP/2 stop bits. + +.br +The baud rate may be between 50 and 1000000 bits per second. + +.br +It is legal to add serial data streams with different baud rates to +the same waveform. + +.br +The bytes required for each character depend upon \fBdb\fP. + +.br +For \fBdb\fP 1-8 there will be one byte per character. +.br +For \fBdb\fP 9-16 there will be two bytes per character. +.br +For \fBdb\fP 17-32 there will be four bytes per character. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvas 4 9600 8 2 0 0x30 0x31 0x32 0x33 +.br +23 +.br + +.br +$ pigs wvas 7 38400 8 2 0 0x41 0x42 +.br +35 +.br + +.EE + +.br + +.IP "\fBWVTAT \fP - Returns the current transmitting waveform" +.IP "" 4 + +.br +This command returns the id of the waveform currently +being transmitted. Chained waves are not supported. + +.br +Returns the waveform id or one of the following special +values: + +.br +9998 - transmitted wave not found +.br +9999 - no wave being transmitted + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvtat +.br +9999 +.br + +.EE + +.br + +.IP "\fBWVBSY \fP - Check if waveform is being transmitted" +.IP "" 4 + +.br +This command checks to see if a waveform is currently being transmitted. + +.br +Returns 1 if a waveform is currently being transmitted, otherwise 0. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvbsy +.br +0 +.br + +.EE + +.br + +.IP "\fBWVCHA bvs\fP - Transmits a chain of waveforms" +.IP "" 4 + +.br +This command transmits a chain of waveforms. + +.br +NOTE: Any hardware PWM started by \fBHP\fP will +be cancelled. + +.br +The waves to be transmitted are specified by the contents of +\fBbvs\fP which contains an ordered list of wave_ids and optional +command codes and related data. + +.br +Upon success 0 is returned. On error a negative status code +will be returned. + +.br +Each wave is transmitted in the order specified. A wave may +occur multiple times per chain. + +.br +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. + +.br +Delays between waves may be added with the delay command. + +.br +The following command codes are supported: + +.br + +.EX +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 + +.EE + +.br +If present Loop Forever must be the last entry in the chain. + +.br +The code is currently dimensioned to support a chain with roughly +600 entries and 20 loop counters. + +.br + +\fBExample\fP +.br + +.EX +#!/bin/bash +.br + +.br +GPIO=4 +.br +WAVES=5 +.br + +.br +pigs m $GPIO w +.br + +.br +for ((i=0; i<$WAVES; i++)) +.br +do +.br + pigs wvag $((1<=0) is returned. On error a negative status +code will be returned. + +.br +The data provided by the \fBWVAG\fP and \fBWVAS\fP commands is +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. \fBWVCRE\fP to create the waveform and get a unique id. + +.br +Repeat steps 2 and 3 as needed. + +.br +Step 4. \fBWVTX\fP or \fBWVTXR\fP with the id of the waveform to transmit. + +.br +A waveform comprises of one or more pulses. + +.br +A pulse specifies + +.br +1) the GPIO to be switched on at the start of the pulse. +.br +2) the GPIO to be switched off at the start of the pulse. +.br +3) the delay in microseconds before the next pulse. + +.br +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). + +.br +When a waveform is started each pulse is executed in order with +the specified delay between the pulse and the next. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvas 4 9600 0 23 45 67 89 90 +.br +37 +.br +$ pigs wvcre +.br +0 +.br + +.br +$ pigs wvcre +.br +-69 +.br +ERROR: attempt to create an empty waveform +.br + +.EE + +.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 + +.br +This command deletes the waveform with id \fBwid\fP. + +.br +The wave is flagged for deletion. The resources used by the wave +will only be reused when either of the following apply. + +.br +- all waves with higher numbered wave ids have been deleted or have +been flagged for deletion. + +.br +- a new wave is created which uses exactly the same resources as +the current wave (see the C source for gpioWaveCreate for details). + +.br +Upon success nothing is returned. On error a negative status code +will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvdel 0 +.br + +.br +$ pigs wvdel 0 +.br +-66 +.br +ERROR: non existent wave id +.br + +.EE + +.br + +.IP "\fBWVHLT \fP - Stop waveform" +.IP "" 4 + +.br +This command aborts the transmission of the current waveform. + +.br +Nothing is returned. + +.br +This command is intended to stop a waveform started in the repeat mode. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvhlt +.br + +.EE + +.br + +.IP "\fBWVNEW \fP - Initialise a new waveform" +.IP "" 4 + +.br +This clears any existing waveform data ready for the creation of a new +waveform. + +.br +Nothing is returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvnew +.br + +.EE + +.br + +.IP "\fBWVSC ws\fP - Get waveform DMA CB stats" +.IP "" 4 + +.br +The statistic requested by \fBws\fP is returned. + +.br +\fBws\fP identifies the subcommand as follows. + +.br +0 Get Cbs +.br +1 Get High Cbs +.br +2 Get Max Cbs + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvas 4 9600 0 23 45 67 89 90 +.br +37 +.br + +.br +$ pigs wvsc 0 +.br +74 +.br +$ pigs wvsc 1 +.br +74 +.br +$ pigs wvsc 2 +.br +25016 +.br + +.EE + +.br + +.IP "\fBWVSM ws\fP - Get waveform time stats" +.IP "" 4 + +.br +The statistic requested by \fBws\fP is returned. + +.br +\fBws\fP identifies the subcommand as follows. + +.br +0 Get Micros +.br +1 Get High Micros +.br +2 Get Max Micros + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvsm 0 +.br +5314 +.br +$ pigs wvsm 1 +.br +5314 +.br +$ pigs wvsm 2 +.br +1800000000 +.br + +.EE + +.br + +.IP "\fBWVSP ws\fP - Get waveform pulse stats" +.IP "" 4 + +.br +The statistic requested by \fBws\fP is returned. + +.br +\fBws\fP identifies the subcommand as follows. + +.br +0 Get Pulses +.br +1 Get High Pulses +.br +2 Get Max Pulses + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvsp 0 +.br +37 +.br +$ pigs wvsp 1 +.br +37 +.br +$ pigs wvsp 2 +.br +12000 +.br + +.EE + +.br + +.IP "\fBWVTX wid\fP - Transmits waveform once" +.IP "" 4 + +.br +This command transmits the waveform with id \fBwid\fP once. + +.br +NOTE: Any hardware PWM started by \fBHP\fP will be cancelled. + +.br +Upon success the number of DMA control blocks in the waveform is returned. +On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvtx 1 +.br +75 +.br + +.br +$ pigs wvtx 2 +.br +-66 +.br +ERROR: non existent wave id +.br + +.EE + +.br + +.IP "\fBWVTXM wid wmde\fP - Transmits waveform using mode" +.IP "" 4 + +.br +This command transmits the waveform with id \fBwid\fP using mode \fBwmde\fP. + +.br +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). + +.br +WARNING: bad things may happen if you delete the previous +waveform before it has been synced to the new waveform. + +.br +NOTE: Any hardware PWM started by \fBHP\fP will be cancelled. + +.br +Upon success the number of DMA control blocks in the waveform is returned. +On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvtxm 1 3 +.br +75 +.br + +.br +$ pigs wvtxm 2 0 +.br +-66 +.br +ERROR: non existent wave id +.br + +.EE + +.br + +.IP "\fBWVTXR wid\fP - Transmits waveform repeatedly" +.IP "" 4 + +.br +This command transmits the waveform with id \fBwid\fP repeatedly. + +.br +NOTE: Any hardware PWM started by \fBHP\fP will be cancelled. + +.br +Upon success the number of DMA control blocks in the waveform is returned. +On error a negative status code will be returned. + +.br + +\fBExample\fP +.br + +.EX +$ pigs wvtxr 1 +.br +75 +.br + +.br +$ pigs wvtxr 2 +.br +-66 +.br +ERROR: non existent wave id +.br + +.EE + +.br + +.SH PARAMETERS + +.br + +.IP "\fBactv\fP - 0-1000000" 0 + +.br +The number of microseconds level changes are reported for once +a noise filter has been triggered (by \fBstdy\fP microseconds of +a stable level). + +.br + +.IP "\fBb\fP - baud" 0 +The command expects the baud rate in bits per second for +the transmission of serial data (I2C/SPI/serial link, waves). + +.br + +.IP "\fBbctl\fP - BSC control word" 0 +The command expects a BSC control word, see \fBBSCX\fP. + +.br + +.IP "\fBbit\fP - bit value (0-1)" 0 +The command expects 0 or 1. + +.br + +.IP "\fBbits\fP - a bit mask" 0 +A mask is used to select one or more GPIO. A GPIO is selected +if bit (1<=0)" 0 +The command expects a handle. + +.br +A handle is a number referencing an object opened by one of \fBFO\fP, +\fBI2CO\fP, \fBNO\fP, \fBSERO\fP, \fBSPIO\fP. + +.br + +.IP "\fBib\fP - I2C bus (>=0)" 0 +The command expects an I2C bus number. + +.br + +.IP "\fBid\fP - I2C device (0-0x7F)" 0 +The command expects the address of an I2C device. + +.br + +.IP "\fBif\fP - I2C flags (0)" 0 +The command expects an I2C flags value. No flags are currently defined. + +.br + +.IP "\fBL\fP - level (0-1)" 0 +The command expects a GPIO level. + +.br + +.IP "\fBm\fP - mode (RW540123)" 0 +The command expects a mode character. + +.br +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. + +.br +To set the mode use the code for the mode. + +.br +The value is returned by the mode get command. + +.br + +.EX +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 + +.EE + +.br + +.IP "\fBmiso\fP - GPIO (0-31)" 0 +The GPIO used for the MISO signal when bit banging SPI. + +.br + +.IP "\fBmode\fP - file open mode" 0 +One of the following values. + +.br + +.EX + Value Meaning +READ 1 open file for reading +WRITE 2 open file for writing +RW 3 open file for reading and writing + +.EE + +.br +The following values can be or'd into the mode. + +.br + +.EX + 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 + +.EE + +.br + +.IP "\fBmosi\fP - GPIO (0-31)" 0 +The GPIO used for the MOSI signal when bit banging SPI. + +.br + +.IP "\fBname\fP - the name of a script" 0 +Only alphanumeric characters, '-' and '_' are allowed in the name. + +.br + +.IP "\fBnum\fP - maximum number of bytes to return (1-)" 0 +The command expects the maximum number of bytes to return. + +.br +For the I2C and SPI commands the requested number of bytes will always +be returned. + +.br +For the serial and file commands the smaller of the number of +bytes available to be read (which may be zero) and \fBnum\fP bytes +will be returned. + +.br + +.IP "\fBo\fP - offset (>=0)" 0 +Serial data is stored offset microseconds from the start of the waveform. + +.br + +.IP "\fBp\fP - PUD (ODU)" 0 +The command expects a PUD character. + +.br +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. + +.br +A pull up will default the input to 1 (high). + +.br +A pull down will default the input to 0 (low). + +.br +To set the pull up down state use the command character for the state. + +.br + +.EX +Pull Up Down Off Pull Down Pull Up +Command Character O D U + +.EE + +.br +There is no mechanism to read the pull up down state. + +.br + +.IP "\fBpad\fP - 0-2" 0 +A set of GPIO which share common drivers. + +.br + +.EX +Pad GPIO +0 0-27 +1 28-45 +2 46-53 + +.EE + +.br + +.IP "\fBpadma\fP - 1-16" 0 +The mA which may be drawn from each GPIO whilst still guaranteeing the +high and low levels. + +.br + +.IP "\fBpars\fP - script parameters" 0 +The command expects 0 to 10 numbers as parameters to be passed to the script. + +.br + +.IP "\fBpat\fP - a file name pattern" 0 +A file path which may contain wildcards. To be accessible the path +must match an entry in /opt/pigpio/access. + +.br + +.IP "\fBpdc\fP - hardware PWM dutycycle (0-1000000)" 0 +The command expects a dutycycle. + +.br + +.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 + +.IP "\fBpl\fP - pulse length (1-100)" 0 +The command expects a pulse length in microseconds. + +.br + +.IP "\fBr\fP - register (0-255)" 0 +The command expects an I2C register number. + +.br + +.IP "\fBsb\fP - serial stop (half) bits (2-8)" 0 +The command expects the number of stop (half) bits per serial character. + +.br + +.IP "\fBscl\fP - user GPIO (0-31)" 0 +The command expects the number of the GPIO to be used for SCL +when bit banging I2C. + +.br + +.IP "\fBsclk\fP - user GPIO (0-31)" 0 +The GPIO used for the SCLK signal when bit banging SPI. + +.br + +.IP "\fBsda\fP - user GPIO (0-31)" 0 +The command expects the number of the GPIO to be used for SDA +when bit banging I2C. + +.br + +.IP "\fBsef\fP - serial flags (32 bits)" 0 +The command expects a flag value. No serial flags are currently defined. + +.br + +.IP "\fBsid\fP - script id (>= 0)" 0 +The command expects a script id as returned by a call to \fBPROC\fP. + +.br + +.IP "\fBspf\fP - SPI flags (32 bits)" 0 +See \fBSPIO\fP and \fBBSPIO\fP. + +.br + +.IP "\fBstdy\fP - 0-300000" 0 + +.br +The number of microseconds level changes must be stable for +before reporting the level changed (\fBFG\fP) or triggering +the active part of a noise filter (\fBFN\fP). + +.br + +.IP "\fBstr\fP - a string" 0 +The command expects a string. + +.br + +.IP "\fBt\fP - a string" 0 +The command expects a string. + +.br + +.IP "\fBtrips\fP - triplets" 0 +The command expects 1 or more triplets of GPIO on, GPIO off, delay. + +.br +E.g. 0x400000 0 100000 0 0x400000 900000 defines two pulses as follows + +.br + +.EX + GPIO on GPIO off delay +0x400000 (GPIO 22) 0 (None) 100000 (1/10th s) + 0 (None) 0x400000 (GPIO 22) 900000 (9/10th s) + +.EE + +.br + +.IP "\fBu\fP - user GPIO (0-31)" 0 +The command expects the number of a user GPIO. + +.br +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. + +.br +It is your responsibility to ensure that the PWM and servo commands +are only used on safe GPIO. + +.br +See \fBg\fP + +.br + +.IP "\fBuvs\fP - values" 0 +The command expects an arbitrary number of >=0 values (possibly none). +Any after the first two must be <= 255. + +.br + +.IP "\fBv\fP - value" 0 +The command expects a number. + +.br + +.IP "\fBwid\fP - wave id (>=0)" 0 +The command expects a wave id. + +.br +When a waveform is created it is given an id (0, 1, 2, ...). + +.br + +.IP "\fBwmde\fP - mode (0-3)" 0 +The command expects a wave transmission mode. + +.br +0 = send once +.br +1 = send repeatedly +.br +2 = send once but first sync with previous wave +.br +3 = send repeatedly but first sync with previous wave +.br + +.br + +.IP "\fBws\fP - wave stats sucommand (0-2)" 0 +The command expects a subcommand. + +.br +0 = current value. +.br +1 = highest value so far. +.br +2 = maximum possible value. + +.br + +.IP "\fBwv\fP - word value (0-65535)" 0 +The command expects a word value. + +.br + +.SH SCRIPTS + +.br +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. + +.br +.SS Example +.br +A trivial example might be useful. Suppose you want to toggle a GPIO +on and off as fast as possible. + +.br +From the command line you could write + +.br + +.EX +for ((i=0; i<1000;i++)); do pigs w 22 1 w 22 0; done +.br + +.EE + +.br +Timing that you will see it takes about 14 seconds, or roughly +70 toggles per second. + +.br +Using the pigpio Python module you could use code such as + +.br + +.EX +#!/usr/bin/env python +.br + +.br +import time +.br + +.br +import pigpio +.br + +.br +PIN=4 +.br + +.br +TOGGLE=10000 +.br + +.br +pi = pigpio.pi() # Connect to local Pi. +.br + +.br +s = time.time() +.br + +.br +for i in range(TOGGLE): +.br + pi.write(PIN, 1) +.br + pi.write(PIN, 0) +.br + +.br +e = time.time() +.br + +.br +print("pigpio did {} toggles per second".format(int(TOGGLE/(e-s)))) +.br + +.br +pi.stop() +.br + +.EE + +.br +Timing that shows a speed improvement to roughly 800 toggles per second. + +.br +Now let's use a script. + +.br + +.EX +pigs proc tag 999 w 22 1 w 22 0 dcr p0 jp 999 +.br + +.EE + +.br +Ignore the details for now. + +.br +Let's time the script running. + +.br +Again, ignore the details for now. + +.br + +.EX +time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\ +.br + do sleep 0.2; done) +.br + +.EE + +.br +The script takes roughly 12 seconds to complete, or 800,000 toggles per second. + +.br +That is the advantage of a stored script. + +.br +Some details. + +.br + +.EX +pigs proc tag 999 w 22 1 w 22 0 dcr p0 jp 999 +.br + +.EE + +.br +proc introduces a script. Everything after proc is part of the script. +.br +tag 999 names the current position in the script. +.br +w 22 1 writes 1 to GPIO 22. +.br +w 22 0 writes 0 to GPIO 22. +.br +dcr p0 decrements parameter 0. +.br +jp 999 jumps to tag 999 if the result is positive. + +.br + +.EX +time (pigs procr 0 10000000; while a=$(pigs procp 0); [[ ${a::1} -eq 2 ]];\ +.br + do sleep 0.2; done) +.br + +.EE + +.br +pigs procr 0 10000000 starts script 0 with parameter 0 of 10 million. + +.br +The rest is bash apart from + +.br +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. + +.br +.SS Virtual machine +.br +A script runs within a virtual machine with + +.br +a 32 bit accumulator A. +.br +a flags register F. +.br +a program counter PC. + +.br +Each script has + +.br +10 parameters named 0 through 9. +.br +150 variables named 0 through 149. +.br +50 labels which are named by any unique number. + +.br +.SS Commands +.br +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 permitted within a script: + +.br + +.EX +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 + +.EE + +.br +x may be a constant, a parameter (p0-p9), or a variable (v0-v149). + +.br +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. + +.br +The EVTWT command parameter is a bit-mask with 1 set for events of interest. + +.br +The WAIT command parameter is a bit-mask with 1 set for GPIO of interest. + +.br +The SYS script receives two unsigned parameters: the accumulator A and +the current GPIO levels. + +.br + +.SH SEE ALSO + +pigpiod(1), pig2vcd(1), pigpio(3), pigpiod_if(3), pigpiod_if2(3) +.SH AUTHOR + +joan@abyz.me.uk diff --git a/pigs.c b/pigs.c new file mode 100644 index 0000000..928afa3 --- /dev/null +++ b/pigs.c @@ -0,0 +1,394 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +/* +This version is for pigpio version 69+ +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pigpio.h" +#include "command.h" +#include "pigs.h" + +/* +This program provides a socket interface to some of +the commands available from pigpio. +*/ + +char command_buf[CMD_MAX_EXTENSION]; +char response_buf[CMD_MAX_EXTENSION]; + +int printFlags = 0; + +int status = PIGS_OK; + +#define SOCKET_OPEN_FAILED -1 + +#define PRINT_HEX 1 +#define PRINT_ASCII 2 + +void report(int err, char *fmt, ...) +{ + char buf[128]; + va_list ap; + + if (err > status) status = err; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + fprintf(stderr, "%s\n", buf); + + fflush(stderr); +} + +static int initOpts(int argc, char *argv[]) +{ + int opt, args; + + opterr = 0; + + args = 1; + + while ((opt = getopt(argc, argv, "ax")) != -1) + { + switch (opt) + { + case 'a': + printFlags |= PRINT_ASCII; + args++; + break; + + case 'x': + printFlags |= PRINT_HEX; + args++; + break; + + default: + args++; + report(PIGS_OPTION_ERR, "ERROR: bad option %c", optopt); + } + } + return args; +} + +static int openSocket(void) +{ + int sock, err; + struct addrinfo hints, *res, *rp; + const char *addrStr, *portStr; + + portStr = getenv(PI_ENVPORT); + + if (!portStr) portStr = PI_DEFAULT_SOCKET_PORT_STR; + + addrStr = getenv(PI_ENVADDR); + + if (!addrStr) addrStr = PI_DEFAULT_SOCKET_ADDR_STR; + + memset (&hints, 0, sizeof (hints)); + + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags |= AI_CANONNAME; + + err = getaddrinfo(addrStr, portStr, &hints, &res); + + if (err) return SOCKET_OPEN_FAILED; + + for (rp=res; rp!=NULL; rp=rp->ai_next) + { + sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); + + if (sock == -1) continue; + + if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) break; + } + + freeaddrinfo(res); + + if (rp == NULL) return SOCKET_OPEN_FAILED; + + return sock; +} + +void print_result(int sock, int rv, cmdCmd_t cmd) +{ + int i, r, ch; + uint32_t *p; + + r = cmd.res; + + switch (rv) + { + case 0: + case 1: + if (r < 0) + { + printf("%d\n", r); + report(PIGS_SCRIPT_ERR, "ERROR: %s", cmdErrStr(r)); + } + break; + + case 2: + printf("%d\n", r); + if (r < 0) report(PIGS_SCRIPT_ERR, "ERROR: %s", cmdErrStr(r)); + break; + + case 3: + printf("%08X\n", cmd.res); + break; + + case 4: + printf("%u\n", cmd.res); + break; + + case 5: + printf("%s", cmdUsage); + break; + + case 6: /* + BI2CZ CF2 FL FR I2CPK I2CRD I2CRI I2CRK + I2CZ SERR SLR SPIX SPIR + */ + printf("%d", r); + if (r < 0) report(PIGS_SCRIPT_ERR, "ERROR: %s", cmdErrStr(r)); + if (r > 0) + { + if (printFlags == PRINT_ASCII) printf(" "); + + for (i=0; i 4) + { + if (printFlags == PRINT_ASCII) printf(" "); + + for (i=4; i 0) + { + recv(sock, response_buf, res, MSG_WAITALL); + response_buf[res] = 0; + } + break; + } +} + +int main(int argc , char *argv[]) +{ + int sock, command; + int args, idx, i, pp, l, len; + cmdCmd_t cmd; + uintptr_t p[CMD_P_ARR]; + cmdCtlParse_t ctl; + cmdScript_t s; + char v[CMD_MAX_EXTENSION]; + + sock = openSocket(); + + args = initOpts(argc, argv); + + command_buf[0] = 0; + l = 0; + pp = 0; + + for (i=args; i= 0) && (ctl.eaten < len)) + { + if ((idx=cmdParse(command_buf, p, CMD_MAX_EXTENSION, v, &ctl)) >= 0) + { + command = p[0]; + + if (command < PI_CMD_SCRIPT) + { + if (command == PI_CMD_HELP) + { + printf("%s", cmdUsage); + } + else if (command == PI_CMD_PARSE) + { + cmdParseScript(v, &s, 1); + if (s.par) free (s.par); + } + else + { + cmd.cmd = command; + cmd.p1 = p[1]; + cmd.p2 = p[2]; + cmd.p3 = p[3]; + + if (sock != SOCKET_OPEN_FAILED) + { + if (send(sock, &cmd, sizeof(cmdCmd_t), 0) == + sizeof(cmdCmd_t)) + { + if (p[3]) send(sock, v, p[3], 0); /* send extensions */ + + if (recv(sock, &cmd, sizeof(cmdCmd_t), MSG_WAITALL) == + sizeof(cmdCmd_t)) + { + get_extensions(sock, command, cmd.res); + + print_result(sock, cmdInfo[idx].rv, cmd); + } + else report(PIGS_CONNECT_ERR, "socket receive failed"); + } + else report(PIGS_CONNECT_ERR, "socket send failed"); + } + else report(PIGS_CONNECT_ERR, "socket connect failed"); + } + } + else report(PIGS_SCRIPT_ERR, + "%s only allowed within a script", cmdInfo[idx].name); + } + else + { + if (idx == CMD_UNKNOWN_CMD) + report(PIGS_SCRIPT_ERR, + "%s? unknown command, pigs h for help", cmdStr()); + else + report(PIGS_SCRIPT_ERR, + "%s: bad parameter, pigs h for help", cmdStr()); + } + } + + if (sock >= 0) close(sock); + + return status; +} + diff --git a/pigs.h b/pigs.h new file mode 100644 index 0000000..16cfcdd --- /dev/null +++ b/pigs.h @@ -0,0 +1,41 @@ +/* +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +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. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to +*/ + +/* +This version is for pigpio version 67+ +*/ + +#ifndef PIGS_H +#define PIGS_H + +#define PIGS_OK 0 +#define PIGS_CONNECT_ERR 255 +#define PIGS_OPTION_ERR 254 +#define PIGS_SCRIPT_ERR 253 + +#endif + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4dbb8a9 --- /dev/null +++ b/setup.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +from distutils.core import setup + +setup(name='pigpio', + version='1.78', + 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", + ] + ) + diff --git a/util/Findpigpio.cmake b/util/Findpigpio.cmake new file mode 100644 index 0000000..eebfbfe --- /dev/null +++ b/util/Findpigpio.cmake @@ -0,0 +1,31 @@ +################################################################################ +### Find the pigpio shared libraries. +################################################################################ + +# Find the path to the pigpio includes. +find_path(pigpio_INCLUDE_DIR + NAMES pigpio.h pigpiod_if.h pigpiod_if2.h + HINTS /usr/local/include) + +# Find the pigpio libraries. +find_library(pigpio_LIBRARY + NAMES libpigpio.so + HINTS /usr/local/lib) +find_library(pigpiod_if_LIBRARY + NAMES libpigpiod_if.so + HINTS /usr/local/lib) +find_library(pigpiod_if2_LIBRARY + NAMES libpigpiod_if2.so + HINTS /usr/local/lib) + +# Set the pigpio variables to plural form to make them accessible for +# the paramount cmake modules. +set(pigpio_INCLUDE_DIRS ${pigpio_INCLUDE_DIR}) +set(pigpio_INCLUDES ${pigpio_INCLUDE_DIR}) + +# Handle REQUIRED, QUIET, and version arguments +# and set the _FOUND variable. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(pigpio + DEFAULT_MSG + pigpio_INCLUDE_DIR pigpio_LIBRARY pigpiod_if_LIBRARY pigpiod_if2_LIBRARY) diff --git a/util/pigpiod.service b/util/pigpiod.service new file mode 100644 index 0000000..f040d38 --- /dev/null +++ b/util/pigpiod.service @@ -0,0 +1,10 @@ +[Unit] +Description=Pigpio daemon + +[Service] +Type=forking +PIDFile=pigpio.pid +ExecStart=/usr/bin/pigpiod + +[Install] +WantedBy=multi-user.target diff --git a/util/readme.md b/util/readme.md new file mode 100644 index 0000000..27c4c3d --- /dev/null +++ b/util/readme.md @@ -0,0 +1,31 @@ +This folder provides utility files for the pigpio library. + +### pigpiod + +`pigpiod` is a script that allows to run pigpiod as a Linux service with root privileges. +The advantage of running pigpiod as a service is that pigpiod can be automatically launched on system startup. +To automatically start pigpiod as a service, do the following: + ++ Copy `pigpiod` from this directory to `/etc/init.d/`. + ++ Make it executable: + ``` + sudo chmod +x /etc/init.d/pigpiod + ``` + ++ Tell update-rc.d to automatically start the pigpiod service on system startup: + ``` + sudo update-rc.d pigpiod defaults + ``` + ++ Now, you can start, stop, and restart pigpiod using + ``` + sudo service pigpiod start + sudo service pigpiod stop + sudo service pigpiod restart + ``` + + +### Findpigpio.cmake + +`Findpigpio.cmake` is a script used by CMake to find out where the pigpio header and library files are located. diff --git a/x_pigpio.c b/x_pigpio.c new file mode 100644 index 0000000..8119d73 --- /dev/null +++ b/x_pigpio.c @@ -0,0 +1,952 @@ +/* +gcc -Wall -pthread -o x_pigpio x_pigpio.c -lpigpio +sudo ./x_pigpio + +*** WARNING ************************************************ +* * +* All the tests make extensive use of gpio 25 (pin 22). * +* Ensure that either nothing or just a LED is connected to * +* gpio 25 before running any of the tests. * +* * +* Some tests are statistical in nature and so may on * +* occasion fail. Repeated failures on the same test or * +* many failures in a group of tests indicate a problem. * +************************************************************ +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pigpio.h" + +#define USERDATA 18249013 + +#define GPIO 25 + +void CHECK(int t, int st, int got, int expect, int pc, char *desc) +{ + if ((got >= (((1E2-pc)*expect)/1E2)) && (got <= (((1E2+pc)*expect)/1E2))) + { + printf("TEST %2d.%-2d PASS (%s: %d)\n", t, st, desc, expect); + } + else + { + fprintf(stderr, + "TEST %2d.%-2d FAILED got %d (%s: %d)\n", + t, st, got, desc, expect); + } +} + +void t0() +{ + printf("\nTesting pigpio C I/F\n"); + + printf("pigpio version %d.\n", gpioVersion()); + + printf("Hardware revision %d.\n", gpioHardwareRevision()); +} + +void t1() +{ + int v; + + printf("Mode/PUD/read/write tests.\n"); + + gpioSetMode(GPIO, PI_INPUT); + v = gpioGetMode(GPIO); + 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"); + + gpioWrite(GPIO, PI_LOW); + v = gpioGetMode(GPIO); + CHECK(1, 4, v, 1, 0, "write, get mode"); + + v = gpioRead(GPIO); + CHECK(1, 5, v, 0, 0, "read"); + + gpioWrite(GPIO, PI_HIGH); + gpioDelay(1); /* 1 micro delay to let GPIO reach level reliably */ + v = gpioRead(GPIO); + CHECK(1, 6, v, 1, 0, "write, read"); +} + +int t2_count; + +void t2cb(int gpio, int level, uint32_t tick) +{ + t2_count++; +} + +void t2() +{ + int dc, f, r, rr, oc; + + printf("PWM dutycycle/range/frequency tests.\n"); + + gpioSetPWMrange(GPIO, 255); + gpioSetPWMfrequency(GPIO, 0); + f = gpioGetPWMfrequency(GPIO); + CHECK(2, 1, f, 10, 0, "set PWM range, set/get PWM frequency"); + + t2_count=0; + + gpioSetAlertFunc(GPIO, t2cb); + + gpioPWM(GPIO, 0); + dc = gpioGetPWMdutycycle(GPIO); + CHECK(2, 2, dc, 0, 0, "get PWM dutycycle"); + + time_sleep(0.5); /* allow old notifications to flush */ + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 3, f, 0, 0, "set PWM dutycycle, callback"); + + gpioPWM(GPIO, 128); + dc = gpioGetPWMdutycycle(GPIO); + CHECK(2, 4, dc, 128, 0, "get PWM dutycycle"); + + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 5, f, 40, 5, "set PWM dutycycle, callback"); + + gpioSetPWMfrequency(GPIO, 100); + f = gpioGetPWMfrequency(GPIO); + CHECK(2, 6, f, 100, 0, "set/get PWM frequency"); + + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 7, f, 400, 1, "callback"); + + gpioSetPWMfrequency(GPIO, 1000); + f = gpioGetPWMfrequency(GPIO); + CHECK(2, 8, f, 1000, 0, "set/get PWM frequency"); + + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 9, f, 4000, 1, "callback"); + + r = gpioGetPWMrange(GPIO); + CHECK(2, 10, r, 255, 0, "get PWM range"); + + rr = gpioGetPWMrealRange(GPIO); + CHECK(2, 11, rr, 200, 0, "get PWM real range"); + + gpioSetPWMrange(GPIO, 2000); + r = gpioGetPWMrange(GPIO); + CHECK(2, 12, r, 2000, 0, "set/get PWM range"); + + rr = gpioGetPWMrealRange(GPIO); + CHECK(2, 13, rr, 200, 0, "get PWM real range"); + + gpioPWM(GPIO, 0); +} + +int t3_val; +int t3_reset; +int t3_count; +uint32_t t3_tick; +float t3_on; +float t3_off; + +void t3cbf(int gpio, int level, uint32_t tick, void *userdata) +{ + static int unreported = 1; + + uint32_t td; + int *val; + + val = userdata; + + if (*val != USERDATA) + { + if (unreported) + { + fprintf + ( + stderr, + "unexpected userdata %d (expected %d)\n", + *val, USERDATA + ); + } + unreported = 0; + } + + if (t3_reset) + { + t3_count = 0; + t3_on = 0.0; + t3_off = 0.0; + t3_reset = 0; + } + else + { + td = tick - t3_tick; + + if (level == 0) t3_on += td; + else t3_off += td; + } + + t3_count ++; + t3_tick = tick; +} + +void t3() +{ + int f, rr; + + float on, off; + + int t, v; + + int pw[3]={500, 1500, 2500}; + int dc[4]={20, 40, 60, 80}; + + printf("PWM/Servo pulse accuracy tests.\n"); + + t3_val = USERDATA; + t3_reset=1; + t3_count=0; + t3_tick=0; + t3_on=0.0; + t3_off=0.0; + + gpioSetAlertFuncEx(GPIO, t3cbf, &t3_val); /* test extended alert */ + + for (t=0; t<3; t++) + { + gpioServo(GPIO, pw[t]); + v = gpioGetServoPulsewidth(GPIO); + CHECK(3, t+t+1, v, pw[t], 0, "get servo pulsewidth"); + + time_sleep(1); + t3_reset = 1; + time_sleep(4); + on = t3_on; + off = t3_off; + CHECK(3, t+t+2, (1E3*(on+off))/on, 2E7/pw[t], 1, + "set servo pulsewidth"); + } + + gpioServo(GPIO, 0); + gpioSetPWMfrequency(GPIO, 1000); + f = gpioGetPWMfrequency(GPIO); + CHECK(3, 7, f, 1000, 0, "set/get PWM frequency"); + + rr = gpioSetPWMrange(GPIO, 100); + CHECK(3, 8, rr, 200, 0, "set PWM range"); + + for (t=0; t<4; t++) + { + gpioPWM(GPIO, dc[t]); + v = gpioGetPWMdutycycle(GPIO); + CHECK(3, t+t+9, v, dc[t], 0, "get PWM dutycycle"); + + time_sleep(1); + t3_reset = 1; + time_sleep(2); + on = t3_on; + off = t3_off; + CHECK(3, t+t+10, (1E3*on)/(on+off), 1E1*dc[t], 1, + "set PWM dutycycle"); + } + + gpioPWM(GPIO, 0); +} + +void t4() +{ + int h, e, f, n, s, b, l, seq_ok, toggle_ok; + gpioReport_t r; + char p[32]; + + printf("Pipe notification tests.\n"); + + gpioSetPWMfrequency(GPIO, 0); + gpioPWM(GPIO, 0); + gpioSetPWMrange(GPIO, 100); + + h = gpioNotifyOpen(); + + sprintf(p, "/dev/pigpio%d", h); + f = open(p, O_RDONLY); + + e = gpioNotifyBegin(h, (1< 0) text[c] = 0; + CHECK(5, 11, strcmp(TEXT, text), 0, 0, "wave tx busy, serial read"); + + e = gpioSerialReadClose(GPIO); + CHECK(5, 12, e, 0, 0, "serial read close"); + + c = gpioWaveGetMicros(); + CHECK(5, 13, c, 6158148, 0, "wave get micros"); + + c = gpioWaveGetHighMicros(); + CHECK(5, 14, c, 6158148, 0, "wave get high micros"); + + c = gpioWaveGetMaxMicros(); + CHECK(5, 15, c, 1800000000, 0, "wave get max micros"); + + c = gpioWaveGetPulses(); + CHECK(5, 16, c, 3405, 0, "wave get pulses"); + + c = gpioWaveGetHighPulses(); + CHECK(5, 17, c, 3405, 0, "wave get high pulses"); + + c = gpioWaveGetMaxPulses(); + CHECK(5, 18, c, 12000, 0, "wave get max pulses"); + + c = gpioWaveGetCbs(); + if (e < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs"); + else CHECK(5, 19, c, 7115, 0, "wave get cbs"); + + c = gpioWaveGetHighCbs(); + if (e < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs"); + else CHECK(5, 20, c, 7115, 0, "wave get high cbs"); + + 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<= 0) text[b] = 0; + CHECK(10, 7, strcmp(TEXT, text), 0, 0, "serial read"); + + b = serReadByte(h); + CHECK(10, 8, b, 0xAA, 0, "serial read byte"); + + b = serReadByte(h); + CHECK(10, 9, b, 0x55, 0, "serial read byte"); + + b = serReadByte(h); + CHECK(10, 10, b, 0x00, 0, "serial read byte"); + + b = serReadByte(h); + CHECK(10, 11, b, 0xFF, 0, "serial read byte"); + + b = serDataAvailable(h); + CHECK(10, 12, b, 0, 0, "serial data availabe"); + + e = serClose(h); + CHECK(10, 13, e, 0, 0, "serial close"); +} + +void tb() +{ + int h, e, b, len; + char *exp; + char buf[128]; + + printf("SMBus / I2C tests."); + + /* this test requires an ADXL345 on I2C bus 1 addr 0x53 */ + + h = i2cOpen(1, 0x53, 0); + CHECK(11, 1, h, 0, 0, "i2cOpen"); + + e = i2cWriteDevice(h, "\x00", 1); /* move to known register */ + CHECK(11, 2, e, 0, 0, "i2cWriteDevice"); + + b = i2cReadDevice(h, buf, 1); + CHECK(11, 3, b, 1, 0, "i2cReadDevice"); + CHECK(11, 4, buf[0], 0xE5, 0, "i2cReadDevice"); + + b = i2cReadByte(h); + CHECK(11, 5, b, 0xE5, 0, "i2cReadByte"); + + b = i2cReadByteData(h, 0); + CHECK(11, 6, b, 0xE5, 0, "i2cReadByteData"); + + b = i2cReadByteData(h, 48); + CHECK(11, 7, b, 2, 0, "i2cReadByteData"); + + exp = "\x1D[aBcDeFgHjKM]"; + len = strlen(exp); + + e = i2cWriteDevice(h, exp, len); + CHECK(11, 8, e, 0, 0, "i2cWriteDevice"); + + e = i2cWriteDevice(h, "\x1D", 1); + b = i2cReadDevice(h, buf, len-1); + CHECK(11, 9, b, len-1, 0, "i2cReadDevice"); + CHECK(11, 10, strncmp(buf, exp+1, len-1), 0, 0, "i2cReadDevice"); + + if (strncmp(buf, exp+1, len-1)) + printf("got [%.*s] expected [%.*s]\n", len-1, buf, len-1, exp+1); + + e = i2cWriteByteData(h, 0x1d, 0xAA); + CHECK(11, 11, e, 0, 0, "i2cWriteByteData"); + + b = i2cReadByteData(h, 0x1d); + CHECK(11, 12, b, 0xAA, 0, "i2cReadByteData"); + + e = i2cWriteByteData(h, 0x1d, 0x55); + CHECK(11, 13, e, 0, 0, "i2cWriteByteData"); + + b = i2cReadByteData(h, 0x1d); + CHECK(11, 14, b, 0x55, 0, "i2cReadByteData"); + + exp = "[1234567890#]"; + len = strlen(exp); + + e = i2cWriteBlockData(h, 0x1C, exp, len); + CHECK(11, 15, e, 0, 0, "i2c writeBlockData"); + + e = i2cWriteDevice(h, "\x1D", 1); + b = i2cReadDevice(h, buf, len); + CHECK(11, 16, b, len, 0, "i2cReadDevice"); + CHECK(11, 17, strncmp(buf, exp, len), 0, 0, "i2cReadDevice"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + b = i2cReadI2CBlockData(h, 0x1D, buf, len); + CHECK(11, 18, b, len, 0, "i2cReadI2CBlockData"); + CHECK(11, 19, strncmp(buf, exp, len), 0, 0, "i2cReadI2CBlockData"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + exp = "(-+=;:,<>!%)"; + len = strlen(exp); + + e = i2cWriteI2CBlockData(h, 0x1D, exp, len); + CHECK(11, 20, e, 0, 0, "i2cWriteI2CBlockData"); + + b = i2cReadI2CBlockData(h, 0x1D, buf, len); + CHECK(11, 21, b, len, 0, "i2cReadI2CBlockData"); + CHECK(11, 22, strncmp(buf, exp, len), 0, 0, "i2cReadI2CBlockData"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + e = i2cClose(h); + CHECK(11, 23, e, 0, 0, "i2cClose"); +} + +void tc() +{ + int h, x, b, e; + char txBuf[8], rxBuf[8]; + + printf("SPI tests."); + + /* this test requires a MCP3202 on SPI channel 1 */ + + h = spiOpen(1, 50000, 0); + CHECK(12, 1, h, 0, 0, "spiOpen"); + + sprintf(txBuf, "\x01\x80"); + + for (x=0; x<5; x++) + { + b = spiXfer(h, txBuf, rxBuf, 3); + CHECK(12, 2, b, 3, 0, "spiXfer"); + if (b == 3) + { + time_sleep(1.0); + printf("%d ", ((rxBuf[1]&0x0F)*256)|rxBuf[2]); + } + } + + e = spiClose(h); + CHECK(12, 99, e, 0, 0, "spiClose"); +} + +int main(int argc, char *argv[]) +{ + int i, t, c, status; + + char test[64]={0,}; + + if (argc > 1) + { + t = 0; + + for (i=0; i 0x03000000: + + if type(r) == type(""): + r = bytearray(r, 'latin-1') + + if type(s) == type(""): + s = bytearray(s, 'latin-1') + + if r != s: + print(r, s) + return 0 + + else: + return 1 + +def CHECK(t, st, got, expect, pc, desc): + if got >= (((1E2-pc)*expect)/1E2) and got <= (((1E2+pc)*expect)/1E2): + print("TEST {:2d}.{:<2d} PASS ({}: {:d})".format(t, st, desc, expect)) + else: + print("TEST {:2d}.{:<2d} FAILED got {:d} ({}: {:d})". + format(t, st, got, desc, expect)) + +def t0(): + + print("\nTesting pigpio Python module {}".format(pigpio.VERSION)) + + print("Python {}".format(sys.version.replace("\n", " "))) + + print("pigpio version {}.".format(pi.get_pigpio_version())) + + print("Hardware revision {}.".format(pi.get_hardware_revision())) + +def t1(): + + print("Mode/PUD/read/write tests.") + + pi.set_mode(GPIO, pigpio.INPUT) + v = pi.get_mode(GPIO) + CHECK(1, 1, v, 0, 0, "set mode, get mode") + + pi.set_pull_up_down(GPIO, pigpio.PUD_UP) + v = pi.read(GPIO) + CHECK(1, 2, v, 1, 0, "set pull up down, read") + + pi.set_pull_up_down(GPIO, pigpio.PUD_DOWN) + v = pi.read(GPIO) + CHECK(1, 3, v, 0, 0, "set pull up down, read") + + pi.write(GPIO, pigpio.LOW) + v = pi.get_mode(GPIO) + CHECK(1, 4, v, 1, 0, "write, get mode") + + v = pi.read(GPIO) + CHECK(1, 5, v, 0, 0, "read") + + pi.write(GPIO, pigpio.HIGH) + v = pi.read(GPIO) + CHECK(1, 6, v, 1, 0, "write, read") + +t2_count=0 + +def t2cbf(gpio, level, tick): + global t2_count + t2_count += 1 + +def t2(): + + global t2_count + + print("PWM dutycycle/range/frequency tests.") + + pi.set_PWM_range(GPIO, 255) + pi.set_PWM_frequency(GPIO,0) + f = pi.get_PWM_frequency(GPIO) + CHECK(2, 1, f, 10, 0, "set PWM range, set/get PWM frequency") + + t2cb = pi.callback(GPIO, pigpio.EITHER_EDGE, t2cbf) + + pi.set_PWM_dutycycle(GPIO, 0) + dc = pi.get_PWM_dutycycle(GPIO) + CHECK(2, 2, dc, 0, 0, "get PWM dutycycle") + + time.sleep(0.5) # allow old notifications to flush + oc = t2_count + time.sleep(2) + f = t2_count - oc + CHECK(2, 3, f, 0, 0, "set PWM dutycycle, callback") + + pi.set_PWM_dutycycle(GPIO, 128) + dc = pi.get_PWM_dutycycle(GPIO) + CHECK(2, 4, dc, 128, 0, "get PWM dutycycle") + + time.sleep(1) + oc = t2_count + time.sleep(2) + f = t2_count - oc + CHECK(2, 5, f, 40, 10, "set PWM dutycycle, callback") + + pi.set_PWM_frequency(GPIO,100) + f = pi.get_PWM_frequency(GPIO) + CHECK(2, 6, f, 100, 0, "set/get PWM frequency") + + time.sleep(1) + oc = t2_count + time.sleep(2) + f = t2_count - oc + CHECK(2, 7, f, 400, 5, "callback") + + pi.set_PWM_frequency(GPIO,1000) + f = pi.get_PWM_frequency(GPIO) + CHECK(2, 8, f, 1000, 0, "set/get PWM frequency") + + time.sleep(1) + oc = t2_count + time.sleep(2) + f = t2_count - oc + CHECK(2, 9, f, 4000, 5, "callback") + + r = pi.get_PWM_range(GPIO) + CHECK(2, 10, r, 255, 0, "get PWM range") + + rr = pi.get_PWM_real_range(GPIO) + CHECK(2, 11, rr, 200, 0, "get PWM real range") + + pi.set_PWM_range(GPIO, 2000) + r = pi.get_PWM_range(GPIO) + CHECK(2, 12, r, 2000, 0, "set/get PWM range") + + rr = pi.get_PWM_real_range(GPIO) + CHECK(2, 13, rr, 200, 0, "get PWM real range") + + pi.set_PWM_dutycycle(GPIO, 0) + + t2cb.cancel() + +t3_reset=True +t3_count=0 +t3_tick=0 +t3_on=0.0 +t3_off=0.0 + +def t3cbf(gpio, level, tick): + global t3_reset, t3_count, t3_tick, t3_on, t3_off + + if t3_reset: + t3_count = 0 + t3_on = 0.0 + t3_off = 0.0 + t3_reset = False + else: + td = pigpio.tickDiff(t3_tick, tick) + + if level == 0: + t3_on += td + else: + t3_off += td + + t3_count += 1 + t3_tick = tick + +def t3(): + + global t3_reset, t3_count, t3_on, t3_off + + pw=[500.0, 1500.0, 2500.0] + dc=[0.2, 0.4, 0.6, 0.8] + + print("PWM/Servo pulse accuracy tests.") + + t3cb = pi.callback(GPIO, pigpio.EITHER_EDGE, t3cbf) + + t = 0 + for x in pw: + t += 1 + pi.set_servo_pulsewidth(GPIO, x) + v = pi.get_servo_pulsewidth(GPIO) + CHECK(3, t, v, int(x), 0, "get servo pulsewidth") + + t += 1 + time.sleep(1) + t3_reset = True + time.sleep(4) + c = t3_count + on = t3_on + off = t3_off + CHECK(3, t, int((1E3*(on+off))/on), int(2E7/x), 1, "set servo pulsewidth") + + + pi.set_servo_pulsewidth(GPIO, 0) + pi.set_PWM_frequency(GPIO, 1000) + f = pi.get_PWM_frequency(GPIO) + CHECK(3, 7, f, 1000, 0, "set/get PWM frequency") + + rr = pi.set_PWM_range(GPIO, 100) + CHECK(3, 8, rr, 200, 0, "set PWM range") + + t = 8 + for x in dc: + t += 1 + pi.set_PWM_dutycycle(GPIO, x*100) + v = pi.get_PWM_dutycycle(GPIO) + CHECK(3, t, v, int(x*100), 0, "get PWM dutycycle") + + t += 1 + time.sleep(1) + t3_reset = True + time.sleep(2) + c = t3_count + on = t3_on + off = t3_off + CHECK(3, t, int((1E3*on)/(on+off)), int(1E3*x), 1, "set PWM dutycycle") + + pi.set_PWM_dutycycle(GPIO, 0) + + t3cb.cancel() + +def t4(): + + print("Pipe notification tests.") + + pi.set_PWM_frequency(GPIO, 0) + pi.set_PWM_dutycycle(GPIO, 0) + pi.set_PWM_range(GPIO, 100) + + h = pi.notify_open() + e = pi.notify_begin(h, (1<=0, 1, 0, "serial open") + + (b, s) = pi.serial_read(h, 1000) # flush buffer + + b = pi.serial_data_available(h) + CHECK(10, 2, b, 0, 0, "serial data available") + + TEXT = """ +To be, or not to be, that is the question- +Whether 'tis Nobler in the mind to suffer +The Slings and Arrows of outrageous Fortune, +Or to take Arms against a Sea of troubles, +""" + e = pi.serial_write(h, TEXT) + CHECK(10, 3, e, 0, 0, "serial write") + + e = pi.serial_write_byte(h, 0xAA) + e = pi.serial_write_byte(h, 0x55) + e = pi.serial_write_byte(h, 0x00) + e = pi.serial_write_byte(h, 0xFF) + + CHECK(10, 4, e, 0, 0, "serial write byte") + + time.sleep(0.1) # allow time for transmission + + b = pi.serial_data_available(h) + CHECK(10, 5, b, len(TEXT)+4, 0, "serial data available") + + (b, text) = pi.serial_read(h, len(TEXT)) + CHECK(10, 6, b, len(TEXT), 0, "serial read") + CHECK(10, 7, STRCMP(text, TEXT), True, 0, "serial read") + + b = pi.serial_read_byte(h) + CHECK(10, 8, b, 0xAA, 0, "serial read byte") + + b = pi.serial_read_byte(h) + CHECK(10, 9, b, 0x55, 0, "serial read byte") + + b = pi.serial_read_byte(h) + CHECK(10, 10, b, 0x00, 0, "serial read byte") + + b = pi.serial_read_byte(h) + CHECK(10, 11, b, 0xFF, 0, "serial read byte") + + b = pi.serial_data_available(h) + CHECK(10, 12, b, 0, 0, "serial data available") + + e = pi.serial_close(h) + CHECK(10, 13, e, 0, 0, "serial close") + +def tb(): + print("SMBus / I2C tests.") + + # this test requires an ADXL345 on I2C bus 1 addr 0x53 + + h = pi.i2c_open(1, 0x53) + CHECK(11, 1, h>=0, 1, 0, "i2c open") + + e = pi.i2c_write_device(h, "\x00") # move to known register + CHECK(11, 2, e, 0, 0, "i2c write device") + + (b, d) = pi.i2c_read_device(h, 1) + CHECK(11, 3, b, 1, 0, "i2c read device") + CHECK(11, 4, ord(d), 0xE5, 0, "i2c read device") + + b = pi.i2c_read_byte(h) + CHECK(11, 5, b, 0xE5, 0, "i2c read byte") + + b = pi.i2c_read_byte_data(h, 0) + CHECK(11, 6, b, 0xE5, 0, "i2c read byte data") + + b = pi.i2c_read_byte_data(h, 48) + CHECK(11, 7, b, 2, 0, "i2c read byte data") + + exp = b"[aB\x08cD\xAAgHj\xFD]" + + e = pi.i2c_write_device(h, b'\x1D'+ exp) + CHECK(11, 8, e, 0, 0, "i2c write device") + + e = pi.i2c_write_device(h, '\x1D') + (b, d) = pi.i2c_read_device(h, 12) + CHECK(11, 9, b, 12, 0, "i2c read device") + CHECK(11, 10, STRCMP(d, exp), True, 0, "i2c read device") + + e = pi.i2c_write_byte_data(h, 0x1d, 0xAA) + CHECK(11, 11, e, 0, 0, "i2c write byte data") + + b = pi.i2c_read_byte_data(h, 0x1d) + CHECK(11, 12, b, 0xAA, 0, "i2c read byte data") + + e = pi.i2c_write_byte_data(h, 0x1d, 0x55) + CHECK(11, 13, e, 0, 0, "i2c write byte data") + + b = pi.i2c_read_byte_data(h, 0x1d) + CHECK(11, 14, b, 0x55, 0, "i2c read byte data") + + exp = "[1234567890#]" + + e = pi.i2c_write_block_data(h, 0x1C, exp) + CHECK(11, 15, e, 0, 0, "i2c write block data") + + e = pi.i2c_write_device(h, '\x1D') + (b, d) = pi.i2c_read_device(h, 13) + CHECK(11, 16, b, 13, 0, "i2c read device") + CHECK(11, 17, STRCMP(d, exp), True, 0, "i2c read device") + + (b, d) = pi.i2c_read_i2c_block_data(h, 0x1D, 13) + CHECK(11, 18, b, 13, 0, "i2c read i2c block data") + CHECK(11, 19, STRCMP(d, exp), True, 0, "i2c read i2c block data") + + expl = [0x01, 0x05, 0x06, 0x07, 0x09, 0x1B, 0x99, 0xAA, 0xBB, 0xCC] + exp = "\x01\x05\x06\x07\x09\x1B\x99\xAA\xBB\xCC" + + e = pi.i2c_write_i2c_block_data(h, 0x1D, expl) + CHECK(11, 20, e, 0, 0, "i2c write i2c block data") + + (b, d) = pi.i2c_read_i2c_block_data(h, 0x1D, 10) + CHECK(11, 21, b, 10, 0, "i2c read i2c block data") + CHECK(11, 22, STRCMP(d, exp), True, 0, "i2c read i2c block data") + + e = pi.i2c_close(h) + CHECK(11, 23, e, 0, 0, "i2c close") + +def tca(b, d): + if b == 3: + c1 = d[1] & 0x0F + c2 = d[2] + time.sleep(1.0) + print((c1*256)+c2) + +def tc(): + print("SPI tests.") + + # this test requires a MCP3202 on SPI channel 1 + + h = pi.spi_open(1, 50000) + CHECK(12, 1, h>=0, 1, 0, "spi open") + + (b, d) = pi.spi_xfer(h, [1,128,0]) + CHECK(12, 2, b, 3, 0, "spi xfer") + tca(b, d) + + (b, d) = pi.spi_xfer(h, "\x01\x80\x00") + CHECK(12, 2, b, 3, 0, "spi xfer") + tca(b, d) + + (b, d) = pi.spi_xfer(h, b"\x01\x80\x00") + CHECK(12, 2, b, 3, 0, "spi xfer") + tca(b, d) + + (b, d) = pi.spi_xfer(h, '\x01\x80\x00') + CHECK(12, 2, b, 3, 0, "spi xfer") + tca(b, d) + + (b, d) = pi.spi_xfer(h, b'\x01\x80\x00') + CHECK(12, 2, b, 3, 0, "spi xfer") + tca(b, d) + + e = pi.spi_close(h) + CHECK(12, 99, e, 0, 0, "spi close") + +def td(): + + print("Wavechains & filter tests.") + + tdcb = pi.callback(GPIO) + + pi.set_mode(GPIO, pigpio.OUTPUT) + + pi.write(GPIO, pigpio.LOW) + + e = pi.wave_clear() + CHECK(13, 1, e, 0, 0, "callback, set mode, wave clear") + + wf = [] + + wf.append(pigpio.pulse(1< 1: + tests = "" + for C in sys.argv[1]: + c = C.lower() + if c not in tests: + tests += c + +else: + tests = "0123456789d" + +pi = pigpio.pi() + +if pi.connected: + print("Connected to pigpio daemon.") + + if '0' in tests: t0() + if '1' in tests: t1() + if '2' in tests: t2() + if '3' in tests: t3() + if '4' in tests: t4() + if '5' in tests: t5() + if '6' in tests: t6() + if '7' in tests: t7() + if '8' in tests: t8() + if '9' in tests: t9() + if 'a' in tests: ta() + if 'b' in tests: tb() + if 'c' in tests: tc() + if 'd' in tests: td() + +pi.stop() + diff --git a/x_pigpiod_if.c b/x_pigpiod_if.c new file mode 100644 index 0000000..ae4d7a5 --- /dev/null +++ b/x_pigpiod_if.c @@ -0,0 +1,875 @@ +/* +gcc -Wall -pthread -o x_pigpiod_if x_pigpiod_if.c -lpigpiod_if +./x_pigpiod_if + +*** WARNING ************************************************ +* * +* All the tests make extensive use of gpio 25 (pin 22). * +* Ensure that either nothing or just a LED is connected to * +* gpio 25 before running any of the tests. * +* * +* Some tests are statistical in nature and so may on * +* occasion fail. Repeated failures on the same test or * +* many failures in a group of tests indicate a problem. * +************************************************************ +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "pigpiod_if.h" + +#define GPIO 25 + +void CHECK(int t, int st, int got, int expect, int pc, char *desc) +{ + if ((got >= (((1E2-pc)*expect)/1E2)) && (got <= (((1E2+pc)*expect)/1E2))) + { + printf("TEST %2d.%-2d PASS (%s: %d)\n", t, st, desc, expect); + } + else + { + fprintf(stderr, + "TEST %2d.%-2d FAILED got %d (%s: %d)\n", + t, st, got, desc, expect); + } +} + +void t0() +{ + printf("\nTesting pigpiod C I/F 1\n"); + + printf("pigpio version %d.\n", get_pigpio_version()); + + printf("Hardware revision %d.\n", get_hardware_revision()); +} + +void t1() +{ + int v; + + printf("Mode/PUD/read/write tests.\n"); + + set_mode(GPIO, PI_INPUT); + v = get_mode(GPIO); + CHECK(1, 1, v, 0, 0, "set mode, get mode"); + + set_pull_up_down(GPIO, PI_PUD_UP); + v = gpio_read(GPIO); + CHECK(1, 2, v, 1, 0, "set pull up down, read"); + + set_pull_up_down(GPIO, PI_PUD_DOWN); + v = gpio_read(GPIO); + CHECK(1, 3, v, 0, 0, "set pull up down, read"); + + gpio_write(GPIO, PI_LOW); + v = get_mode(GPIO); + CHECK(1, 4, v, 1, 0, "write, get mode"); + + v = gpio_read(GPIO); + CHECK(1, 5, v, 0, 0, "read"); + + gpio_write(GPIO, PI_HIGH); + v = gpio_read(GPIO); + CHECK(1, 6, v, 1, 0, "write, read"); +} + +int t2_count=0; + +void t2cb(unsigned gpio, unsigned level, uint32_t tick) +{ + t2_count++; +} + +void t2() +{ + int dc, f, r, rr, oc; + + printf("PWM dutycycle/range/frequency tests.\n"); + + set_PWM_range(GPIO, 255); + set_PWM_frequency(GPIO, 0); + f = get_PWM_frequency(GPIO); + CHECK(2, 1, f, 10, 0, "set PWM range, set/get PWM frequency"); + + callback(GPIO, EITHER_EDGE, t2cb); + + set_PWM_dutycycle(GPIO, 0); + dc = get_PWM_dutycycle(GPIO); + CHECK(2, 2, dc, 0, 0, "get PWM dutycycle"); + + time_sleep(0.5); /* allow old notifications to flush */ + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 3, f, 0, 0, "set PWM dutycycle, callback"); + + set_PWM_dutycycle(GPIO, 128); + dc = get_PWM_dutycycle(GPIO); + CHECK(2, 4, dc, 128, 0, "get PWM dutycycle"); + + time_sleep(0.2); + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 5, f, 40, 5, "set PWM dutycycle, callback"); + + set_PWM_frequency(GPIO, 100); + f = get_PWM_frequency(GPIO); + CHECK(2, 6, f, 100, 0, "set/get PWM frequency"); + + time_sleep(0.2); + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 7, f, 400, 1, "callback"); + + set_PWM_frequency(GPIO, 1000); + f = get_PWM_frequency(GPIO); + CHECK(2, 8, f, 1000, 0, "set/get PWM frequency"); + + time_sleep(0.2); + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 9, f, 4000, 1, "callback"); + + r = get_PWM_range(GPIO); + CHECK(2, 10, r, 255, 0, "get PWM range"); + + rr = get_PWM_real_range(GPIO); + CHECK(2, 11, rr, 200, 0, "get PWM real range"); + + set_PWM_range(GPIO, 2000); + r = get_PWM_range(GPIO); + CHECK(2, 12, r, 2000, 0, "set/get PWM range"); + + rr = get_PWM_real_range(GPIO); + CHECK(2, 13, rr, 200, 0, "get PWM real range"); + + set_PWM_dutycycle(GPIO, 0); +} + +int t3_reset=1; +int t3_count=0; +uint32_t t3_tick=0; +float t3_on=0.0; +float t3_off=0.0; + +void t3cbf(unsigned gpio, unsigned level, uint32_t tick) +{ + uint32_t td; + + if (t3_reset) + { + t3_count = 0; + t3_on = 0.0; + t3_off = 0.0; + t3_reset = 0; + } + else + { + td = tick - t3_tick; + + if (level == 0) t3_on += td; + else t3_off += td; + } + + t3_count ++; + t3_tick = tick; +} + +void t3() +{ + int pw[3]={500, 1500, 2500}; + int dc[4]={20, 40, 60, 80}; + + int f, rr, v; + float on, off; + + int t; + + printf("PWM/Servo pulse accuracy tests.\n"); + + callback(GPIO, EITHER_EDGE, t3cbf); + + for (t=0; t<3; t++) + { + set_servo_pulsewidth(GPIO, pw[t]); + v = get_servo_pulsewidth(GPIO); + CHECK(3, t+t+1, v, pw[t], 0, "get servo pulsewidth"); + + time_sleep(1); + t3_reset = 1; + time_sleep(4); + on = t3_on; + off = t3_off; + CHECK(3, t+t+2, (1000.0*(on+off))/on, 20000000.0/pw[t], 1, + "set servo pulsewidth"); + } + + set_servo_pulsewidth(GPIO, 0); + set_PWM_frequency(GPIO, 1000); + f = get_PWM_frequency(GPIO); + CHECK(3, 7, f, 1000, 0, "set/get PWM frequency"); + + rr = set_PWM_range(GPIO, 100); + CHECK(3, 8, rr, 200, 0, "set PWM range"); + + for (t=0; t<4; t++) + { + set_PWM_dutycycle(GPIO, dc[t]); + v = get_PWM_dutycycle(GPIO); + CHECK(3, t+t+9, v, dc[t], 0, "get PWM dutycycle"); + + time_sleep(1); + t3_reset = 1; + time_sleep(2); + on = t3_on; + off = t3_off; + CHECK(3, t+t+10, (1000.0*on)/(on+off), 10.0*dc[t], 1, + "set PWM dutycycle"); + } + + set_PWM_dutycycle(GPIO, 0); + +} + +void t4() +{ + int h, e, f, n, s, b, l, seq_ok, toggle_ok; + gpioReport_t r; + char p[32]; + + printf("Pipe notification tests.\n"); + + set_PWM_frequency(GPIO, 0); + set_PWM_dutycycle(GPIO, 0); + set_PWM_range(GPIO, 100); + + h = notify_open(); + + sprintf(p, "/dev/pigpio%d", h); + f = open(p, O_RDONLY); + + e = notify_begin(h, (1< 0) text[c] = 0; /* null terminate string */ + CHECK(5, 11, strcmp(TEXT, text), 0, 0, "wave tx busy, serial read"); + + e = bb_serial_read_close(GPIO); + CHECK(5, 12, e, 0, 0, "serial read close"); + + c = wave_get_micros(); + CHECK(5, 13, c, 6158148, 0, "wave get micros"); + + c = wave_get_high_micros(); + if (c > 6158148) c = 6158148; + CHECK(5, 14, c, 6158148, 0, "wave get high micros"); + + c = wave_get_max_micros(); + CHECK(5, 15, c, 1800000000, 0, "wave get max micros"); + + c = wave_get_pulses(); + CHECK(5, 16, c, 3405, 0, "wave get pulses"); + + c = wave_get_high_pulses(); + CHECK(5, 17, c, 3405, 0, "wave get high pulses"); + + c = wave_get_max_pulses(); + CHECK(5, 18, c, 12000, 0, "wave get max pulses"); + + c = wave_get_cbs(); + if (c < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs"); + else CHECK(5, 19, c, 7115, 0, "wave get cbs"); + + c = wave_get_high_cbs(); + if (c < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs"); + else CHECK(5, 20, c, 7115, 0, "wave get high cbs"); + + c = wave_get_max_cbs(); + CHECK(5, 21, c, 25016, 0, "wave get max cbs"); +} + +int t6_count=0; +int t6_on=0; +uint32_t t6_on_tick=0; + +void t6cbf(unsigned gpio, unsigned level, uint32_t tick) +{ + if (level == 1) + { + t6_on_tick = tick; + t6_count++; + } + else + { + if (t6_on_tick) t6_on += (tick - t6_on_tick); + } +} + +void t6() +{ + int tp, t, p; + + printf("Trigger tests.\n"); + + gpio_write(GPIO, PI_LOW); + + tp = 0; + + callback(GPIO, EITHER_EDGE, t6cbf); + + time_sleep(0.2); + + for (t=0; t<5; t++) + { + time_sleep(0.1); + p = 10 + (t*10); + tp += p; + gpio_trigger(GPIO, p, 1); + } + + time_sleep(0.5); + + CHECK(6, 1, t6_count, 5, 0, "gpio trigger count"); + + CHECK(6, 2, t6_on, tp, 25, "gpio trigger pulse length"); +} + +int t7_count=0; + +void t7cbf(unsigned gpio, unsigned level, uint32_t tick) +{ + if (level == PI_TIMEOUT) t7_count++; +} + +void t7() +{ + int c, oc; + + printf("Watchdog tests.\n"); + + /* type of edge shouldn't matter for watchdogs */ + callback(GPIO, FALLING_EDGE, t7cbf); + + set_watchdog(GPIO, 50); /* 50 ms, 20 per second */ + time_sleep(0.5); + oc = t7_count; + time_sleep(2); + c = t7_count - oc; + CHECK(7, 1, c, 39, 5, "set watchdog on count"); + + set_watchdog(GPIO, 0); /* 0 switches watchdog off */ + time_sleep(0.5); + oc = t7_count; + time_sleep(2); + c = t7_count - oc; + CHECK(7, 2, c, 0, 1, "set watchdog off count"); +} + +void t8() +{ + int v; + + printf("Bank read/write tests.\n"); + + gpio_write(GPIO, 0); + v = read_bank_1() & (1<= 0) text[b] = 0; + CHECK(10, 7, strcmp(TEXT, text), 0, 0, "serial read"); + + b = serial_read_byte(h); + CHECK(10, 8, b, 0xAA, 0, "serial read byte"); + + b = serial_read_byte(h); + CHECK(10, 9, b, 0x55, 0, "serial read byte"); + + b = serial_read_byte(h); + CHECK(10, 10, b, 0x00, 0, "serial read byte"); + + b = serial_read_byte(h); + CHECK(10, 11, b, 0xFF, 0, "serial read byte"); + + b = serial_data_available(h); + CHECK(10, 12, b, 0, 0, "serial data availabe"); + + e = serial_close(h); + CHECK(10, 13, e, 0, 0, "serial close"); +} + +void tb() +{ + int h, e, b, len; + char *exp; + char buf[128]; + + printf("SMBus / I2C tests."); + + /* this test requires an ADXL345 on I2C bus 1 addr 0x53 */ + + h = i2c_open(1, 0x53, 0); + CHECK(11, 1, h, 0, 0, "i2c open"); + + e = i2c_write_device(h, "\x00", 1); /* move to known register */ + CHECK(11, 2, e, 0, 0, "i2c write device"); + + b = i2c_read_device(h, buf, 1); + CHECK(11, 3, b, 1, 0, "i2c read device"); + CHECK(11, 4, buf[0], 0xE5, 0, "i2c read device"); + + b = i2c_read_byte(h); + CHECK(11, 5, b, 0xE5, 0, "i2c read byte"); + + b = i2c_read_byte_data(h, 0); + CHECK(11, 6, b, 0xE5, 0, "i2c read byte data"); + + b = i2c_read_byte_data(h, 48); + CHECK(11, 7, b, 2, 0, "i2c read byte data"); + + exp = "\x1D[aBcDeFgHjKM]"; + len = strlen(exp); + + e = i2c_write_device(h, exp, len); + CHECK(11, 8, e, 0, 0, "i2c write device"); + + e = i2c_write_device(h, "\x1D", 1); + b = i2c_read_device(h, buf, len-1); + CHECK(11, 9, b, len-1, 0, "i2c read device"); + CHECK(11, 10, strncmp(buf, exp+1, len-1), 0, 0, "i2c read device"); + + if (strncmp(buf, exp+1, len-1)) + printf("got [%.*s] expected [%.*s]\n", len-1, buf, len-1, exp+1); + + e = i2c_write_byte_data(h, 0x1d, 0xAA); + CHECK(11, 11, e, 0, 0, "i2c write byte data"); + + b = i2c_read_byte_data(h, 0x1d); + CHECK(11, 12, b, 0xAA, 0, "i2c read byte data"); + + e = i2c_write_byte_data(h, 0x1d, 0x55); + CHECK(11, 13, e, 0, 0, "i2c write byte data"); + + b = i2c_read_byte_data(h, 0x1d); + CHECK(11, 14, b, 0x55, 0, "i2c read byte data"); + + exp = "[1234567890#]"; + len = strlen(exp); + + e = i2c_write_block_data(h, 0x1C, exp, len); + CHECK(11, 15, e, 0, 0, "i2c write block data"); + + e = i2c_write_device(h, "\x1D", 1); + b = i2c_read_device(h, buf, len); + CHECK(11, 16, b, len, 0, "i2c read device"); + CHECK(11, 17, strncmp(buf, exp, len), 0, 0, "i2c read device"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + b = i2c_read_i2c_block_data(h, 0x1D, buf, len); + CHECK(11, 18, b, len, 0, "i2c read i2c block data"); + CHECK(11, 19, strncmp(buf, exp, len), 0, 0, "i2c read i2c block data"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + exp = "(-+=;:,<>!%)"; + len = strlen(exp); + + e = i2c_write_i2c_block_data(h, 0x1D, exp, len); + CHECK(11, 20, e, 0, 0, "i2c write i2c block data"); + + b = i2c_read_i2c_block_data(h, 0x1D, buf, len); + CHECK(11, 21, b, len, 0, "i2c read i2c block data"); + CHECK(11, 22, strncmp(buf, exp, len), 0, 0, "i2c read i2c block data"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + e = i2c_close(h); + CHECK(11, 23, e, 0, 0, "i2c close"); +} + +void tc() +{ + int h, x, b, e; + char buf[128]; + + printf("SPI tests."); + + /* this test requires a MCP3202 on SPI channel 1 */ + + h = spi_open(1, 50000, 0); + CHECK(12, 1, h, 0, 0, "spi open"); + + + for (x=0; x<5; x++) + { + sprintf(buf, "\x01\x80"); + b = spi_xfer(h, buf, buf, 3); + CHECK(12, 2, b, 3, 0, "spi xfer"); + if (b == 3) + { + time_sleep(1.0); + printf("%d ", ((buf[1]&0x0F)*256)|buf[2]); + } + } + + e = spi_close(h); + CHECK(12, 99, e, 0, 0, "spi close"); +} + + +int main(int argc, char *argv[]) +{ + int i, t, c, status; + + char test[64]={0,}; + + if (argc > 1) + { + t = 0; + + for (i=0; i +#include +#include +#include +#include +#include +#include + +#include "pigpiod_if2.h" + +#define GPIO 25 + +void CHECK(int t, int st, int got, int expect, int pc, char *desc) +{ + if ((got >= (((1E2-pc)*expect)/1E2)) && (got <= (((1E2+pc)*expect)/1E2))) + { + printf("TEST %2d.%-2d PASS (%s: %d)\n", t, st, desc, expect); + } + else + { + fprintf(stderr, + "TEST %2d.%-2d FAILED got %d (%s: %d)\n", + t, st, got, desc, expect); + } +} + +void t0(int pi) +{ + printf("\nTesting pigpiod C I/F 2\n"); + + printf("pigpio version %d.\n", get_pigpio_version(pi)); + + printf("Hardware revision %d.\n", get_hardware_revision(pi)); +} + +void t1(int pi) +{ + int v; + + printf("Mode/PUD/read/write tests.\n"); + + set_mode(pi, GPIO, PI_INPUT); + v = get_mode(pi, GPIO); + CHECK(1, 1, v, 0, 0, "set mode, get mode"); + + set_pull_up_down(pi, GPIO, PI_PUD_UP); + v = gpio_read(pi, GPIO); + CHECK(1, 2, v, 1, 0, "set pull up down, read"); + + set_pull_up_down(pi, GPIO, PI_PUD_DOWN); + v = gpio_read(pi, GPIO); + CHECK(1, 3, v, 0, 0, "set pull up down, read"); + + gpio_write(pi, GPIO, PI_LOW); + v = get_mode(pi, GPIO); + CHECK(1, 4, v, 1, 0, "write, get mode"); + + v = gpio_read(pi, GPIO); + CHECK(1, 5, v, 0, 0, "read"); + + gpio_write(pi, GPIO, PI_HIGH); + v = gpio_read(pi, GPIO); + CHECK(1, 6, v, 1, 0, "write, read"); +} + +int t2_count=0; + +void t2cb(int pi, unsigned gpio, unsigned level, uint32_t tick) +{ + t2_count++; +} + +void t2(int pi) +{ + int dc, f, r, rr, oc, id; + + printf("PWM dutycycle/range/frequency tests.\n"); + + set_PWM_range(pi, GPIO, 255); + set_PWM_frequency(pi, GPIO, 0); + f = get_PWM_frequency(pi, GPIO); + CHECK(2, 1, f, 10, 0, "set PWM range, set/get PWM frequency"); + + id = callback(pi, GPIO, EITHER_EDGE, t2cb); + + set_PWM_dutycycle(pi, GPIO, 0); + dc = get_PWM_dutycycle(pi, GPIO); + CHECK(2, 2, dc, 0, 0, "get PWM dutycycle"); + + time_sleep(0.5); /* allow old notifications to flush */ + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 3, f, 0, 0, "set PWM dutycycle, callback"); + + set_PWM_dutycycle(pi, GPIO, 128); + dc = get_PWM_dutycycle(pi, GPIO); + CHECK(2, 4, dc, 128, 0, "get PWM dutycycle"); + + time_sleep(0.2); + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 5, f, 40, 5, "set PWM dutycycle, callback"); + + set_PWM_frequency(pi, GPIO, 100); + f = get_PWM_frequency(pi, GPIO); + CHECK(2, 6, f, 100, 0, "set/get PWM frequency"); + + time_sleep(0.2); + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 7, f, 400, 1, "callback"); + + set_PWM_frequency(pi, GPIO, 1000); + f = get_PWM_frequency(pi, GPIO); + CHECK(2, 8, f, 1000, 0, "set/get PWM frequency"); + + time_sleep(0.2); + oc = t2_count; + time_sleep(2); + f = t2_count - oc; + CHECK(2, 9, f, 4000, 1, "callback"); + + r = get_PWM_range(pi, GPIO); + CHECK(2, 10, r, 255, 0, "get PWM range"); + + rr = get_PWM_real_range(pi, GPIO); + CHECK(2, 11, rr, 200, 0, "get PWM real range"); + + set_PWM_range(pi, GPIO, 2000); + r = get_PWM_range(pi, GPIO); + CHECK(2, 12, r, 2000, 0, "set/get PWM range"); + + rr = get_PWM_real_range(pi, GPIO); + CHECK(2, 13, rr, 200, 0, "get PWM real range"); + + set_PWM_dutycycle(pi, GPIO, 0); + + callback_cancel(id); +} + +int t3_reset=1; +int t3_count=0; +uint32_t t3_tick=0; +float t3_on=0.0; +float t3_off=0.0; + +void t3cbf(int pi, unsigned gpio, unsigned level, uint32_t tick) +{ + uint32_t td; + +// printf("pi=%d g=%d l=%d t=%u\n", pi, gpio, level, tick); + if (t3_reset) + { + t3_count = 0; + t3_on = 0.0; + t3_off = 0.0; + t3_reset = 0; + } + else + { + td = tick - t3_tick; + + if (level == 0) t3_on += td; + else t3_off += td; + } + + t3_count ++; + t3_tick = tick; +} + +void t3(int pi) +{ + int pw[3]={500, 1500, 2500}; + int dc[4]={20, 40, 60, 80}; + + int f, rr, v; + float on, off; + + int t, id; + + printf("PWM/Servo pulse accuracy tests.\n"); + + id = callback(pi, GPIO, EITHER_EDGE, t3cbf); + + for (t=0; t<3; t++) + { + set_servo_pulsewidth(pi, GPIO, pw[t]); + v = get_servo_pulsewidth(pi, GPIO); + CHECK(3, t+t+1, v, pw[t], 0, "get servo pulsewidth"); + + time_sleep(1); + t3_reset = 1; + time_sleep(4); + on = t3_on; + off = t3_off; + CHECK(3, t+t+2, (1000.0*(on+off))/on, 20000000.0/pw[t], 1, + "set servo pulsewidth"); + } + + set_servo_pulsewidth(pi, GPIO, 0); + set_PWM_frequency(pi, GPIO, 1000); + f = get_PWM_frequency(pi, GPIO); + CHECK(3, 7, f, 1000, 0, "set/get PWM frequency"); + + rr = set_PWM_range(pi, GPIO, 100); + CHECK(3, 8, rr, 200, 0, "set PWM range"); + + for (t=0; t<4; t++) + { + set_PWM_dutycycle(pi, GPIO, dc[t]); + v = get_PWM_dutycycle(pi, GPIO); + CHECK(3, t+t+9, v, dc[t], 0, "get PWM dutycycle"); + + time_sleep(1); + t3_reset = 1; + time_sleep(2); + on = t3_on; + off = t3_off; + CHECK(3, t+t+10, (1000.0*on)/(on+off), 10.0*dc[t], 1, + "set PWM dutycycle"); + } + + set_PWM_dutycycle(pi, GPIO, 0); + + callback_cancel(id); +} + +void t4(int pi) +{ + int h, e, f, n, s, b, l, seq_ok, toggle_ok; + gpioReport_t r; + char p[32]; + + printf("Pipe notification tests.\n"); + + set_PWM_frequency(pi, GPIO, 0); + set_PWM_dutycycle(pi, GPIO, 0); + set_PWM_range(pi, GPIO, 100); + + h = notify_open(pi); + + sprintf(p, "/dev/pigpio%d", h); + f = open(p, O_RDONLY); + + e = notify_begin(pi, h, (1< 0) text[c] = 0; /* null terminate string */ + CHECK(5, 11, strcmp(TEXT, text), 0, 0, "wave tx busy, serial read"); + + e = bb_serial_read_close(pi, GPIO); + CHECK(5, 12, e, 0, 0, "serial read close"); + + c = wave_get_micros(pi); + CHECK(5, 13, c, 6158148, 0, "wave get micros"); + + c = wave_get_high_micros(pi); + if (c > 6158148) c = 6158148; + CHECK(5, 14, c, 6158148, 0, "wave get high micros"); + + c = wave_get_max_micros(pi); + CHECK(5, 15, c, 1800000000, 0, "wave get max micros"); + + c = wave_get_pulses(pi); + CHECK(5, 16, c, 3405, 0, "wave get pulses"); + + c = wave_get_high_pulses(pi); + CHECK(5, 17, c, 3405, 0, "wave get high pulses"); + + c = wave_get_max_pulses(pi); + CHECK(5, 18, c, 12000, 0, "wave get max pulses"); + + c = wave_get_cbs(pi); + if (c < 6963) CHECK(5, 19, c, 6810, 0, "wave get cbs"); + else CHECK(5, 19, c, 7115, 0, "wave get cbs"); + + c = wave_get_high_cbs(pi); + if (c < 6963) CHECK(5, 20, c, 6810, 0, "wave get high cbs"); + else CHECK(5, 20, c, 7115, 0, "wave get high cbs"); + + c = wave_get_max_cbs(pi); + 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<= 0) text[b] = 0; + CHECK(10, 7, strcmp(TEXT, text), 0, 0, "serial read"); + + b = serial_read_byte(pi, h); + CHECK(10, 8, b, 0xAA, 0, "serial read byte"); + + b = serial_read_byte(pi, h); + CHECK(10, 9, b, 0x55, 0, "serial read byte"); + + b = serial_read_byte(pi, h); + CHECK(10, 10, b, 0x00, 0, "serial read byte"); + + b = serial_read_byte(pi, h); + CHECK(10, 11, b, 0xFF, 0, "serial read byte"); + + b = serial_data_available(pi, h); + CHECK(10, 12, b, 0, 0, "serial data availabe"); + + e = serial_close(pi, h); + CHECK(10, 13, e, 0, 0, "serial close"); +} + +void tb(int pi) +{ + int h, e, b, len; + char *exp; + char buf[128]; + + printf("SMBus / I2C tests."); + + /* this test requires an ADXL345 on I2C bus 1 addr 0x53 */ + + h = i2c_open(pi, 1, 0x53, 0); + CHECK(11, 1, h, 0, 0, "i2c open"); + + e = i2c_write_device(pi, h, "\x00", 1); /* move to known register */ + CHECK(11, 2, e, 0, 0, "i2c write device"); + + b = i2c_read_device(pi, h, buf, 1); + CHECK(11, 3, b, 1, 0, "i2c read device"); + CHECK(11, 4, buf[0], 0xE5, 0, "i2c read device"); + + b = i2c_read_byte(pi, h); + CHECK(11, 5, b, 0xE5, 0, "i2c read byte"); + + b = i2c_read_byte_data(pi, h, 0); + CHECK(11, 6, b, 0xE5, 0, "i2c read byte data"); + + b = i2c_read_byte_data(pi, h, 48); + CHECK(11, 7, b, 2, 0, "i2c read byte data"); + + exp = "\x1D[aBcDeFgHjKM]"; + len = strlen(exp); + + e = i2c_write_device(pi, h, exp, len); + CHECK(11, 8, e, 0, 0, "i2c write device"); + + e = i2c_write_device(pi, h, "\x1D", 1); + b = i2c_read_device(pi, h, buf, len-1); + CHECK(11, 9, b, len-1, 0, "i2c read device"); + CHECK(11, 10, strncmp(buf, exp+1, len-1), 0, 0, "i2c read device"); + + if (strncmp(buf, exp+1, len-1)) + printf("got [%.*s] expected [%.*s]\n", len-1, buf, len-1, exp+1); + + e = i2c_write_byte_data(pi, h, 0x1d, 0xAA); + CHECK(11, 11, e, 0, 0, "i2c write byte data"); + + b = i2c_read_byte_data(pi, h, 0x1d); + CHECK(11, 12, b, 0xAA, 0, "i2c read byte data"); + + e = i2c_write_byte_data(pi, h, 0x1d, 0x55); + CHECK(11, 13, e, 0, 0, "i2c write byte data"); + + b = i2c_read_byte_data(pi, h, 0x1d); + CHECK(11, 14, b, 0x55, 0, "i2c read byte data"); + + exp = "[1234567890#]"; + len = strlen(exp); + + e = i2c_write_block_data(pi, h, 0x1C, exp, len); + CHECK(11, 15, e, 0, 0, "i2c write block data"); + + e = i2c_write_device(pi, h, "\x1D", 1); + b = i2c_read_device(pi, h, buf, len); + CHECK(11, 16, b, len, 0, "i2c read device"); + CHECK(11, 17, strncmp(buf, exp, len), 0, 0, "i2c read device"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + b = i2c_read_i2c_block_data(pi, h, 0x1D, buf, len); + CHECK(11, 18, b, len, 0, "i2c read i2c block data"); + CHECK(11, 19, strncmp(buf, exp, len), 0, 0, "i2c read i2c block data"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + exp = "(-+=;:,<>!%)"; + len = strlen(exp); + + e = i2c_write_i2c_block_data(pi, h, 0x1D, exp, len); + CHECK(11, 20, e, 0, 0, "i2c write i2c block data"); + + b = i2c_read_i2c_block_data(pi, h, 0x1D, buf, len); + CHECK(11, 21, b, len, 0, "i2c read i2c block data"); + CHECK(11, 22, strncmp(buf, exp, len), 0, 0, "i2c read i2c block data"); + + if (strncmp(buf, exp, len)) + printf("got [%.*s] expected [%.*s]\n", len, buf, len, exp); + + e = i2c_close(pi, h); + CHECK(11, 23, e, 0, 0, "i2c close"); +} + +void tc(int pi) +{ + int h, x, b, e; + char buf[128]; + + printf("SPI tests."); + + /* this test requires a MCP3202 on SPI channel 1 */ + + h = spi_open(pi, 1, 50000, 0); + CHECK(12, 1, h, 0, 0, "spi open"); + + + for (x=0; x<5; x++) + { + sprintf(buf, "\x01\x80"); + b = spi_xfer(pi, h, buf, buf, 3); + CHECK(12, 2, b, 3, 0, "spi xfer"); + if (b == 3) + { + time_sleep(1.0); + printf("%d ", ((buf[1]&0x0F)*256)|buf[2]); + } + } + + e = spi_close(pi, h); + CHECK(12, 99, e, 0, 0, "spi close"); +} + + +int main(int argc, char *argv[]) +{ + int i, t, c, pi; + + char test[64]={0,}; + + if (argc > 1) + { + t = 0; + + for (i=0; i/dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 h /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 p /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 -a v /dev/pigpio +read -t 1 s /dev/pigpio +sleep 0.1 +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 w /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +echo "tick" >/dev/pigpio +read -t 1 t1 /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 w /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s /dev/pigpio +read -t 1 s

5F6aiVvkc6=aqWC$okg#~GuRy)el*cE+B z3iCd`Cj*}s2U|C`VCqoi7Qo(Ml);DZt^GPYEPgg)q8WaSwceBDo-^UCd(t#PR%ww| zrGXad_di$&CtFww_X?Q~T;aRl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uS^xZ^r38u^oS}UU}=Y8YB?iS3c858XO$_B%hG1 zCH${5IlbFz(RR$=?qDmSU4Z;WLoAgO;p^+0ntIcsehO59MEk$IY`pt4R$r*3=Kogv z-yWCxeDn8}vxoX0dXhGAOa1Xd+T`RUNGcUskqJt>?6@?(B@%Mmy-Y|L6c~sFH7H)C zjo$V|5XDVQq=C4`wQJFdiSTQaj~GLR?XT|`boJrkp_G)=nY>c~ED75Stf(8mfB)Xt zC>2K6^^q30rbLC7cZo)`({%Mom(&y4#{(4kDujMTK4u^sgM13 zSI0{1=h_DcRfx$2OW8#>8gOM~WXAp;AR^^8?L)w;ls)_DY1~#PM-L6Zqv`R%4mi!A zI#N}^c!SCu1kdwljgq?z3`XOnW;D#NO^sL!X*Md`-Q%cw8+Xq+@ygc!V$mwU!^mhe zUfMP_m9kR2@gQ^A;q>HKz-e`Ve*}zMSQOR{ zS3BE;UKCuh{O{T`4Lua=zwQwxMgOj_{)C^0XYb^2JxgJl`a?oOLQ+z#=dr7dqTuF_ zcciz4PxcLoFA4UY2_}QZ2pY*ULGRyd6&ajw!Amv({o6Aot@-XG3$&2a>WdI+uKbC# zw6yc*&qH}kjq3FOmIq#;$sR%klzh)_*P-`o{0b!{uTgtc>)(TC%6&VpudJ_A^~1BxItqTd@C{?{nkdtT~`2?&mF&2>P-0u2o~_{|6JxqAO16+T=o zIfskinaEcn7sJ}*9~c;zr&dsGU8q~j|L9RT?s<}e&V~B~f_dzE#`u3Ai=q3mv3J%D z_E)XSibBYZ>2H1nB*NI)$hNjNnyas~qgk{R;yK$uL0S8A;8jLluj3t>t19-&pPpg| zQcj}cpDUfW$b`vLLqrq_QrF{PRx ZdKsPD^s|<@^X2S1G7<_;K8xx5{vUv+4O;*J literal 0 HcmV?d00001 diff --git a/DOC/HTML/images/LDR-gnup-2.png b/DOC/HTML/images/LDR-gnup-2.png new file mode 100644 index 0000000000000000000000000000000000000000..44530965f27181a0d357ae1b7398e91dd1bda912 GIT binary patch literal 31410 zcmb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J}-x)6HoMHPxi`G+pRy4yxn3sJ8`fvqVIk~{VKsSH``BE`Gc*zlxl#~Qn2UKym z)xS=(3692z*jqJRDS-=4{p<4!aJ0IM*aVJy!7l^JS0AO-?q3pR67T`lB~4+-Mrg+ Gum2CWU|Svl literal 0 HcmV?d00001 diff --git a/DOC/HTML/images/LDR-photo.jpg b/DOC/HTML/images/LDR-photo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..95a63a3081090ae2d24be52b4fdbfed6b6cff3e0 GIT binary patch literal 109499 zcmeFZ1z1%<7dE=j;gBK?(jeW^-CfdMQitwCBOwSX(jiI-2-2W*+cYArprUl6l+t$} z1muhR-|zqLeV+f`=YF%9z28~0)|xeIV$YtvImaK5zX5oviYkf#1Ofq+!2>w{E*q@i z?`Q`ADk^LM1^@uq04@Xypn)hGjCdf%0k8RBB!Hj*5b%nO694c(ko8K! zI2Tb{c3`pM~`NqK$$|;@#F$~0XAbknMXdoA|M{}Wq zEdgRu5Q~Et6U4M2)&ns%D1j{N(sBjiWsnPLgf~dXJEdDefiS{T{oa=VfcTUSisX=i zbfhdYGJzOuDBvc@6Y-Y^NCxTTApJ8)PX)_W1Th{q06YLO9*7MSKLj{F<^lEqArQp? z9AK3&XiqqfkpYR2;S3*#o*}SWfF9uaTT~waY)^RP!Sgqu;W!3(2_j_w0d;}L15g@- zCjsd(04(Pvpn8ISpJ+bQc{(4R&qRujUao#tUT|6ixEI3F-Hn!qi?~NY^4EU^FkT`Qh+Gz-d-f> zkHFtdWEvT@kTddWICC`eigdzR{Aby4Fz<|pyhR`bvfCkja+-#qA(emuIg$NyfUxU= zLsSUZOY~_1=aO?>|IBxmP5`^1CD`pfK%LuQ`#lE@^9B1r4p`{7GebaTWV#4UpOQ`* z@1%*4_ZkS~Pa_EMu<&xTf|UzHsyE{(hdk8lfpA;#Ss~N^5Rl#DEPe-v=2?JWpd;&h zF;h&zH}DW+seNpBQkx_2^Z;LGoOcx^m8Hz z{u4T~+<(V+(VmMs|7Ym80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{HJtr*Lqf5n_Q2(NPFl7tBE0 z7b^E_3O1)VQ%2GD5BHEI$OEFal1IVhoo}(A3os`wR-AWbV?+Bl3!6TXDKJC#4mm7Q3jD|#$}=q=R_t9+_X_m@eRVs+^UyN4xxb-;VnOm0ug6%x@fS}B83o5 z%NroOShnUo+Zah}cIA{5#S-!(HgGUHS%7NmU$ny0Fcr@O#WM^RT9@IvsiEQpYyh~_ zyI54BUD`!+6`g7VJW=GL$K6z=v;7lqq`j|lQp@dLp@O(t-l3`7y6>|%i`R;$|p z+1$peE3g5Ow;j$!{gouTUtMp&B|7d3mI|JfB<3Aq3O literal 0 HcmV?d00001 diff --git a/DOC/HTML/images/LDR-wave-1.png b/DOC/HTML/images/LDR-wave-1.png new file mode 100644 index 0000000000000000000000000000000000000000..69bb43b5f58cb31127013818f2698fe8f4656bba GIT binary patch literal 4557 zcmds4i91wb`yM3*(b(4^5i0vwDr?A^vF{|iEZMRfRD&dhgoHH7jAd*^_BCrrmNAx* zUG`nJ{NAqb_x%&!nQPv6u5-?u^S;k>Klgn@C4;u2L1+~!#Sh3g^9YSi}FLZtWW%glwQrTJf#`LW96Qv9$Dp4!Pzk=$|I zG{k?~&m6a8Gu(q?G;nu@r z=O*KE@`tLBP{fNiHZ}E)r>JipU*MoEC@NZ&v+y9*ed`(5KsoljDRyoR5)l#E)%4M# zifHRhNT3tG4S~FUGKg~ZR8jHq>H2w9hYJpmzR0cuo%XFp!>p{vZO=~QC|r1%kY}NW z$;Q{ErKR)Kk*qA`#MO;PrIn2hjd-TmxVlgGroC^Pg8)kfs0aP=UT=?&rC|vZhCw|% z{~fyb?m>CE=sHG6&7W0xdwZ9bRkFmzVU>8~gEo7_8ilE-t_caf7vmFU(94ox?xBT5 z3dpKFQHJrbMy#I%r)uXZ;v3wIamIM7MpE-YlDpLNqulo1=&cVQKG;l7Oi4(Gnr)Jz z;#hH8rJI}dd}}XtqibraS()CgZ{e+L13VYLTfAv4=Hh~5Fb|n+3=HTJkRW7F584e0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JUe1Jhizj8Kr%-l5MU{i$>bFqFfHNSge^bC znQGUu`dYB-unawsR#cpxnc*_O0G`A=)o+Pg6EI|QfD71ynj(?0|2oV0t*wy7&dXln zpmOb8whj(HIoe(LV`W($a##U^W%3 zjo{=DTz6g~z*;aiHbx-Yw}=fxLqmc6R<5oJ&*ob{f0kllVeygzb+QLO{`Uc4bQFa% zN1>8?9Teo`9)Aro1sS=&?d0SHq?iAaX>t{gTWZv5c=LuHcLV%w;W7*#`0)Jszw2>g zcyOb}2kzDzs=<;1tXIye)7-l_W8iYlx!OGy2cE_PvbXjNc Q6BrPnrGZp0g;M1& literal 0 HcmV?d00001 diff --git a/DOC/HTML/images/LDR-wave-3.png b/DOC/HTML/images/LDR-wave-3.png new file mode 100644 index 0000000000000000000000000000000000000000..a2ca42a329555650350804a30c190c722dc3d944 GIT binary patch literal 4872 zcmd5=gZ0Rse)4v`v+Pz0nU6^4`UMnXVJKys9zlyrB9 z5;7Wu!RYtF_x&T@XP@2e^W6K~d(L^j=X<{A2CAzm(o(^xAP@+xvXZ92Jkx##t9V!}YmimJ^s1xrRe|;)mFI(?f`W>W{&b33N!*?zE<{%2$Z`2GhdFbZJeUa{fH_)$F z+xDEqQZ_9t+cpx}X1eYr_QB-^+8jnlMo_>Yi;PS%2;>dxMF`{}tiJ!}PoH1EWD$Ge z-R>;Q%S%sECArYY9!Mo+WlBT2ZTq8XTiWiZsH^)+EhB}2MRw~0vCYk#Qr>pv=9yVh zzQ+<9P503y49S-u-!{Jyj3;3KC8qg$+dO;|8=GBODawZJwxmOLb#*bHZdo(zAz2fM z-m0oDE)_*Z{5sVUA0Fon`tC18;qml3?cMDz#{>>?|F@4RAf{vMSD0md*d-*Eg9W7B zoSlV*&c>XB7#2qEpOKj<6yj-SV`K9i9Tgp|a!fkf-&PD~CL#i&ueV|HeyTn)dsb$Mao%fUb0ak{#;w2zmA^H-Lfni?C|R&Pr8 z4Ikp>NOc8zc^>Kxn>h0>7qQIM)tfzO4XoQ4Q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C3Q(;$jR z!n(4ZEapYzPZ_1Dk`dj(%d1Sd$Otx?l5L1bc!@v|78W)I zhJNdVHrCWg0I|DVsl*A&1{gO$mCCp$AW$rzqOPZxqgJ4-s>+ES8X4(0%^?BV;J5h% z;C;mr8UsUPFcnUVJ%CbOot>3}q;A52a2kkAjF11ZxLslgf&7vpoW^26XO$-H?Xf;p z4O&er48|qx8$i6GB9D;JU}tA=zB&c6mYRkJ^p0Qa>+1^(*8t0l+D#=yM7(kN-#wY0 zd88DOn3M#MZU>g9NP8auN&|U{>0!QlH7Y8Kow6~NL?Qtr`3);S*VRq6wcTQ8ZyX$? zTOkLpV8o%G6K_{Mr#m}W3U4b>LeIvx1Aw>v2@b5;tRAwG=2WA;iK~tBA0#(Ug#B2t zY_`G3kb!2-&!1^}-Tr}_)+ literal 0 HcmV?d00001 diff --git a/DOC/HTML/images/breadboard.jpg b/DOC/HTML/images/breadboard.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5d916f70e9b5815035b85516b8552a104d3cb6bf GIT binary patch literal 46953 zcmb4qbx<5l5bxm@AZUU^;BX1D+PdofdR<;I{@!cfcSsZ{|ngvN&I(({Xc+%gNOSM zu(1E#!2btWI0OWE_7&wG~+Wuc4!NDWKz#<@{q5%H2>wo;$4i5wOPbfSbDk3@x3d}#@2#82n*Z^b- z999(EFQRyCD)^LQMxWT7J`+#@RgD7@3g)QAog4a=XgD~zB&F0e0*gzUhPc6+$%W1H zi@)6yQ;Qn=2N!n!@h5=+!2A>c|0sa?AAcld7y!z@W@W5@;$h+c`2-0b0~zU`n*YRO z!6N_=u_=&nSVg~3s^GF2A>*-&IRzwqqAHlf2db(Wn>f1!CN|73{N@l3N-8Ys+o9%^ z0RL>fHho_Qe1L=bXFVJiKp1eR*{b^vFn?Gxo4=|$OmSJNz|+ZyQV4&j=1H=qP5dj{ z__4WABK;UWSmXybzWSKVvkX<4!pM+Ui=Myj`K-TUvY&;ew86}fN!>h?sLtMXCsnbM ztsoih&#@jWzk5B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