2013-12-12 11:27:22 +01:00
|
|
|
/*
|
|
|
|
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 <http://unlicense.org/>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PIGPIO_H
|
|
|
|
#define PIGPIO_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2014-01-12 22:31:59 +01:00
|
|
|
#include <pthread.h>
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2017-04-24 22:05:43 +02:00
|
|
|
#define PIGPIO_VERSION 62
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*TEXT
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
pigpio is a C library for the Raspberry which allows control of the GPIO.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
*Features*
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
o hardware timed PWM on any of GPIO 0-31
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
o hardware timed servo pulses on any of GPIO 0-31
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
o callbacks when any of GPIO 0-31 change state
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
o callbacks at timed intervals
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
o reading/writing all of the GPIO in a bank as one operation
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
o individually setting GPIO modes, reading and writing
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
o notifications when any of GPIO 0-31 change state
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
o the construction of output waveforms with microsecond timing
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
o rudimentary permission control over GPIO
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
o a simple interface to start and stop new threads
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
o I2C, SPI, and serial link wrappers
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
o creating and running scripts
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
*GPIO*
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
ALL GPIO are identified by their Broadcom number.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
*Credits*
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The PWM and servo pulses are timed using the DMA and PWM peripherals.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
This use was inspired by Richard Hirst's servoblaster kernel module.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
See [[https://github.com/richardghirst/PiBits/tree/master/ServoBlaster]]
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
*Usage*
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Include <pigpio.h> in your source files.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Assuming your source is in prog.c use the following command to build and
|
|
|
|
run the executable.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
gcc -Wall -pthread -o prog prog.c -lpigpio -lrt
|
2014-08-01 10:30:25 +02:00
|
|
|
sudo ./prog
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
For examples of usage see the C programs within the pigpio archive file.
|
|
|
|
|
|
|
|
*Notes*
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
All the functions which return an int return < 0 on error.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
[*gpioInitialise*] must be called before all other library functions
|
|
|
|
with the following exceptions:
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
. .
|
|
|
|
[*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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
TEXT*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*OVERVIEW
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
ESSENTIAL
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioInitialise Initialise library
|
|
|
|
gpioTerminate Stop library
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
BEGINNER
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetMode Set a GPIO mode
|
|
|
|
gpioGetMode Get a GPIO mode
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetPullUpDown Set/clear GPIO pull up/down resistor
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioRead Read a GPIO
|
|
|
|
gpioWrite Write a GPIO
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioPWM Start/stop PWM pulses on a GPIO
|
|
|
|
gpioGetPWMdutycycle Get dutycycle setting on a GPIO
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioServo Start/stop servo pulses on a GPIO
|
|
|
|
gpioGetServoPulsewidth Get pulsewidth setting on a GPIO
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioDelay Delay for a number of microseconds
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetAlertFunc Request a GPIO level change callback
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
gpioSetTimerFunc Request a regular timed callback
|
|
|
|
|
|
|
|
INTERMEDIATE
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioTrigger Send a trigger pulse to a GPIO.
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetWatchdog Set a watchdog on a GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetPWMrange Configure PWM range for a GPIO
|
|
|
|
gpioGetPWMrange Get configured PWM range for a GPIO
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetPWMfrequency Configure PWM frequency for a GPIO
|
|
|
|
gpioGetPWMfrequency Get configured PWM frequency for a GPIO
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioRead_Bits_0_31 Read all GPIO in bank 1
|
|
|
|
gpioRead_Bits_32_53 Read all GPIO in bank 2
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioWrite_Bits_0_31_Clear Clear selected GPIO in bank 1
|
|
|
|
gpioWrite_Bits_32_53_Clear Clear selected GPIO in bank 2
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioWrite_Bits_0_31_Set Set selected GPIO in bank 1
|
|
|
|
gpioWrite_Bits_32_53_Set Set selected GPIO in bank 2
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioStartThread Start a new thread
|
|
|
|
gpioStopThread Stop a previously started thread
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
ADVANCED
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioGetPWMrealRange Get underlying PWM range for a GPIO
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetAlertFuncEx Request a GPIO change callback, extended
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetISRFunc Request a GPIO interrupt callback
|
|
|
|
gpioSetISRFuncEx Request a GPIO interrupt callback, extended
|
2015-10-02 09:23:02 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioSetSignalFunc Request a signal callback
|
|
|
|
gpioSetSignalFuncEx Request a signal callback, extended
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSetGetSamplesFunc Requests a GPIO samples callback
|
|
|
|
gpioSetGetSamplesFuncEx Requests a GPIO samples callback, extended
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioSetTimerFuncEx Request a regular timed callback, extended
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioNotifyOpen Request a notification handle
|
2015-11-22 11:49:55 +01:00
|
|
|
gpioNotifyOpenWithSize Request a notification handle with sized pipe
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioNotifyBegin Start notifications for selected GPIO
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioNotifyPause Pause notifications
|
|
|
|
gpioNotifyClose Close a notification
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSerialReadOpen Opens a GPIO for bit bang serial reads
|
2015-08-29 15:06:27 +02:00
|
|
|
gpioSerialReadInvert Configures normal/inverted for serial reads
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioSerialRead Reads bit bang serial data from a GPIO
|
|
|
|
gpioSerialReadClose Closes a GPIO for bit bang serial reads
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioHardwareClock Start hardware clock on supported GPIO
|
|
|
|
gpioHardwarePWM Start hardware PWM on supported GPIO
|
2014-12-17 23:31:17 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioGlitchFilter Set a glitch filter on a GPIO
|
|
|
|
gpioNoiseFilter Set a noise filter on a GPIO
|
2015-10-28 12:06:53 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioGetPad Gets a pads drive strength
|
|
|
|
gpioSetPad Sets a pads drive strength
|
|
|
|
|
|
|
|
shell Executes a shell command
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
SCRIPTS
|
|
|
|
|
|
|
|
gpioStoreScript Store a script
|
|
|
|
gpioRunScript Run a stored script
|
|
|
|
gpioScriptStatus Get script status and parameters
|
|
|
|
gpioStopScript Stop a running script
|
|
|
|
gpioDeleteScript Delete a stored script
|
|
|
|
|
|
|
|
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
|
2015-07-24 22:17:29 +02:00
|
|
|
gpioWaveDelete Deletes a waveform
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
gpioWaveTxSend Transmits a waveform
|
2015-06-18 12:46:46 +02:00
|
|
|
|
|
|
|
gpioWaveChain Transmits a chain of waveforms
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioWaveTxAt Returns the current transmitting waveform
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioWaveTxBusy Checks to see if the waveform has ended
|
|
|
|
gpioWaveTxStop Aborts the current waveform
|
|
|
|
|
|
|
|
gpioWaveGetMicros Length in microseconds 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
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
gpioWaveGetCbs Length in control blocks of the current waveform
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioWaveGetHighCbs Length of longest waveform so far
|
2015-02-25 21:34:52 +01:00
|
|
|
gpioWaveGetMaxCbs Absolute maximum allowed control blocks
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
I2C
|
|
|
|
|
|
|
|
i2cOpen Opens an I2C device
|
|
|
|
i2cClose Closes an I2C device
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
i2cWriteQuick SMBus write quick
|
|
|
|
i2cWriteByte SMBus write byte
|
|
|
|
i2cReadByte SMBus read byte
|
|
|
|
i2cWriteByteData SMBus write byte data
|
|
|
|
i2cWriteWordData SMBus write word data
|
|
|
|
i2cReadByteData SMBus read byte data
|
|
|
|
i2cReadWordData SMBus read word data
|
|
|
|
i2cProcessCall SMBus process call
|
|
|
|
i2cWriteBlockData SMBus write block data
|
|
|
|
i2cReadBlockData SMBus read block data
|
|
|
|
i2cBlockProcessCall SMBus block process call
|
|
|
|
|
|
|
|
i2cWriteI2CBlockData SMBus write I2C block data
|
|
|
|
i2cReadI2CBlockData SMBus read I2C block data
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
i2cReadDevice Reads the raw I2C device
|
|
|
|
i2cWriteDevice Writes the raw I2C device
|
|
|
|
|
|
|
|
i2cSwitchCombined Sets or clears the combined flag
|
|
|
|
|
|
|
|
i2cSegments Performs multiple I2C transactions
|
|
|
|
|
|
|
|
i2cZip Performs multiple I2C transactions
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
bbI2COpen Opens GPIO for bit banging I2C
|
|
|
|
bbI2CClose Closes GPIO for bit banging I2C
|
2015-05-17 13:36:40 +02:00
|
|
|
bbI2CZip Performs multiple bit banged I2C transactions
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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
|
|
|
|
|
2016-08-06 12:18:17 +02:00
|
|
|
bbSPIOpen Opens GPIO for bit banging SPI
|
|
|
|
bbSPIClose Closes GPIO for bit banging SPI
|
|
|
|
bbSPIXfer Performs multiple bit banged SPI transactions
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
I2C/SPI_SLAVE
|
|
|
|
|
|
|
|
bscXfer I2C/SPI as slave transfer
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
SERIAL
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
serOpen Opens a serial device
|
2014-06-12 19:31:00 +02:00
|
|
|
serClose Closes a serial device
|
|
|
|
|
|
|
|
serReadByte Reads a byte from a serial device
|
2016-07-10 22:29:14 +02:00
|
|
|
serWriteByte Writes a byte to a serial device
|
2014-06-12 19:31:00 +02:00
|
|
|
serRead Reads bytes from a serial device
|
2016-07-10 22:29:14 +02:00
|
|
|
serWrite Writes bytes to a serial device
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
serDataAvailable Returns number of bytes ready to be read
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
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
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
EVENTS
|
|
|
|
|
|
|
|
eventMonitor Sets the events to monitor
|
|
|
|
eventSetFunc Request an event callback
|
|
|
|
eventSetFuncEx Request an event callback, extended
|
|
|
|
eventTrigger Trigger an event
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
CONFIGURATION
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioCfgBufferSize Configure the GPIO sample buffer size
|
|
|
|
gpioCfgClock Configure the GPIO sample rate
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioCfgDMAchannel Configure the DMA channel (DEPRECATED)
|
|
|
|
gpioCfgDMAchannels Configure the DMA channels
|
2016-03-01 22:41:36 +01:00
|
|
|
gpioCfgPermissions Configure the GPIO access permissions
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioCfgInterfaces Configure user interfaces
|
|
|
|
gpioCfgSocketPort Configure socket port
|
2015-02-25 21:34:52 +01:00
|
|
|
gpioCfgMemAlloc Configure DMA memory allocation mode
|
2016-09-22 15:12:26 +02:00
|
|
|
gpioCfgNetAddr Configure allowed network addresses
|
2015-02-25 21:34:52 +01:00
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
gpioCfgInternals Configure miscellaneous internals (DEPRECATED)
|
|
|
|
gpioCfgGetInternals Get internal configuration settings
|
|
|
|
gpioCfgSetInternals Set internal configuration settings
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
CUSTOM
|
|
|
|
|
|
|
|
gpioCustom1 User custom function 1
|
|
|
|
gpioCustom2 User custom function 2
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
UTILITIES
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
EXPERT
|
|
|
|
|
|
|
|
rawWaveAddSPI Not intended for general use
|
|
|
|
rawWaveAddGeneric Not intended for general use
|
2014-12-17 23:31:17 +01:00
|
|
|
rawWaveCB Not intended for general use
|
|
|
|
rawWaveCBAdr Not intended for general use
|
2016-09-22 15:12:26 +02:00
|
|
|
rawWaveGetOOL Not intended for general use
|
|
|
|
rawWaveSetOOL Not intended for general use
|
2014-06-12 19:31:00 +02:00
|
|
|
rawWaveGetOut Not intended for general use
|
|
|
|
rawWaveSetOut Not intended for general use
|
|
|
|
rawWaveGetIn Not intended for general use
|
|
|
|
rawWaveSetIn Not intended for general use
|
2014-09-09 23:58:39 +02:00
|
|
|
rawWaveInfo Not intended for general use
|
2014-06-12 19:31:00 +02:00
|
|
|
rawDumpWave Not intended for general use
|
|
|
|
rawDumpScript Not intended for general use
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
OVERVIEW*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2015-03-02 23:38:55 +01:00
|
|
|
#define PI_I2C_COMBINED "/sys/module/i2c_bcm2708/parameters/combined"
|
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-03-13 16:50:23 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-23 09:58:59 +02:00
|
|
|
uint16_t func;
|
|
|
|
uint16_t size;
|
2014-03-13 16:50:23 +01:00
|
|
|
} gpioHeader_t;
|
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-23 09:58:59 +02:00
|
|
|
size_t size;
|
|
|
|
void *ptr;
|
|
|
|
uint32_t data;
|
2014-01-21 20:04:59 +01:00
|
|
|
} gpioExtent_t;
|
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-23 09:58:59 +02:00
|
|
|
uint32_t tick;
|
|
|
|
uint32_t level;
|
2013-12-12 11:27:22 +01:00
|
|
|
} gpioSample_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-23 09:58:59 +02:00
|
|
|
uint16_t seqno;
|
|
|
|
uint16_t flags;
|
|
|
|
uint32_t tick;
|
|
|
|
uint32_t level;
|
2013-12-12 11:27:22 +01:00
|
|
|
} gpioReport_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-23 09:58:59 +02:00
|
|
|
uint32_t gpioOn;
|
|
|
|
uint32_t gpioOff;
|
|
|
|
uint32_t usDelay;
|
2013-12-12 11:27:22 +01:00
|
|
|
} gpioPulse_t;
|
|
|
|
|
2015-02-02 22:11:28 +01:00
|
|
|
#define WAVE_FLAG_READ 1
|
|
|
|
#define WAVE_FLAG_TICK 2
|
2014-03-13 16:50:23 +01:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2015-04-23 09:58:59 +02:00
|
|
|
uint32_t gpioOn;
|
|
|
|
uint32_t gpioOff;
|
|
|
|
uint32_t usDelay;
|
|
|
|
uint32_t flags;
|
2014-04-19 14:00:51 +02:00
|
|
|
} rawWave_t;
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The GPIO on and off settings climb up from the bottom (botOOL/numBOOL).
|
2015-07-24 22:17:29 +02:00
|
|
|
|
|
|
|
The level and tick read values are stored in descending locations
|
|
|
|
from the top (topOOL/numTOOL).
|
|
|
|
*/
|
|
|
|
|
2014-09-09 23:58:39 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint16_t botCB; /* first CB used by wave */
|
|
|
|
uint16_t topCB; /* last CB used by wave */
|
2015-07-24 22:17:29 +02:00
|
|
|
uint16_t botOOL; /* first bottom OOL used by wave */
|
2016-09-22 15:12:26 +02:00
|
|
|
/* botOOL to botOOL + numBOOL - 1 are in use */
|
2015-07-24 22:17:29 +02:00
|
|
|
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;
|
2014-09-09 23:58:39 +02:00
|
|
|
} rawWaveInfo_t;
|
|
|
|
|
2014-03-13 16:50:23 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2016-03-01 22:41:36 +01:00
|
|
|
int clk; /* GPIO for clock */
|
|
|
|
int mosi; /* GPIO for MOSI */
|
|
|
|
int miso; /* GPIO for MISO */
|
2015-04-23 09:58:59 +02:00
|
|
|
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 */
|
2014-04-19 13:19:29 +02:00
|
|
|
} rawSPI_t;
|
|
|
|
|
|
|
|
typedef struct { /* linux/arch/arm/mach-bcm2708/include/mach/dma.h */
|
2015-04-23 09:58:59 +02:00
|
|
|
uint32_t info;
|
|
|
|
uint32_t src;
|
|
|
|
uint32_t dst;
|
|
|
|
uint32_t length;
|
|
|
|
uint32_t stride;
|
|
|
|
uint32_t next;
|
|
|
|
uint32_t pad[2];
|
2014-04-19 13:19:29 +02:00
|
|
|
} rawCbs_t;
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2015-03-02 23:38:55 +01:00
|
|
|
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;
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
/* BSC FIFO size */
|
|
|
|
|
|
|
|
#define BSC_FIFO_SIZE 16
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
typedef void (*gpioAlertFunc_t) (int gpio,
|
2014-12-17 23:31:17 +01:00
|
|
|
int level,
|
|
|
|
uint32_t tick);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
typedef void (*gpioAlertFuncEx_t) (int gpio,
|
2014-12-17 23:31:17 +01:00
|
|
|
int level,
|
|
|
|
uint32_t tick,
|
|
|
|
void *userdata);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
typedef void (*eventFunc_t) (int event,
|
|
|
|
uint32_t tick);
|
|
|
|
|
|
|
|
typedef void (*eventFuncEx_t) (int event,
|
|
|
|
uint32_t tick,
|
|
|
|
void *userdata);
|
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
typedef void (*gpioISRFunc_t) (int gpio,
|
|
|
|
int level,
|
|
|
|
uint32_t tick);
|
|
|
|
|
|
|
|
typedef void (*gpioISRFuncEx_t) (int gpio,
|
|
|
|
int level,
|
|
|
|
uint32_t tick,
|
|
|
|
void *userdata);
|
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
typedef void (*gpioTimerFunc_t) (void);
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
typedef void (*gpioTimerFuncEx_t) (void *userdata);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
typedef void (*gpioSignalFunc_t) (int signum);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
typedef void (*gpioSignalFuncEx_t) (int signum,
|
2014-12-17 23:31:17 +01:00
|
|
|
void *userdata);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
typedef void (*gpioGetSamplesFunc_t) (const gpioSample_t *samples,
|
2014-12-17 23:31:17 +01:00
|
|
|
int numSamples);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
typedef void (*gpioGetSamplesFuncEx_t) (const gpioSample_t *samples,
|
2014-12-17 23:31:17 +01:00
|
|
|
int numSamples,
|
|
|
|
void *userdata);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-01-21 20:04:59 +01:00
|
|
|
typedef void *(gpioThreadFunc_t) (void *);
|
2014-01-12 22:31:59 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/* 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
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
/* level: only reported for GPIO time-out, see gpioSetWatchdog */
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
#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
|
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
/* hardware PWM */
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
#define PI_HW_PWM_MIN_FREQ 1
|
|
|
|
#define PI_HW_PWM_MAX_FREQ 125000000
|
|
|
|
#define PI_HW_PWM_RANGE 1000000
|
2014-12-17 23:31:17 +01:00
|
|
|
|
|
|
|
/* hardware clock */
|
|
|
|
|
|
|
|
#define PI_HW_CLK_MIN_FREQ 4689
|
|
|
|
#define PI_HW_CLK_MAX_FREQ 250000000
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_NOTIFY_SLOTS 32
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
#define PI_NTFY_FLAGS_EVENT (1 <<7)
|
2015-04-23 09:58:59 +02:00
|
|
|
#define PI_NTFY_FLAGS_ALIVE (1 <<6)
|
2014-08-01 10:30:25 +02:00
|
|
|
#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)
|
2014-12-17 23:31:17 +01:00
|
|
|
#define PI_WAVE_MAX_CHARS (PI_WAVE_BLOCKS * 300)
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
#define PI_BB_I2C_MIN_BAUD 50
|
|
|
|
#define PI_BB_I2C_MAX_BAUD 500000
|
|
|
|
|
2016-08-06 12:18:17 +02:00
|
|
|
#define PI_BB_SPI_MIN_BAUD 50
|
2016-08-06 12:53:23 +02:00
|
|
|
#define PI_BB_SPI_MAX_BAUD 250000
|
2016-08-06 12:18:17 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
#define PI_BB_SER_MIN_BAUD 50
|
|
|
|
#define PI_BB_SER_MAX_BAUD 250000
|
|
|
|
|
2015-08-29 15:06:27 +02:00
|
|
|
#define PI_BB_SER_NORMAL 0
|
|
|
|
#define PI_BB_SER_INVERT 1
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
#define PI_WAVE_MIN_BAUD 50
|
|
|
|
#define PI_WAVE_MAX_BAUD 1000000
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
#define PI_SPI_MIN_BAUD 32000
|
|
|
|
#define PI_SPI_MAX_BAUD 125000000
|
2014-12-17 23:31:17 +01:00
|
|
|
|
|
|
|
#define PI_MIN_WAVE_DATABITS 1
|
|
|
|
#define PI_MAX_WAVE_DATABITS 32
|
|
|
|
|
|
|
|
#define PI_MIN_WAVE_HALFSTOPBITS 2
|
|
|
|
#define PI_MAX_WAVE_HALFSTOPBITS 8
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
#define PI_WAVE_MAX_MICROS (30 * 60 * 1000000) /* half an hour */
|
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
#define PI_MAX_WAVES 250
|
|
|
|
|
|
|
|
#define PI_MAX_WAVE_CYCLES 65535
|
|
|
|
#define PI_MAX_WAVE_DELAY 65535
|
|
|
|
|
|
|
|
#define PI_WAVE_COUNT_PAGES 10
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/* wave tx mode */
|
|
|
|
|
2016-02-18 22:51:10 +01:00
|
|
|
#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
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
/* 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. */
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
/* Files, I2C, SPI, SER */
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2017-02-19 12:28:15 +01:00
|
|
|
#define PI_FILE_SLOTS 16
|
|
|
|
#define PI_I2C_SLOTS 64
|
|
|
|
#define PI_SPI_SLOTS 32
|
|
|
|
#define PI_SER_SLOTS 16
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
#define PI_MAX_I2C_ADDR 0x7F
|
2014-09-03 20:52:48 +02:00
|
|
|
|
|
|
|
#define PI_NUM_AUX_SPI_CHANNEL 3
|
|
|
|
#define PI_NUM_STD_SPI_CHANNEL 2
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-11-20 16:36:16 +01:00
|
|
|
#define PI_MAX_I2C_DEVICE_COUNT (1<<16)
|
|
|
|
#define PI_MAX_SPI_DEVICE_COUNT (1<<16)
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
/* max pi_i2c_msg_t per transaction */
|
|
|
|
|
|
|
|
#define PI_I2C_RDRW_IOCTL_MAX_MSGS 42
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
/* flags for i2cTransaction, pi_i2c_msg_t */
|
2015-04-23 09:58:59 +02:00
|
|
|
|
|
|
|
#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 */
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
/* bbI2CZip and i2cZip commands */
|
2015-04-23 09:58:59 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
#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
|
2015-04-23 09:58:59 +02:00
|
|
|
|
|
|
|
/* SPI */
|
|
|
|
|
2014-09-03 20:52:48 +02:00
|
|
|
#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))
|
2014-08-12 19:47:26 +02:00
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
/* 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
|
|
|
|
|
2014-08-12 19:47:26 +02:00
|
|
|
/* Longest busy delay */
|
|
|
|
|
|
|
|
#define PI_MAX_BUSY_DELAY 100
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/* 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-14 */
|
|
|
|
|
|
|
|
#define PI_MIN_DMA_CHANNEL 0
|
|
|
|
#define PI_MAX_DMA_CHANNEL 14
|
|
|
|
|
|
|
|
/* port */
|
|
|
|
|
|
|
|
#define PI_MIN_SOCKET_PORT 1024
|
|
|
|
#define PI_MAX_SOCKET_PORT 32000
|
|
|
|
|
|
|
|
|
|
|
|
/* ifFlags: */
|
|
|
|
|
2015-12-22 17:36:17 +01:00
|
|
|
#define PI_DISABLE_FIFO_IF 1
|
|
|
|
#define PI_DISABLE_SOCK_IF 2
|
|
|
|
#define PI_LOCALHOST_SOCK_IF 4
|
2017-04-25 13:50:01 +02:00
|
|
|
#define PI_DISABLE_ALERT 8
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
/* memAllocMode */
|
|
|
|
|
|
|
|
#define PI_MEM_ALLOC_AUTO 0
|
|
|
|
#define PI_MEM_ALLOC_PAGEMAP 1
|
|
|
|
#define PI_MEM_ALLOC_MAILBOX 2
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-10-28 12:06:53 +01:00
|
|
|
/* filters */
|
|
|
|
|
|
|
|
#define PI_MAX_STEADY 300000
|
|
|
|
#define PI_MAX_ACTIVE 1000000
|
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
/* 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_ILLEGAL_VAL (1<<10)
|
|
|
|
|
|
|
|
/* gpioISR */
|
|
|
|
|
|
|
|
#define RISING_EDGE 0
|
|
|
|
#define FALLING_EDGE 1
|
|
|
|
#define EITHER_EDGE 2
|
|
|
|
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
/* 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
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
/* Allowed socket connect addresses */
|
|
|
|
|
|
|
|
#define MAX_CONNECT_ADDRESSES 256
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
/* events */
|
|
|
|
|
|
|
|
#define PI_MAX_EVENT 31
|
|
|
|
|
|
|
|
/* Event auto generated on BSC slave activity */
|
|
|
|
|
|
|
|
#define PI_EVENT_BSC 31
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioInitialise(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Initialises the library.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the pigpio version number if OK, otherwise PI_INIT_FAILED.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
gpioInitialise must be called before using the other library functions
|
|
|
|
with the following exceptions:
|
|
|
|
|
|
|
|
. .
|
|
|
|
[*gpioCfg**]
|
|
|
|
[*gpioVersion*]
|
|
|
|
[*gpioHardwareRevision*]
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
if (gpioInitialise() < 0)
|
|
|
|
{
|
|
|
|
// pigpio initialisation failed.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// pigpio initialised okay.
|
|
|
|
}
|
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
void gpioTerminate(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Terminates the library.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns nothing.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Call before program exit.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
This function resets the used DMA channels, releases memory, and
|
2014-06-12 19:31:00 +02:00
|
|
|
terminates any running threads.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
gpioTerminate();
|
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetMode(unsigned gpio, unsigned mode);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets the GPIO mode, typically input or output.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
gpio: 0-53
|
|
|
|
mode: 0-7
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_MODE.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Arduino style: pinMode.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioSetMode(17, PI_INPUT); // Set GPIO17 as input.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioSetMode(18, PI_OUTPUT); // Set GPIO18 as output.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioSetMode(22,PI_ALT0); // Set GPIO22 to alternative mode 0.
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioGetMode(unsigned gpio);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Gets the GPIO mode.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
gpio: 0-53
|
|
|
|
. .
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
|
|
|
if (gpioGetMode(17) != PI_ALT0)
|
|
|
|
{
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioSetMode(17, PI_ALT0); // set GPIO17 to ALT0
|
2014-06-12 19:31:00 +02:00
|
|
|
}
|
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetPullUpDown(unsigned gpio, unsigned pud);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets or clears resistor pull ups or downs on the GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
gpio: 0-53
|
|
|
|
pud: 0-2
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_PUD.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioSetPullUpDown(17, PI_PUD_UP); // Sets a pull-up.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioSetPullUpDown(18, PI_PUD_DOWN); // Sets a pull-down.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioSetPullUpDown(23, PI_PUD_OFF); // Clear any pull-ups/downs.
|
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioRead (unsigned gpio);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Reads the GPIO level, on or off.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
gpio: 0-53
|
|
|
|
. .
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Arduino style: digitalRead.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2016-07-10 22:29:14 +02:00
|
|
|
printf("GPIO24 is level %d", gpioRead(24));
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioWrite(unsigned gpio, unsigned level);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets the GPIO level, on or off.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
gpio: 0-53
|
2016-05-31 19:44:12 +02:00
|
|
|
level: 0-1
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If PWM or servo pulses are active on the GPIO they are switched off.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Arduino style: digitalWrite
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioWrite(24, 1); // Set GPIO24 high.
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioPWM(unsigned user_gpio, unsigned dutycycle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on).
|
2014-06-12 19:31:00 +02:00
|
|
|
Range defaults to 255.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
dutycycle: 0-range
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYCYCLE.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Arduino style: analogWrite
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
This and the servo functionality use the DMA and PWM or PCM peripherals
|
2014-11-20 16:36:16 +01:00
|
|
|
to control and schedule the pulse lengths and dutycycles.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The [*gpioSetPWMrange*] function may be used to change the default
|
|
|
|
range of 255.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioPWM(17, 255); // Sets GPIO17 full on.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioPWM(18, 128); // Sets GPIO18 half on.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioPWM(23, 0); // Sets GPIO23 full off.
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-11-20 16:36:16 +01:00
|
|
|
/*F*/
|
|
|
|
int gpioGetPWMdutycycle(unsigned user_gpio);
|
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the PWM dutycycle setting for the GPIO.
|
2014-11-20 16:36:16 +01:00
|
|
|
|
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
. .
|
|
|
|
|
|
|
|
Returns between 0 (off) and range (fully on) if OK, otherwise
|
|
|
|
PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
|
|
|
|
|
2014-12-24 23:12:21 +01:00
|
|
|
For normal PWM the dutycycle will be out of the defined range
|
2016-03-01 22:41:36 +01:00
|
|
|
for the GPIO (see [*gpioGetPWMrange*]).
|
2015-02-25 21:34:52 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If a hardware clock is active on the GPIO the reported dutycycle
|
2015-02-25 21:34:52 +01:00
|
|
|
will be 500000 (500k) out of 1000000 (1M).
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If hardware PWM is active on the GPIO the reported dutycycle
|
2015-02-25 21:34:52 +01:00
|
|
|
will be out of a 1000000 (1M).
|
2014-12-24 23:12:21 +01:00
|
|
|
|
|
|
|
Normal PWM range defaults to 255.
|
2014-11-20 16:36:16 +01:00
|
|
|
D*/
|
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetPWMrange(unsigned user_gpio, unsigned range);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Selects the dutycycle range to be used for the GPIO. Subsequent calls
|
2014-06-12 19:31:00 +02:00
|
|
|
to gpioPWM will use a dutycycle between 0 (off) and range (fully on).
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
range: 25-40000
|
|
|
|
. .
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the real range for the given GPIO's frequency if OK,
|
2014-06-12 19:31:00 +02:00
|
|
|
otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If PWM is currently active on the GPIO its dutycycle will be scaled
|
2014-06-12 19:31:00 +02:00
|
|
|
to reflect the new range.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The real range, the number of steps between fully off and fully
|
|
|
|
on for each frequency, is given in the following table.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
25, 50, 100, 125, 200, 250, 400, 500, 625,
|
|
|
|
800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The real value set by [*gpioPWM*] is (dutycycle * real range) / range.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioSetPWMrange(24, 2000); // Now 2000 is fully on
|
|
|
|
// 1000 is half on
|
|
|
|
// 500 is quarter on, etc.
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioGetPWMrange(unsigned user_gpio);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the dutycycle range used for the GPIO if OK, otherwise
|
2014-06-12 19:31:00 +02:00
|
|
|
PI_BAD_USER_GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
. .
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If a hardware clock or hardware PWM is active on the GPIO
|
2015-02-25 21:34:52 +01:00
|
|
|
the reported range will be 1000000 (1M).
|
2014-12-24 23:12:21 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
r = gpioGetPWMrange(23);
|
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioGetPWMrealRange(unsigned user_gpio);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the real range used for the GPIO if OK, otherwise
|
2014-06-12 19:31:00 +02:00
|
|
|
PI_BAD_USER_GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
. .
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If a hardware clock is active on the GPIO the reported real
|
2015-02-25 21:34:52 +01:00
|
|
|
range will be 1000000 (1M).
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If hardware PWM is active on the GPIO the reported real range
|
2015-02-25 21:34:52 +01:00
|
|
|
will be approximately 250M divided by the set PWM frequency.
|
2014-12-24 23:12:21 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
rr = gpioGetPWMrealRange(17);
|
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets the frequency in hertz to be used for the GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
frequency: >=0
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the numerically closest frequency if OK, otherwise
|
|
|
|
PI_BAD_USER_GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
If PWM is currently active on the GPIO it will be
|
|
|
|
switched off and then back on at the new frequency.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
Each GPIO can be independently set to one of 18 different PWM
|
2014-06-12 19:31:00 +02:00
|
|
|
frequencies.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
The selectable frequencies depend upon the sample rate which
|
|
|
|
may be 1, 2, 4, 5, 8, or 10 microseconds (default 5).
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The frequencies for each sample rate are:
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
Hertz
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
|
2014-06-12 19:31:00 +02:00
|
|
|
1250 1000 800 500 400 250 200 100 50
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
2: 20000 10000 5000 4000 2500 2000 1250 1000 800
|
2014-06-12 19:31:00 +02:00
|
|
|
625 500 400 250 200 125 100 50 25
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
4: 10000 5000 2500 2000 1250 1000 625 500 400
|
2014-06-12 19:31:00 +02:00
|
|
|
313 250 200 125 100 63 50 25 13
|
2013-12-12 11:27:22 +01:00
|
|
|
sample
|
|
|
|
rate
|
|
|
|
(us) 5: 8000 4000 2000 1600 1000 800 500 400 320
|
2014-06-12 19:31:00 +02:00
|
|
|
250 200 160 100 80 50 40 20 10
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
8: 5000 2500 1250 1000 625 500 313 250 200
|
2014-06-12 19:31:00 +02:00
|
|
|
156 125 100 63 50 31 25 13 6
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
10: 4000 2000 1000 800 500 400 250 200 160
|
|
|
|
125 100 80 50 40 25 20 10 5
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioSetPWMfrequency(24, 500); // Set GPIO24 to 500Hz.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
gpioSetPWMfrequency(25, 100000); // Set GPIO25 to highest frequency.
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioGetPWMfrequency(unsigned user_gpio);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the frequency (in hertz) used for the GPIO if OK, otherwise
|
2014-06-12 19:31:00 +02:00
|
|
|
PI_BAD_USER_GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
. .
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
For normal PWM the frequency will be that defined for the GPIO by
|
2015-02-25 21:34:52 +01:00
|
|
|
[*gpioSetPWMfrequency*].
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If a hardware clock is active on the GPIO the reported frequency
|
2015-02-25 21:34:52 +01:00
|
|
|
will be that set by [*gpioHardwareClock*].
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If hardware PWM is active on the GPIO the reported frequency
|
2014-12-24 23:12:21 +01:00
|
|
|
will be that set by [*gpioHardwarePWM*].
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
2016-07-10 22:29:14 +02:00
|
|
|
f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23.
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioServo(unsigned user_gpio, unsigned pulsewidth);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to
|
2014-06-12 19:31:00 +02:00
|
|
|
2500 (most clockwise).
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
pulsewidth: 0, 500-2500
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_PULSEWIDTH.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The following causes an on pulse of 1500 microseconds duration to be
|
2016-03-01 22:41:36 +01:00
|
|
|
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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
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.
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
OTHER UPDATE RATES:
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
This function updates servos at 50Hz. If you wish to use a different
|
|
|
|
update frequency you will have to use the PWM functions.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
PWM Hz 50 100 200 400 500
|
|
|
|
1E6/Hz 20000 10000 5000 2500 2000
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Firstly set the desired PWM frequency using [*gpioSetPWMfrequency*].
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Then set the PWM range using [*gpioSetPWMrange*] to 1E6/frequency.
|
2014-06-12 19:31:00 +02:00
|
|
|
Doing this allows you to use units of microseconds when setting
|
2014-11-20 16:36:16 +01:00
|
|
|
the servo pulsewidth.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
E.g. If you want to update a servo connected to GPIO25 at 400Hz
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
gpioSetPWMfrequency(25, 400);
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioSetPWMrange(25, 2500);
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Thereafter use the PWM command to move the servo,
|
|
|
|
e.g. gpioPWM(25, 1500) will set a 1500 us pulse.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-11-20 16:36:16 +01:00
|
|
|
/*F*/
|
|
|
|
int gpioGetServoPulsewidth(unsigned user_gpio);
|
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the servo pulsewidth setting for the GPIO.
|
2014-11-20 16:36:16 +01:00
|
|
|
|
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
. .
|
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
Returns 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)
|
2014-11-20 16:36:16 +01:00
|
|
|
if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Registers a function to be called (a callback) when the specified
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO changes state.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
f: the callback function
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
One function may be registered per GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The function is passed the GPIO, the new level, and the tick.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The alert may be cancelled by passing NULL as the function.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The GPIO are sampled at a rate set when the library is started.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
If a value isn't specifically set the default of 5 us is used.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The number of samples per second is given in the following table.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
samples
|
|
|
|
per sec
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
1 1,000,000
|
|
|
|
2 500,000
|
|
|
|
sample 4 250,000
|
|
|
|
rate 5 200,000
|
|
|
|
(us) 8 125,000
|
|
|
|
10 100,000
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Level changes shorter than the sample rate may be missed.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The tick value is the time stamp of the sample in microseconds, see
|
2014-08-01 10:30:25 +02:00
|
|
|
[*gpioTick*] for more details.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
|
|
|
void aFunction(int gpio, int level, uint32_t tick)
|
|
|
|
{
|
2016-03-01 22:41:36 +01:00
|
|
|
printf("GPIO %d became %d at %d", gpio, level, tick);
|
2014-06-12 19:31:00 +02:00
|
|
|
}
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
// call aFunction whenever GPIO 4 changes state
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
gpioSetAlertFunc(4, aFunction);
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetAlertFuncEx(
|
|
|
|
unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Registers a function to be called (a callback) when the specified
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO changes state.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
f: the callback function
|
|
|
|
userdata: pointer to arbitrary user data
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
One function may be registered per GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The function is passed the GPIO, the new level, the tick, and
|
2014-06-12 19:31:00 +02:00
|
|
|
the userdata pointer.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Only one of [*gpioSetAlertFunc*] or [*gpioSetAlertFuncEx*] can be
|
2016-03-01 22:41:36 +01:00
|
|
|
registered per GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
See [*gpioSetAlertFunc*] for further details.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
/*F*/
|
|
|
|
int gpioSetISRFunc(
|
|
|
|
unsigned user_gpio, unsigned edge, int timeout, gpioISRFunc_t f);
|
|
|
|
/*D
|
|
|
|
Registers a function to be called (a callback) whenever the specified
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO interrupt occurs.
|
2015-10-02 09:23:02 +02:00
|
|
|
|
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
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_USER_GPIO, PI_BAD_EDGE,
|
|
|
|
or PI_BAD_ISR_INIT.
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
One function may be registered per GPIO.
|
2015-10-02 09:23:02 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The function is passed the GPIO, the current level, and the
|
2015-10-02 09:23:02 +02:00
|
|
|
current tick. The level will be PI_TIMEOUT if the optional
|
|
|
|
interrupt timeout expires.
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The underlying Linux sysfs GPIO interface is used to provide
|
2015-10-02 09:23:02 +02:00
|
|
|
the interrupt services.
|
|
|
|
|
|
|
|
The first time the function is called, with a non-NULL f, the
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO is exported, set to be an input, and set to interrupt
|
2015-10-02 09:23:02 +02:00
|
|
|
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
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO is unexported.
|
2015-10-02 09:23:02 +02:00
|
|
|
|
|
|
|
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 user_gpio,
|
|
|
|
unsigned edge,
|
|
|
|
int timeout,
|
|
|
|
gpioISRFuncEx_t f,
|
|
|
|
void *userdata);
|
|
|
|
/*D
|
|
|
|
Registers a function to be called (a callback) whenever the specified
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO interrupt occurs.
|
2015-10-02 09:23:02 +02:00
|
|
|
|
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
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_USER_GPIO, PI_BAD_EDGE,
|
|
|
|
or PI_BAD_ISR_INIT.
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The function is passed the GPIO, the current level, the
|
2015-10-02 09:23:02 +02:00
|
|
|
current tick, and the userdata pointer.
|
|
|
|
|
|
|
|
Only one of [*gpioSetISRFunc*] or [*gpioSetISRFuncEx*] can be
|
2016-03-01 22:41:36 +01:00
|
|
|
registered per GPIO.
|
2015-10-02 09:23:02 +02:00
|
|
|
|
|
|
|
See [*gpioSetISRFunc*] for further details.
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioNotifyOpen(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function requests a free notification handle.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns a handle greater than or equal to zero if OK,
|
|
|
|
otherwise PI_NO_HANDLE.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
A notification is a method for being notified of GPIO state changes
|
2014-06-12 19:31:00 +02:00
|
|
|
via a pipe or socket.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Socket notifications are returned to the socket which requested the
|
|
|
|
handle.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
h = gpioNotifyOpen();
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
if (h >= 0)
|
|
|
|
{
|
|
|
|
sprintf(str, "/dev/pigpio%d", h);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
fd = open(str, O_RDONLY);
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
if (fd >= 0)
|
|
|
|
{
|
|
|
|
// Okay.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Error.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Error.
|
|
|
|
}
|
|
|
|
...
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
2015-11-22 11:49:55 +01:00
|
|
|
/*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*/
|
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioNotifyBegin(unsigned handle, uint32_t bits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function starts notifications on a previously opened handle.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by [*gpioNotifyOpen*]
|
2016-03-01 22:41:36 +01:00
|
|
|
bits: a bit mask indicating the GPIO of interest
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The notification sends state changes for each GPIO whose corresponding
|
2014-06-12 19:31:00 +02:00
|
|
|
bit in bits is set.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Each notification occupies 12 bytes in the fifo and has the
|
|
|
|
following structure.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint16_t seqno;
|
|
|
|
uint16_t flags;
|
|
|
|
uint32_t tick;
|
|
|
|
uint32_t level;
|
|
|
|
} gpioReport_t;
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-08-30 10:40:42 +02:00
|
|
|
seqno: starts at 0 each time the handle is opened and then increments
|
2014-06-12 19:31:00 +02:00
|
|
|
by one for each report.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
flags: three flags are defined, PI_NTFY_FLAGS_WDOG,
|
|
|
|
PI_NTFY_FLAGS_ALIVE, and PI_NTFY_FLAGS_EVENT.
|
2016-07-10 22:29:14 +02:00
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
|
2016-07-10 22:29:14 +02:00
|
|
|
indicate a GPIO which has had a watchdog timeout.
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
If bit 6 is set (PI_NTFY_FLAGS_ALIVE) this indicates a keep alive
|
2016-07-10 22:29:14 +02:00
|
|
|
signal on the pipe/socket and is sent once a minute in the absence
|
|
|
|
of other notification activity.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
If bit 7 is set (PI_NTFY_FLAGS_EVENT) then bits 0-4 of the flags
|
|
|
|
indicate an event which has been triggered.
|
|
|
|
|
2015-08-30 10:40:42 +02:00
|
|
|
tick: the number of microseconds since system boot. It wraps around
|
|
|
|
after 1h12m.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
level: indicates the level of each GPIO. If bit 1<<x is set then
|
|
|
|
GPIO x is high.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2016-03-01 22:41:36 +01:00
|
|
|
// Start notifications for GPIO 1, 4, 6, 7, 10.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
// 1
|
|
|
|
// 0 76 4 1
|
2014-06-12 19:31:00 +02:00
|
|
|
// (1234 = 0x04D2 = 0b0000010011010010)
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioNotifyBegin(h, 1234);
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioNotifyPause(unsigned handle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function pauses notifications on a previously opened handle.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by [*gpioNotifyOpen*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Notifications for the handle are suspended until [*gpioNotifyBegin*]
|
2014-06-12 19:31:00 +02:00
|
|
|
is called again.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
gpioNotifyPause(h);
|
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioNotifyClose(unsigned handle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function stops notifications on a previously opened handle
|
|
|
|
and releases the handle for reuse.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by [*gpioNotifyOpen*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
...
|
|
|
|
gpioNotifyClose(h);
|
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveClear(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function clears all waveforms and any data added by calls to the
|
2014-08-01 10:30:25 +02:00
|
|
|
[*gpioWaveAdd**] functions.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
gpioWaveClear();
|
|
|
|
...
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioWaveAddNew(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
gpioWaveAddNew();
|
|
|
|
...
|
|
|
|
D*/
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function adds a number of pulses to the current waveform.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
numPulses: the number of pulses
|
|
|
|
pulses: an array of pulses
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the new total number of pulses in the current waveform if OK,
|
|
|
|
otherwise PI_TOO_MANY_PULSES.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The pulses are interleaved in time order within the existing waveform
|
|
|
|
(if any).
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Merging allows the waveform to be built in parts, that is the settings
|
2016-03-01 22:41:36 +01:00
|
|
|
for GPIO#1 can be added, and then GPIO#2 etc.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
If the added waveform is intended to start after or within the existing
|
|
|
|
waveform then the first pulse should consist of a delay.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
// Construct and send a 30 microsecond square wave.
|
|
|
|
|
|
|
|
gpioSetMode(gpio, PI_OUTPUT);
|
|
|
|
|
|
|
|
pulse[0].gpioOn = (1<<gpio);
|
|
|
|
pulse[0].gpioOff = 0;
|
|
|
|
pulse[0].usDelay = 15;
|
|
|
|
|
|
|
|
pulse[1].gpioOn = 0;
|
|
|
|
pulse[1].gpioOff = (1<<gpio);
|
|
|
|
pulse[1].usDelay = 15;
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioWaveAddNew();
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioWaveAddGeneric(2, pulse);
|
|
|
|
|
|
|
|
wave_id = gpioWaveCreate();
|
|
|
|
|
|
|
|
if (wave_id >= 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,
|
2015-05-17 13:36:40 +02:00
|
|
|
unsigned baud,
|
|
|
|
unsigned data_bits,
|
|
|
|
unsigned stop_bits,
|
2014-08-01 10:30:25 +02:00
|
|
|
unsigned offset,
|
2014-12-17 23:31:17 +01:00
|
|
|
unsigned numBytes,
|
2014-08-01 10:30:25 +02:00
|
|
|
char *str);
|
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function adds a waveform representing serial data to the
|
2014-12-17 23:31:17 +01:00
|
|
|
existing waveform (if any). The serial data starts offset
|
|
|
|
microseconds from the start of the waveform.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
2015-05-17 13:36:40 +02:00
|
|
|
baud: 50-1000000
|
|
|
|
data_bits: 1-32
|
|
|
|
stop_bits: 2-8
|
2016-05-31 19:44:12 +02:00
|
|
|
offset: >=0
|
|
|
|
numBytes: >=1
|
2014-08-01 10:30:25 +02:00
|
|
|
str: an array of chars (which may contain nulls)
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the new total number of pulses in the current waveform if OK,
|
2014-12-17 23:31:17 +01:00
|
|
|
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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
NOTES:
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
The serial data is formatted as one start bit, data_bits data bits, and
|
|
|
|
stop_bits/2 stop bits.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
It is legal to add serial data streams with different baud rates to
|
|
|
|
the same waveform.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
numBytes is the number of bytes of data in str.
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
The bytes required for each character depend upon data_bits.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
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.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
#define MSG_LEN 8
|
2013-12-12 11:32:49 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
int i;
|
|
|
|
char *str;
|
|
|
|
char data[MSG_LEN];
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
str = "Hello world!";
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
gpioWaveAddSerial(4, 9600, 8, 2, 0, strlen(str), str);
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
for (i=0; i<MSG_LEN; i++) data[i] = i;
|
|
|
|
|
|
|
|
// Data added is offset 1 second from the waveform start.
|
2014-12-17 23:31:17 +01:00
|
|
|
gpioWaveAddSerial(4, 9600, 8, 2, 1000000, MSG_LEN, data);
|
2014-08-01 10:30:25 +02:00
|
|
|
...
|
|
|
|
D*/
|
2014-04-19 13:19:29 +02:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioWaveCreate(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function creates a waveform from the data provided by the prior
|
2015-07-24 22:17:29 +02:00
|
|
|
calls to the [*gpioWaveAdd**] 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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The data provided by the [*gpioWaveAdd**] functions is consumed by this
|
2014-06-12 19:31:00 +02:00
|
|
|
function.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
As many waveforms may be created as there is space available. The
|
2014-08-01 10:30:25 +02:00
|
|
|
wave id is passed to [*gpioWaveTxSend*] to specify the waveform to transmit.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Normal usage would be
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Step 1. [*gpioWaveClear*] to clear all waveforms and added data.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Step 2. [*gpioWaveAdd**] calls to supply the waveform data.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Step 3. [*gpioWaveCreate*] to create the waveform and get a unique id
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Repeat steps 2 and 3 as needed.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Step 4. [*gpioWaveTxSend*] with the id of the waveform to transmit.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A waveform comprises one of more pulses. Each pulse consists of a
|
2014-08-01 10:30:25 +02:00
|
|
|
[*gpioPulse_t*] structure.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t gpioOn;
|
|
|
|
uint32_t gpioOff;
|
|
|
|
uint32_t usDelay;
|
|
|
|
} gpioPulse_t;
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The fields specify
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
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.
|
2014-06-12 19:31:00 +02:00
|
|
|
3) the delay in microseconds before the next pulse.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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).
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
When a waveform is started each pulse is executed in order with the
|
|
|
|
specified delay between the pulse and the next.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
|
|
|
|
PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioWaveDelete(unsigned wave_id);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2015-07-24 22:17:29 +02:00
|
|
|
This function deletes the waveform with id wave_id.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
wave_id: >=0, as returned by [*gpioWaveCreate*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Wave ids are allocated in order, 0, 1, 2, etc.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
|
|
|
int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode);
|
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function transmits the waveform with id wave_id. The mode
|
|
|
|
determines whether the waveform is sent once or cycles endlessly.
|
2016-02-18 22:51:10 +01:00
|
|
|
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.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
NOTE: Any hardware PWM started by [*gpioHardwarePWM*] will be cancelled.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
wave_id: >=0, as returned by [*gpioWaveCreate*]
|
2016-02-18 22:51:10 +01:00
|
|
|
wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
|
|
|
|
PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the number of DMA control blocks in the waveform if OK,
|
|
|
|
otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2015-06-18 12:46:46 +02:00
|
|
|
/*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
|
2015-07-24 22:17:29 +02:00
|
|
|
which contains an ordered list of [*wave_id*]s and optional command
|
2015-06-18 12:46:46 +02:00
|
|
|
codes and related data.
|
|
|
|
|
|
|
|
. .
|
|
|
|
buf: pointer to the wave_ids and optional command codes
|
|
|
|
bufSize: the number of bytes in buf
|
|
|
|
. .
|
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
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.
|
2015-06-18 12:46:46 +02:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
Each wave is transmitted in the order specified. A wave may
|
|
|
|
occur multiple times per chain.
|
2015-06-18 12:46:46 +02:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
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.
|
2015-06-18 12:46:46 +02:00
|
|
|
|
|
|
|
The following command codes are supported:
|
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
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.
|
2015-07-24 22:17:29 +02:00
|
|
|
|
|
|
|
The code is currently dimensioned to support a chain with roughly
|
|
|
|
600 entries and 20 loop counters.
|
2015-06-18 12:46:46 +02:00
|
|
|
|
|
|
|
...
|
2015-07-24 22:17:29 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <pigpio.h>
|
|
|
|
|
|
|
|
#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);
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
printf("start piscope, press return"); getchar();
|
2015-07-24 22:17:29 +02:00
|
|
|
|
|
|
|
for (i=0; i<WAVES; i++)
|
|
|
|
{
|
|
|
|
gpioWaveAddGeneric(2, (gpioPulse_t[])
|
|
|
|
{{1<<GPIO, 0, 20},
|
|
|
|
{0, 1<<GPIO, (i+1)*200}});
|
|
|
|
|
|
|
|
wid[i] = gpioWaveCreate();
|
|
|
|
}
|
2015-06-18 12:46:46 +02:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
gpioWaveChain((char []) {
|
|
|
|
wid[4], wid[3], wid[2], // transmit waves 4+3+2
|
|
|
|
255, 0, // loop start
|
|
|
|
wid[0], wid[0], wid[0], // transmit waves 0+0+0
|
|
|
|
255, 0, // loop start
|
|
|
|
wid[0], wid[1], // transmit waves 0+1
|
|
|
|
255, 2, 0x88, 0x13, // delay 5000us
|
|
|
|
255, 1, 30, 0, // loop end (repeat 30 times)
|
|
|
|
255, 0, // loop start
|
|
|
|
wid[2], wid[3], wid[0], // transmit waves 2+3+0
|
|
|
|
wid[3], wid[1], wid[2], // transmit waves 3+1+2
|
|
|
|
255, 1, 10, 0, // loop end (repeat 10 times)
|
|
|
|
255, 1, 5, 0, // loop end (repeat 5 times)
|
|
|
|
wid[4], wid[4], wid[4], // transmit waves 4+4+4
|
|
|
|
255, 2, 0x20, 0x4E, // delay 20000us
|
|
|
|
wid[0], wid[0], wid[0], // transmit waves 0+0+0
|
2015-06-18 12:46:46 +02:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
}, 46);
|
2015-06-18 12:46:46 +02:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
while (gpioWaveTxBusy()) time_sleep(0.1);
|
2015-06-18 12:46:46 +02:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
for (i=0; i<WAVES; i++) gpioWaveDelete(wid[i]);
|
2015-06-18 12:46:46 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
printf("stop piscope, press return"); getchar();
|
2015-06-18 12:46:46 +02:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
gpioTerminate();
|
|
|
|
}
|
2015-06-18 12:46:46 +02:00
|
|
|
...
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
/*F*/
|
|
|
|
int gpioWaveTxAt(void);
|
|
|
|
/*D
|
|
|
|
This function returns the id of the waveform currently being
|
|
|
|
transmitted.
|
|
|
|
|
|
|
|
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*/
|
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioWaveTxBusy(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function checks to see if a waveform is currently being
|
|
|
|
transmitted.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 1 if a waveform is currently being transmitted, otherwise 0.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioWaveTxStop(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function aborts the transmission of the current waveform.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
This function is intended to stop a waveform started in repeat mode.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetMicros(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the length in microseconds of the current
|
|
|
|
waveform.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetHighMicros(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the length in microseconds of the longest waveform
|
2014-08-01 10:30:25 +02:00
|
|
|
created since [*gpioInitialise*] was called.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetMaxMicros(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the maximum possible size of a waveform in
|
|
|
|
microseconds.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetPulses(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the length in pulses of the current waveform.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetHighPulses(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the length in pulses of the longest waveform
|
2014-08-01 10:30:25 +02:00
|
|
|
created since [*gpioInitialise*] was called.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetMaxPulses(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the maximum possible size of a waveform in pulses.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetCbs(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the length in DMA control blocks of the current
|
|
|
|
waveform.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetHighCbs(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the length in DMA control blocks of the longest
|
2014-08-01 10:30:25 +02:00
|
|
|
waveform created since [*gpioInitialise*] was called.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioWaveGetMaxCbs(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the maximum possible size of a waveform in DMA
|
|
|
|
control blocks.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2015-05-17 13:36:40 +02:00
|
|
|
int gpioSerialReadOpen(unsigned user_gpio, unsigned baud, unsigned data_bits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
This function opens a GPIO for bit bang reading of serial data.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
2015-05-17 13:36:40 +02:00
|
|
|
baud: 50-250000
|
|
|
|
data_bits: 1-32
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
|
2014-12-24 23:12:21 +01:00
|
|
|
PI_BAD_DATABITS, or PI_GPIO_IN_USE.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The serial data is returned in a cyclic buffer and is read using
|
2014-08-01 10:30:25 +02:00
|
|
|
[*gpioSerialRead*].
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
It is the caller's responsibility to read data from the cyclic buffer
|
|
|
|
in a timely fashion.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2015-08-29 15:06:27 +02:00
|
|
|
/*F*/
|
|
|
|
int gpioSerialReadInvert(unsigned user_gpio, unsigned invert);
|
|
|
|
/*D
|
2015-08-30 10:40:42 +02:00
|
|
|
This function configures the level logic for bit bang serial reads.
|
2015-08-29 15:06:27 +02:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
Use PI_BB_SER_INVERT to invert the serial logic and PI_BB_SER_NORMAL for
|
2015-08-29 15:06:27 +02:00
|
|
|
normal logic. Default is PI_BB_SER_NORMAL.
|
|
|
|
|
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
2016-05-31 19:44:12 +02:00
|
|
|
invert: 0-1
|
2015-08-29 15:06:27 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_GPIO_IN_USE,
|
2015-08-30 10:40:42 +02:00
|
|
|
PI_NOT_SERIAL_GPIO, or PI_BAD_SER_INVERT.
|
2015-08-29 15:06:27 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The GPIO must be opened for bit bang reading of serial data using
|
2015-08-29 15:06:27 +02:00
|
|
|
[*gpioSerialReadOpen*] prior to calling this function.
|
|
|
|
D*/
|
|
|
|
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioSerialRead(unsigned user_gpio, void *buf, size_t bufSize);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function copies up to bufSize bytes of data read from the
|
2014-08-01 10:30:25 +02:00
|
|
|
bit bang serial cyclic buffer to the buffer starting at buf.
|
|
|
|
|
|
|
|
. .
|
|
|
|
user_gpio: 0-31, previously opened with [*gpioSerialReadOpen*]
|
|
|
|
buf: an array to receive the read bytes
|
2016-05-31 19:44:12 +02:00
|
|
|
bufSize: >=0
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
|
|
|
|
or PI_NOT_SERIAL_GPIO.
|
2014-12-24 23:12:21 +01:00
|
|
|
|
|
|
|
The bytes returned for each character depend upon the number of
|
2015-05-17 13:36:40 +02:00
|
|
|
data bits [*data_bits*] specified in the [*gpioSerialReadOpen*] command.
|
2014-12-24 23:12:21 +01:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
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.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-04-19 13:19:29 +02:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioSerialReadClose(unsigned user_gpio);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
This function closes a GPIO for bit bang reading of serial data.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31, previously opened with [*gpioSerialReadOpen*]
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO.
|
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This returns a handle for the device at the address on the I2C bus.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2016-05-31 19:44:12 +02:00
|
|
|
i2cBus: >=0
|
|
|
|
i2cAddr: 0-0x7F
|
2014-08-01 10:30:25 +02:00
|
|
|
i2cFlags: 0
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
No flags are currently defined. This parameter should be set to zero.
|
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
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.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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.
|
2015-03-02 23:38:55 +01:00
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
For the SMBus commands the low level transactions are shown at the end
|
2015-03-02 23:38:55 +01:00
|
|
|
of the function description. The following abbreviations are used.
|
|
|
|
|
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
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.
|
2015-03-02 23:38:55 +01:00
|
|
|
|
|
|
|
[..]: Data sent by the device.
|
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cClose(unsigned handle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This closes the I2C device associated with the handle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*i2cOpen*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cWriteQuick(unsigned handle, unsigned bit);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
|
|
|
|
PI_I2C_WRITE_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Quick command. SMBus 2.0 5.5.1
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr bit [A] P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
|
|
|
|
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cWriteByte(unsigned handle, unsigned bVal);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
|
|
|
|
PI_I2C_WRITE_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Send byte. SMBus 2.0 5.5.2
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] bVal [A] P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
|
|
|
|
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cReadByte(unsigned handle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
|
|
|
This reads a single byte from the device associated with handle.
|
|
|
|
|
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*i2cOpen*]
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
|
|
|
|
or PI_I2C_READ_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Receive byte. SMBus 2.0 5.5.3
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
|
|
|
S Addr Rd [A] [Data] NA P
|
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
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.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Write byte. SMBus 2.0 5.5.4
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A] bVal [A] P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
|
|
|
|
PI_I2C_WRITE_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Write word. SMBus 2.0 5.5.4
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A] P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
|
|
|
|
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Read byte. SMBus 2.0 5.5.5
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A] S Addr Rd [A] [Data] NA P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
|
|
|
|
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Read word. SMBus 2.0 5.5.5
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
|
|
|
|
|
|
|
|
|
|
|
/*F*/
|
|
|
|
int i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal);
|
|
|
|
/*D
|
|
|
|
This writes 16 bits of data to the specified register of the device
|
2015-06-01 19:32:03 +02:00
|
|
|
associated with handle and reads 16 bits of data in return.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*i2cOpen*]
|
|
|
|
i2cReg: 0-255, the register to write/read
|
|
|
|
wVal: 0-0xFFFF, the value to write
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
|
|
|
|
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Process call. SMBus 2.0 5.5.6
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A]
|
2015-03-02 23:38:55 +01:00
|
|
|
S Addr Rd [A] [DataLow] A [DataHigh] NA P
|
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
|
|
|
|
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cWriteBlockData(
|
2014-08-01 10:30:25 +02:00
|
|
|
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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
|
|
|
|
PI_I2C_WRITE_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Block write. SMBus 2.0 5.5.7
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A] count [A]
|
|
|
|
buf0 [A] buf1 [A] ... [A] bufn [A] P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Block read. SMBus 2.0 5.5.7
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A]
|
|
|
|
S Addr Rd [A] [Count] A [buf0] A [buf1] A ... A [bufn] NA P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
|
|
|
|
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cBlockProcessCall(
|
2014-08-01 10:30:25 +02:00
|
|
|
unsigned handle, unsigned i2cReg, char *buf, unsigned count);
|
|
|
|
/*D
|
|
|
|
This writes data bytes to the specified register of the device
|
2014-06-12 19:31:00 +02:00
|
|
|
associated with handle and reads a device specified number
|
2014-08-01 10:30:25 +02:00
|
|
|
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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
|
|
|
|
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
The SMBus 2.0 documentation states that a minimum of 1 byte may be
|
2014-06-12 19:31:00 +02:00
|
|
|
sent and a minimum of 1 byte may be received. The total number of
|
|
|
|
bytes sent/received must be 32 or less.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
Block write-block read. SMBus 2.0 5.5.8
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A] count [A] buf0 [A] ... bufn [A]
|
|
|
|
S Addr Rd [A] [Count] A [buf0] A ... [bufn] A P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cReadI2CBlockData(
|
2014-08-01 10:30:25 +02:00
|
|
|
unsigned handle, unsigned i2cReg, char *buf, unsigned count);
|
|
|
|
/*D
|
|
|
|
This reads count bytes from the specified register of the device
|
2014-06-12 19:31:00 +02:00
|
|
|
associated with handle . The count may be 1-32.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
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,
|
2014-06-12 19:31:00 +02:00
|
|
|
PI_BAD_PARAM, or PI_I2C_READ_FAILED.
|
2015-03-02 23:38:55 +01:00
|
|
|
|
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A]
|
|
|
|
S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int i2cWriteI2CBlockData(
|
2014-08-01 10:30:25 +02:00
|
|
|
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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
|
|
|
|
PI_I2C_WRITE_FAILED.
|
2015-03-02 23:38:55 +01:00
|
|
|
|
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
S Addr Wr [A] i2cReg [A] buf0 [A] buf1 [A] ... [A] bufn [A] P
|
2015-03-02 23:38:55 +01:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
/*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.
|
2015-11-10 15:57:12 +01:00
|
|
|
|
|
|
|
. .
|
|
|
|
S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P
|
|
|
|
. .
|
2015-05-17 13:36:40 +02:00
|
|
|
D*/
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
/*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.
|
2015-11-10 15:57:12 +01:00
|
|
|
|
|
|
|
. .
|
|
|
|
S Addr Wr [A] buf0 [A] buf1 [A] ... [A] bufn [A] P
|
|
|
|
. .
|
2015-05-17 13:36:40 +02:00
|
|
|
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
|
2016-03-01 22:41:36 +01:00
|
|
|
This function selects a pair of GPIO for bit banging I2C at a
|
2015-05-17 13:36:40 +02:00
|
|
|
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
|
2016-03-01 22:41:36 +01:00
|
|
|
o I2C on any pair of spare GPIO
|
2015-05-17 13:36:40 +02:00
|
|
|
|
|
|
|
. .
|
|
|
|
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:
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
|
2015-05-17 13:36:40 +02:00
|
|
|
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
|
|
|
|
D*/
|
|
|
|
|
|
|
|
/*F*/
|
2015-04-23 09:58:59 +02:00
|
|
|
int bbI2CClose(unsigned SDA);
|
2015-05-17 13:36:40 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
This function stops bit banging I2C on a pair of GPIO previously
|
2015-05-17 13:36:40 +02:00
|
|
|
opened with [*bbI2COpen*].
|
2015-04-23 09:58:59 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
. .
|
2016-03-01 22:41:36 +01:00
|
|
|
SDA: 0-31, the SDA GPIO used in a prior call to [*bbI2COpen*]
|
2015-05-17 13:36:40 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
|
|
|
|
D*/
|
|
|
|
|
2016-08-06 12:18:17 +02:00
|
|
|
/*F*/
|
2016-09-22 15:12:26 +02:00
|
|
|
int bbI2CZip(
|
|
|
|
unsigned SDA,
|
|
|
|
char *inBuf,
|
|
|
|
unsigned inLen,
|
|
|
|
char *outBuf,
|
|
|
|
unsigned outLen);
|
2016-08-06 12:18:17 +02:00
|
|
|
/*D
|
2016-09-22 15:12:26 +02:00
|
|
|
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
|
|
|
|
. .
|
2016-08-06 12:18:17 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
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*/
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
/*F*/
|
|
|
|
int bscXfer(bsc_xfer_t *bsc_xfer);
|
|
|
|
/*D
|
|
|
|
This function provides a low-level interface to the
|
|
|
|
SPI/I2C Slave peripheral. This peripheral allows the
|
|
|
|
Pi to act as a slave device on an I2C or SPI bus.
|
|
|
|
|
|
|
|
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) and copy the bytes to
|
|
|
|
be sent (if any) to txBuf and set the byte count in txCnt.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
The BSC peripheral uses GPIO 18 (SDA) and 19 (SCL) in I2C mode
|
|
|
|
and GPIO 18 (MOSI), 19 (SCLK), 20 (MISO), and 21 (CE) in SPI mode. You
|
|
|
|
need to swap MISO/MOSI between master and slave.
|
|
|
|
|
|
|
|
When a zero control word is received GPIO 18-21 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*/
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
/*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.
|
2016-08-06 12:18:17 +02:00
|
|
|
|
|
|
|
. .
|
2016-09-22 15:12:26 +02:00
|
|
|
CS: 0-31
|
|
|
|
MISO: 0-31
|
|
|
|
MOSI: 0-31
|
|
|
|
SCLK: 0-31
|
|
|
|
baud: 50-250000
|
2016-08-06 12:18:17 +02:00
|
|
|
spiFlags: see below
|
|
|
|
. .
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2016-08-06 12:18:17 +02:00
|
|
|
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
|
2016-09-22 15:12:26 +02:00
|
|
|
0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m
|
2016-08-06 12:18:17 +02:00
|
|
|
. .
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
mm defines the SPI mode, defaults to 0
|
2016-08-06 12:18:17 +02:00
|
|
|
|
|
|
|
. .
|
2016-09-22 15:12:26 +02:00
|
|
|
Mode CPOL CPHA
|
|
|
|
0 0 0
|
|
|
|
1 0 1
|
|
|
|
2 1 0
|
|
|
|
3 1 1
|
2016-08-06 12:18:17 +02:00
|
|
|
. .
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
p is 0 if CS is active low (default) and 1 for active high.
|
2016-08-06 12:18:17 +02:00
|
|
|
|
2016-08-06 12:53:23 +02:00
|
|
|
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.
|
|
|
|
|
2016-08-06 12:18:17 +02:00
|
|
|
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.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
...
|
2016-08-06 12:18:17 +02:00
|
|
|
D*/
|
|
|
|
|
|
|
|
/*F*/
|
|
|
|
int bbSPIClose(unsigned CS);
|
|
|
|
/*D
|
2016-09-22 15:12:26 +02:00
|
|
|
This function stops bit banging SPI on a set of GPIO
|
2016-08-06 12:18:17 +02:00
|
|
|
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,
|
2016-09-22 15:12:26 +02:00
|
|
|
unsigned count);
|
2016-08-06 12:18:17 +02:00
|
|
|
/*D
|
2016-09-22 15:12:26 +02:00
|
|
|
This function executes a bit banged SPI transfer.
|
2016-08-06 12:18:17 +02:00
|
|
|
|
|
|
|
. .
|
2016-09-22 15:12:26 +02:00
|
|
|
CS: 0-31 (as used in a prior call to [*bbSPIOpen*])
|
2016-08-06 12:18:17 +02:00
|
|
|
inBuf: pointer to buffer to hold data to be sent
|
|
|
|
outBuf: pointer to buffer to hold returned data
|
2016-09-22 15:12:26 +02:00
|
|
|
count: size of data transfer
|
2016-08-06 12:18:17 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
Returns >= 0 if OK (the number of bytes read), otherwise
|
|
|
|
PI_BAD_USER_GPIO, PI_NOT_SPI_GPIO or PI_BAD_POINTER.
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
...
|
|
|
|
// gcc -Wall -pthread -o bbSPIx_test bbSPIx_test.c -lpigpio
|
|
|
|
// sudo ./bbSPIx_test
|
2016-08-06 12:18:17 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
#include <stdio.h>
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
#include "pigpio.h"
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
#define CE0 5
|
|
|
|
#define CE1 6
|
|
|
|
#define MISO 13
|
|
|
|
#define MOSI 19
|
|
|
|
#define SCLK 12
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
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};
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
if (gpioInitialise() < 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "pigpio initialisation failed.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2015-04-23 09:58:59 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
bbSPIOpen(CE0, MISO, MOSI, SCLK, 10000, 0); // MCP4251 DAC
|
|
|
|
bbSPIOpen(CE1, MISO, MOSI, SCLK, 20000, 3); // MCP3008 ADC
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
for (i=0; i<256; i++)
|
|
|
|
{
|
|
|
|
cmd1[1] = i;
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
count = bbSPIXfer(CE0, cmd1, (char *)inBuf, 2); // > DAC
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
if (count == 2)
|
|
|
|
{
|
|
|
|
count = bbSPIXfer(CE0, cmd2, (char *)inBuf, 2); // < DAC
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
if (count == 2)
|
|
|
|
{
|
|
|
|
set_val = inBuf[1];
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
count = bbSPIXfer(CE1, cmd3, (char *)inBuf, 3); // < ADC
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
if (count == 3)
|
|
|
|
{
|
|
|
|
read_val = ((inBuf[1]&3)<<8) | inBuf[2];
|
|
|
|
printf("%d %d\n", set_val, read_val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
bbSPIClose(CE0);
|
|
|
|
bbSPIClose(CE1);
|
|
|
|
|
|
|
|
gpioTerminate();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-17 13:36:40 +02:00
|
|
|
...
|
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2015-05-17 13:36:40 +02:00
|
|
|
int spiOpen(unsigned spiChan, unsigned baud, unsigned spiFlags);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-08-12 19:47:26 +02:00
|
|
|
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.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
An auxiliary SPI device is available on all models but the
|
|
|
|
A and B and may be selected by setting the A bit in the flags.
|
|
|
|
The auxiliary device has 3 chip selects and a selectable word
|
|
|
|
size in bits.
|
2014-09-03 20:52:48 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2016-03-01 22:41:36 +01:00
|
|
|
spiChan: 0-1 (0-2 for the auxiliary SPI device)
|
2015-05-17 13:36:40 +02:00
|
|
|
baud: 32K-125M (values above 30M are unlikely to work)
|
2014-09-03 20:52:48 +02:00
|
|
|
spiFlags: see below
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL,
|
2014-09-03 20:52:48 +02:00
|
|
|
PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-09-03 20:52:48 +02:00
|
|
|
spiFlags consists of the least significant 22 bits.
|
2014-08-12 19:47:26 +02:00
|
|
|
|
|
|
|
. .
|
2014-09-03 20:52:48 +02:00
|
|
|
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
|
2014-08-12 19:47:26 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
mm defines the SPI mode.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
Warning: modes 1 and 3 do not appear to work on the auxiliary device.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
Mode POL PHA
|
|
|
|
0 0 0
|
|
|
|
1 0 1
|
|
|
|
2 1 0
|
|
|
|
3 1 1
|
|
|
|
. .
|
|
|
|
|
2014-09-03 20:52:48 +02:00
|
|
|
px is 0 if CEx is active low (default) and 1 for active high.
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
|
2014-09-03 20:52:48 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
A is 0 for the standard SPI device, 1 for the auxiliary SPI.
|
2014-08-12 19:47:26 +02:00
|
|
|
|
2014-09-03 20:52:48 +02:00
|
|
|
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
|
|
|
|
SPI device only.
|
2014-08-12 19:47:26 +02:00
|
|
|
|
|
|
|
nnnn defines the number of bytes (0-15) to write before switching
|
|
|
|
the MOSI line to MISO to read data. This field is ignored
|
2014-09-03 20:52:48 +02:00
|
|
|
if W is not set. Standard SPI device 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
|
|
|
|
device 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
|
|
|
|
device only.
|
|
|
|
|
|
|
|
bbbbbb defines the word size in bits (0-32). The default (0)
|
|
|
|
sets 8 bits per word. Auxiliary SPI device only.
|
2014-08-12 19:47:26 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
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 character.
|
|
|
|
For bits 9-16 there will be two bytes per character.
|
|
|
|
For bits 17-32 there will be four bytes per character.
|
|
|
|
|
|
|
|
E.g. to transfer 32 12-bit words buf should contain 64 bytes
|
|
|
|
and count should be 64.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The other bits in flags should be set to zero.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int spiClose(unsigned handle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This functions closes the SPI device identified by the handle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*spiOpen*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int spiRead(unsigned handle, char *buf, unsigned count);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function reads count bytes of data from the SPI
|
|
|
|
device associated with the handle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
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
|
|
|
|
. .
|
|
|
|
|
2015-02-02 22:11:28 +01:00
|
|
|
Returns the number of bytes transferred if OK, otherwise
|
|
|
|
PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int spiWrite(unsigned handle, char *buf, unsigned count);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function writes count bytes of data from buf to the SPI
|
|
|
|
device associated with the handle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*spiOpen*]
|
|
|
|
buf: the data bytes to write
|
|
|
|
count: the number of bytes to write
|
|
|
|
. .
|
|
|
|
|
2015-02-02 22:11:28 +01:00
|
|
|
Returns the number of bytes transferred if OK, otherwise
|
|
|
|
PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int spiXfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function transfers count bytes of data from txBuf to the SPI
|
2014-08-01 10:30:25 +02:00
|
|
|
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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-02-02 22:11:28 +01:00
|
|
|
Returns the number of bytes transferred if OK, otherwise
|
|
|
|
PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2015-05-17 13:36:40 +02:00
|
|
|
int serOpen(char *sertty, unsigned baud, unsigned serFlags);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
|
|
|
This function opens a serial device at a specified baud rate
|
2016-07-10 22:29:14 +02:00
|
|
|
and with specified flags. The device name must start with
|
|
|
|
/dev/tty or /dev/serial.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2016-07-10 22:29:14 +02:00
|
|
|
sertty: the serial device to open
|
2015-05-17 13:36:40 +02:00
|
|
|
baud: the baud rate in bits per second, see below
|
2014-08-01 10:30:25 +02:00
|
|
|
serFlags: 0
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
|
|
|
|
PI_SER_OPEN_FAILED.
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
The baud rate must be one of 50, 75, 110, 134, 150,
|
2016-02-06 19:46:07 +01:00
|
|
|
200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
|
2015-05-17 13:36:40 +02:00
|
|
|
38400, 57600, 115200, or 230400.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
No flags are currently defined. This parameter should be set to zero.
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int serClose(unsigned handle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function closes the serial device associated with handle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*serOpen*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int serWriteByte(unsigned handle, unsigned bVal);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function writes bVal to the serial port associated with handle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*serOpen*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
|
|
|
|
PI_SER_WRITE_FAILED.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int serReadByte(unsigned handle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function reads a byte from the serial port associated with handle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*serOpen*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE,
|
|
|
|
PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED.
|
2016-10-30 16:30:20 +01:00
|
|
|
|
|
|
|
If no data is ready PI_SER_READ_NO_DATA is returned.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int serWrite(unsigned handle, char *buf, unsigned count);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function writes count bytes from buf to the the serial port
|
|
|
|
associated with handle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
handle: >=0, as returned by a call to [*serOpen*]
|
|
|
|
buf: the array of bytes to write
|
|
|
|
count: the number of bytes to write
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
|
|
|
|
PI_SER_WRITE_FAILED.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int serRead(unsigned handle, char *buf, unsigned count);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
|
|
|
This function reads up count bytes from the the serial port
|
2014-06-12 19:31:00 +02:00
|
|
|
associated with handle and writes them to buf.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2016-07-10 22:29:14 +02:00
|
|
|
handle: >=0, as returned by a call to [*serOpen*]
|
2014-08-01 10:30:25 +02:00
|
|
|
buf: an array to receive the read data
|
|
|
|
count: the maximum number of bytes to read
|
|
|
|
. .
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
Returns the number of bytes read (>0=) if OK, otherwise PI_BAD_HANDLE,
|
2016-07-10 22:29:14 +02:00
|
|
|
PI_BAD_PARAM, or PI_SER_READ_NO_DATA.
|
2016-10-30 16:30:20 +01:00
|
|
|
|
|
|
|
If no data is ready zero is returned.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int serDataAvailable(unsigned handle);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*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*]
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
Returns the number of bytes of data available (>=0) if OK,
|
|
|
|
otherwise PI_BAD_HANDLE.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-01-21 20:04:59 +01:00
|
|
|
int gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
This function sends a trigger pulse to a GPIO. The GPIO is set to
|
2014-06-12 19:31:00 +02:00
|
|
|
level for pulseLen microseconds and then reset to not level.
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
2014-08-17 20:53:43 +02:00
|
|
|
pulseLen: 1-100
|
2014-08-01 10:30:25 +02:00
|
|
|
level: 0,1
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL,
|
|
|
|
or PI_BAD_PULSELEN.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-01-21 20:04:59 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetWatchdog(unsigned user_gpio, unsigned timeout);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets a watchdog for a GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
user_gpio: 0-31
|
|
|
|
timeout: 0-60000
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_WDOG_TIMEOUT.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The watchdog is nominally in milliseconds.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
One watchdog may be registered per GPIO.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The watchdog may be cancelled by setting timeout to 0.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If no level change has been detected for the GPIO for timeout
|
2014-06-12 19:31:00 +02:00
|
|
|
milliseconds:-
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
1) any registered alert function for the GPIO is called with
|
2014-06-12 19:31:00 +02:00
|
|
|
the level set to PI_TIMEOUT.
|
2016-03-01 22:41:36 +01:00
|
|
|
2) any notification for the GPIO has a report written to the
|
2014-06-12 19:31:00 +02:00
|
|
|
fifo with the flags set to indicate a watchdog timeout.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
|
|
|
void aFunction(int gpio, int level, uint32_t tick)
|
|
|
|
{
|
2016-03-01 22:41:36 +01:00
|
|
|
printf("GPIO %d became %d at %d", gpio, level, tick);
|
2014-06-12 19:31:00 +02:00
|
|
|
}
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
// call aFunction whenever GPIO 4 changes state
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioSetAlertFunc(4, aFunction);
|
|
|
|
|
|
|
|
// or approximately every 5 millis
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioSetWatchdog(4, 5);
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2015-10-28 12:06:53 +01:00
|
|
|
/*F*/
|
|
|
|
int gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active);
|
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets a noise filter on a GPIO.
|
2015-10-28 12:06:53 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
Level changes on the GPIO are ignored until a level which has
|
2015-10-28 12:06:53 +01:00
|
|
|
been stable for [*steady*] microseconds is detected. Level changes
|
2016-03-01 22:41:36 +01:00
|
|
|
on the GPIO are then reported for [*active*] microseconds after
|
2015-10-28 12:06:53 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
Note, 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
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets a glitch filter on a GPIO.
|
2015-10-28 12:06:53 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
Level changes on the GPIO are not reported unless the level
|
2015-10-28 12:06:53 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
Note, each (stable) edge will be timestamped [*steady*] microseconds
|
|
|
|
after it was first detected.
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Registers a function to be called (a callback) every millisecond
|
2016-03-01 22:41:36 +01:00
|
|
|
with the latest GPIO samples.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
f: the function to call
|
2016-03-01 22:41:36 +01:00
|
|
|
bits: the GPIO of interest
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
The function is passed a pointer to the samples (an array of
|
|
|
|
[*gpioSample_t*]), and the number of samples.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Only one function can be registered.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The callback may be cancelled by passing NULL as the function.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The samples returned will be the union of bits, plus any active alerts,
|
|
|
|
plus any active notifications.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
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
|
2014-06-12 19:31:00 +02:00
|
|
|
7, 8, 9, 10, 17, 23, and 24 will be reported.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetGetSamplesFuncEx(
|
|
|
|
gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Registers a function to be called (a callback) every millisecond
|
2016-03-01 22:41:36 +01:00
|
|
|
with the latest GPIO samples.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
f: the function to call
|
2016-03-01 22:41:36 +01:00
|
|
|
bits: the GPIO of interest
|
2014-08-01 10:30:25 +02:00
|
|
|
userdata: a pointer to arbitrary user data
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
The function is passed a pointer to the samples (an array of
|
|
|
|
[*gpioSample_t*]), the number of samples, and the userdata pointer.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Only one of [*gpioGetSamplesFunc*] or [*gpioGetSamplesFuncEx*] can be
|
2014-06-12 19:31:00 +02:00
|
|
|
registered.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
See [*gpioSetGetSamplesFunc*] for further details.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetTimerFunc(unsigned timer, unsigned millis, gpioTimerFunc_t f);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Registers a function to be called (a callback) every millis milliseconds.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
timer: 0-9
|
|
|
|
millis: 10-60000
|
|
|
|
f: the function to call
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
10 timers are supported numbered 0 to 9.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
One function may be registered per timer.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The timer may be cancelled by passing NULL as the function.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
|
|
|
void bFunction(void)
|
|
|
|
{
|
2016-03-01 22:41:36 +01:00
|
|
|
printf("two seconds have elapsed");
|
2014-06-12 19:31:00 +02:00
|
|
|
}
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
// call bFunction every 2000 milliseconds
|
|
|
|
gpioSetTimerFunc(0, 2000, bFunction);
|
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetTimerFuncEx(
|
|
|
|
unsigned timer, unsigned millis, gpioTimerFuncEx_t f, void *userdata);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Registers a function to be called (a callback) every millis milliseconds.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
timer: 0-9.
|
|
|
|
millis: 10-60000
|
|
|
|
f: the function to call
|
|
|
|
userdata: a pointer to arbitrary user data
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The function is passed the userdata pointer.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Only one of [*gpioSetTimerFunc*] or [*gpioSetTimerFuncEx*] can be
|
2014-06-12 19:31:00 +02:00
|
|
|
registered per timer.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
See [*gpioSetTimerFunc*] for further details.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2015-11-10 15:57:12 +01:00
|
|
|
pthread_t *gpioStartThread(gpioThreadFunc_t f, void *userdata);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Starts a new thread of execution with f as the main routine.
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
f: the main function for the new thread
|
|
|
|
userdata: a pointer to arbitrary user data
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns a pointer to pthread_t if OK, otherwise NULL.
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The function is passed the single argument arg.
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The thread can be cancelled by passing the pointer to pthread_t to
|
2014-08-01 10:30:25 +02:00
|
|
|
[*gpioStopThread*].
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <pigpio.h>
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
void *myfunc(void *arg)
|
|
|
|
{
|
|
|
|
while (1)
|
2014-01-12 22:31:59 +01:00
|
|
|
{
|
2016-03-01 22:41:36 +01:00
|
|
|
printf("%s", arg);
|
2014-06-12 19:31:00 +02:00
|
|
|
sleep(1);
|
2014-01-12 22:31:59 +01:00
|
|
|
}
|
2014-06-12 19:31:00 +02:00
|
|
|
}
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
pthread_t *p1, *p2, *p3;
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
if (gpioInitialise() < 0) return 1;
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
p1 = gpioStartThread(myfunc, "thread 1"); sleep(3);
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
p2 = gpioStartThread(myfunc, "thread 2"); sleep(3);
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
p3 = gpioStartThread(myfunc, "thread 3"); sleep(3);
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioStopThread(p3); sleep(3);
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioStopThread(p2); sleep(3);
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioStopThread(p1); sleep(3);
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioTerminate();
|
|
|
|
}
|
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-01-12 22:31:59 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-01-12 22:31:59 +01:00
|
|
|
void gpioStopThread(pthread_t *pth);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Cancels the thread pointed at by pth.
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
pth: a thread pointer returned by [*gpioStartThread*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
No value is returned.
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The thread to be stopped should have been started with [*gpioStartThread*].
|
|
|
|
D*/
|
2014-01-12 22:31:59 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-01-21 20:04:59 +01:00
|
|
|
int gpioStoreScript(char *script);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function stores a null terminated script for later execution.
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
See [[http://abyz.co.uk/rpi/pigpio/pigs.html#Scripts]] for details.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
script: the text of the script
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The function returns a script id if the script is valid,
|
|
|
|
otherwise PI_BAD_SCRIPT.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-01-21 20:04:59 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
|
|
|
int gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param);
|
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function runs a stored script.
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
script_id: >=0, as returned by [*gpioStoreScript*]
|
|
|
|
numPar: 0-10, the number of parameters
|
|
|
|
param: an array of parameters
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
|
|
|
|
PI_TOO_MANY_PARAM.
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
param is an array of up to 10 parameters which may be referenced in
|
2014-08-01 10:30:25 +02:00
|
|
|
the script as p0 to p9.
|
|
|
|
D*/
|
2014-03-13 16:50:23 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioScriptStatus(unsigned script_id, uint32_t *param);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function returns the run status of a stored script as well as
|
|
|
|
the current values of parameters 0 to 9.
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
script_id: >=0, as returned by [*gpioStoreScript*]
|
|
|
|
param: an array to hold the returned 10 parameters
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The function returns greater than or equal to 0 if OK,
|
|
|
|
otherwise PI_BAD_SCRIPT_ID.
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The run status may be
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
PI_SCRIPT_INITING
|
2014-06-12 19:31:00 +02:00
|
|
|
PI_SCRIPT_HALTED
|
|
|
|
PI_SCRIPT_RUNNING
|
|
|
|
PI_SCRIPT_WAITING
|
|
|
|
PI_SCRIPT_FAILED
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The current value of script parameters 0 to 9 are returned in param.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-01-21 20:04:59 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioStopScript(unsigned script_id);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function stops a running script.
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
script_id: >=0, as returned by [*gpioStoreScript*]
|
|
|
|
. .
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
|
|
|
|
D*/
|
2014-01-21 20:04:59 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int gpioDeleteScript(unsigned script_id);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function deletes a stored script.
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
script_id: >=0, as returned by [*gpioStoreScript*]
|
|
|
|
. .
|
2014-01-21 20:04:59 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
|
|
|
|
D*/
|
2014-01-12 22:31:59 +01:00
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetSignalFunc(unsigned signum, gpioSignalFunc_t f);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Registers a function to be called (a callback) when a signal occurs.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
signum: 0-63
|
|
|
|
f: the callback function
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_SIGNUM.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The function is passed the signal number.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
One function may be registered per signal.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The callback may be cancelled by passing NULL.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
By default all signals are treated as fatal and cause the library
|
|
|
|
to call gpioTerminate and then exit.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSetSignalFuncEx(
|
|
|
|
unsigned signum, gpioSignalFuncEx_t f, void *userdata);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Registers a function to be called (a callback) when a signal occurs.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
signum: 0-63
|
|
|
|
f: the callback function
|
|
|
|
userdata: a pointer to arbitrary user data
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_SIGNUM.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The function is passed the signal number and the userdata pointer.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Only one of gpioSetSignalFunc or gpioSetSignalFuncEx can be
|
|
|
|
registered per signal.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
See gpioSetSignalFunc for further details.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
uint32_t gpioRead_Bits_0_31(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the current level of GPIO 0-31.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
uint32_t gpioRead_Bits_32_53(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Returns the current level of GPIO 32-53.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioWrite_Bits_0_31_Clear(uint32_t bits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Clears GPIO 0-31 if the corresponding bit in bits is set.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2016-03-01 22:41:36 +01:00
|
|
|
bits: a bit mask of GPIO to clear
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2016-03-01 22:41:36 +01:00
|
|
|
// To clear (set to 0) GPIO 4, 7, and 15
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) );
|
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioWrite_Bits_32_53_Clear(uint32_t bits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2016-03-01 22:41:36 +01:00
|
|
|
bits: a bit mask of GPIO to clear
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Returns 0 if OK.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioWrite_Bits_0_31_Set(uint32_t bits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets GPIO 0-31 if the corresponding bit in bits is set.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2016-03-01 22:41:36 +01:00
|
|
|
bits: a bit mask of GPIO to set
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Returns 0 if OK.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioWrite_Bits_32_53_Set(uint32_t bits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2016-03-01 22:41:36 +01:00
|
|
|
bits: a bit mask of GPIO to set
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2016-03-01 22:41:36 +01:00
|
|
|
// To set (set to 1) GPIO 32, 40, and 53
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32)));
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
/*F*/
|
|
|
|
int gpioHardwareClock(unsigned gpio, unsigned clkfreq);
|
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Starts a hardware clock on a GPIO at the specified frequency.
|
2015-02-25 21:34:52 +01:00
|
|
|
Frequencies above 30MHz are unlikely to work.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
|
|
|
. .
|
|
|
|
gpio: see description
|
2015-02-25 21:34:52 +01:00
|
|
|
clkfreq: 0 (off) or 4689-250000000 (250M)
|
2014-12-17 23:31:17 +01:00
|
|
|
. .
|
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HCLK_GPIO,
|
|
|
|
PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The same clock is available on multiple GPIO. The latest
|
|
|
|
frequency setting will be used by all GPIO which share a clock.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The GPIO must be one of the following.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
|
|
|
. .
|
|
|
|
4 clock 0 All models
|
2016-03-01 22:41:36 +01:00
|
|
|
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)
|
2014-12-17 23:31:17 +01:00
|
|
|
|
|
|
|
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
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO number.
|
2014-12-17 23:31:17 +01:00
|
|
|
D*/
|
|
|
|
|
|
|
|
/*F*/
|
|
|
|
int gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty);
|
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
|
2015-02-25 21:34:52 +01:00
|
|
|
Frequencies above 30MHz are unlikely to work.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
NOTE: Any waveform started by [*gpioWaveTxSend*], or
|
|
|
|
[*gpioWaveChain*] will be cancelled.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
|
|
|
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
|
2015-02-25 21:34:52 +01:00
|
|
|
PWMfreq: 0 (off) or 1-125000000 (125M)
|
|
|
|
PWMduty: 0 (off) to 1000000 (1M)(fully on)
|
2014-12-17 23:31:17 +01:00
|
|
|
. .
|
|
|
|
|
|
|
|
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HPWM_GPIO,
|
|
|
|
PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, or PI_HPWM_ILLEGAL.
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The same PWM channel is available on multiple GPIO. The latest
|
|
|
|
frequency and dutycycle setting will be used by all GPIO which
|
2015-02-25 21:34:52 +01:00
|
|
|
share a PWM channel.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The GPIO must be one of the following.
|
2014-12-17 23:31:17 +01:00
|
|
|
|
|
|
|
. .
|
2016-03-01 22:41:36 +01:00
|
|
|
12 PWM channel 0 All models but A and B
|
|
|
|
13 PWM channel 1 All models but A and B
|
2014-12-17 23:31:17 +01:00
|
|
|
18 PWM channel 0 All models
|
2016-03-01 22:41:36 +01:00
|
|
|
19 PWM channel 1 All models but A and B
|
2014-12-17 23:31:17 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
. .
|
2015-12-31 18:01:34 +01:00
|
|
|
|
|
|
|
The actual number of steps beween off and fully on is the
|
|
|
|
integral part of 250 million divided by PWMfreq.
|
|
|
|
|
|
|
|
The actual frequency set is 250 million / steps.
|
|
|
|
|
|
|
|
There will only be a million steps for a PWMfreq of 250.
|
|
|
|
Lower frequencies will have more steps and higher
|
|
|
|
frequencies will have fewer steps. PWMduty is
|
|
|
|
automatically scaled to take this into account.
|
2014-12-17 23:31:17 +01:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioTime(unsigned timetype, int *seconds, int *micros);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Updates the seconds and micros variables with the current time.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
timetype: 0 (relative), 1 (absolute)
|
|
|
|
seconds: a pointer to an int to hold seconds
|
|
|
|
micros: a pointer to an int to hold microseconds
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_TIMETYPE.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
If timetype is PI_TIME_ABSOLUTE updates seconds and micros with the
|
|
|
|
number of seconds and microseconds since the epoch (1st January 1970).
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
If timetype is PI_TIME_RELATIVE updates seconds and micros with the
|
|
|
|
number of seconds and microseconds since the library was initialised.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
|
|
|
int secs, mics;
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
// print the number of seconds since the library was started
|
|
|
|
gpioTime(PI_TIME_RELATIVE, &secs, &mics);
|
2016-03-01 22:41:36 +01:00
|
|
|
printf("library started %d.%03d seconds ago", secs, mics/1000);
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioSleep(unsigned timetype, int seconds, int micros);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Sleeps for the number of seconds and microseconds specified by seconds
|
|
|
|
and micros.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
timetype: 0 (relative), 1 (absolute)
|
|
|
|
seconds: seconds to sleep
|
|
|
|
micros: microseconds to sleep
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns 0 if OK, otherwise PI_BAD_TIMETYPE, PI_BAD_SECONDS,
|
|
|
|
or PI_BAD_MICROS.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
For short delays (say, 50 microseonds or less) use [*gpioDelay*].
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
|
|
|
gpioSleep(PI_TIME_RELATIVE, 2, 500000); // sleep for 2.5 seconds
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioSleep(PI_TIME_RELATIVE, 0, 100000); // sleep for 0.1 seconds
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
gpioSleep(PI_TIME_RELATIVE, 60, 0); // sleep for one minute
|
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
uint32_t gpioDelay(uint32_t micros);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Delays for at least the number of microseconds specified by micros.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
micros: the number of microseconds to sleep
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the actual length of the delay in microseconds.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-09-03 20:52:48 +02:00
|
|
|
Delays of 100 microseconds or less use busy waits.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
uint32_t gpioTick(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the current system tick.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Tick is the number of microseconds since system boot.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
As tick is an unsigned 32 bit quantity it wraps around after
|
|
|
|
2^32 microseconds, which is approximately 1 hour 12 minutes.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
|
|
|
uint32_t startTick, endTick;
|
|
|
|
int diffTick;
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
startTick = gpioTick();
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
// do some processing
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
endTick = gpioTick();
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
diffTick = endTick - startTick;
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
printf("some processing took %d microseconds", diffTick);
|
2014-06-12 19:31:00 +02:00
|
|
|
...
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
unsigned gpioHardwareRevision(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the hardware revision.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
If the hardware revision can not be found or is not a valid hexadecimal
|
|
|
|
number the function returns 0.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
The hardware revision is the last few characters on the Revision line of
|
2014-06-12 19:31:00 +02:00
|
|
|
/proc/cpuinfo.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The revision number can be used to determine the assignment of GPIO
|
2015-02-25 21:34:52 +01:00
|
|
|
to pins (see [*gpio*]).
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
There are at least three types of board.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Type 1 boards have hardware revision numbers of 2 and 3.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Type 2 boards have hardware revision numbers of 4, 5, 6, and 15.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
Type 3 boards have hardware revision numbers of 16 or greater.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
for "Revision : 0002" the function returns 2.
|
|
|
|
for "Revision : 000f" the function returns 15.
|
|
|
|
for "Revision : 000g" the function returns 0.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-01-12 22:31:59 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-01-12 22:31:59 +01:00
|
|
|
unsigned gpioVersion(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the pigpio version.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
/*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*/
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
/*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*/
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
|
|
|
|
/*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 <stdio.h>
|
|
|
|
#include <pigpio.h>
|
|
|
|
|
|
|
|
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 <stdio.h>
|
|
|
|
#include <pigpio.h>
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
|
|
|
int gpioCfgBufferSize(unsigned cfgMillis);
|
|
|
|
/*D
|
2016-03-01 22:41:36 +01:00
|
|
|
Configures pigpio to buffer cfgMillis milliseconds of GPIO samples.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
cfgMillis: 100-10000
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The default setting is 120 milliseconds.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The intention is to allow for bursts of data and protection against
|
|
|
|
other processes hogging cpu time.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
I haven't seen a process locked out for more than 100 milliseconds.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Making the buffer bigger uses a LOT of memory at the more frequent
|
|
|
|
sampling rates as shown in the following table in MBs.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
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
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioCfgClock(
|
2014-08-01 10:30:25 +02:00
|
|
|
unsigned cfgMicros, unsigned cfgPeripheral, unsigned cfgSource);
|
|
|
|
/*D
|
2015-02-25 21:34:52 +01:00
|
|
|
Configures pigpio to use a particular sample rate timed by a specified
|
2014-12-17 23:31:17 +01:00
|
|
|
peripheral.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
cfgMicros: 1, 2, 4, 5, 8, 10
|
|
|
|
cfgPeripheral: 0 (PWM), 1 (PCM)
|
2014-12-17 23:31:17 +01:00
|
|
|
cfgSource: deprecated, value is ignored
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
The timings are provided by the specified peripheral (PWM or PCM).
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
The default setting is 5 microseconds using the PCM peripheral.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The approximate CPU percentage used for each sample rate is:
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
sample cpu
|
|
|
|
rate %
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
1 25
|
|
|
|
2 16
|
|
|
|
4 11
|
|
|
|
5 10
|
|
|
|
8 15
|
|
|
|
10 14
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A sample rate of 5 microseconds seeems to be the sweet spot.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioCfgDMAchannel(unsigned DMAchannel); /* DEPRECATED */
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Configures pigpio to use the specified DMA channel.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
DMAchannel: 0-14
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The default setting is to use channel 14.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int gpioCfgDMAchannels(
|
|
|
|
unsigned primaryChannel, unsigned secondaryChannel);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Configures pigpio to use the specified DMA channels.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
primaryChannel: 0-14
|
2016-03-08 15:28:15 +01:00
|
|
|
secondaryChannel: 0-14
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The default setting is to use channel 14 for the primary channel and
|
2016-03-08 15:28:15 +01:00
|
|
|
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.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:32:49 +01:00
|
|
|
int gpioCfgPermissions(uint64_t updateMask);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Configures pigpio to only allow updates (writes or mode changes) for the
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO specified by the mask.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2016-03-01 22:41:36 +01:00
|
|
|
updateMask: bit (1<<n) is set for each GPIO n which may be updated
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
|
2016-03-08 15:28:15 +01:00
|
|
|
The default setting depends upon the Pi model. The user GPIO are
|
|
|
|
added to the mask.
|
|
|
|
|
|
|
|
If the board revision is not recognised then GPIO 0-31 are allowed.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-08 15:28:15 +01:00
|
|
|
Unknown board @ PI_DEFAULT_UPDATE_MASK_UNKNOWN @ 0xFFFFFFFF
|
|
|
|
Type 1 board @ PI_DEFAULT_UPDATE_MASK_B1 @ 0x03E6CF93
|
|
|
|
Type 2 board @ PI_DEFAULT_UPDATE_MASK_A_B2 @ 0xFBC6CF9C
|
2014-08-01 10:30:25 +02:00
|
|
|
Type 3 board @ PI_DEFAULT_UPDATE_MASK_R3 @ 0x0FFFFFFC
|
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioCfgSocketPort(unsigned port);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Configures pigpio to use the specified socket port.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
port: 1024-32000
|
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The default setting is to use port 8888.
|
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2013-12-12 11:27:22 +01:00
|
|
|
int gpioCfgInterfaces(unsigned ifFlags);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Configures pigpio support of the fifo and socket interfaces.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2015-12-31 18:01:34 +01:00
|
|
|
ifFlags: 0-7
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The default setting (0) is that both interfaces are enabled.
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Or in PI_DISABLE_FIFO_IF to disable the pipe interface.
|
2015-12-31 18:01:34 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Or in PI_DISABLE_SOCK_IF to disable the socket interface.
|
2015-12-31 18:01:34 +01:00
|
|
|
|
|
|
|
Or in PI_LOCALHOST_SOCK_IF to disable remote socket
|
|
|
|
access (this means that the socket interface is only
|
|
|
|
usable from the local Pi).
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-02-02 22:11:28 +01:00
|
|
|
/*F*/
|
2015-02-25 21:34:52 +01:00
|
|
|
int gpioCfgMemAlloc(unsigned memAllocMode);
|
|
|
|
/*D
|
|
|
|
Selects the method of DMA memory allocation.
|
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
. .
|
|
|
|
memAllocMode: 0-2
|
|
|
|
. .
|
|
|
|
|
|
|
|
There are two methods of DMA memory allocation. The original method
|
|
|
|
uses the /proc/self/pagemap file to allocate bus memory. The new
|
|
|
|
method uses the mailbox property interface to allocate bus memory.
|
|
|
|
|
|
|
|
Auto will use the mailbox method unless a larger than default buffer
|
|
|
|
size is requested with [*gpioCfgBufferSize*].
|
|
|
|
D*/
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
/*F*/
|
|
|
|
int gpioCfgNetAddr(int numSockAddr, uint32_t *sockAddr);
|
|
|
|
/*D
|
|
|
|
Sets the network addresses which are allowed to talk over the
|
|
|
|
socket interface.
|
|
|
|
|
|
|
|
This function is only effective if called before [*gpioInitialise*].
|
|
|
|
|
|
|
|
. .
|
|
|
|
numSockAddr: 0-256 (0 means all addresses allowed)
|
|
|
|
sockAddr: an array of permitted network addresses.
|
|
|
|
. .
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
/*F*/
|
2015-10-02 09:23:02 +02:00
|
|
|
int gpioCfgInternals(unsigned cfgWhat, unsigned cfgVal);
|
2015-02-25 21:34:52 +01:00
|
|
|
/*D
|
|
|
|
Used to tune internal settings.
|
|
|
|
|
|
|
|
. .
|
|
|
|
cfgWhat: see source code
|
|
|
|
cfgVal: see source code
|
|
|
|
. .
|
|
|
|
D*/
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
/*F*/
|
|
|
|
uint32_t gpioCfgGetInternals(void);
|
|
|
|
/*D
|
|
|
|
This function returns the current library internal configuration
|
|
|
|
settings.
|
|
|
|
D*/
|
|
|
|
|
|
|
|
/*F*/
|
|
|
|
int gpioCfgSetInternals(uint32_t cfgVal);
|
|
|
|
/*D
|
|
|
|
This function sets the current library internal configuration
|
|
|
|
settings.
|
|
|
|
|
|
|
|
. .
|
|
|
|
cfgVal: see source code
|
|
|
|
. .
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
/*F*/
|
|
|
|
int gpioCustom1(unsigned arg1, unsigned arg2, char *argx, unsigned argc);
|
2015-02-02 22:11:28 +01:00
|
|
|
/*D
|
|
|
|
This function is available for user customisation.
|
|
|
|
|
|
|
|
It returns a single integer value.
|
|
|
|
|
|
|
|
. .
|
2015-02-25 21:34:52 +01:00
|
|
|
arg1: >=0
|
|
|
|
arg2: >=0
|
|
|
|
argx: extra (byte) arguments
|
|
|
|
argc: number of extra arguments
|
2015-02-02 22:11:28 +01:00
|
|
|
. .
|
|
|
|
|
|
|
|
Returns >= 0 if OK, less than 0 indicates a user defined error.
|
|
|
|
D*/
|
|
|
|
|
|
|
|
|
|
|
|
/*F*/
|
2015-02-25 21:34:52 +01:00
|
|
|
int gpioCustom2(unsigned arg1, char *argx, unsigned argc,
|
2015-02-02 22:11:28 +01:00
|
|
|
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
|
2015-02-25 21:34:52 +01:00
|
|
|
argc: number of extra arguments
|
2015-02-02 22:11:28 +01:00
|
|
|
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*/
|
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
int rawWaveAddSPI(
|
|
|
|
rawSPI_t *spi,
|
2014-03-13 16:50:23 +01:00
|
|
|
unsigned offset,
|
2014-06-12 19:31:00 +02:00
|
|
|
unsigned spiSS,
|
|
|
|
char *buf,
|
|
|
|
unsigned spiTxBits,
|
|
|
|
unsigned spiBitFirst,
|
|
|
|
unsigned spiBitLast,
|
|
|
|
unsigned spiBits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function adds a waveform representing SPI data to the
|
|
|
|
existing waveform (if any).
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
spi: a pointer to a spi object
|
|
|
|
offset: microseconds from the start of the waveform
|
2016-03-01 22:41:36 +01:00
|
|
|
spiSS: the slave select GPIO
|
2014-08-01 10:30:25 +02:00
|
|
|
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
|
|
|
|
. .
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
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.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 14:00:51 +02:00
|
|
|
int rawWaveAddGeneric(unsigned numPulses, rawWave_t *pulses);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
This function adds a number of pulses to the current waveform.
|
2014-04-19 14:00:51 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
numPulses: the number of pulses
|
|
|
|
pulses: the array containing the pulses
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the new total number of pulses in the current waveform if OK,
|
|
|
|
otherwise PI_TOO_MANY_PULSES.
|
2014-04-19 14:00:51 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The advantage of this function over gpioWaveAddGeneric is that it
|
|
|
|
allows the setting of the flags field.
|
2014-04-19 14:00:51 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The pulses are interleaved in time order within the existing waveform
|
|
|
|
(if any).
|
2014-04-19 14:00:51 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Merging allows the waveform to be built in parts, that is the settings
|
2016-03-01 22:41:36 +01:00
|
|
|
for GPIO#1 can be added, and then GPIO#2 etc.
|
2014-04-19 14:00:51 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
If the added waveform is intended to start after or within the existing
|
|
|
|
waveform then the first pulse should consist of a delay.
|
2014-04-19 14:00:51 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-04-19 14:00:51 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
unsigned rawWaveCB(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the number of the cb being currently output.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
|
|
|
rawCbs_t *rawWaveCBAdr(int cbNum);
|
|
|
|
/*D
|
2016-09-22 15:12:26 +02:00
|
|
|
Return the (Linux) address of contol block cbNum.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
. .
|
|
|
|
cbNum: the cb of interest
|
|
|
|
. .
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
/*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*/
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
uint32_t rawWaveGetOut(int pos);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Gets the wave output parameter stored at pos.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
DEPRECATED: use rawWaveGetOOL instead.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
pos: the position of interest.
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
|
|
|
void rawWaveSetOut(int pos, uint32_t lVal);
|
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Sets the wave output parameter stored at pos to value.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
DEPRECATED: use rawWaveSetOOL instead.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
pos: the position of interest
|
|
|
|
lVal: the value to write
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
uint32_t rawWaveGetIn(int pos);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Gets the wave input value parameter stored at pos.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
DEPRECATED: use rawWaveGetOOL instead.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
pos: the position of interest
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-03-13 16:50:23 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
|
|
|
void rawWaveSetIn(int pos, uint32_t lVal);
|
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Sets the wave input value stored at pos to value.
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
DEPRECATED: use rawWaveSetOOL instead.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
pos: the position of interest
|
|
|
|
lVal: the value to write
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-09-09 23:58:39 +02:00
|
|
|
/*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*/
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
int getBitInBytes(int bitPos, char *buf, int numBits);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Returns the value of the bit bitPos bits from the start of buf. Returns
|
|
|
|
0 if bitPos is greater than or equal to numBits.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
bitPos: bit index from the start of buf
|
|
|
|
buf: array of bits
|
|
|
|
numBits: number of valid bits in buf
|
|
|
|
. .
|
|
|
|
|
|
|
|
D*/
|
|
|
|
|
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
void putBitInBytes(int bitPos, char *buf, int bit);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Sets the bit bitPos bits from the start of buf to bit.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
bitPos: bit index from the start of buf
|
|
|
|
buf: array of bits
|
|
|
|
bit: 0-1, value to set
|
|
|
|
. .
|
|
|
|
|
|
|
|
D*/
|
|
|
|
|
|
|
|
/*F*/
|
2014-03-13 16:50:23 +01:00
|
|
|
double time_time(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Return the current time in seconds since the Epoch.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-03-13 16:50:23 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-03-13 16:50:23 +01:00
|
|
|
void time_sleep(double seconds);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Delay execution for a given number of seconds
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
. .
|
|
|
|
seconds: the number of seconds to sleep
|
|
|
|
. .
|
|
|
|
D*/
|
2014-03-13 16:50:23 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-04-19 13:19:29 +02:00
|
|
|
void rawDumpWave(void);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Used to print a readable version of the current waveform to stderr.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2014-03-13 16:50:23 +01:00
|
|
|
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*F*/
|
2014-06-12 19:31:00 +02:00
|
|
|
void rawDumpScript(unsigned script_id);
|
2014-08-01 10:30:25 +02:00
|
|
|
/*D
|
2014-06-12 19:31:00 +02:00
|
|
|
Used to print a readable version of a script to stderr.
|
2014-04-19 13:19:29 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
script_id: >=0, a script_id returned by [*gpioStoreScript*]
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Not intended for general use.
|
2014-08-01 10:30:25 +02:00
|
|
|
D*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*PARAMS
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-10-28 12:06:53 +01:00
|
|
|
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).
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
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.
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
baud::
|
|
|
|
The speed of serial communication (I2C, SPI, serial link, waves) in
|
|
|
|
bits per second.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
bit::
|
2014-06-12 19:31:00 +02:00
|
|
|
A value of 0 or 1.
|
|
|
|
|
|
|
|
bitPos::
|
|
|
|
A bit position within a byte or word. The least significant bit is
|
|
|
|
position 0.
|
|
|
|
|
|
|
|
bits::
|
2016-03-01 22:41:36 +01:00
|
|
|
A value used to select GPIO. If bit n of bits is set then GPIO n is
|
2014-06-12 19:31:00 +02:00
|
|
|
selected.
|
|
|
|
|
|
|
|
A convenient way to set bit n is to or in (1<<n).
|
|
|
|
|
|
|
|
e.g. to select bits 5, 9, 23 you could use (1<<5) | (1<<9) | (1<<23).
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
*bsc_xfer::
|
|
|
|
A pointer to a [*bsc_xfer_t*] object used to control a BSC transfer.
|
|
|
|
|
|
|
|
bsc_xfer_t::
|
|
|
|
|
|
|
|
. .
|
|
|
|
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;
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
*buf::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A buffer to hold data being sent or being received.
|
|
|
|
|
|
|
|
bufSize::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
The size in bytes of a buffer.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
bVal::0-255 (Hex 0x0-0xFF, Octal 0-0377)
|
|
|
|
|
|
|
|
An 8-bit byte value.
|
|
|
|
|
|
|
|
cbNum::
|
|
|
|
|
|
|
|
A number identifying a DMA contol block.
|
|
|
|
|
|
|
|
cfgMicros::
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The GPIO sample rate in microseconds. The default is 5us, or 200 thousand
|
2014-08-01 10:30:25 +02:00
|
|
|
samples per second.
|
|
|
|
|
|
|
|
cfgMillis:: 100-10000
|
|
|
|
|
2015-06-01 19:32:03 +02:00
|
|
|
The size of the sample buffer in milliseconds. Generally this should be
|
2014-08-01 10:30:25 +02:00
|
|
|
left at the default of 120ms. If you expect intense bursts of signals it
|
|
|
|
might be necessary to increase the buffer size.
|
|
|
|
|
|
|
|
cfgPeripheral::
|
|
|
|
|
|
|
|
One of the PWM or PCM peripherals used to pace DMA transfers for timing
|
|
|
|
purposes.
|
|
|
|
|
|
|
|
cfgSource::
|
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
Deprecated.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
cfgVal::
|
|
|
|
|
|
|
|
A number specifying the value of a configuration item. See [*cfgWhat*].
|
|
|
|
|
|
|
|
cfgWhat::
|
|
|
|
|
|
|
|
A number specifying a configuration item.
|
|
|
|
|
|
|
|
562484977: print enhanced statistics at termination.
|
|
|
|
984762879: set the initial debug level.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
char::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A single character, an 8 bit quantity able to store 0-255.
|
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
clkfreq::4689-250M
|
|
|
|
|
|
|
|
The hardware clock frequency.
|
|
|
|
|
|
|
|
. .
|
2015-10-02 09:23:02 +02:00
|
|
|
PI_HW_CLK_MIN_FREQ 4689
|
|
|
|
PI_HW_CLK_MAX_FREQ 250000000
|
2014-12-17 23:31:17 +01:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
count::
|
2014-08-01 10:30:25 +02:00
|
|
|
The number of bytes to be transferred in an I2C, SPI, or Serial
|
2014-06-12 19:31:00 +02:00
|
|
|
command.
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
CS::
|
|
|
|
The GPIO used for the slave select signal when bit banging SPI.
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
data_bits::1-32
|
|
|
|
|
|
|
|
The number of data bits to be used when adding serial data to a
|
|
|
|
waveform.
|
|
|
|
|
|
|
|
. .
|
2015-10-02 09:23:02 +02:00
|
|
|
PI_MIN_WAVE_DATABITS 1
|
|
|
|
PI_MAX_WAVE_DATABITS 32
|
2015-05-17 13:36:40 +02:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
DMAchannel::0-14
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
PI_MIN_DMA_CHANNEL 0
|
|
|
|
PI_MAX_DMA_CHANNEL 14
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
double::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A floating point number.
|
|
|
|
|
|
|
|
dutycycle::0-range
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A number representing the ratio of on time to off time for PWM.
|
|
|
|
|
|
|
|
The number may vary between 0 and range (default 255) where
|
2014-08-01 10:30:25 +02:00
|
|
|
0 is off and range is fully on.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
edge::0-2
|
2016-10-30 16:30:20 +01:00
|
|
|
The type of GPIO edge to generate an interrupt. See [*gpioSetISRFunc*]
|
2015-10-02 09:23:02 +02:00
|
|
|
and [*gpioSetISRFuncEx*].
|
|
|
|
|
|
|
|
. .
|
|
|
|
RISING_EDGE 0
|
|
|
|
FALLING_EDGE 1
|
|
|
|
EITHER_EDGE 2
|
|
|
|
. .
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
event::0-31
|
|
|
|
An event is a signal used to inform one or more consumers
|
|
|
|
to start an action.
|
|
|
|
|
|
|
|
eventFunc_t::
|
|
|
|
. .
|
|
|
|
typedef void (*eventFunc_t) (int event, uint32_t tick);
|
|
|
|
. .
|
|
|
|
|
|
|
|
eventFuncEx_t::
|
|
|
|
. .
|
|
|
|
typedef void (*eventFuncEx_t)
|
|
|
|
(int event, uint32_t tick, void *userdata);
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
f::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A function.
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
*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.
|
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
frequency::>=0
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
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
|
2014-06-12 19:31:00 +02:00
|
|
|
by its dutycycle.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpio::
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
A Broadcom numbered GPIO, in the range 0-53.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through
|
|
|
|
GPIO53.
|
2015-02-25 21:34:52 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
They are split into two banks. Bank 1 consists of GPIO0 through
|
|
|
|
GPIO31. Bank 2 consists of GPIO32 through GPIO53.
|
2015-02-25 21:34:52 +01:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
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.
|
2015-02-25 21:34:52 +01:00
|
|
|
|
|
|
|
See [*gpioHardwareRevision*].
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The user GPIO are marked with an X in the following table.
|
2015-02-25 21:34:52 +01:00
|
|
|
|
|
|
|
. .
|
|
|
|
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 - - - -
|
|
|
|
. .
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioAlertFunc_t::
|
|
|
|
. .
|
|
|
|
typedef void (*gpioAlertFunc_t) (int gpio, int level, uint32_t tick);
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioAlertFuncEx_t::
|
|
|
|
. .
|
2016-10-30 16:30:20 +01:00
|
|
|
typedef void (*eventFuncEx_t)
|
|
|
|
(int event, int level, uint32_t tick, void *userdata);
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioCfg*::
|
|
|
|
|
2016-04-25 10:58:51 +02:00
|
|
|
These functions are only effective if called before [*gpioInitialise*].
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
[*gpioCfgBufferSize*]
|
|
|
|
[*gpioCfgClock*]
|
|
|
|
[*gpioCfgDMAchannel*]
|
|
|
|
[*gpioCfgDMAchannels*]
|
|
|
|
[*gpioCfgPermissions*]
|
|
|
|
[*gpioCfgInterfaces*]
|
2015-02-25 21:34:52 +01:00
|
|
|
[*gpioCfgSocketPort*]
|
|
|
|
[*gpioCfgMemAlloc*]
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
gpioGetSamplesFunc_t::
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
typedef void (*gpioGetSamplesFunc_t)
|
|
|
|
(const gpioSample_t *samples, int numSamples);
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
gpioGetSamplesFuncEx_t::
|
|
|
|
. .
|
|
|
|
typedef void (*gpioGetSamplesFuncEx_t)
|
|
|
|
(const gpioSample_t *samples, int numSamples, void *userdata);
|
|
|
|
. .
|
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
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);
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
gpioPulse_t::
|
|
|
|
. .
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t gpioOn;
|
|
|
|
uint32_t gpioOff;
|
|
|
|
uint32_t usDelay;
|
|
|
|
} gpioPulse_t;
|
|
|
|
. .
|
|
|
|
|
2014-09-03 20:52:48 +02:00
|
|
|
gpioSample_t::
|
|
|
|
. .
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t tick;
|
|
|
|
uint32_t level;
|
|
|
|
} gpioSample_t;
|
|
|
|
. .
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioSignalFunc_t::
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
typedef void (*gpioSignalFunc_t) (int signum);
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioSignalFuncEx_t::
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
typedef void (*gpioSignalFuncEx_t) (int signum, void *userdata);
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
gpioThreadFunc_t::
|
|
|
|
. .
|
|
|
|
typedef void *(gpioThreadFunc_t) (void *);
|
|
|
|
. .
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioTimerFunc_t::
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
typedef void (*gpioTimerFunc_t) (void);
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioTimerFuncEx_t::
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
typedef void (*gpioTimerFuncEx_t) (void *userdata);
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
gpioWaveAdd*::
|
|
|
|
|
|
|
|
One of
|
|
|
|
|
|
|
|
[*gpioWaveAddNew*]
|
|
|
|
[*gpioWaveAddGeneric*]
|
|
|
|
[*gpioWaveAddSerial*]
|
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
handle::>=0
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
A number referencing an object opened by one of
|
|
|
|
|
|
|
|
[*fileOpen*]
|
|
|
|
[*gpioNotifyOpen*]
|
|
|
|
[*i2cOpen*]
|
|
|
|
[*serOpen*]
|
|
|
|
[*spiOpen*]
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
i2cAddr:: 0-0x7F
|
2015-05-17 13:36:40 +02:00
|
|
|
The address of a device on the I2C bus.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
i2cBus::>=0
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
An I2C bus number.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
i2cFlags::0
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
Flags which modify an I2C open command. None are currently defined.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
i2cReg:: 0-255
|
|
|
|
|
|
|
|
A register of an I2C device.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
ifFlags::0-3
|
|
|
|
. .
|
|
|
|
PI_DISABLE_FIFO_IF 1
|
|
|
|
PI_DISABLE_SOCK_IF 2
|
|
|
|
. .
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
*inBuf::
|
|
|
|
A buffer used to pass data to a function.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
inLen::
|
|
|
|
The number of bytes of data in a buffer.
|
|
|
|
|
|
|
|
int::
|
2014-06-12 19:31:00 +02:00
|
|
|
A whole number, negative or positive.
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
int32_t::
|
|
|
|
A 32-bit signed value.
|
|
|
|
|
2015-08-30 10:40:42 +02:00
|
|
|
invert::
|
|
|
|
A flag used to set normal or inverted bit bang serial data level logic.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
level::
|
2016-03-01 22:41:36 +01:00
|
|
|
The level of a GPIO. Low or High.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
PI_OFF 0
|
|
|
|
PI_ON 1
|
|
|
|
|
|
|
|
PI_CLEAR 0
|
|
|
|
PI_SET 1
|
|
|
|
|
|
|
|
PI_LOW 0
|
|
|
|
PI_HIGH 1
|
|
|
|
. .
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
There is one exception. If a watchdog expires on a GPIO the level will be
|
2014-08-01 10:30:25 +02:00
|
|
|
reported as PI_TIMEOUT. See [*gpioSetWatchdog*].
|
|
|
|
|
|
|
|
. .
|
|
|
|
PI_TIMEOUT 2
|
|
|
|
. .
|
|
|
|
|
|
|
|
|
|
|
|
lVal::0-4294967295 (Hex 0x0-0xFFFFFFFF, Octal 0-37777777777)
|
|
|
|
|
|
|
|
A 32-bit word value.
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
memAllocMode:: 0-2
|
|
|
|
|
|
|
|
The DMA memory allocation mode.
|
|
|
|
|
|
|
|
. .
|
|
|
|
PI_MEM_ALLOC_AUTO 0
|
|
|
|
PI_MEM_ALLOC_PAGEMAP 1
|
|
|
|
PI_MEM_ALLOC_MAILBOX 2
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
*micros::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A value representing microseconds.
|
|
|
|
|
|
|
|
micros::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A value representing microseconds.
|
|
|
|
|
|
|
|
millis::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A value representing milliseconds.
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
MISO::
|
|
|
|
The GPIO used for the MISO signal when bit banging SPI.
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
mode::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
1. The operational mode of a GPIO, normally INPUT or OUTPUT.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
PI_INPUT 0
|
|
|
|
PI_OUTPUT 1
|
|
|
|
PI_ALT0 4
|
|
|
|
PI_ALT1 5
|
|
|
|
PI_ALT2 6
|
|
|
|
PI_ALT3 7
|
|
|
|
PI_ALT4 3
|
|
|
|
PI_ALT5 2
|
|
|
|
. .
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
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
|
|
|
|
. .
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
MOSI::
|
|
|
|
The GPIO used for the MOSI signal when bit banging SPI.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
numBits::
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
The number of bits stored in a buffer.
|
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
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.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
numPar:: 0-10
|
|
|
|
The number of parameters passed to a script.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-03-02 23:38:55 +01:00
|
|
|
numPulses::
|
2014-08-01 10:30:25 +02:00
|
|
|
The number of pulses to be added to a waveform.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
numSegs::
|
|
|
|
The number of segments in a combined I2C transaction.
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
numSockAddr::
|
|
|
|
The number of network addresses allowed to use the socket interface.
|
|
|
|
|
|
|
|
0 means all addresses allowed.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
offset::
|
2014-08-01 10:30:25 +02:00
|
|
|
The associated data starts this number of microseconds from the start of
|
2015-06-01 19:32:03 +02:00
|
|
|
the waveform.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
*outBuf::
|
|
|
|
A buffer used to return data from a function.
|
|
|
|
|
|
|
|
outLen::
|
|
|
|
The size in bytes of an output buffer.
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
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.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
*param::
|
2014-08-01 10:30:25 +02:00
|
|
|
An array of script parameters.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-03-02 23:38:55 +01:00
|
|
|
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
|
2014-08-01 10:30:25 +02:00
|
|
|
The port used to bind to the pigpio socket. Defaults to 8888.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
pos::
|
2014-08-01 10:30:25 +02:00
|
|
|
The position of an item.
|
|
|
|
|
|
|
|
primaryChannel:: 0-14
|
2016-03-01 22:41:36 +01:00
|
|
|
The DMA channel used to time the sampling of GPIO and to time servo and
|
2014-08-01 10:30:25 +02:00
|
|
|
PWM pulses.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
*pth::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
A thread identifier, returned by [*gpioStartThread*].
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
pthread_t::
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
A thread identifier.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
pud::0-2
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
The setting of the pull up/down resistor for a GPIO, which may be off,
|
2014-08-01 10:30:25 +02:00
|
|
|
pull-up, or pull-down.
|
2016-10-30 16:30:20 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
PI_PUD_OFF 0
|
|
|
|
PI_PUD_DOWN 1
|
|
|
|
PI_PUD_UP 2
|
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
pulseLen::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-08-17 20:53:43 +02:00
|
|
|
1-100, the length of a trigger pulse in microseconds.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
*pulses::
|
|
|
|
|
2014-09-03 20:52:48 +02:00
|
|
|
An array of pulses to be added to a waveform.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
pulsewidth::0, 500-2500
|
|
|
|
. .
|
|
|
|
PI_SERVO_OFF 0
|
|
|
|
PI_MIN_SERVO_PULSEWIDTH 500
|
|
|
|
PI_MAX_SERVO_PULSEWIDTH 2500
|
|
|
|
. .
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
PWMduty::0-1000000 (1M)
|
2014-12-17 23:31:17 +01:00
|
|
|
The hardware PWM dutycycle.
|
|
|
|
|
|
|
|
. .
|
2015-10-02 09:23:02 +02:00
|
|
|
PI_HW_PWM_RANGE 1000000
|
2014-12-17 23:31:17 +01:00
|
|
|
. .
|
|
|
|
|
|
|
|
PWMfreq::5-250K
|
|
|
|
The hardware PWM frequency.
|
|
|
|
|
|
|
|
. .
|
2015-10-02 09:23:02 +02:00
|
|
|
PI_HW_PWM_MIN_FREQ 1
|
|
|
|
PI_HW_PWM_MAX_FREQ 125000000
|
2014-12-17 23:31:17 +01:00
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
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
|
|
|
|
{
|
2016-03-01 22:41:36 +01:00
|
|
|
int clk; // GPIO for clock
|
|
|
|
int mosi; // GPIO for MOSI
|
|
|
|
int miso; // GPIO for MISO
|
2014-06-12 19:31:00 +02:00
|
|
|
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;
|
|
|
|
. .
|
|
|
|
|
2014-09-09 23:58:39 +02:00
|
|
|
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
|
2016-03-01 22:41:36 +01:00
|
|
|
uint16_t deleted;
|
|
|
|
uint16_t numCB;
|
|
|
|
uint16_t numBOOL;
|
|
|
|
uint16_t numTOOL;
|
2014-09-09 23:58:39 +02:00
|
|
|
} rawWaveInfo_t;
|
|
|
|
. .
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
*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.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
*rxBuf::
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
A pointer to a buffer to receive data.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
SCL::
|
2016-03-01 22:41:36 +01:00
|
|
|
The user GPIO to use for the clock when bit banging I2C.
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
SCLK::
|
|
|
|
The GPIO used for the SCLK signal when bit banging SPI.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
*script::
|
2014-08-01 10:30:25 +02:00
|
|
|
A pointer to the text of a script.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
script_id::
|
2014-08-01 10:30:25 +02:00
|
|
|
An id of a stored script as returned by [*gpioStoreScript*].
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
*scriptName::
|
|
|
|
The name of a [*shell*] script to be executed. The script must be present in
|
|
|
|
/opt/pigpio/cgi and must have execute permission.
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
*scriptString::
|
|
|
|
The string to be passed to a [*shell*] script to be executed.
|
|
|
|
|
|
|
|
SDA::
|
2016-03-01 22:41:36 +01:00
|
|
|
The user GPIO to use for data when bit banging I2C.
|
2015-05-17 13:36:40 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
secondaryChannel:: 0-6
|
|
|
|
|
|
|
|
The DMA channel used to time output waveforms.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
*seconds::
|
|
|
|
|
|
|
|
A pointer to a uint32_t to store the second component of
|
|
|
|
a returned time.
|
|
|
|
|
|
|
|
seconds::
|
2014-08-01 10:30:25 +02:00
|
|
|
The number of seconds.
|
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
seekFrom::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
. .
|
|
|
|
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::
|
2015-05-17 13:36:40 +02:00
|
|
|
An array of segments which make up a combined I2C transaction.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
serFlags::
|
|
|
|
Flags which modify a serial open command. None are currently defined.
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
*sertty::
|
|
|
|
The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1.
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
setting::
|
|
|
|
A value used to set a flag, 0 for false, non-zero for true.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
signum::0-63
|
|
|
|
. .
|
|
|
|
PI_MIN_SIGNUM 0
|
|
|
|
PI_MAX_SIGNUM 63
|
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
size_t::
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
A standard type used to indicate the size of an object in bytes.
|
|
|
|
|
2016-09-22 15:12:26 +02:00
|
|
|
*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.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
*spi::
|
2014-08-01 10:30:25 +02:00
|
|
|
A pointer to a [*rawSPI_t*] structure.
|
|
|
|
|
|
|
|
spiBitFirst::
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO reads are made from spiBitFirst to spiBitLast.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
spiBitLast::
|
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
GPIO reads are made from spiBitFirst to spiBitLast.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
spiBits::
|
|
|
|
The number of bits to transfer in a raw SPI transaction.
|
|
|
|
|
|
|
|
spiChan::
|
2014-09-09 23:58:39 +02:00
|
|
|
A SPI channel, 0-2.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
spiFlags::
|
2016-09-22 15:12:26 +02:00
|
|
|
See [*spiOpen*] and [*bbSPIOpen*].
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
spiSS::
|
2016-03-01 22:41:36 +01:00
|
|
|
The SPI slave select GPIO in a raw SPI transaction.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
spiTxBits::
|
|
|
|
The number of bits to transfer dring a raw SPI transaction
|
|
|
|
|
2015-10-28 12:06:53 +01:00
|
|
|
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*]).
|
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
stop_bits::2-8
|
|
|
|
The number of (half) stop bits to be used when adding serial data
|
|
|
|
to a waveform.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
. .
|
2015-10-02 09:23:02 +02:00
|
|
|
PI_MIN_WAVE_HALFSTOPBITS 2
|
|
|
|
PI_MAX_WAVE_HALFSTOPBITS 8
|
2015-05-17 13:36:40 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
*str::
|
2014-08-01 10:30:25 +02:00
|
|
|
An array of characters.
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
timeout::
|
2016-03-01 22:41:36 +01:00
|
|
|
A GPIO level change timeout in milliseconds.
|
2015-10-02 09:23:02 +02:00
|
|
|
|
|
|
|
[*gpioSetWatchdog*]
|
2014-06-12 19:31:00 +02:00
|
|
|
. .
|
|
|
|
PI_MIN_WDOG_TIMEOUT 0
|
|
|
|
PI_MAX_WDOG_TIMEOUT 60000
|
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
[*gpioSetISRFunc*] and [*gpioSetISRFuncEx*]
|
|
|
|
. .
|
|
|
|
<=0 cancel timeout
|
|
|
|
>0 timeout after specified milliseconds
|
|
|
|
. .
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
timer::
|
|
|
|
. .
|
|
|
|
PI_MIN_TIMER 0
|
|
|
|
PI_MAX_TIMER 9
|
|
|
|
. .
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
timetype::
|
|
|
|
. .
|
|
|
|
PI_TIME_RELATIVE 0
|
|
|
|
PI_TIME_ABSOLUTE 1
|
|
|
|
. .
|
|
|
|
|
|
|
|
*txBuf::
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
An array of bytes to transmit.
|
|
|
|
|
|
|
|
uint32_t::0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
A 32-bit unsigned value.
|
|
|
|
|
|
|
|
uint64_t::0-(2^64)-1
|
|
|
|
|
|
|
|
A 64-bit unsigned value.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
unsigned::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
A whole number >= 0.
|
|
|
|
|
|
|
|
updateMask::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
A 64 bit mask indicating which GPIO may be written to by the user.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
If GPIO#n may be written then bit (1<<n) is set.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
|
|
|
user_gpio::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2016-03-01 22:41:36 +01:00
|
|
|
0-31, a Broadcom numbered GPIO.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
See [*gpio*].
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
*userdata::
|
2014-08-01 10:30:25 +02:00
|
|
|
A pointer to arbitrary user data. This may be used to identify the instance.
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2015-11-10 15:57:12 +01:00
|
|
|
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:
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
user_type *userdata;
|
|
|
|
user_type my_userdata;
|
|
|
|
|
|
|
|
userdata = malloc(sizeof(user_type));
|
|
|
|
*userdata = my_userdata;
|
2016-10-30 16:30:20 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
|
|
|
|
In the receiving function:
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
user_type my_userdata = *(user_type*)userdata;
|
|
|
|
|
|
|
|
free(userdata);
|
2016-10-30 16:30:20 +01:00
|
|
|
. .
|
2015-11-10 15:57:12 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
void::
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
Denoting no parameter is required
|
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
wave_id::
|
2014-08-01 10:30:25 +02:00
|
|
|
|
2015-07-24 22:17:29 +02:00
|
|
|
A number identifying a waveform created by [*gpioWaveCreate*].
|
2014-06-12 19:31:00 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
wave_mode::
|
|
|
|
|
2016-02-18 22:51:10 +01:00
|
|
|
The mode determines if the waveform is sent once or cycles
|
|
|
|
repeatedly. The SYNC variants wait for the current waveform
|
|
|
|
to reach the end of a cycle or finish before starting the new
|
|
|
|
waveform.
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
. .
|
2016-02-18 22:51:10 +01:00
|
|
|
PI_WAVE_MODE_ONE_SHOT 0
|
|
|
|
PI_WAVE_MODE_REPEAT 1
|
|
|
|
PI_WAVE_MODE_ONE_SHOT_SYNC 2
|
|
|
|
PI_WAVE_MODE_REPEAT_SYNC 3
|
2014-08-01 10:30:25 +02:00
|
|
|
. .
|
|
|
|
|
|
|
|
wVal::0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777)
|
|
|
|
|
|
|
|
A 16-bit word value.
|
|
|
|
|
|
|
|
PARAMS*/
|
|
|
|
|
|
|
|
/*DEF_S Socket Command Codes*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
#define PI_CMD_MODES 0
|
|
|
|
#define PI_CMD_MODEG 1
|
|
|
|
#define PI_CMD_PUD 2
|
|
|
|
#define PI_CMD_READ 3
|
|
|
|
#define PI_CMD_WRITE 4
|
|
|
|
#define PI_CMD_PWM 5
|
|
|
|
#define PI_CMD_PRS 6
|
|
|
|
#define PI_CMD_PFS 7
|
|
|
|
#define PI_CMD_SERVO 8
|
|
|
|
#define PI_CMD_WDOG 9
|
|
|
|
#define PI_CMD_BR1 10
|
|
|
|
#define PI_CMD_BR2 11
|
|
|
|
#define PI_CMD_BC1 12
|
|
|
|
#define PI_CMD_BC2 13
|
|
|
|
#define PI_CMD_BS1 14
|
|
|
|
#define PI_CMD_BS2 15
|
|
|
|
#define PI_CMD_TICK 16
|
|
|
|
#define PI_CMD_HWVER 17
|
|
|
|
#define PI_CMD_NO 18
|
|
|
|
#define PI_CMD_NB 19
|
|
|
|
#define PI_CMD_NP 20
|
|
|
|
#define PI_CMD_NC 21
|
|
|
|
#define PI_CMD_PRG 22
|
|
|
|
#define PI_CMD_PFG 23
|
|
|
|
#define PI_CMD_PRRG 24
|
|
|
|
#define PI_CMD_HELP 25
|
2014-01-12 22:31:59 +01:00
|
|
|
#define PI_CMD_PIGPV 26
|
2014-01-21 20:04:59 +01:00
|
|
|
#define PI_CMD_WVCLR 27
|
|
|
|
#define PI_CMD_WVAG 28
|
|
|
|
#define PI_CMD_WVAS 29
|
|
|
|
#define PI_CMD_WVGO 30
|
|
|
|
#define PI_CMD_WVGOR 31
|
|
|
|
#define PI_CMD_WVBSY 32
|
|
|
|
#define PI_CMD_WVHLT 33
|
|
|
|
#define PI_CMD_WVSM 34
|
|
|
|
#define PI_CMD_WVSP 35
|
|
|
|
#define PI_CMD_WVSC 36
|
|
|
|
#define PI_CMD_TRIG 37
|
|
|
|
#define PI_CMD_PROC 38
|
|
|
|
#define PI_CMD_PROCD 39
|
|
|
|
#define PI_CMD_PROCR 40
|
|
|
|
#define PI_CMD_PROCS 41
|
2014-01-29 00:07:05 +01:00
|
|
|
#define PI_CMD_SLRO 42
|
|
|
|
#define PI_CMD_SLR 43
|
|
|
|
#define PI_CMD_SLRC 44
|
2014-03-13 16:50:23 +01:00
|
|
|
#define PI_CMD_PROCP 45
|
2014-04-19 13:19:29 +02:00
|
|
|
#define PI_CMD_MICS 46
|
|
|
|
#define PI_CMD_MILS 47
|
|
|
|
#define PI_CMD_PARSE 48
|
|
|
|
#define PI_CMD_WVCRE 49
|
|
|
|
#define PI_CMD_WVDEL 50
|
|
|
|
#define PI_CMD_WVTX 51
|
|
|
|
#define PI_CMD_WVTXR 52
|
|
|
|
#define PI_CMD_WVNEW 53
|
2014-03-13 16:50:23 +01:00
|
|
|
|
2014-06-12 19:31:00 +02:00
|
|
|
#define PI_CMD_I2CO 54
|
|
|
|
#define PI_CMD_I2CC 55
|
|
|
|
#define PI_CMD_I2CRD 56
|
|
|
|
#define PI_CMD_I2CWD 57
|
|
|
|
#define PI_CMD_I2CWQ 58
|
|
|
|
#define PI_CMD_I2CRS 59
|
|
|
|
#define PI_CMD_I2CWS 60
|
|
|
|
#define PI_CMD_I2CRB 61
|
|
|
|
#define PI_CMD_I2CWB 62
|
|
|
|
#define PI_CMD_I2CRW 63
|
|
|
|
#define PI_CMD_I2CWW 64
|
|
|
|
#define PI_CMD_I2CRK 65
|
|
|
|
#define PI_CMD_I2CWK 66
|
|
|
|
#define PI_CMD_I2CRI 67
|
|
|
|
#define PI_CMD_I2CWI 68
|
|
|
|
#define PI_CMD_I2CPC 69
|
|
|
|
#define PI_CMD_I2CPK 70
|
|
|
|
|
|
|
|
#define PI_CMD_SPIO 71
|
|
|
|
#define PI_CMD_SPIC 72
|
|
|
|
#define PI_CMD_SPIR 73
|
|
|
|
#define PI_CMD_SPIW 74
|
|
|
|
#define PI_CMD_SPIX 75
|
|
|
|
|
|
|
|
#define PI_CMD_SERO 76
|
|
|
|
#define PI_CMD_SERC 77
|
|
|
|
#define PI_CMD_SERRB 78
|
|
|
|
#define PI_CMD_SERWB 79
|
|
|
|
#define PI_CMD_SERR 80
|
|
|
|
#define PI_CMD_SERW 81
|
|
|
|
#define PI_CMD_SERDA 82
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-11-20 16:36:16 +01:00
|
|
|
#define PI_CMD_GDC 83
|
|
|
|
#define PI_CMD_GPW 84
|
|
|
|
|
2014-12-17 23:31:17 +01:00
|
|
|
#define PI_CMD_HC 85
|
|
|
|
#define PI_CMD_HP 86
|
|
|
|
|
2015-02-02 22:11:28 +01:00
|
|
|
#define PI_CMD_CF1 87
|
|
|
|
#define PI_CMD_CF2 88
|
|
|
|
|
2015-04-23 09:58:59 +02:00
|
|
|
#define PI_CMD_BI2CC 89
|
|
|
|
#define PI_CMD_BI2CO 90
|
2015-05-17 13:36:40 +02:00
|
|
|
#define PI_CMD_BI2CZ 91
|
2015-04-23 09:58:59 +02:00
|
|
|
|
2015-05-17 13:36:40 +02:00
|
|
|
#define PI_CMD_I2CZ 92
|
2015-04-23 09:58:59 +02:00
|
|
|
|
2015-06-18 12:46:46 +02:00
|
|
|
#define PI_CMD_WVCHA 93
|
|
|
|
|
2015-08-29 15:06:27 +02:00
|
|
|
#define PI_CMD_SLRI 94
|
|
|
|
|
2015-10-02 09:23:02 +02:00
|
|
|
#define PI_CMD_CGI 95
|
|
|
|
#define PI_CMD_CSI 96
|
|
|
|
|
2015-10-28 12:06:53 +01:00
|
|
|
#define PI_CMD_FG 97
|
|
|
|
#define PI_CMD_FN 98
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_CMD_NOIB 99
|
|
|
|
|
2016-02-18 22:51:10 +01:00
|
|
|
#define PI_CMD_WVTXM 100
|
2016-03-01 22:41:36 +01:00
|
|
|
#define PI_CMD_WVTAT 101
|
2016-02-18 22:51:10 +01:00
|
|
|
|
2016-07-10 22:29:14 +02:00
|
|
|
#define PI_CMD_PADS 102
|
|
|
|
#define PI_CMD_PADG 103
|
|
|
|
|
|
|
|
#define PI_CMD_FO 104
|
|
|
|
#define PI_CMD_FC 105
|
|
|
|
#define PI_CMD_FR 106
|
|
|
|
#define PI_CMD_FW 107
|
|
|
|
#define PI_CMD_FS 108
|
|
|
|
#define PI_CMD_FL 109
|
|
|
|
|
|
|
|
#define PI_CMD_SHELL 110
|
|
|
|
|
2016-08-06 12:18:17 +02:00
|
|
|
#define PI_CMD_BSPIC 111
|
|
|
|
#define PI_CMD_BSPIO 112
|
|
|
|
#define PI_CMD_BSPIX 113
|
|
|
|
|
2016-10-30 16:30:20 +01:00
|
|
|
#define PI_CMD_BSCX 114
|
|
|
|
|
|
|
|
#define PI_CMD_EVM 115
|
|
|
|
#define PI_CMD_EVT 116
|
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*DEF_E*/
|
|
|
|
|
2013-12-12 11:27:22 +01:00
|
|
|
/*
|
2014-08-01 10:30:25 +02:00
|
|
|
PI CMD_NOIB only works on the socket interface.
|
2013-12-12 11:27:22 +01:00
|
|
|
It returns a spare notification handle. Notifications for
|
|
|
|
that handle will be sent to the socket (rather than a
|
|
|
|
/dev/pigpiox pipe).
|
|
|
|
|
|
|
|
The socket should be dedicated to receiving notifications
|
|
|
|
after this command is issued.
|
|
|
|
*/
|
|
|
|
|
2014-03-13 16:50:23 +01:00
|
|
|
/* pseudo commands */
|
|
|
|
|
|
|
|
#define PI_CMD_SCRIPT 800
|
|
|
|
|
2014-04-19 13:19:29 +02:00
|
|
|
#define PI_CMD_ADD 800
|
|
|
|
#define PI_CMD_AND 801
|
|
|
|
#define PI_CMD_CALL 802
|
2014-06-12 19:31:00 +02:00
|
|
|
#define PI_CMD_CMDR 803
|
|
|
|
#define PI_CMD_CMDW 804
|
|
|
|
#define PI_CMD_CMP 805
|
|
|
|
#define PI_CMD_DCR 806
|
|
|
|
#define PI_CMD_DCRA 807
|
|
|
|
#define PI_CMD_DIV 808
|
|
|
|
#define PI_CMD_HALT 809
|
|
|
|
#define PI_CMD_INR 810
|
|
|
|
#define PI_CMD_INRA 811
|
|
|
|
#define PI_CMD_JM 812
|
|
|
|
#define PI_CMD_JMP 813
|
|
|
|
#define PI_CMD_JNZ 814
|
|
|
|
#define PI_CMD_JP 815
|
|
|
|
#define PI_CMD_JZ 816
|
|
|
|
#define PI_CMD_TAG 817
|
|
|
|
#define PI_CMD_LD 818
|
|
|
|
#define PI_CMD_LDA 819
|
|
|
|
#define PI_CMD_LDAB 820
|
|
|
|
#define PI_CMD_MLT 821
|
|
|
|
#define PI_CMD_MOD 822
|
|
|
|
#define PI_CMD_NOP 823
|
|
|
|
#define PI_CMD_OR 824
|
|
|
|
#define PI_CMD_POP 825
|
|
|
|
#define PI_CMD_POPA 826
|
|
|
|
#define PI_CMD_PUSH 827
|
|
|
|
#define PI_CMD_PUSHA 828
|
|
|
|
#define PI_CMD_RET 829
|
|
|
|
#define PI_CMD_RL 830
|
|
|
|
#define PI_CMD_RLA 831
|
|
|
|
#define PI_CMD_RR 832
|
|
|
|
#define PI_CMD_RRA 833
|
|
|
|
#define PI_CMD_STA 834
|
|
|
|
#define PI_CMD_STAB 835
|
|
|
|
#define PI_CMD_SUB 836
|
|
|
|
#define PI_CMD_SYS 837
|
|
|
|
#define PI_CMD_WAIT 838
|
|
|
|
#define PI_CMD_X 839
|
|
|
|
#define PI_CMD_XA 840
|
|
|
|
#define PI_CMD_XOR 841
|
2016-10-30 16:30:20 +01:00
|
|
|
#define PI_CMD_EVTWT 842
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*DEF_S Error Codes*/
|
|
|
|
|
|
|
|
#define PI_INIT_FAILED -1 // gpioInitialise failed
|
2016-03-01 22:41:36 +01:00
|
|
|
#define PI_BAD_USER_GPIO -2 // GPIO not 0-31
|
|
|
|
#define PI_BAD_GPIO -3 // GPIO not 0-53
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_BAD_MODE -4 // mode not 0-7
|
|
|
|
#define PI_BAD_LEVEL -5 // level not 0-1
|
|
|
|
#define PI_BAD_PUD -6 // pud not 0-2
|
|
|
|
#define PI_BAD_PULSEWIDTH -7 // pulsewidth not 0 or 500-2500
|
|
|
|
#define PI_BAD_DUTYCYCLE -8 // dutycycle outside set range
|
|
|
|
#define PI_BAD_TIMER -9 // timer not 0-9
|
|
|
|
#define PI_BAD_MS -10 // ms not 10-60000
|
|
|
|
#define PI_BAD_TIMETYPE -11 // timetype not 0-1
|
|
|
|
#define PI_BAD_SECONDS -12 // seconds < 0
|
|
|
|
#define PI_BAD_MICROS -13 // micros not 0-999999
|
|
|
|
#define PI_TIMER_FAILED -14 // gpioSetTimerFunc failed
|
|
|
|
#define PI_BAD_WDOG_TIMEOUT -15 // timeout not 0-60000
|
|
|
|
#define PI_NO_ALERT_FUNC -16 // DEPRECATED
|
|
|
|
#define PI_BAD_CLK_PERIPH -17 // clock peripheral not 0-1
|
2014-12-17 23:31:17 +01:00
|
|
|
#define PI_BAD_CLK_SOURCE -18 // DEPRECATED
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_BAD_CLK_MICROS -19 // clock micros not 1, 2, 4, 5, 8, or 10
|
|
|
|
#define PI_BAD_BUF_MILLIS -20 // buf millis not 100-10000
|
|
|
|
#define PI_BAD_DUTYRANGE -21 // dutycycle range not 25-40000
|
|
|
|
#define PI_BAD_DUTY_RANGE -21 // DEPRECATED (use PI_BAD_DUTYRANGE)
|
|
|
|
#define PI_BAD_SIGNUM -22 // signum not 0-63
|
|
|
|
#define PI_BAD_PATHNAME -23 // can't open pathname
|
|
|
|
#define PI_NO_HANDLE -24 // no handle available
|
|
|
|
#define PI_BAD_HANDLE -25 // unknown handle
|
2017-05-19 10:01:51 +02:00
|
|
|
#define PI_BAD_IF_FLAGS -26 // ifFlags > 4
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_BAD_CHANNEL -27 // DMA channel not 0-14
|
|
|
|
#define PI_BAD_PRIM_CHANNEL -27 // DMA primary channel not 0-14
|
|
|
|
#define PI_BAD_SOCKET_PORT -28 // socket port not 1024-32000
|
|
|
|
#define PI_BAD_FIFO_COMMAND -29 // unrecognized fifo command
|
|
|
|
#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-6
|
|
|
|
#define PI_NOT_INITIALISED -31 // function called before gpioInitialise
|
|
|
|
#define PI_INITIALISED -32 // function called after gpioInitialise
|
2016-02-18 22:51:10 +01:00
|
|
|
#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call
|
2014-12-17 23:31:17 +01:00
|
|
|
#define PI_BAD_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX)
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses
|
|
|
|
#define PI_TOO_MANY_CHARS -37 // waveform has too many chars
|
2016-07-10 22:29:14 +02:00
|
|
|
#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read on GPIO
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter
|
|
|
|
#define PI_BAD_SERIAL_BUF -40 // bad (null) serial buf parameter
|
2016-03-01 22:41:36 +01:00
|
|
|
#define PI_NOT_PERMITTED -41 // GPIO operation not permitted
|
|
|
|
#define PI_SOME_PERMITTED -42 // one or more GPIO not permitted
|
2014-08-01 10:30:25 +02:00
|
|
|
#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
|
2014-12-17 23:31:17 +01:00
|
|
|
#define PI_BAD_PULSELEN -46 // trigger pulse length not 1-100
|
2014-08-01 10:30:25 +02:00
|
|
|
#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
|
2016-03-01 22:41:36 +01:00
|
|
|
#define PI_GPIO_IN_USE -50 // GPIO already in use
|
2014-08-01 10:30:25 +02:00
|
|
|
#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time
|
2014-12-17 23:31:17 +01:00
|
|
|
#define PI_BAD_PARAM_NUM -52 // script parameter id not 0-9
|
2014-08-01 10:30:25 +02:00
|
|
|
#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
|
2014-12-17 23:31:17 +01:00
|
|
|
#define PI_BAD_VAR_NUM -56 // script variable id not 0-149
|
2014-08-01 10:30:25 +02:00
|
|
|
#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
|
2014-12-17 23:31:17 +01:00
|
|
|
#define PI_TOO_MANY_PARAM -61 // too many script parameters (> 10)
|
2016-05-31 19:44:12 +02:00
|
|
|
#define PI_NOT_HALTED -62 // DEPRECATED
|
|
|
|
#define PI_SCRIPT_NOT_READY -62 // script initialising
|
2014-08-01 10:30:25 +02:00
|
|
|
#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
|
2016-03-01 22:41:36 +01:00
|
|
|
#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
|
2015-02-25 21:34:52 +01:00
|
|
|
#define PI_BAD_HPWM_FREQ -96 // hardware PWM frequency not 1-125M
|
|
|
|
#define PI_BAD_HPWM_DUTY -97 // hardware PWM dutycycle not 0-1M
|
|
|
|
#define PI_BAD_HCLK_FREQ -98 // hardware clock frequency not 4689-250M
|
2014-12-17 23:31:17 +01:00
|
|
|
#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
|
2015-02-02 22:11:28 +01:00
|
|
|
#define PI_MSG_TOOBIG -103 // socket/pipe message too big
|
2015-02-25 21:34:52 +01:00
|
|
|
#define PI_BAD_MALLOC_MODE -104 // bad memory allocation mode
|
2015-05-17 13:36:40 +02:00
|
|
|
#define PI_TOO_MANY_SEGS -105 // too many I2C transaction segments
|
|
|
|
#define PI_BAD_I2C_SEG -106 // an I2C transaction segment failed
|
2015-04-23 09:58:59 +02:00
|
|
|
#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
|
2016-03-01 22:41:36 +01:00
|
|
|
#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO
|
2015-05-17 13:36:40 +02:00
|
|
|
#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
|
2015-07-24 22:17:29 +02:00
|
|
|
#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
|
2015-08-30 10:40:42 +02:00
|
|
|
#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1
|
2015-10-02 09:23:02 +02:00
|
|
|
#define PI_BAD_EDGE -122 // bad ISR edge value, not 0-2
|
|
|
|
#define PI_BAD_ISR_INIT -123 // bad ISR initialisation
|
2016-07-10 22:29:14 +02:00
|
|
|
#define PI_BAD_FOREVER -124 // loop forever must be last command
|
2015-10-28 12:06:53 +01:00
|
|
|
#define PI_BAD_FILTER -125 // bad filter parameter
|
2016-07-10 22:29:14 +02:00
|
|
|
#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
|
2016-08-06 12:18:17 +02:00
|
|
|
#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
|
2016-10-30 16:30:20 +01:00
|
|
|
#define PI_BAD_EVENT_ID -143 // bad event id
|
2015-02-02 22:11:28 +01:00
|
|
|
|
|
|
|
#define PI_PIGIF_ERR_0 -2000
|
|
|
|
#define PI_PIGIF_ERR_99 -2099
|
|
|
|
|
|
|
|
#define PI_CUSTOM_ERR_0 -3000
|
|
|
|
#define PI_CUSTOM_ERR_999 -3999
|
2014-08-01 10:30:25 +02:00
|
|
|
|
|
|
|
/*DEF_E*/
|
|
|
|
|
|
|
|
/*DEF_S Defaults*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
2016-03-08 15:28:15 +01:00
|
|
|
#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
|
2016-10-31 00:05:30 +01:00
|
|
|
#define PI_DEFAULT_FOREGROUND 0
|
2016-03-08 15:28:15 +01:00
|
|
|
#define PI_DEFAULT_DMA_CHANNEL 14
|
|
|
|
#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
|
|
|
|
#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
|
|
|
|
#define PI_DEFAULT_SOCKET_PORT 8888
|
|
|
|
#define PI_DEFAULT_SOCKET_PORT_STR "8888"
|
|
|
|
#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
|
|
|
|
#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0xFFFFFFFF
|
|
|
|
#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_COMPUTE 0x00FFFFFFFFFFFFLL
|
|
|
|
#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
|
2015-02-25 21:34:52 +01:00
|
|
|
|
2016-05-31 19:44:12 +02:00
|
|
|
#define PI_DEFAULT_CFG_INTERNALS 0
|
2015-10-02 09:23:02 +02:00
|
|
|
|
2014-08-01 10:30:25 +02:00
|
|
|
/*DEF_E*/
|
2013-12-12 11:27:22 +01:00
|
|
|
|
|
|
|
#endif
|
2014-01-12 22:31:59 +01:00
|
|
|
|