*/
/*
-This version is for pigpio version 46+
+This version is for pigpio version 47+
*/
#include <stdio.h>
{PI_CMD_WVAG, "WVAG", 192, 2}, // gpioWaveAddGeneric
{PI_CMD_WVAS, "WVAS", 196, 2}, // gpioWaveAddSerial
+ {PI_CMD_WVTAT, "WVTAT", 101, 2}, // gpioWaveTxAt
{PI_CMD_WVBSY, "WVBSY", 101, 2}, // gpioWaveTxBusy
{PI_CMD_WVCHA, "WVCHA", 197, 0}, // gpioWaveChain
{PI_CMD_WVCLR, "WVCLR", 101, 0}, // gpioWaveClear
char * cmdUsage = "\n\
-BC1 bits Clear gpios in bank 1\n\
-BC2 bits Clear gpios in bank 2\n\
+BC1 bits Clear GPIO in bank 1\n\
+BC2 bits Clear GPIO in bank 2\n\
BI2CC sda Close bit bang I2C\n\
BI2CO sda scl baud | Open bit bang I2C\n\
BI2CZ sda ... I2C bit bang multiple transactions\n\
-BR1 Read bank 1 gpios\n\
-BR2 Read bank 2 gpios\n\
-BS1 bits Set gpios in bank 2\n\
-BS2 bits Set gpios in bank 2\n\
+BR1 Read bank 1 GPIO\n\
+BR2 Read bank 2 GPIO\n\
+BS1 bits Set GPIO in bank 2\n\
+BS2 bits Set GPIO in bank 2\n\
\n\
CF1 ... Custom function 1\n\
CF2 ... Custom function 2\n\
CGI Configuration get internals\n\
CSI v Configuration set internals\n\
\n\
-FG g steady Set glitch filter on gpio\n\
-FN g steady active | Set noise filter on gpio\n\
+FG g steady Set glitch filter on GPIO\n\
+FN g steady active | Set noise filter on GPIO\n\
\n\
-GDC g Get PWM dutycycle for gpio\n\
-GPW g Get servo pulsewidth for gpio\n\
+GDC g Get PWM dutycycle for GPIO\n\
+GPW g Get servo pulsewidth for GPIO\n\
\n\
H/HELP Display command help\n\
HC g f Set hardware clock frequency\n\
I2CWW h r word SMBus Write Word Data: write word to register\n\
I2CZ h ... I2C multiple transactions\n\
\n\
-M/MODES g mode Set gpio mode\n\
-MG/MODEG g Get gpio mode\n\
+M/MODES g mode Set GPIO mode\n\
+MG/MODEG g Get GPIO mode\n\
MICS n Delay for microseconds\n\
MILS n Delay for milliseconds\n\
\n\
NO Request a notification\n\
NP h Pause notification\n\
\n\
-P/PWM g v Set gpio PWM value\n\
+P/PWM g v Set GPIO PWM value\n\
PARSE text Validate script\n\
-PFG g Get gpio PWM frequency\n\
-PFS g v Set gpio PWM frequency\n\
+PFG g Get GPIO PWM frequency\n\
+PFS g v Set GPIO PWM frequency\n\
PIGPV Get pigpio library version\n\
-PRG g Get gpio PWM range\n\
+PRG g Get GPIO PWM range\n\
PROC text Store script\n\
PROCD sid Delete script\n\
PROCP sid Get script status and parameters\n\
PROCR sid ... Run script\n\
PROCS sid Stop script\n\
-PRRG g Get gpio PWM real range\n\
-PRS g v Set gpio PWM range\n\
-PUD g pud Set gpio pull up/down\n\
+PRRG g Get GPIO PWM real range\n\
+PRS g v Set GPIO PWM range\n\
+PUD g pud Set GPIO pull up/down\n\
\n\
-R/READ g Read gpio level\n\
+R/READ g Read GPIO level\n\
\n\
-S/SERVO g v Set gpio servo pulsewidth\n\
+S/SERVO g v Set GPIO servo pulsewidth\n\
SERC h Close serial handle\n\
SERDA h Check for serial data ready to read\n\
SERO text baud flags | Open serial device at baud with flags\n\
SERRB h Read byte from serial handle\n\
SERW h ... Write bytes to serial handle\n\
SERWB h byte Write byte to serial handle\n\
-SLR g v Read bit bang serial data from gpio\n\
-SLRC g Close gpio for bit bang serial data\n\
-SLRO g baud bitlen | Open gpio for bit bang serial data\n\
+SLR g v Read bit bang serial data from GPIO\n\
+SLRC g Close GPIO for bit bang serial data\n\
+SLRO g baud bitlen | Open GPIO for bit bang serial data\n\
SLRI g invert Invert serial logic (1 invert, 0 normal)\n\
SPIC h SPI close handle\n\
SPIO channel baud flags | SPI open channel at baud with flags\n\
SPIX h ... SPI transfer bytes to handle\n\
\n\
T/TICK Get current tick\n\
-TRIG g micros l Trigger level for micros on gpio\n\
+TRIG g micros l Trigger level for micros on GPIO\n\
\n\
-W/WRITE g l Write level to gpio\n\
-WDOG g millis Set millisecond watchdog on gpio\n\
+W/WRITE g l Write level to GPIO\n\
+WDOG g millis Set millisecond watchdog on GPIO\n\
WVAG triplets Wave add generic pulses\n\
WVAS g baud bitlen stopbits offset ... | Wave add serial data\n\
WVBSY Check if wave busy\n\
WVSC 0,1,2 Wave get DMA control block stats\n\
WVSM 0,1,2 Wave get micros stats\n\
WVSP 0,1,2 Wave get pulses stats\n\
+WVTAT Returns the current transmitting wave\n\
WVTX wid Transmit wave as one-shot\n\
WVTXM wid wmde Transmit wave using mode\n\
WVTXR wid Transmit wave repeatedly\n\
static errInfo_t errInfo[]=
{
{PI_INIT_FAILED , "pigpio initialisation failed"},
- {PI_BAD_USER_GPIO , "gpio not 0-31"},
- {PI_BAD_GPIO , "gpio not 0-53"},
+ {PI_BAD_USER_GPIO , "GPIO not 0-31"},
+ {PI_BAD_GPIO , "GPIO not 0-53"},
{PI_BAD_MODE , "mode not 0-7"},
{PI_BAD_LEVEL , "level not 0-1"},
{PI_BAD_PUD , "pud not 0-2"},
{PI_BAD_WAVE_BAUD , "baud rate not 50-250K(RX)/50-1M(TX)"},
{PI_TOO_MANY_PULSES , "waveform has too many pulses"},
{PI_TOO_MANY_CHARS , "waveform has too many chars"},
- {PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on gpio"},
+ {PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on GPIO"},
{PI_BAD_SERIAL_STRUC , "bad (null) serial structure parameter"},
{PI_BAD_SERIAL_BUF , "bad (null) serial buf parameter"},
- {PI_NOT_PERMITTED , "no permission to update gpio"},
- {PI_SOME_PERMITTED , "no permission to update one or more gpios"},
+ {PI_NOT_PERMITTED , "no permission to update GPIO"},
+ {PI_SOME_PERMITTED , "no permission to update one or more GPIO"},
{PI_BAD_WVSC_COMMND , "bad WVSC subcommand"},
{PI_BAD_WVSM_COMMND , "bad WVSM subcommand"},
{PI_BAD_WVSP_COMMND , "bad WVSP subcommand"},
{PI_BAD_SCRIPT , "invalid script"},
{PI_BAD_SCRIPT_ID , "unknown script id"},
{PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"},
- {PI_GPIO_IN_USE , "gpio already in use"},
+ {PI_GPIO_IN_USE , "GPIO already in use"},
{PI_BAD_SERIAL_COUNT , "must read at least a byte at a time"},
{PI_BAD_PARAM_NUM , "script parameter id not 0-9"},
{PI_DUP_TAG , "script has duplicate tag"},
{PI_SPI_XFER_FAILED , "spi xfer/read/write failed"},
{PI_BAD_POINTER , "bad (NULL) pointer"},
{PI_NO_AUX_SPI , "need a B+ for auxiliary SPI"},
- {PI_NOT_PWM_GPIO , "gpio is not in use for PWM"},
- {PI_NOT_SERVO_GPIO , "gpio is not in use for servo pulses"},
- {PI_NOT_HCLK_GPIO , "gpio has no hardware clock"},
- {PI_NOT_HPWM_GPIO , "gpio has no hardware PWM"},
+ {PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"},
+ {PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"},
+ {PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"},
+ {PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"},
{PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"},
{PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"},
{PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"},
{PI_TOO_MANY_SEGS , "too many I2C transaction segments"},
{PI_BAD_I2C_SEG , "an I2C transaction segment failed"},
{PI_BAD_SMBUS_CMD , "SMBus command not supported by driver"},
- {PI_NOT_I2C_GPIO , "no bit bang I2C in progress on gpio"},
+ {PI_NOT_I2C_GPIO , "no bit bang I2C in progress on GPIO"},
{PI_BAD_I2C_WLEN , "bad I2C write length"},
{PI_BAD_I2C_RLEN , "bad I2C read length"},
{PI_BAD_I2C_CMD , "bad I2C command"},
."
.TH pigpio 3 2012-2015 Linux "pigpio archive"
.SH NAME
-pigpio - A C library to manipulate the Pi's gpios.
+pigpio - A C library to manipulate the Pi's GPIO.
.SH SYNOPSIS
.br
.br
-pigpio is a C library for the Raspberry which allows control of the gpios.
+pigpio is a C library for the Raspberry which allows control of the GPIO.
.br
.br
.br
-o PWM on any of gpios 0-31
+o PWM on any of GPIO 0-31
.br
.br
-o servo pulses on any of gpios 0-31
+o servo pulses on any of GPIO 0-31
.br
.br
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
.br
.br
.br
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
.br
.br
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
.br
.br
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
.br
.br
.br
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
.br
.br
.br
-.SS gpios
+.SS GPIO
.br
.br
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
.br
.IP "\fBint gpioSetMode(unsigned gpio, unsigned mode)\fP"
.IP "" 4
-Sets the gpio mode, typically input or output.
+Sets the GPIO mode, typically input or output.
.br
.IP "\fBint gpioGetMode(unsigned gpio)\fP"
.IP "" 4
-Gets the gpio mode.
+Gets the GPIO mode.
.br
.br
.br
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
.br
.IP "\fBint gpioSetPullUpDown(unsigned gpio, unsigned pud)\fP"
.IP "" 4
-Sets or clears resistor pull ups or downs on the gpio.
+Sets or clears resistor pull ups or downs on the GPIO.
.br
.IP "\fBint gpioRead(unsigned gpio)\fP"
.IP "" 4
-Reads the gpio level, on or off.
+Reads the GPIO level, on or off.
.br
.br
.br
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
.br
.br
.EX
-printf("gpio24 is level %d\n", gpioRead(24));
+printf("gpio24 is level %d", gpioRead(24));
.br
.EE
.IP "\fBint gpioWrite(unsigned gpio, unsigned level)\fP"
.IP "" 4
-Sets the gpio level, on or off.
+Sets the GPIO level, on or off.
.br
.br
.br
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
.br
.IP "\fBint gpioPWM(unsigned user_gpio, unsigned dutycycle)\fP"
.IP "" 4
-Starts PWM on the gpio, dutycycle between 0 (off) and range (fully on).
+Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on).
Range defaults to 255.
.br
.IP "\fBint gpioGetPWMdutycycle(unsigned user_gpio)\fP"
.IP "" 4
-Returns the PWM dutycycle setting for the gpio.
+Returns the PWM dutycycle setting for the GPIO.
.br
.br
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see \fBgpioGetPWMrange\fP).
+for the GPIO (see \fBgpioGetPWMrange\fP).
.br
.br
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
.br
.IP "\fBint gpioSetPWMrange(unsigned user_gpio, unsigned range)\fP"
.IP "" 4
-Selects the dutycycle range to be used for the gpio. Subsequent calls
+Selects the dutycycle range to be used for the GPIO. Subsequent calls
to gpioPWM will use a dutycycle between 0 (off) and range (fully on).
.br
.br
.br
-Returns the real range for the given gpio's frequency if OK,
+Returns the real range for the given GPIO's frequency if OK,
otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE.
.br
.br
-If PWM is currently active on the gpio its dutycycle will be scaled
+If PWM is currently active on the GPIO its dutycycle will be scaled
to reflect the new range.
.br
.IP "\fBint gpioGetPWMrange(unsigned user_gpio)\fP"
.IP "" 4
-Returns the dutycycle range used for the gpio if OK, otherwise
+Returns the dutycycle range used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
.br
.br
.br
-If a hardware clock or hardware PWM is active on the gpio
+If a hardware clock or hardware PWM is active on the GPIO
the reported range will be 1000000 (1M).
.br
.IP "\fBint gpioGetPWMrealRange(unsigned user_gpio)\fP"
.IP "" 4
-Returns the real range used for the gpio if OK, otherwise
+Returns the real range used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
.br
.br
.br
-If a hardware clock is active on the gpio the reported real
+If a hardware clock is active on the GPIO the reported real
range will be 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
.br
.IP "\fBint gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency)\fP"
.IP "" 4
-Sets the frequency in hertz to be used for the gpio.
+Sets the frequency in hertz to be used for the GPIO.
.br
.br
.br
-Each gpio can be independently set to one of 18 different PWM
+Each GPIO can be independently set to one of 18 different PWM
frequencies.
.br
.br
-If PWM is currently active on the gpio it will be
+If PWM is currently active on the GPIO it will be
switched off and then back on at the new frequency.
.br
.IP "\fBint gpioGetPWMfrequency(unsigned user_gpio)\fP"
.IP "" 4
-Returns the frequency (in hertz) used for the gpio if OK, otherwise
+Returns the frequency (in hertz) used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
.br
.br
.br
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
\fBgpioSetPWMfrequency\fP.
.br
.br
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by \fBgpioHardwareClock\fP.
.br
.br
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by \fBgpioHardwarePWM\fP.
.br
.IP "\fBint gpioServo(unsigned user_gpio, unsigned pulsewidth)\fP"
.IP "" 4
-Starts servo pulses on the gpio, 0 (off), 500 (most anti-clockwise) to
+Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to
2500 (most clockwise).
.br
.br
The following causes an on pulse of 1500 microseconds duration to be
-transmitted on gpio 17 at a rate of 50 times per second. This will
-command a servo connected to gpio 17 to rotate to its mid-point.
+transmitted on GPIO 17 at a rate of 50 times per second. This will
+command a servo connected to GPIO 17 to rotate to its mid-point.
.br
.IP "\fBint gpioGetServoPulsewidth(unsigned user_gpio)\fP"
.IP "" 4
-Returns the servo pulsewidth setting for the gpio.
+Returns the servo pulsewidth setting for the GPIO.
.br
.IP "\fBint gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f)\fP"
.IP "" 4
Registers a function to be called (a callback) when the specified
-gpio changes state.
+GPIO changes state.
.br
.br
.br
-One function may be registered per gpio.
+One function may be registered per GPIO.
.br
.br
-The function is passed the gpio, the new level, and the tick.
+The function is passed the GPIO, the new level, and the tick.
.br
.br
.br
-The gpios are sampled at a rate set when the library is started.
+The GPIO are sampled at a rate set when the library is started.
.br
.br
{
.br
- printf("gpio %d became %d at %d\n", gpio, level, tick);
+ printf("GPIO %d became %d at %d", gpio, level, tick);
.br
}
.br
.br
-// call aFunction whenever gpio 4 changes state
+// call aFunction whenever GPIO 4 changes state
.br
.br
.IP "\fBint gpioSetAlertFuncEx(unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata)\fP"
.IP "" 4
Registers a function to be called (a callback) when the specified
-gpio changes state.
+GPIO changes state.
.br
.br
.br
-One function may be registered per gpio.
+One function may be registered per GPIO.
.br
.br
-The function is passed the gpio, the new level, the tick, and
+The function is passed the GPIO, the new level, the tick, and
the userdata pointer.
.br
.br
Only one of \fBgpioSetAlertFunc\fP or \fBgpioSetAlertFuncEx\fP can be
-registered per gpio.
+registered per GPIO.
.br
.IP "\fBint gpioSetISRFunc(unsigned user_gpio, unsigned edge, int timeout, gpioISRFunc_t f)\fP"
.IP "" 4
Registers a function to be called (a callback) whenever the specified
-gpio interrupt occurs.
+GPIO interrupt occurs.
.br
.br
.br
-One function may be registered per gpio.
+One function may be registered per GPIO.
.br
.br
-The function is passed the gpio, the current level, and the
+The function is passed the GPIO, the current level, and the
current tick. The level will be PI_TIMEOUT if the optional
interrupt timeout expires.
.br
.br
-The underlying Linux sysfs gpio interface is used to provide
+The underlying Linux sysfs GPIO interface is used to provide
the interrupt services.
.br
.br
The first time the function is called, with a non-NULL f, the
-gpio is exported, set to be an input, and set to interrupt
+GPIO is exported, set to be an input, and set to interrupt
on the given edge and timeout.
.br
.br
The ISR may be cancelled by passing a NULL f, in which case the
-gpio is unexported.
+GPIO is unexported.
.br
.IP "\fBint gpioSetISRFuncEx(unsigned user_gpio, unsigned edge, int timeout, gpioISRFuncEx_t f, void *userdata)\fP"
.IP "" 4
Registers a function to be called (a callback) whenever the specified
-gpio interrupt occurs.
+GPIO interrupt occurs.
.br
.br
.br
-The function is passed the gpio, the current level, the
+The function is passed the GPIO, the current level, the
current tick, and the userdata pointer.
.br
.br
Only one of \fBgpioSetISRFunc\fP or \fBgpioSetISRFuncEx\fP can be
-registered per gpio.
+registered per GPIO.
.br
.br
.br
-A notification is a method for being notified of gpio state changes
+A notification is a method for being notified of GPIO state changes
via a pipe or socket.
.br
.EX
handle: >=0, as returned by \fBgpioNotifyOpen\fP
.br
- bits: a bit mask indicating the gpios of interest
+ bits: a bit mask indicating the GPIO of interest
.br
.EE
.br
.br
-The notification sends state changes for each gpio whose corresponding
+The notification sends state changes for each GPIO whose corresponding
bit in bits is set.
.br
.br
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
-indicate a gpio which has had a watchdog timeout; if bit 6 is set
+indicate a GPIO which has had a watchdog timeout; if bit 6 is set
(PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the
pipe/socket and is sent once a minute in the absence of other
notification activity.
.br
.br
-level: indicates the level of each gpio. If bit 1<<x is set then
-gpio x is high.
+level: indicates the level of each GPIO. If bit 1<<x is set then
+GPIO x is high.
.br
.br
.EX
-// Start notifications for gpios 1, 4, 6, 7, 10.
+// Start notifications for GPIO 1, 4, 6, 7, 10.
.br
.br
.br
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
.br
.br
.br
-1) the gpios to be switched on at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
.br
-2) the gpios to be switched off at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
.br
3) the delay in microseconds before the next pulse.
.br
.br
- printf("start piscope, press return\n"); getchar();
+ printf("start piscope, press return"); getchar();
.br
.br
.br
.br
- printf("stop piscope, press return\n"); getchar();
+ printf("stop piscope, press return"); getchar();
.br
.br
.EE
+.IP "\fBint gpioWaveTxAt(void)\fP"
+.IP "" 4
+This function returns the id of the waveform currently being
+transmitted.
+
+.br
+
+.br
+Returns the waveform id or one of the following special values:
+
+.br
+
+.br
+PI_WAVE_NOT_FOUND (9998) - transmitted wave not found.
+.br
+PI_NO_TX_WAVE (9999) - no wave being transmitted.
+
.IP "\fBint gpioWaveTxBusy(void)\fP"
.IP "" 4
This function checks to see if a waveform is currently being
.IP "\fBint gpioSerialReadOpen(unsigned user_gpio, unsigned baud, unsigned data_bits)\fP"
.IP "" 4
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
.br
.br
.br
-The gpio must be opened for bit bang reading of serial data using
+The GPIO must be opened for bit bang reading of serial data using
\fBgpioSerialReadOpen\fP prior to calling this function.
.IP "\fBint gpioSerialRead(unsigned user_gpio, void *buf, size_t bufSize)\fP"
.IP "\fBint gpioSerialReadClose(unsigned user_gpio)\fP"
.IP "" 4
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
.br
.IP "\fBint bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud)\fP"
.IP "" 4
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
.br
.br
o clock stretching
.br
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
.br
.br
.br
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
.IP "\fBint bbI2CClose(unsigned SDA)\fP"
.IP "" 4
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with \fBbbI2COpen\fP.
.br
.br
.EX
-SDA: 0-31, the SDA gpio used in a prior call to \fBbbI2COpen\fP
+SDA: 0-31, the SDA GPIO used in a prior call to \fBbbI2COpen\fP
.br
.EE
.br
.br
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero 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.
+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.
.br
.br
.EX
- spiChan: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device)
+ spiChan: 0-1 (0-2 for the auxiliary SPI device)
.br
baud: 32K-125M (values above 30M are unlikely to work)
.br
.br
.br
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
.br
.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
.br
.br
+.br
+The \fBspiRead\fP, \fBspiWrite\fP, and \fBspiXfer\fP functions
+transfer data packed into 1, 2, or 4 bytes according to
+the word size in bits.
+
+.br
+
+.br
+For bits 1-8 there will be one byte per character.
+.br
+For bits 9-16 there will be two bytes per character.
+.br
+For bits 17-32 there will be four bytes per character.
+
+.br
+
+.br
+E.g. to transfer 32 12-bit words buf should contain 64 bytes
+and count should be 64.
+
+.br
+
.br
The other bits in flags should be set to zero.
.IP "\fBint gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level)\fP"
.IP "" 4
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
.br
.IP "\fBint gpioSetWatchdog(unsigned user_gpio, unsigned timeout)\fP"
.IP "" 4
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
.br
.br
.br
-One watchdog may be registered per gpio.
+One watchdog may be registered per GPIO.
.br
.br
.br
-If no level change has been detected for the gpio for timeout
+If no level change has been detected for the GPIO for timeout
milliseconds:-
.br
.br
-1) any registered alert function for the gpio is called with
+1) any registered alert function for the GPIO is called with
the level set to PI_TIMEOUT.
.br
-2) any notification for the gpio has a report written to the
+2) any notification for the GPIO has a report written to the
fifo with the flags set to indicate a watchdog timeout.
.br
.br
{
.br
- printf("gpio %d became %d at %d\n", gpio, level, tick);
+ printf("GPIO %d became %d at %d", gpio, level, tick);
.br
}
.br
.br
-// call aFunction whenever gpio 4 changes state
+// call aFunction whenever GPIO 4 changes state
.br
gpioSetAlertFunc(4, aFunction);
.br
.IP "\fBint gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active)\fP"
.IP "" 4
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
.br
.br
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for \fBsteady\fP microseconds is detected. Level changes
-on the gpio are then reported for \fBactive\fP microseconds after
+on the GPIO are then reported for \fBactive\fP microseconds after
which the process repeats.
.br
.IP "\fBint gpioGlitchFilter(unsigned user_gpio, unsigned steady)\fP"
.IP "" 4
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
.br
.br
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least \fBsteady\fP microseconds. The
level is then reported. Level changes of less than \fBsteady\fP
microseconds are ignored.
.IP "\fBint gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits)\fP"
.IP "" 4
Registers a function to be called (a callback) every millisecond
-with the latest gpio samples.
+with the latest GPIO samples.
.br
.EX
f: the function to call
.br
-bits: the gpios of interest
+bits: the GPIO of interest
.br
.EE
.br
.br
-e.g. if there are alerts for gpios 7, 8, and 9, notifications for gpios
-8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for gpios
+e.g. if there are alerts for GPIO 7, 8, and 9, notifications for GPIO
+8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for GPIO
7, 8, 9, 10, 17, 23, and 24 will be reported.
.IP "\fBint gpioSetGetSamplesFuncEx(gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata)\fP"
.IP "" 4
Registers a function to be called (a callback) every millisecond
-with the latest gpio samples.
+with the latest GPIO samples.
.br
.EX
f: the function to call
.br
- bits: the gpios of interest
+ bits: the GPIO of interest
.br
userdata: a pointer to arbitrary user data
.br
.br
{
.br
- printf("two seconds have elapsed\n");
+ printf("two seconds have elapsed");
.br
}
.br
.br
{
.br
- printf("%s\n", arg);
+ printf("%s", arg);
.br
sleep(1);
.br
.IP "\fBuint32_t gpioRead_Bits_0_31(void)\fP"
.IP "" 4
-Returns the current level of gpios 0-31.
+Returns the current level of GPIO 0-31.
.IP "\fBuint32_t gpioRead_Bits_32_53(void)\fP"
.IP "" 4
-Returns the current level of gpios 32-53.
+Returns the current level of GPIO 32-53.
.IP "\fBint gpioWrite_Bits_0_31_Clear(uint32_t bits)\fP"
.IP "" 4
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
.br
.br
.EX
-bits: a bit mask of gpios to clear
+bits: a bit mask of GPIO to clear
.br
.EE
.br
.EX
-// To clear (set to 0) gpios 4, 7, and 15
+// To clear (set to 0) GPIO 4, 7, and 15
.br
gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) );
.br
.IP "\fBint gpioWrite_Bits_32_53_Clear(uint32_t bits)\fP"
.IP "" 4
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.br
.EX
-bits: a bit mask of gpios to clear
+bits: a bit mask of GPIO to clear
.br
.EE
.IP "\fBint gpioWrite_Bits_0_31_Set(uint32_t bits)\fP"
.IP "" 4
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
.br
.br
.EX
-bits: a bit mask of gpios to set
+bits: a bit mask of GPIO to set
.br
.EE
.IP "\fBint gpioWrite_Bits_32_53_Set(uint32_t bits)\fP"
.IP "" 4
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.br
.EX
-bits: a bit mask of gpios to set
+bits: a bit mask of GPIO to set
.br
.EE
.br
.EX
-// To set (set to 1) gpios 32, 40, and 53
+// To set (set to 1) GPIO 32, 40, and 53
.br
gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32)));
.br
.IP "\fBint gpioHardwareClock(unsigned gpio, unsigned clkfreq)\fP"
.IP "" 4
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
.br
.br
.br
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.EX
4 clock 0 All models
.br
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
.br
-6 clock 2 A+/B+/Pi2/Zero and compute module only
+6 clock 2 All models but A and B
.br
-20 clock 0 A+/B+/Pi2/Zero and compute module only
+20 clock 0 All models but A and B
.br
-21 clock 1 All models but Rev.2 B (reserved for system use)
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
.br
.br
.br
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
.IP "\fBint gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty)\fP"
.IP "" 4
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
.br
.br
.br
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.br
.EX
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
.br
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+13 PWM channel 1 All models but A and B
.br
18 PWM channel 0 All models
.br
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
.br
.br
.br
gpioTime(PI_TIME_RELATIVE, &secs, &mics);
.br
-printf("library started %d.%03d seconds ago\n", secs, mics/1000);
+printf("library started %d.%03d seconds ago", secs, mics/1000);
.br
.EE
.br
.br
-printf("some processing took %d microseconds\n", diffTick);
+printf("some processing took %d microseconds", diffTick);
.br
.EE
.br
.br
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see \fBgpio\fP).
.br
.IP "\fBint gpioCfgBufferSize(unsigned cfgMillis)\fP"
.IP "" 4
-Configures pigpio to buffer cfgMillis milliseconds of gpio samples.
+Configures pigpio to buffer cfgMillis milliseconds of GPIO samples.
.br
.IP "\fBint gpioCfgPermissions(uint64_t updateMask)\fP"
.IP "" 4
Configures pigpio to only allow updates (writes or mode changes) for the
-gpios specified by the mask.
+GPIO specified by the mask.
.br
.br
.EX
-updateMask: bit (1<<n) is set for each gpio n which may be updated
+updateMask: bit (1<<n) is set for each GPIO n which may be updated
.br
.EE
.br
The default setting depends upon the board revision (Type 1, 2, or 3).
-The user gpios are added to the mask. If the board revision is not
-recognised then gpios 0-31 are allowed.
+The user GPIO are added to the mask. If the board revision is not
+recognised then GPIO 0-31 are allowed.
.br
.br
offset: microseconds from the start of the waveform
.br
- spiSS: the slave select gpio
+ spiSS: the slave select GPIO
.br
buf: the bits to transmit, most significant bit first
.br
.br
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
.br
.br
.IP "\fBbits\fP" 0
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
.br
.br
.br
-The gpio sample rate in microseconds. The default is 5us, or 200 thousand
+The GPIO sample rate in microseconds. The default is 5us, or 200 thousand
samples per second.
.br
.br
.IP "\fBedge\fP: 0-2" 0
-The type of gpio edge to generate an intrrupt. See\fBgpioSetISRFunc\fP,
+The type of GPIO edge to generate an intrrupt. See\fBgpioSetISRFunc\fP,
and \fBgpioSetISRFuncEx\fP.
.br
.br
.br
-The number of times a gpio is swiched on and off per second. This
-can be set per gpio and may be as little as 5Hz or as much as
-40KHz. The gpio will be on for a proportion of the time as defined
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
.br
.br
.br
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
.br
.br
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
gpio53.
.br
.br
.br
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
.br
.br
.br
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
.br
.br
.IP "\fBlevel\fP" 0
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
.br
.br
.br
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See \fBgpioSetWatchdog\fP.
.br
.br
.br
-The operational mode of a gpio, normally INPUT or OUTPUT.
+The operational mode of a GPIO, normally INPUT or OUTPUT.
.br
.br
.IP "\fBprimaryChannel\fP: 0-14" 0
-The DMA channel used to time the sampling of gpios and to time servo and
+The DMA channel used to time the sampling of GPIO and to time servo and
PWM pulses.
.br
.br
.br
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
.EX
.br
{
.br
- int clk; // gpio for clock
+ int clk; // GPIO for clock
.br
- int mosi; // gpio for MOSI
+ int mosi; // GPIO for MOSI
.br
- int miso; // gpio for MISO
+ int miso; // GPIO for MISO
.br
int ss_pol; // slave select off state
.br
uint16_t botOOL; // last OOL used by wave
.br
uint16_t topOOL; // first OOL used by wave
+.br
+ uint16_t deleted;
+.br
+ uint16_t numCB;
+.br
+ uint16_t numBOOL;
+.br
+ uint16_t numTOOL;
.br
} rawWaveInfo_t;
.br
.br
.br
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
.br
.br
.br
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
.br
.br
.IP "\fBspiBitFirst\fP" 0
-Gpio reads are made from spiBitFirst to spiBitLast.
+GPIO reads are made from spiBitFirst to spiBitLast.
.br
.br
.br
-Gpio reads are made from spiBitFirst to spiBitLast.
+GPIO reads are made from spiBitFirst to spiBitLast.
.br
.br
.IP "\fBspiSS\fP" 0
-The SPI slave select gpio in a raw SPI transaction.
+The SPI slave select GPIO in a raw SPI transaction.
.br
.br
.IP "\fBtimeout\fP" 0
-A gpio level change timeout in milliseconds.
+A GPIO level change timeout in milliseconds.
.br
.br
.br
-A 64 bit mask indicating which gpios may be written to by the user.
+A 64 bit mask indicating which GPIO may be written to by the user.
.br
.br
-If gpio#n may be written then bit (1<<n) is set.
+If GPIO#n may be written then bit (1<<n) is set.
.br
.br
.br
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
.br
.br
#define PI_CMD_WVTXM 100
.br
+#define PI_CMD_WVTAT 101
+.br
.br
.br
#define PI_INIT_FAILED -1 // gpioInitialise failed
.br
-#define PI_BAD_USER_GPIO -2 // gpio not 0-31
+#define PI_BAD_USER_GPIO -2 // GPIO not 0-31
.br
-#define PI_BAD_GPIO -3 // gpio not 0-53
+#define PI_BAD_GPIO -3 // GPIO not 0-53
.br
#define PI_BAD_MODE -4 // mode not 0-7
.br
.br
#define PI_TOO_MANY_CHARS -37 // waveform has too many chars
.br
-#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read in progress on gpio
+#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read in progress on GPIO
.br
#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter
.br
#define PI_BAD_SERIAL_BUF -40 // bad (null) serial buf parameter
.br
-#define PI_NOT_PERMITTED -41 // gpio operation not permitted
+#define PI_NOT_PERMITTED -41 // GPIO operation not permitted
.br
-#define PI_SOME_PERMITTED -42 // one or more gpios not permitted
+#define PI_SOME_PERMITTED -42 // one or more GPIO not permitted
.br
#define PI_BAD_WVSC_COMMND -43 // bad WVSC subcommand
.br
.br
#define PI_BAD_SER_OFFSET -49 // add serial data offset > 30 minutes
.br
-#define PI_GPIO_IN_USE -50 // gpio already in use
+#define PI_GPIO_IN_USE -50 // GPIO already in use
.br
#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time
.br
.br
#define PI_BAD_POINTER -90 // bad (NULL) pointer
.br
-#define PI_NO_AUX_SPI -91 // need a A+/B+/Pi2/Zero for auxiliary SPI
+#define PI_NO_AUX_SPI -91 // no auxiliary SPI on Pi A or B
.br
-#define PI_NOT_PWM_GPIO -92 // gpio is not in use for PWM
+#define PI_NOT_PWM_GPIO -92 // GPIO is not in use for PWM
.br
-#define PI_NOT_SERVO_GPIO -93 // gpio is not in use for servo pulses
+#define PI_NOT_SERVO_GPIO -93 // GPIO is not in use for servo pulses
.br
-#define PI_NOT_HCLK_GPIO -94 // gpio has no hardware clock
+#define PI_NOT_HCLK_GPIO -94 // GPIO has no hardware clock
.br
-#define PI_NOT_HPWM_GPIO -95 // gpio has no hardware PWM
+#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM
.br
#define PI_BAD_HPWM_FREQ -96 // hardware PWM frequency not 1-125M
.br
.br
#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
.br
-#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on gpio
+#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO
.br
#define PI_BAD_I2C_WLEN -109 // bad I2C write length
.br
For more information, please refer to <http://unlicense.org/>
*/
-/* pigpio version 46 */
+/* pigpio version 47 */
/* include ------------------------------------------------------- */
}
break;
+ case PI_CMD_WVTAT: res = gpioWaveTxAt(); break;
+
case PI_CMD_WVTX:
res = gpioWaveTxSend(p[1], PI_WAVE_MODE_ONE_SHOT); break;
/* ----------------------------------------------------------------------- */
+static int dmaNowAtOCB(void)
+{
+ unsigned cb;
+ unsigned page;
+ uint32_t cbAddr;
+
+ cbAddr = dmaOut[DMA_CONBLK_AD];
+
+ if (!cbAddr) return -PI_NO_TX_WAVE;
+
+ page = 0;
+
+ /* which page are we dma'ing? */
+
+ while (1)
+ {
+ cb = (cbAddr - ((int)dmaOBus[page])) / 32;
+
+ if (cb < CBS_PER_OPAGE) return (page*CBS_PER_OPAGE) + cb;
+
+ if (page++ >= DMAO_PAGES) break;
+ }
+
+ /* Try twice */
+
+ cbAddr = dmaOut[DMA_CONBLK_AD];
+
+ if (!cbAddr) return -PI_NO_TX_WAVE;
+
+ page = 0;
+
+ /* which page are we dma'ing? */
+
+ while (1)
+ {
+ cb = (cbAddr - ((int)dmaOBus[page])) / 32;
+
+ if (cb < CBS_PER_OPAGE) return (page*CBS_PER_OPAGE) + cb;
+
+ if (page++ >= DMAO_PAGES) break;
+ }
+
+ return -PI_WAVE_NOT_FOUND;
+}
+
+/* ----------------------------------------------------------------------- */
+
unsigned rawWaveCB(void)
{
unsigned cb;
unsigned spiBitLast,
unsigned spiBits)
{
- int p, dbv, bit, halfbit;
+ int p, bit, dbv, halfbit;
int rising_edge[2], read_cycle[2];
uint32_t on_bits, off_bits;
int tx_bit_pos;
p++;
}
- /* preset initial mosi bit in case it's read at leading clock bit */
-
on_bits = 0;
off_bits = 0;
tx_bit_pos = 0;
+ /* preset initial mosi bit */
+
if (getBitInBytes(tx_bit_pos, buf, spiTxBits))
{
- dbv = 1;
on_bits |= (1<<(spi->mosi));
+ dbv = 1;
}
else
{
+ off_bits |= (1<<(spi->mosi));
dbv = 0;
- off_bits |= (1<<(spi->mosi));
}
+ if (!spi->clk_pha) tx_bit_pos ++;
+
if (spi->ss_pol) off_bits |= (1<<spiSS);
else on_bits |= (1<<spiSS);
+ if (spi->clk_pol) on_bits |= (1<<(spi->clk));
+ else off_bits |= (1<<(spi->clk));
+
wf[2][p].gpioOn = on_bits;
wf[2][p].gpioOff = off_bits;
wf[2][p].flags = 0;
{
if (getBitInBytes(tx_bit_pos, buf, spiTxBits))
{
- if (!dbv) on_bits |= (1<<(spi->mosi));
+ if (!dbv) on_bits |= (1<<(spi->mosi));
dbv = 1;
}
else
return 0;
}
+/*-------------------------------------------------------------------------*/
+
+int gpioWaveTxAt(void)
+{
+ int i, cb;
+
+ DBG(DBG_USER, "");
+
+ CHECK_INITED;
+
+ cb = dmaNowAtOCB();
+
+ if (cb < 0) return -cb;
+
+ for (i=0; i<PI_MAX_WAVES; i++)
+ {
+ if ( !waveInfo[i].deleted &&
+ (cb >= waveInfo[i].botCB) &&
+ (cb <= waveInfo[i].topCB) ) return i;
+ }
+
+ return PI_WAVE_NOT_FOUND;
+}
+
/* ----------------------------------------------------------------------- */
int gpioWaveTxStop(void)
#include <stdint.h>
#include <pthread.h>
-#define PIGPIO_VERSION 46
+#define PIGPIO_VERSION 47
/*TEXT
-pigpio is a C library for the Raspberry which allows control of the gpios.
+pigpio is a C library for the Raspberry which allows control of the GPIO.
*Features*
-o PWM on any of gpios 0-31
+o PWM on any of GPIO 0-31
-o servo pulses on any of gpios 0-31
+o servo pulses on any of GPIO 0-31
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
o callbacks at timed intervals
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
o the construction of output waveforms with microsecond timing
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
o a simple interface to start and stop new threads
o creating and running scripts
-*gpios*
+*GPIO*
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
*Credits*
BEGINNER
-gpioSetMode Set a gpio mode
-gpioGetMode Get a gpio mode
+gpioSetMode Set a GPIO mode
+gpioGetMode Get a GPIO mode
-gpioSetPullUpDown Set/clear gpio pull up/down resistor
+gpioSetPullUpDown Set/clear GPIO pull up/down resistor
-gpioRead Read a gpio
-gpioWrite Write a gpio
+gpioRead Read a GPIO
+gpioWrite Write a GPIO
-gpioPWM Start/stop PWM pulses on a gpio
-gpioGetPWMdutycycle Get dutycycle setting on a gpio
+gpioPWM Start/stop PWM pulses on a GPIO
+gpioGetPWMdutycycle Get dutycycle setting on a GPIO
-gpioServo Start/stop servo pulses on a gpio
-gpioGetServoPulsewidth Get pulsewidth setting on a gpio
+gpioServo Start/stop servo pulses on a GPIO
+gpioGetServoPulsewidth Get pulsewidth setting on a GPIO
gpioDelay Delay for a number of microseconds
-gpioSetAlertFunc Request a gpio level change callback
+gpioSetAlertFunc Request a GPIO level change callback
gpioSetTimerFunc Request a regular timed callback
INTERMEDIATE
-gpioTrigger Send a trigger pulse to a gpio.
+gpioTrigger Send a trigger pulse to a GPIO.
-gpioSetWatchdog Set a watchdog on a gpio.
+gpioSetWatchdog Set a watchdog on a GPIO.
-gpioSetPWMrange Configure PWM range for a gpio
-gpioGetPWMrange Get configured PWM range for a gpio
+gpioSetPWMrange Configure PWM range for a GPIO
+gpioGetPWMrange Get configured PWM range for a GPIO
-gpioSetPWMfrequency Configure PWM frequency for a gpio
-gpioGetPWMfrequency Get configured PWM frequency for a gpio
+gpioSetPWMfrequency Configure PWM frequency for a GPIO
+gpioGetPWMfrequency Get configured PWM frequency for a GPIO
-gpioRead_Bits_0_31 Read all gpios in bank 1
-gpioRead_Bits_32_53 Read all gpios in bank 2
+gpioRead_Bits_0_31 Read all GPIO in bank 1
+gpioRead_Bits_32_53 Read all GPIO in bank 2
-gpioWrite_Bits_0_31_Clear Clear selected gpios in bank 1
-gpioWrite_Bits_32_53_Clear Clear selected gpios in bank 2
+gpioWrite_Bits_0_31_Clear Clear selected GPIO in bank 1
+gpioWrite_Bits_32_53_Clear Clear selected GPIO in bank 2
-gpioWrite_Bits_0_31_Set Set selected gpios in bank 1
-gpioWrite_Bits_32_53_Set Set selected gpios in bank 2
+gpioWrite_Bits_0_31_Set Set selected GPIO in bank 1
+gpioWrite_Bits_32_53_Set Set selected GPIO in bank 2
gpioStartThread Start a new thread
gpioStopThread Stop a previously started thread
ADVANCED
-gpioGetPWMrealRange Get underlying PWM range for a gpio
+gpioGetPWMrealRange Get underlying PWM range for a GPIO
-gpioSetAlertFuncEx Request a gpio change callback, extended
+gpioSetAlertFuncEx Request a GPIO change callback, extended
-gpioSetISRFunc Request a gpio interrupt callback
-gpioSetISRFuncEx Request a gpio interrupt callback, extended
+gpioSetISRFunc Request a GPIO interrupt callback
+gpioSetISRFuncEx Request a GPIO interrupt callback, extended
gpioSetSignalFunc Request a signal callback
gpioSetSignalFuncEx Request a signal callback, extended
-gpioSetGetSamplesFunc Requests a gpio samples callback
-gpioSetGetSamplesFuncEx Requests a gpio samples callback, extended
+gpioSetGetSamplesFunc Requests a GPIO samples callback
+gpioSetGetSamplesFuncEx Requests a GPIO samples callback, extended
gpioSetTimerFuncEx Request a regular timed callback, extended
gpioNotifyOpen Request a notification handle
gpioNotifyOpenWithSize Request a notification handle with sized pipe
-gpioNotifyBegin Start notifications for selected gpios
+gpioNotifyBegin Start notifications for selected GPIO
gpioNotifyPause Pause notifications
gpioNotifyClose Close a notification
-gpioSerialReadOpen Opens a gpio for bit bang serial reads
+gpioSerialReadOpen Opens a GPIO for bit bang serial reads
gpioSerialReadInvert Configures normal/inverted for serial reads
-gpioSerialRead Reads bit bang serial data from a gpio
-gpioSerialReadClose Closes a gpio for bit bang serial reads
+gpioSerialRead Reads bit bang serial data from a GPIO
+gpioSerialReadClose Closes a GPIO for bit bang serial reads
-gpioHardwareClock Start hardware clock on supported gpios
-gpioHardwarePWM Start hardware PWM on supported gpios
+gpioHardwareClock Start hardware clock on supported GPIO
+gpioHardwarePWM Start hardware PWM on supported GPIO
-gpioGlitchFilter Set a glitch filter on a gpio
-gpioNoiseFilter Set a noise filter on a gpio
+gpioGlitchFilter Set a glitch filter on a GPIO
+gpioNoiseFilter Set a noise filter on a GPIO
SCRIPTS
gpioWaveChain Transmits a chain of waveforms
+gpioWaveTxAt Returns the current transmitting waveform
+
gpioWaveTxBusy Checks to see if the waveform has ended
gpioWaveTxStop Aborts the current waveform
i2cZip Performs multiple I2C transactions
-bbI2COpen Opens gpios for bit banging I2C
-bbI2CClose Closes gpios for bit banging I2C
+bbI2COpen Opens GPIO for bit banging I2C
+bbI2CClose Closes GPIO for bit banging I2C
bbI2CZip Performs multiple bit banged I2C transactions
SPI
CONFIGURATION
-gpioCfgBufferSize Configure the gpio sample buffer size
-gpioCfgClock Configure the gpio sample rate
+gpioCfgBufferSize Configure the GPIO sample buffer size
+gpioCfgClock Configure the GPIO sample rate
gpioCfgDMAchannel Configure the DMA channel (DEPRECATED)
gpioCfgDMAchannels Configure the DMA channels
-gpioCfgPermissions Configure the gpio access permissions
+gpioCfgPermissions Configure the GPIO access permissions
gpioCfgInterfaces Configure user interfaces
gpioCfgSocketPort Configure socket port
gpioCfgMemAlloc Configure DMA memory allocation mode
OOLS are used from the bottom climbing up and from
the top climbing down.
-The gpio on and off settings climb up from the bottom (botOOL/numBOOL).
+The GPIO on and off settings climb up from the bottom (botOOL/numBOOL).
The level and tick read values are stored in descending locations
from the top (topOOL/numTOOL).
typedef struct
{
- int clk; /* gpio for clock */
- int mosi; /* gpio for MOSI */
- int miso; /* gpio for MISO */
+ int clk; /* GPIO for clock */
+ int mosi; /* GPIO for MOSI */
+ int miso; /* GPIO for MISO */
int ss_pol; /* slave select off state */
int ss_us; /* delay after slave select */
int clk_pol; /* clock off state */
#define PI_LOW 0
#define PI_HIGH 1
-/* level: only reported for gpio time-out, see gpioSetWatchdog */
+/* level: only reported for GPIO time-out, see gpioSetWatchdog */
#define PI_TIMEOUT 2
#define PI_WAVE_MIN_BAUD 50
#define PI_WAVE_MAX_BAUD 1000000
-//#define PI_SPI_MIN_BAUD 32000
-//#define PI_SPI_MAX_BAUD 125000000
-
-#define PI_SPI_MIN_BAUD 1
-#define PI_SPI_MAX_BAUD 500000000
+#define PI_SPI_MIN_BAUD 32000
+#define PI_SPI_MAX_BAUD 125000000
#define PI_MIN_WAVE_DATABITS 1
#define PI_MAX_WAVE_DATABITS 32
#define PI_WAVE_MODE_ONE_SHOT_SYNC 2
#define PI_WAVE_MODE_REPEAT_SYNC 3
+/* special wave at return values */
+
+#define PI_WAVE_NOT_FOUND 9998 /* Transmitted wave not found. */
+#define PI_NO_TX_WAVE 9999 /* No wave being transmitted. */
+
/* I2C, SPI, SER */
#define PI_I2C_SLOTS 32
/*F*/
int gpioSetMode(unsigned gpio, unsigned mode);
/*D
-Sets the gpio mode, typically input or output.
+Sets the GPIO mode, typically input or output.
. .
gpio: 0-53
/*F*/
int gpioGetMode(unsigned gpio);
/*D
-Gets the gpio mode.
+Gets the GPIO mode.
. .
gpio: 0-53
. .
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
...
if (gpioGetMode(17) != PI_ALT0)
/*F*/
int gpioSetPullUpDown(unsigned gpio, unsigned pud);
/*D
-Sets or clears resistor pull ups or downs on the gpio.
+Sets or clears resistor pull ups or downs on the GPIO.
. .
gpio: 0-53
/*F*/
int gpioRead (unsigned gpio);
/*D
-Reads the gpio level, on or off.
+Reads the GPIO level, on or off.
. .
gpio: 0-53
. .
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
Arduino style: digitalRead.
...
-printf("gpio24 is level %d\n", gpioRead(24));
+printf("gpio24 is level %d", gpioRead(24));
...
D*/
/*F*/
int gpioWrite(unsigned gpio, unsigned level);
/*D
-Sets the gpio level, on or off.
+Sets the GPIO level, on or off.
. .
gpio: 0-53
Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL.
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
Arduino style: digitalWrite
/*F*/
int gpioPWM(unsigned user_gpio, unsigned dutycycle);
/*D
-Starts PWM on the gpio, dutycycle between 0 (off) and range (fully on).
+Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on).
Range defaults to 255.
. .
/*F*/
int gpioGetPWMdutycycle(unsigned user_gpio);
/*D
-Returns the PWM dutycycle setting for the gpio.
+Returns the PWM dutycycle setting for the GPIO.
. .
user_gpio: 0-31
PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see [*gpioGetPWMrange*]).
+for the GPIO (see [*gpioGetPWMrange*]).
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
Normal PWM range defaults to 255.
/*F*/
int gpioSetPWMrange(unsigned user_gpio, unsigned range);
/*D
-Selects the dutycycle range to be used for the gpio. Subsequent calls
+Selects the dutycycle range to be used for the GPIO. Subsequent calls
to gpioPWM will use a dutycycle between 0 (off) and range (fully on).
. .
range: 25-40000
. .
-Returns the real range for the given gpio's frequency if OK,
+Returns the real range for the given GPIO's frequency if OK,
otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE.
-If PWM is currently active on the gpio its dutycycle will be scaled
+If PWM is currently active on the GPIO its dutycycle will be scaled
to reflect the new range.
The real range, the number of steps between fully off and fully
/*F*/
int gpioGetPWMrange(unsigned user_gpio);
/*D
-Returns the dutycycle range used for the gpio if OK, otherwise
+Returns the dutycycle range used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
. .
user_gpio: 0-31
. .
-If a hardware clock or hardware PWM is active on the gpio
+If a hardware clock or hardware PWM is active on the GPIO
the reported range will be 1000000 (1M).
...
/*F*/
int gpioGetPWMrealRange(unsigned user_gpio);
/*D
-Returns the real range used for the gpio if OK, otherwise
+Returns the real range used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
. .
user_gpio: 0-31
. .
-If a hardware clock is active on the gpio the reported real
+If a hardware clock is active on the GPIO the reported real
range will be 1000000 (1M).
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
...
/*F*/
int gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency);
/*D
-Sets the frequency in hertz to be used for the gpio.
+Sets the frequency in hertz to be used for the GPIO.
. .
user_gpio: 0-31
The selectable frequencies depend upon the sample rate which
may be 1, 2, 4, 5, 8, or 10 microseconds (default 5).
-Each gpio can be independently set to one of 18 different PWM
+Each GPIO can be independently set to one of 18 different PWM
frequencies.
-If PWM is currently active on the gpio it will be
+If PWM is currently active on the GPIO it will be
switched off and then back on at the new frequency.
The frequencies for each sample rate are:
/*F*/
int gpioGetPWMfrequency(unsigned user_gpio);
/*D
-Returns the frequency (in hertz) used for the gpio if OK, otherwise
+Returns the frequency (in hertz) used for the GPIO if OK, otherwise
PI_BAD_USER_GPIO.
. .
user_gpio: 0-31
. .
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
[*gpioSetPWMfrequency*].
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by [*gpioHardwareClock*].
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by [*gpioHardwarePWM*].
...
/*F*/
int gpioServo(unsigned user_gpio, unsigned pulsewidth);
/*D
-Starts servo pulses on the gpio, 0 (off), 500 (most anti-clockwise) to
+Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to
2500 (most clockwise).
. .
to move beyond its limits.
The following causes an on pulse of 1500 microseconds duration to be
-transmitted on gpio 17 at a rate of 50 times per second. This will
-command a servo connected to gpio 17 to rotate to its mid-point.
+transmitted on GPIO 17 at a rate of 50 times per second. This will
+command a servo connected to GPIO 17 to rotate to its mid-point.
...
gpioServo(17, 1000); // Move servo to safe position anti-clockwise.
/*F*/
int gpioGetServoPulsewidth(unsigned user_gpio);
/*D
-Returns the servo pulsewidth setting for the gpio.
+Returns the servo pulsewidth setting for the GPIO.
. .
user_gpio: 0-31
int gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f);
/*D
Registers a function to be called (a callback) when the specified
-gpio changes state.
+GPIO changes state.
. .
user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
-One function may be registered per gpio.
+One function may be registered per GPIO.
-The function is passed the gpio, the new level, and the tick.
+The function is passed the GPIO, the new level, and the tick.
The alert may be cancelled by passing NULL as the function.
-The gpios are sampled at a rate set when the library is started.
+The GPIO are sampled at a rate set when the library is started.
If a value isn't specifically set the default of 5 us is used.
...
void aFunction(int gpio, int level, uint32_t tick)
{
- printf("gpio %d became %d at %d\n", gpio, level, tick);
+ printf("GPIO %d became %d at %d", gpio, level, tick);
}
-// call aFunction whenever gpio 4 changes state
+// call aFunction whenever GPIO 4 changes state
gpioSetAlertFunc(4F, aFunction);
...
unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata);
/*D
Registers a function to be called (a callback) when the specified
-gpio changes state.
+GPIO changes state.
. .
user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
-One function may be registered per gpio.
+One function may be registered per GPIO.
-The function is passed the gpio, the new level, the tick, and
+The function is passed the GPIO, the new level, the tick, and
the userdata pointer.
Only one of [*gpioSetAlertFunc*] or [*gpioSetAlertFuncEx*] can be
-registered per gpio.
+registered per GPIO.
See [*gpioSetAlertFunc*] for further details.
D*/
unsigned user_gpio, unsigned edge, int timeout, gpioISRFunc_t f);
/*D
Registers a function to be called (a callback) whenever the specified
-gpio interrupt occurs.
+GPIO interrupt occurs.
. .
user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_EDGE,
or PI_BAD_ISR_INIT.
-One function may be registered per gpio.
+One function may be registered per GPIO.
-The function is passed the gpio, the current level, and the
+The function is passed the GPIO, the current level, and the
current tick. The level will be PI_TIMEOUT if the optional
interrupt timeout expires.
-The underlying Linux sysfs gpio interface is used to provide
+The underlying Linux sysfs GPIO interface is used to provide
the interrupt services.
The first time the function is called, with a non-NULL f, the
-gpio is exported, set to be an input, and set to interrupt
+GPIO is exported, set to be an input, and set to interrupt
on the given edge and timeout.
Subsequent calls, with a non-NULL f, can vary one or more of the
edge, timeout, or function.
The ISR may be cancelled by passing a NULL f, in which case the
-gpio is unexported.
+GPIO is unexported.
The tick is that read at the time the process was informed of
the interrupt. This will be a variable number of microseconds
void *userdata);
/*D
Registers a function to be called (a callback) whenever the specified
-gpio interrupt occurs.
+GPIO interrupt occurs.
. .
user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_EDGE,
or PI_BAD_ISR_INIT.
-The function is passed the gpio, the current level, the
+The function is passed the GPIO, the current level, the
current tick, and the userdata pointer.
Only one of [*gpioSetISRFunc*] or [*gpioSetISRFuncEx*] can be
-registered per gpio.
+registered per GPIO.
See [*gpioSetISRFunc*] for further details.
D*/
Returns a handle greater than or equal to zero if OK,
otherwise PI_NO_HANDLE.
-A notification is a method for being notified of gpio state changes
+A notification is a method for being notified of GPIO state changes
via a pipe or socket.
Pipe notifications for handle x will be available at the pipe
. .
handle: >=0, as returned by [*gpioNotifyOpen*]
- bits: a bit mask indicating the gpios of interest
+ bits: a bit mask indicating the GPIO of interest
. .
Returns 0 if OK, otherwise PI_BAD_HANDLE.
-The notification sends state changes for each gpio whose corresponding
+The notification sends state changes for each GPIO whose corresponding
bit in bits is set.
Each notification occupies 12 bytes in the fifo and has the
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags
-indicate a gpio which has had a watchdog timeout; if bit 6 is set
+indicate a GPIO which has had a watchdog timeout; if bit 6 is set
(PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the
pipe/socket and is sent once a minute in the absence of other
notification activity.
tick: the number of microseconds since system boot. It wraps around
after 1h12m.
-level: indicates the level of each gpio. If bit 1<<x is set then
-gpio x is high.
+level: indicates the level of each GPIO. If bit 1<<x is set then
+GPIO x is high.
...
-// Start notifications for gpios 1, 4, 6, 7, 10.
+// Start notifications for GPIO 1, 4, 6, 7, 10.
// 1
// 0 76 4 1
(if any).
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
If the added waveform is intended to start after or within the existing
waveform then the first pulse should consist of a delay.
The fields specify
-1) the gpios to be switched on at the start of the pulse.
-2) the gpios to be switched off at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
3) the delay in microseconds before the next pulse.
Any or all the fields can be zero. It doesn't make any sense to
gpioSetMode(GPIO, PI_OUTPUT);
- printf("start piscope, press return\n"); getchar();
+ printf("start piscope, press return"); getchar();
for (i=0; i<WAVES; i++)
{
for (i=0; i<WAVES; i++) gpioWaveDelete(wid[i]);
- printf("stop piscope, press return\n"); getchar();
+ printf("stop piscope, press return"); getchar();
gpioTerminate();
}
D*/
+/*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*/
+
+
/*F*/
int gpioWaveTxBusy(void);
/*D
/*F*/
int gpioSerialReadOpen(unsigned user_gpio, unsigned baud, unsigned data_bits);
/*D
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
. .
user_gpio: 0-31
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_GPIO_IN_USE,
PI_NOT_SERIAL_GPIO, or PI_BAD_SER_INVERT.
-The gpio must be opened for bit bang reading of serial data using
+The GPIO must be opened for bit bang reading of serial data using
[*gpioSerialReadOpen*] prior to calling this function.
D*/
/*F*/
int gpioSerialReadClose(unsigned user_gpio);
/*D
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
. .
user_gpio: 0-31, previously opened with [*gpioSerialReadOpen*]
/*F*/
int bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud);
/*D
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
Bit banging I2C allows for certain operations which are not possible
o baud rates as low as 50
o repeated starts
o clock stretching
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
. .
SDA: 0-31
NOTE:
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
D*/
/*F*/
int bbI2CClose(unsigned SDA);
/*D
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with [*bbI2COpen*].
. .
-SDA: 0-31, the SDA gpio used in a prior call to [*bbI2COpen*]
+SDA: 0-31, the SDA GPIO used in a prior call to [*bbI2COpen*]
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
be used to modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero 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.
+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.
. .
- spiChan: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device)
+ spiChan: 0-1 (0-2 for the auxiliary SPI device)
baud: 32K-125M (values above 30M are unlikely to work)
spiFlags: see below
. .
px is 0 if CEx is active low (default) and 1 for active high.
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
SPI device only.
bbbbbb defines the word size in bits (0-32). The default (0)
sets 8 bits per word. Auxiliary SPI device only.
+The [*spiRead*], [*spiWrite*], and [*spiXfer*] functions
+transfer data packed into 1, 2, or 4 bytes according to
+the word size in bits.
+
+For bits 1-8 there will be one byte per 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.
+
The other bits in flags should be set to zero.
D*/
/*F*/
int gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level);
/*D
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
. .
/*F*/
int gpioSetWatchdog(unsigned user_gpio, unsigned timeout);
/*D
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
. .
user_gpio: 0-31
The watchdog is nominally in milliseconds.
-One watchdog may be registered per gpio.
+One watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
-If no level change has been detected for the gpio for timeout
+If no level change has been detected for the GPIO for timeout
milliseconds:-
-1) any registered alert function for the gpio is called with
+1) any registered alert function for the GPIO is called with
the level set to PI_TIMEOUT.
-2) any notification for the gpio has a report written to the
+2) any notification for the GPIO has a report written to the
fifo with the flags set to indicate a watchdog timeout.
...
void aFunction(int gpio, int level, uint32_t tick)
{
- printf("gpio %d became %d at %d\n", gpio, level, tick);
+ printf("GPIO %d became %d at %d", gpio, level, tick);
}
-// call aFunction whenever gpio 4 changes state
+// call aFunction whenever GPIO 4 changes state
gpioSetAlertFunc(4, aFunction);
// or approximately every 5 millis
/*F*/
int gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active);
/*D
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for [*steady*] microseconds is detected. Level changes
-on the gpio are then reported for [*active*] microseconds after
+on the GPIO are then reported for [*active*] microseconds after
which the process repeats.
. .
/*F*/
int gpioGlitchFilter(unsigned user_gpio, unsigned steady);
/*D
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least [*steady*] microseconds. The
level is then reported. Level changes of less than [*steady*]
microseconds are ignored.
int gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits);
/*D
Registers a function to be called (a callback) every millisecond
-with the latest gpio samples.
+with the latest GPIO samples.
. .
f: the function to call
-bits: the gpios of interest
+bits: the GPIO of interest
. .
Returns 0 if OK.
The samples returned will be the union of bits, plus any active alerts,
plus any active notifications.
-e.g. if there are alerts for gpios 7, 8, and 9, notifications for gpios
-8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for gpios
+e.g. if there are alerts for GPIO 7, 8, and 9, notifications for GPIO
+8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for GPIO
7, 8, 9, 10, 17, 23, and 24 will be reported.
D*/
gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata);
/*D
Registers a function to be called (a callback) every millisecond
-with the latest gpio samples.
+with the latest GPIO samples.
. .
f: the function to call
- bits: the gpios of interest
+ bits: the GPIO of interest
userdata: a pointer to arbitrary user data
. .
...
void bFunction(void)
{
- printf("two seconds have elapsed\n");
+ printf("two seconds have elapsed");
}
// call bFunction every 2000 milliseconds
{
while (1)
{
- printf("%s\n", arg);
+ printf("%s", arg);
sleep(1);
}
}
/*F*/
uint32_t gpioRead_Bits_0_31(void);
/*D
-Returns the current level of gpios 0-31.
+Returns the current level of GPIO 0-31.
D*/
/*F*/
uint32_t gpioRead_Bits_32_53(void);
/*D
-Returns the current level of gpios 32-53.
+Returns the current level of GPIO 32-53.
D*/
/*F*/
int gpioWrite_Bits_0_31_Clear(uint32_t bits);
/*D
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
. .
-bits: a bit mask of gpios to clear
+bits: a bit mask of GPIO to clear
. .
Returns 0 if OK.
...
-// To clear (set to 0) gpios 4, 7, and 15
+// To clear (set to 0) GPIO 4, 7, and 15
gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) );
...
D*/
/*F*/
int gpioWrite_Bits_32_53_Clear(uint32_t bits);
/*D
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
-bits: a bit mask of gpios to clear
+bits: a bit mask of GPIO to clear
. .
Returns 0 if OK.
/*F*/
int gpioWrite_Bits_0_31_Set(uint32_t bits);
/*D
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
. .
-bits: a bit mask of gpios to set
+bits: a bit mask of GPIO to set
. .
Returns 0 if OK.
/*F*/
int gpioWrite_Bits_32_53_Set(uint32_t bits);
/*D
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
-bits: a bit mask of gpios to set
+bits: a bit mask of GPIO to set
. .
Returns 0 if OK.
...
-// To set (set to 1) gpios 32, 40, and 53
+// To set (set to 1) GPIO 32, 40, and 53
gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32)));
...
D*/
/*F*/
int gpioHardwareClock(unsigned gpio, unsigned clkfreq);
/*D
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
. .
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HCLK_GPIO,
PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
4 clock 0 All models
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
-6 clock 2 A+/B+/Pi2/Zero and compute module only
-20 clock 0 A+/B+/Pi2/Zero and compute module only
-21 clock 1 All models but Rev.2 B (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
+6 clock 2 All models but A and B
+20 clock 0 All models but A and B
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
32 clock 0 Compute module only
34 clock 0 Compute module only
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
D*/
/*F*/
int gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty);
/*D
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
NOTE: Any waveform started by [*gpioWaveTxSend*], or
Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HPWM_GPIO,
PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, or PI_HPWM_ILLEGAL.
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
+13 PWM channel 1 All models but A and B
18 PWM channel 0 All models
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
// print the number of seconds since the library was started
gpioTime(PI_TIME_RELATIVE, &secs, &mics);
-printf("library started %d.%03d seconds ago\n", secs, mics/1000);
+printf("library started %d.%03d seconds ago", secs, mics/1000);
...
D*/
diffTick = endTick - startTick;
-printf("some processing took %d microseconds\n", diffTick);
+printf("some processing took %d microseconds", diffTick);
...
D*/
The hardware revision is the last few characters on the Revision line of
/proc/cpuinfo.
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see [*gpio*]).
There are at least three types of board.
/*F*/
int gpioCfgBufferSize(unsigned cfgMillis);
/*D
-Configures pigpio to buffer cfgMillis milliseconds of gpio samples.
+Configures pigpio to buffer cfgMillis milliseconds of GPIO samples.
. .
cfgMillis: 100-10000
int gpioCfgPermissions(uint64_t updateMask);
/*D
Configures pigpio to only allow updates (writes or mode changes) for the
-gpios specified by the mask.
+GPIO specified by the mask.
. .
-updateMask: bit (1<<n) is set for each gpio n which may be updated
+updateMask: bit (1<<n) is set for each GPIO n which may be updated
. .
The default setting depends upon the board revision (Type 1, 2, or 3).
-The user gpios are added to the mask. If the board revision is not
-recognised then gpios 0-31 are allowed.
+The user GPIO are added to the mask. If the board revision is not
+recognised then GPIO 0-31 are allowed.
Unknown board @ PI_DEFAULT_UPDATE_MASK_R0 @ 0xFFFFFFFF
Type 1 board @ PI_DEFAULT_UPDATE_MASK_R1 @ 0x03E6CF93
. .
spi: a pointer to a spi object
offset: microseconds from the start of the waveform
- spiSS: the slave select gpio
+ spiSS: the slave select GPIO
buf: the bits to transmit, most significant bit first
spiTxBits: the number of bits to write
spiBitFirst: the first bit to read
(if any).
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
If the added waveform is intended to start after or within the existing
waveform then the first pulse should consist of a delay.
position 0.
bits::
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
A convenient way to set bit n is to or in (1<<n).
cfgMicros::
-The gpio sample rate in microseconds. The default is 5us, or 200 thousand
+The GPIO sample rate in microseconds. The default is 5us, or 200 thousand
samples per second.
cfgMillis:: 100-10000
0 is off and range is fully on.
edge::0-2
-The type of gpio edge to generate an intrrupt. See[*gpioSetISRFunc*],
+The type of GPIO edge to generate an intrrupt. See[*gpioSetISRFunc*],
and [*gpioSetISRFuncEx*].
. .
frequency::0-
-The number of times a gpio is swiched on and off per second. This
-can be set per gpio and may be as little as 5Hz or as much as
-40KHz. The gpio will be on for a proportion of the time as defined
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
gpio::
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
gpio53.
They are split into two banks. Bank 1 consists of gpio0 through
gpio31. Bank 2 consists of gpio32 through gpio53.
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
See [*gpioHardwareRevision*].
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
. .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
A flag used to set normal or inverted bit bang serial data level logic.
level::
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
. .
PI_OFF 0
PI_HIGH 1
. .
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See [*gpioSetWatchdog*].
. .
mode::0-7
-The operational mode of a gpio, normally INPUT or OUTPUT.
+The operational mode of a GPIO, normally INPUT or OUTPUT.
. .
PI_INPUT 0
The position of an item.
primaryChannel:: 0-14
-The DMA channel used to time the sampling of gpios and to time servo and
+The DMA channel used to time the sampling of GPIO and to time servo and
PWM pulses.
*pth::
pud::0-2
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
. .
PI_PUD_OFF 0
. .
typedef struct
{
- int clk; // gpio for clock
- int mosi; // gpio for MOSI
- int miso; // gpio for MISO
+ int clk; // GPIO for clock
+ int mosi; // GPIO for MOSI
+ int miso; // GPIO for MISO
int ss_pol; // slave select off state
int ss_us; // delay after slave select
int clk_pol; // clock off state
uint16_t topCB; // last CB used by wave
uint16_t botOOL; // last OOL used by wave
uint16_t topOOL; // first OOL used by wave
+ uint16_t deleted;
+ uint16_t numCB;
+ uint16_t numBOOL;
+ uint16_t numTOOL;
} rawWaveInfo_t;
. .
SCL::
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
*script::
SDA::
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
secondaryChannel:: 0-6
A pointer to a [*rawSPI_t*] structure.
spiBitFirst::
-Gpio reads are made from spiBitFirst to spiBitLast.
+GPIO reads are made from spiBitFirst to spiBitLast.
spiBitLast::
-Gpio reads are made from spiBitFirst to spiBitLast.
+GPIO reads are made from spiBitFirst to spiBitLast.
spiBits::
The number of bits to transfer in a raw SPI transaction.
See [*spiOpen*].
spiSS::
-The SPI slave select gpio in a raw SPI transaction.
+The SPI slave select GPIO in a raw SPI transaction.
spiTxBits::
The number of bits to transfer dring a raw SPI transaction
An array of characters.
timeout::
-A gpio level change timeout in milliseconds.
+A GPIO level change timeout in milliseconds.
[*gpioSetWatchdog*]
. .
updateMask::
-A 64 bit mask indicating which gpios may be written to by the user.
+A 64 bit mask indicating which GPIO may be written to by the user.
-If gpio#n may be written then bit (1<<n) is set.
+If GPIO#n may be written then bit (1<<n) is set.
user_gpio::
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
See [*gpio*].
#define PI_CMD_NOIB 99
#define PI_CMD_WVTXM 100
+#define PI_CMD_WVTAT 101
/*DEF_E*/
/*DEF_S Error Codes*/
#define PI_INIT_FAILED -1 // gpioInitialise failed
-#define PI_BAD_USER_GPIO -2 // gpio not 0-31
-#define PI_BAD_GPIO -3 // gpio not 0-53
+#define PI_BAD_USER_GPIO -2 // GPIO not 0-31
+#define PI_BAD_GPIO -3 // GPIO not 0-53
#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_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX)
#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses
#define PI_TOO_MANY_CHARS -37 // waveform has too many chars
-#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read in progress on gpio
+#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read in progress on GPIO
#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter
#define PI_BAD_SERIAL_BUF -40 // bad (null) serial buf parameter
-#define PI_NOT_PERMITTED -41 // gpio operation not permitted
-#define PI_SOME_PERMITTED -42 // one or more gpios not permitted
+#define PI_NOT_PERMITTED -41 // GPIO operation not permitted
+#define PI_SOME_PERMITTED -42 // one or more GPIO not permitted
#define PI_BAD_WVSC_COMMND -43 // bad WVSC subcommand
#define PI_BAD_WVSM_COMMND -44 // bad WVSM subcommand
#define PI_BAD_WVSP_COMMND -45 // bad WVSP subcommand
#define PI_BAD_SCRIPT -47 // invalid script
#define PI_BAD_SCRIPT_ID -48 // unknown script id
#define PI_BAD_SER_OFFSET -49 // add serial data offset > 30 minutes
-#define PI_GPIO_IN_USE -50 // gpio already in use
+#define PI_GPIO_IN_USE -50 // GPIO already in use
#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time
#define PI_BAD_PARAM_NUM -52 // script parameter id not 0-9
#define PI_DUP_TAG -53 // script has duplicate tag
#define PI_UNKNOWN_COMMAND -88 // unknown command
#define PI_SPI_XFER_FAILED -89 // spi xfer/read/write failed
#define PI_BAD_POINTER -90 // bad (NULL) pointer
-#define PI_NO_AUX_SPI -91 // need a A+/B+/Pi2/Zero for auxiliary SPI
-#define PI_NOT_PWM_GPIO -92 // gpio is not in use for PWM
-#define PI_NOT_SERVO_GPIO -93 // gpio is not in use for servo pulses
-#define PI_NOT_HCLK_GPIO -94 // gpio has no hardware clock
-#define PI_NOT_HPWM_GPIO -95 // gpio has no hardware PWM
+#define PI_NO_AUX_SPI -91 // no auxiliary SPI on Pi A or B
+#define PI_NOT_PWM_GPIO -92 // GPIO is not in use for PWM
+#define PI_NOT_SERVO_GPIO -93 // GPIO is not in use for servo pulses
+#define PI_NOT_HCLK_GPIO -94 // GPIO has no hardware clock
+#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM
#define PI_BAD_HPWM_FREQ -96 // 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
#define PI_TOO_MANY_SEGS -105 // too many I2C transaction segments
#define PI_BAD_I2C_SEG -106 // an I2C transaction segment failed
#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
-#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on gpio
+#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO
#define PI_BAD_I2C_WLEN -109 // bad I2C write length
#define PI_BAD_I2C_RLEN -110 // bad I2C read length
#define PI_BAD_I2C_CMD -111 // bad I2C command
"""
pigpio is a Python module for the Raspberry which talks to
the pigpio daemon to allow control of the general purpose
-input outputs (gpios).
+input outputs (GPIO).
[http://abyz.co.uk/rpi/pigpio/python.html]
o controls one or more Pi's
-o independent PWM on any of gpios 0-31 simultaneously
+o independent PWM on any of GPIO 0-31 simultaneously
-o independent servo pulses on any of gpios 0-31 simultaneously
+o independent servo pulses on any of GPIO 0-31 simultaneously
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
o creating and transmitting precisely timed waveforms
-o reading/writing gpios and setting their modes
+o reading/writing GPIO and setting their modes
o wrappers for I2C, SPI, and serial links
o creating and running scripts on the pigpio daemon
-*gpios*
+*GPIO*
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
*Notes*
o the sample rate (1, 2, 4, 5, 8, or 10 us, default 5 us).
-o the set of gpios which may be updated (generally written to). The
+o the set of GPIO which may be updated (generally written to). The
default set is those available on the Pi board revision.
o the available PWM frequencies (see [*set_PWM_frequency*]).
*Usage*
This module uses the services of the C pigpio library. pigpio
-must be running on the Pi(s) whose gpios are to be manipulated.
+must be running on the Pi(s) whose GPIO are to be manipulated.
The normal way to start pigpio is as a daemon (during system
start).
Your Python program must import pigpio and create one or more
instances of the pigpio.pi class. This class gives access to
-a specified Pi's gpios.
+a specified Pi's GPIO.
...
-pi1 = pigpio.pi() # pi1 accesses the local Pi's gpios
-pi2 = pigpio.pi('tom') # pi2 accesses tom's gpios
-pi3 = pigpio.pi('dick') # pi3 accesses dick's gpios
+pi1 = pigpio.pi() # pi1 accesses the local Pi's GPIO
+pi2 = pigpio.pi('tom') # pi2 accesses tom's GPIO
+pi3 = pigpio.pi('dick') # pi3 accesses dick's GPIO
-pi1.write(4, 0) # set local Pi's gpio 4 low
-pi2.write(4, 1) # set tom's gpio 4 to high
-pi3.read(4) # get level of dick's gpio 4
+pi1.write(4, 0) # set local Pi's GPIO 4 low
+pi2.write(4, 1) # set tom's GPIO 4 to high
+pi3.read(4) # get level of dick's GPIO 4
...
The later example code snippets assume that pi is an instance of
Beginner
-set_mode Set a gpio mode
-get_mode Get a gpio mode
-set_pull_up_down Set/clear gpio pull up/down resistor
+set_mode Set a GPIO mode
+get_mode Get a GPIO mode
+set_pull_up_down Set/clear GPIO pull up/down resistor
-read Read a gpio
-write Write a gpio
+read Read a GPIO
+write Write a GPIO
-set_PWM_dutycycle Start/stop PWM pulses on a gpio
-get_PWM_dutycycle Get PWM dutycycle set on a gpio
+set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+get_PWM_dutycycle Get PWM dutycycle set on a GPIO
-set_servo_pulsewidth Start/Stop servo pulses on a gpio
-get_servo_pulsewidth Get servo pulsewidth set on a gpio
+set_servo_pulsewidth Start/Stop servo pulses on a GPIO
+get_servo_pulsewidth Get servo pulsewidth set on a GPIO
-callback Create gpio level change callback
-wait_for_edge Wait for gpio level change
+callback Create GPIO level change callback
+wait_for_edge Wait for GPIO level change
Intermediate
-gpio_trigger Send a trigger pulse to a gpio
+gpio_trigger Send a trigger pulse to a GPIO
-set_watchdog Set a watchdog on a gpio
+set_watchdog Set a watchdog on a GPIO
-set_PWM_range Configure PWM range of a gpio
-get_PWM_range Get configured PWM range of a gpio
+set_PWM_range Configure PWM range of a GPIO
+get_PWM_range Get configured PWM range of a GPIO
-set_PWM_frequency Set PWM frequency of a gpio
-get_PWM_frequency Get PWM frequency of a gpio
+set_PWM_frequency Set PWM frequency of a GPIO
+get_PWM_frequency Get PWM frequency of a GPIO
-read_bank_1 Read all bank 1 gpios
-read_bank_2 Read all bank 2 gpios
+read_bank_1 Read all bank 1 GPIO
+read_bank_2 Read all bank 2 GPIO
-clear_bank_1 Clear selected gpios in bank 1
-clear_bank_2 Clear selected gpios in bank 2
+clear_bank_1 Clear selected GPIO in bank 1
+clear_bank_2 Clear selected GPIO in bank 2
-set_bank_1 Set selected gpios in bank 1
-set_bank_2 Set selected gpios in bank 2
+set_bank_1 Set selected GPIO in bank 1
+set_bank_2 Set selected GPIO in bank 2
Advanced
-get_PWM_real_range Get underlying PWM range for a gpio
+get_PWM_real_range Get underlying PWM range for a GPIO
notify_open Request a notification handle
-notify_begin Start notifications for selected gpios
+notify_begin Start notifications for selected GPIO
notify_pause Pause notifications
notify_close Close a notification
-bb_serial_read_open Open a gpio for bit bang serial reads
-bb_serial_read Read bit bang serial data from a gpio
-bb_serial_read_close Close a gpio for bit bang serial reads
+bb_serial_read_open Open a GPIO for bit bang serial reads
+bb_serial_read Read bit bang serial data from a GPIO
+bb_serial_read_close Close a GPIO for bit bang serial reads
bb_serial_invert Invert serial logic (1 invert, 0 normal)
-hardware_clock Start hardware clock on supported gpios
-hardware_PWM Start hardware PWM on supported gpios
+hardware_clock Start hardware clock on supported GPIO
+hardware_PWM Start hardware PWM on supported GPIO
-set_glitch_filter Set a glitch filter on a gpio
-set_noise_filter Set a noise filter on a gpio
+set_glitch_filter Set a glitch filter on a GPIO
+set_noise_filter Set a noise filter on a GPIO
Scripts
wave_chain Transmits a chain of waveforms
+wave_tx_at Returns the current transmitting waveform
wave_tx_busy Checks to see if a waveform has ended
wave_tx_stop Aborts the current waveform
i2c_zip Performs multiple I2C transactions
-bb_i2c_open Opens gpios for bit banging I2C
-bb_i2c_close Closes gpios for bit banging I2C
+bb_i2c_open Opens GPIO for bit banging I2C
+bb_i2c_close Closes GPIO for bit banging I2C
bb_i2c_zip Performs multiple bit banged I2C transactions
SPI
import os
import atexit
-VERSION = "1.27"
+VERSION = "1.29"
exceptions = True
-# gpio levels
+# GPIO levels
OFF = 0
LOW = 0
TIMEOUT = 2
-# gpio edges
+# GPIO edges
RISING_EDGE = 0
FALLING_EDGE = 1
EITHER_EDGE = 2
-# gpio modes
+# GPIO modes
INPUT = 0
OUTPUT = 1
ALT4 = 3
ALT5 = 2
-# gpio Pull Up Down
+# GPIO Pull Up Down
PUD_OFF = 0
PUD_DOWN = 1
WAVE_MODE_ONE_SHOT_SYNC=2
WAVE_MODE_REPEAT_SYNC =3
+WAVE_NOT_FOUND = 9998 # Transmitted wave not found.
+NO_TX_WAVE = 9999 # No wave being transmitted.
+
# pigpio command numbers
_PI_CMD_MODES= 0
_PI_CMD_FN =98
_PI_CMD_WVTXM=100
+_PI_CMD_WVAT =101
# pigpio error numbers
_errors=[
[_PI_INIT_FAILED , "pigpio initialisation failed"],
- [PI_BAD_USER_GPIO , "gpio not 0-31"],
- [PI_BAD_GPIO , "gpio not 0-53"],
+ [PI_BAD_USER_GPIO , "GPIO not 0-31"],
+ [PI_BAD_GPIO , "GPIO not 0-53"],
[PI_BAD_MODE , "mode not 0-7"],
[PI_BAD_LEVEL , "level not 0-1"],
[PI_BAD_PUD , "pud not 0-2"],
[PI_BAD_WAVE_BAUD , "baud rate not 50-250000(RX)/1000000(TX)"],
[PI_TOO_MANY_PULSES , "waveform has too many pulses"],
[PI_TOO_MANY_CHARS , "waveform has too many chars"],
- [PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on gpio"],
- [PI_NOT_PERMITTED , "no permission to update gpio"],
- [PI_SOME_PERMITTED , "no permission to update one or more gpios"],
+ [PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on GPIO"],
+ [PI_NOT_PERMITTED , "no permission to update GPIO"],
+ [PI_SOME_PERMITTED , "no permission to update one or more GPIO"],
[PI_BAD_WVSC_COMMND , "bad WVSC subcommand"],
[PI_BAD_WVSM_COMMND , "bad WVSM subcommand"],
[PI_BAD_WVSP_COMMND , "bad WVSP subcommand"],
[PI_BAD_SCRIPT , "invalid script"],
[PI_BAD_SCRIPT_ID , "unknown script id"],
[PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"],
- [PI_GPIO_IN_USE , "gpio already in use"],
+ [PI_GPIO_IN_USE , "GPIO already in use"],
[PI_BAD_SERIAL_COUNT , "must read at least a byte at a time"],
[PI_BAD_PARAM_NUM , "script parameter id not 0-9"],
[PI_DUP_TAG , "script has duplicate tag"],
[PI_UNKNOWN_COMMAND , "unknown command"],
[PI_SPI_XFER_FAILED , "SPI xfer/read/write failed"],
[_PI_BAD_POINTER , "bad (NULL) pointer"],
- [PI_NO_AUX_SPI , "need a A+/B+/Pi2/Zero for auxiliary SPI"],
- [PI_NOT_PWM_GPIO , "gpio is not in use for PWM"],
- [PI_NOT_SERVO_GPIO , "gpio is not in use for servo pulses"],
- [PI_NOT_HCLK_GPIO , "gpio has no hardware clock"],
- [PI_NOT_HPWM_GPIO , "gpio has no hardware PWM"],
+ [PI_NO_AUX_SPI , "no auxiliary SPI on Pi A or B"],
+ [PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"],
+ [PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"],
+ [PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"],
+ [PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"],
[PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"],
[PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"],
[PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"],
[_PI_TOO_MANY_SEGS , "too many I2C transaction segments"],
[_PI_BAD_I2C_SEG , "an I2C transaction segment failed"],
[PI_BAD_SMBUS_CMD , "SMBus command not supported"],
- [PI_NOT_I2C_GPIO , "no bit bang I2C in progress on gpio"],
+ [PI_NOT_I2C_GPIO , "no bit bang I2C in progress on GPIO"],
[PI_BAD_I2C_WLEN , "bad I2C write length"],
[PI_BAD_I2C_RLEN , "bad I2C read length"],
[PI_BAD_I2C_CMD , "bad I2C command"],
"""
Initialises a pulse.
- gpio_on:= the gpios to switch on at the start of the pulse.
- gpio_off:= the gpios to switch off at the start of the pulse.
+ gpio_on:= the GPIO to switch on at the start of the pulse.
+ gpio_off:= the GPIO to switch off at the start of the pulse.
delay:= the delay in microseconds before the next pulse.
"""
"""
Initialises a callback ADT.
- gpio:= Broadcom gpio number.
+ gpio:= Broadcom GPIO number.
edge:= EITHER_EDGE, RISING_EDGE, or FALLING_EDGE.
- func:= a user function taking three arguments (gpio, level, tick).
+ func:= a user function taking three arguments (GPIO, level, tick).
"""
self.gpio = gpio
self.edge = edge
self.sl.s.close()
class _callback:
- """A class to provide gpio level change callbacks."""
+ """A class to provide GPIO level change callbacks."""
def __init__(self, notify, user_gpio, edge=RISING_EDGE, func=None):
"""
self.count = 0
class _wait_for_edge:
- """Encapsulates waiting for gpio edges."""
+ """Encapsulates waiting for GPIO edges."""
def __init__(self, notify, gpio, edge, timeout):
"""Initialises a wait_for_edge."""
def set_mode(self, gpio, mode):
"""
- Sets the gpio mode.
+ Sets the GPIO mode.
gpio:= 0-53.
mode:= INPUT, OUTPUT, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5.
...
- pi.set_mode( 4, pigpio.INPUT) # gpio 4 as input
- pi.set_mode(17, pigpio.OUTPUT) # gpio 17 as output
- pi.set_mode(24, pigpio.ALT2) # gpio 24 as ALT2
+ pi.set_mode( 4, pigpio.INPUT) # GPIO 4 as input
+ pi.set_mode(17, pigpio.OUTPUT) # GPIO 17 as output
+ pi.set_mode(24, pigpio.ALT2) # GPIO 24 as ALT2
...
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_MODES, gpio, mode))
def get_mode(self, gpio):
"""
- Returns the gpio mode.
+ Returns the GPIO mode.
gpio:= 0-53.
def set_pull_up_down(self, gpio, pud):
"""
- Sets or clears the internal gpio pull-up/down resistor.
+ Sets or clears the internal GPIO pull-up/down resistor.
gpio:= 0-53.
pud:= PUD_UP, PUD_DOWN, PUD_OFF.
def read(self, gpio):
"""
- Returns the gpio level.
+ Returns the GPIO level.
gpio:= 0-53.
def write(self, gpio, level):
"""
- Sets the gpio level.
+ Sets the GPIO level.
- gpio:= 0-53.
+ GPIO:= 0-53.
level:= 0, 1.
- If PWM or servo pulses are active on the gpio they are
+ If PWM or servo pulses are active on the GPIO they are
switched off.
...
def set_PWM_dutycycle(self, user_gpio, dutycycle):
"""
- Starts (non-zero dutycycle) or stops (0) PWM pulses on the gpio.
+ Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO.
user_gpio:= 0-31.
dutycycle:= 0-range (range defaults to 255).
def get_PWM_dutycycle(self, user_gpio):
"""
- Returns the PWM dutycycle being used on the gpio.
+ Returns the PWM dutycycle being used on the GPIO.
user_gpio:= 0-31.
For normal PWM the dutycycle will be out of the defined range
- for the gpio (see [*get_PWM_range*]).
+ for the GPIO (see [*get_PWM_range*]).
- If a hardware clock is active on the gpio the reported
+ If a hardware clock is active on the GPIO the reported
dutycycle will be 500000 (500k) out of 1000000 (1M).
- If hardware PWM is active on the gpio the reported dutycycle
+ If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
...
def set_PWM_range(self, user_gpio, range_):
"""
- Sets the range of PWM values to be used on the gpio.
+ Sets the range of PWM values to be used on the GPIO.
user_gpio:= 0-31.
range_:= 25-40000.
def get_PWM_range(self, user_gpio):
"""
- Returns the range of PWM values being used on the gpio.
+ Returns the range of PWM values being used on the GPIO.
user_gpio:= 0-31.
- If a hardware clock or hardware PWM is active on the gpio
+ If a hardware clock or hardware PWM is active on the GPIO
the reported range will be 1000000 (1M).
...
def get_PWM_real_range(self, user_gpio):
"""
Returns the real (underlying) range of PWM values being
- used on the gpio.
+ used on the GPIO.
user_gpio:= 0-31.
- If a hardware clock is active on the gpio the reported
+ If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
- If hardware PWM is active on the gpio the reported real range
+ If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
...
def set_PWM_frequency(self, user_gpio, frequency):
"""
- Sets the frequency (in Hz) of the PWM to be used on the gpio.
+ Sets the frequency (in Hz) of the PWM to be used on the GPIO.
user_gpio:= 0-31.
frequency:= >=0 Hz
def get_PWM_frequency(self, user_gpio):
"""
- Returns the frequency of PWM being used on the gpio.
+ Returns the frequency of PWM being used on the GPIO.
user_gpio:= 0-31.
- Returns the frequency (in Hz) used for the gpio.
+ Returns the frequency (in Hz) used for the GPIO.
- For normal PWM the frequency will be that defined for the gpio
+ For normal PWM the frequency will be that defined for the GPIO
by [*set_PWM_frequency*].
- If a hardware clock is active on the gpio the reported frequency
+ If a hardware clock is active on the GPIO the reported frequency
will be that set by [*hardware_clock*].
- If hardware PWM is active on the gpio the reported frequency
+ If hardware PWM is active on the GPIO the reported frequency
will be that set by [*hardware_PWM*].
...
def set_servo_pulsewidth(self, user_gpio, pulsewidth):
"""
- Starts (500-2500) or stops (0) servo pulses on the gpio.
+ Starts (500-2500) or stops (0) servo pulses on the GPIO.
user_gpio:= 0-31.
pulsewidth:= 0 (off),
def get_servo_pulsewidth(self, user_gpio):
"""
- Returns the servo pulsewidth being used on the gpio.
+ Returns the servo pulsewidth being used on the GPIO.
user_gpio:= 0-31.
"""
Returns a notification handle (>=0).
- A notification is a method for being notified of gpio state
+ A notification is a method for being notified of GPIO state
changes via a pipe.
Pipes are only accessible from the local machine so this
flags: two flags are defined, PI_NTFY_FLAGS_WDOG and
PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG)
- then bits 0-4 of the flags indicate a gpio which has had a
+ then bits 0-4 of the flags indicate a GPIO which has had a
watchdog timeout; if bit 6 is set (PI_NTFY_FLAGS_ALIVE) this
indicates a keep alive signal on the pipe/socket and is sent
once a minute in the absence of other notification activity.
tick: the number of microseconds since system boot. It wraps
around after 1h12m.
- level: indicates the level of each gpio. If bit 1<<x is set
- then gpio x is high.
+ level: indicates the level of each GPIO. If bit 1<<x is set
+ then GPIO x is high.
...
h = pi.notify_open()
Starts notifications on a handle.
handle:= >=0 (as returned by a prior call to [*notify_open*])
- bits:= a 32 bit mask indicating the gpios to be notified.
+ bits:= a 32 bit mask indicating the GPIO to be notified.
- The notification sends state changes for each gpio whose
+ The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
- The following code starts notifications for gpios 1, 4,
+ The following code starts notifications for GPIO 1, 4,
6, 7, and 10 (1234 = 0x04D2 = 0b0000010011010010).
...
def set_watchdog(self, user_gpio, wdog_timeout):
"""
- Sets a watchdog timeout for a gpio.
+ Sets a watchdog timeout for a GPIO.
user_gpio:= 0-31.
wdog_timeout:= 0-60000.
The watchdog is nominally in milliseconds.
- Only one watchdog may be registered per gpio.
+ Only one watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
- If no level change has been detected for the gpio for timeout
- milliseconds any notification for the gpio has a report written
+ If no level change has been detected for the GPIO for timeout
+ milliseconds any notification for the GPIO has a report written
to the fifo with the flags set to indicate a watchdog timeout.
The callback class interprets the flags and will
- call registered callbacks for the gpio with level TIMEOUT.
+ call registered callbacks for the GPIO with level TIMEOUT.
...
- pi.set_watchdog(23, 1000) # 1000 ms watchdog on gpio 23
- pi.set_watchdog(23, 0) # cancel watchdog on gpio 23
+ pi.set_watchdog(23, 1000) # 1000 ms watchdog on GPIO 23
+ pi.set_watchdog(23, 0) # cancel watchdog on GPIO 23
...
"""
return _u2i(_pigpio_command(
def read_bank_1(self):
"""
- Returns the levels of the bank 1 gpios (gpios 0-31).
+ Returns the levels of the bank 1 GPIO (GPIO 0-31).
The returned 32 bit integer has a bit set if the corresponding
- gpio is high. Gpio n has bit value (1<<n).
+ GPIO is high. GPIO n has bit value (1<<n).
...
print(bin(pi.read_bank_1()))
def read_bank_2(self):
"""
- Returns the levels of the bank 2 gpios (gpios 32-53).
+ Returns the levels of the bank 2 GPIO (GPIO 32-53).
The returned 32 bit integer has a bit set if the corresponding
- gpio is high. Gpio n has bit value (1<<(n-32)).
+ GPIO is high. GPIO n has bit value (1<<(n-32)).
...
print(bin(pi.read_bank_2()))
def clear_bank_1(self, bits):
"""
- Clears gpios 0-31 if the corresponding bit in bits is set.
+ Clears GPIO 0-31 if the corresponding bit in bits is set.
- bits:= a 32 bit mask with 1 set if the corresponding gpio is
+ bits:= a 32 bit mask with 1 set if the corresponding GPIO is
to be cleared.
A returned status of PI_SOME_PERMITTED indicates that the user
- is not allowed to write to one or more of the gpios.
+ is not allowed to write to one or more of the GPIO.
...
pi.clear_bank_1(int("111110010000",2))
def clear_bank_2(self, bits):
"""
- Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+ Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
- bits:= a 32 bit mask with 1 set if the corresponding gpio is
+ bits:= a 32 bit mask with 1 set if the corresponding GPIO is
to be cleared.
A returned status of PI_SOME_PERMITTED indicates that the user
- is not allowed to write to one or more of the gpios.
+ is not allowed to write to one or more of the GPIO.
...
pi.clear_bank_2(0x1010)
def set_bank_1(self, bits):
"""
- Sets gpios 0-31 if the corresponding bit in bits is set.
+ Sets GPIO 0-31 if the corresponding bit in bits is set.
- bits:= a 32 bit mask with 1 set if the corresponding gpio is
+ bits:= a 32 bit mask with 1 set if the corresponding GPIO is
to be set.
A returned status of PI_SOME_PERMITTED indicates that the user
- is not allowed to write to one or more of the gpios.
+ is not allowed to write to one or more of the GPIO.
...
pi.set_bank_1(int("111110010000",2))
def set_bank_2(self, bits):
"""
- Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+ Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
- bits:= a 32 bit mask with 1 set if the corresponding gpio is
+ bits:= a 32 bit mask with 1 set if the corresponding GPIO is
to be set.
A returned status of PI_SOME_PERMITTED indicates that the user
- is not allowed to write to one or more of the gpios.
+ is not allowed to write to one or more of the GPIO.
...
pi.set_bank_2(0x303)
def hardware_clock(self, gpio, clkfreq):
"""
- Starts a hardware clock on a gpio at the specified frequency.
+ Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
gpio:= see description
Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
- The same clock is available on multiple gpios. The latest
- frequency setting will be used by all gpios which share a clock.
+ The same clock is available on multiple GPIO. The latest
+ frequency setting will be used by all GPIO which share a clock.
- The gpio must be one of the following.
+ The GPIO must be one of the following.
. .
4 clock 0 All models
- 5 clock 1 A+/B+/Pi2/Zero and compute module only
- (reserved for system use)
- 6 clock 2 A+/B+/Pi2/Zero and compute module only
- 20 clock 0 A+/B+/Pi2/Zero and compute module only
- 21 clock 1 All models but Rev.2 B (reserved for system use)
+ 5 clock 1 All models but A and B (reserved for system use)
+ 6 clock 2 All models but A and B
+ 20 clock 0 All models but A and B
+ 21 clock 1 All models but A and Rev.2 B (reserved for system use)
32 clock 0 Compute module only
34 clock 0 Compute module only
Access to clock 1 is protected by a password as its use will
likely crash the Pi. The password is given by or'ing 0x5A000000
- with the gpio number.
+ with the GPIO number.
...
- pi.hardware_clock(4, 5000) # 5 KHz clock on gpio 4
+ pi.hardware_clock(4, 5000) # 5 KHz clock on GPIO 4
- pi.hardware_clock(4, 40000000) # 40 MHz clock on gpio 4
+ pi.hardware_clock(4, 40000000) # 40 MHz clock on GPIO 4
...
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_HC, gpio, clkfreq))
def hardware_PWM(self, gpio, PWMfreq, PWMduty):
"""
- Starts hardware PWM on a gpio at the specified frequency
+ Starts hardware PWM on a GPIO at the specified frequency
and dutycycle. Frequencies above 30MHz are unlikely to work.
NOTE: Any waveform started by [*wave_send_once*],
Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
PI_NOT_HPWM_GPIO, PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ.
- The same PWM channel is available on multiple gpios.
+ The same PWM channel is available on multiple GPIO.
The latest frequency and dutycycle setting will be used
- by all gpios which share a PWM channel.
+ by all GPIO which share a PWM channel.
- The gpio must be one of the following.
+ The GPIO must be one of the following.
. .
- 12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
- 13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+ 12 PWM channel 0 All models but A and B
+ 13 PWM channel 1 All models but A and B
18 PWM channel 0 All models
- 19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+ 19 PWM channel 1 All models but A and B
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
Revision line of /proc/cpuinfo.
The revision number can be used to determine the assignment
- of gpios to pins (see [*gpio*]).
+ of GPIO to pins (see [*gpio*]).
There are at least three types of board.
waveform (if any).
Merging allows the waveform to be built in parts, that is the
- settings for gpio#1 can be added, and then gpio#2 etc.
+ settings for GPIO#1 can be added, and then GPIO#2 etc.
If the added waveform is intended to start after or within
the existing waveform then the first pulse should consist
waveform (if any). The serial data starts [*offset*]
microseconds from the start of the waveform.
- user_gpio:= gpio to transmit data. You must set the gpio mode
+ user_gpio:= GPIO to transmit data. You must set the GPIO mode
to output.
baud:= 50-1000000 bits per second.
data:= the bytes to write.
A pulse specifies
- 1) the gpios to be switched on at the start of the pulse.
- 2) the gpios to be switched off at the start of the pulse.
+ 1) the GPIO to be switched on at the start of the pulse.
+ 2) the GPIO to be switched off at the start of the pulse.
3) the delay in microseconds before the next pulse.
Any or all the fields can be zero. It doesn't make any sense
"""
return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXM, wave_id, mode))
+ def wave_tx_at(self):
+ """
+ Returns the id of the waveform currently being
+ transmitted.
+
+ Returns the waveform id or one of the following special
+ values:
+
+ WAVE_NOT_FOUND (9998) - transmitted wave not found.
+ NO_TX_WAVE (9999) - no wave being transmitted.
+
+ ...
+ wid = pi.wave_tx_at()
+ ...
+ """
+ return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTAT, 0, 0))
+
def wave_tx_busy(self):
"""
Returns 1 if a waveform is currently being transmitted,
def bb_i2c_open(self, SDA, SCL, baud=100000):
"""
- This function selects a pair of gpios for bit banging I2C at a
+ This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
Bit banging I2C allows for certain operations which are not possible
o baud rates as low as 50
o repeated starts
o clock stretching
- o I2C on any pair of spare gpios
+ o I2C on any pair of spare GPIO
SDA:= 0-31
SCL:= 0-31
NOTE:
- The gpios used for SDA and SCL must have pull-ups to 3V3 connected.
+ The GPIO used for SDA and SCL must have pull-ups to 3V3 connected.
As a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
...
- h = pi.bb_i2c_open(4, 5, 50000) # bit bang on gpio 4/5 at 50kbps
+ h = pi.bb_i2c_open(4, 5, 50000) # bit bang on GPIO 4/5 at 50kbps
...
"""
# I p1 SDA
def bb_i2c_close(self, SDA):
"""
- This function stops bit banging I2C on a pair of gpios
+ This function stops bit banging I2C on a pair of GPIO
previously opened with [*bb_i2c_open*].
- SDA:= 0-31, the SDA gpio used in a prior call to [*bb_i2c_open*]
+ SDA:= 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*]
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
- An auxiliary SPI device is available on the A+/B+/Pi2/Zero
- 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.
+ 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.
- spi_channel:= 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
+ spi_channel:= 0-1 (0-2 for the auxiliary SPI device).
baud:= 32K-125M (values above 30M are unlikely to work).
spi_flags:= see below.
px is 0 if CEx is active low (default) and 1 for active high.
- ux is 0 if the CEx gpio is reserved for SPI (default)
+ ux is 0 if the CEx GPIO is reserved for SPI (default)
and 1 otherwise.
A is 0 for the standard SPI device, 1 for the auxiliary SPI.
- The auxiliary device is only present on the A+/B+/Pi2/Zero.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire.
Standard SPI device only.
bbbbbb defines the word size in bits (0-32). The default (0)
sets 8 bits per word. Auxiliary SPI device only.
+ The [*spi_read*], [*spi_write*], and [*spi_xfer*] functions
+ transfer data packed into 1, 2, or 4 bytes according to
+ the word size in bits.
+
+ For bits 1-8 there will be one byte per character.
+ For bits 9-16 there will be two bytes per character.
+ For bits 17-32 there will be four bytes per character.
+
+ E.g. 32 12-bit words will be transferred in 64 bytes.
+
The other bits in flags should be set to zero.
...
def gpio_trigger(self, user_gpio, pulse_len=10, level=1):
"""
- Send a trigger pulse to a gpio. The gpio is set to
+ Send a trigger pulse to a GPIO. The GPIO is set to
level for pulse_len microseconds and then reset to not level.
user_gpio:= 0-31
def set_glitch_filter(self, user_gpio, steady):
"""
- Sets a glitch filter on a gpio.
+ Sets a glitch filter on a GPIO.
- Level changes on the gpio are not reported unless the level
+ Level changes on the GPIO are not reported unless the level
has been stable for at least [*steady*] microseconds. The
level is then reported. Level changes of less than [*steady*]
microseconds are ignored.
def set_noise_filter(self, user_gpio, steady, active):
"""
- Sets a noise filter on a gpio.
+ Sets a noise filter on a GPIO.
- Level changes on the gpio are ignored until a level which has
+ Level changes on the GPIO are ignored until a level which has
been stable for [*steady*] microseconds is detected. Level
- changes on the gpio are then reported for [*active*]
+ changes on the GPIO are then reported for [*active*]
microseconds after which the process repeats.
user_gpio:= 0-31
def bb_serial_read_open(self, user_gpio, baud, bb_bits=8):
"""
- Opens a gpio for bit bang reading of serial data.
+ Opens a GPIO for bit bang reading of serial data.
- user_gpio:= 0-31, the gpio to use.
+ user_gpio:= 0-31, the GPIO to use.
baud:= 50-250000, the baud rate.
bb_bits:= 1-32, the number of bits per word, default 8.
def bb_serial_read_close(self, user_gpio):
"""
- Closes a gpio for bit bang reading of serial data.
+ Closes a GPIO for bit bang reading of serial data.
user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*])
def callback(self, user_gpio, edge=RISING_EDGE, func=None):
"""
Calls a user supplied function (a callback) whenever the
- specified gpio edge is detected.
+ specified GPIO edge is detected.
user_gpio:= 0-31.
edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE.
func:= user supplied callback function.
- The user supplied callback receives three parameters, the gpio,
+ The user supplied callback receives three parameters, the GPIO,
the level, and the tick.
If a user callback is not specified a default tally callback is
The callback may be cancelled by calling the cancel function.
- A gpio may have multiple callbacks (although I can't think of
+ A GPIO may have multiple callbacks (although I can't think of
a reason to do so).
...
def wait_for_edge(self, user_gpio, edge=RISING_EDGE, wait_timeout=60.0):
"""
- Wait for an edge event on a gpio.
+ Wait for an edge event on a GPIO.
user_gpio:= 0-31.
edge:= EITHER_EDGE, RISING_EDGE (default), or
host = os.getenv("PIGPIO_ADDR", ''),
port = os.getenv("PIGPIO_PORT", 8888)):
"""
- Grants access to a Pi's gpios.
+ Grants access to a Pi's GPIO.
host:= the host name of the Pi on which the pigpio daemon is
running. The default is localhost unless overridden by
A value of 0 or 1.
bits: 32 bit number
- A mask used to select gpios to be operated on. If bit n is set
- then gpio n is selected. A convenient way of setting bit n is to
+ A mask used to select GPIO to be operated on. If bit n is set
+ then GPIO n is selected. A convenient way of setting bit n is to
bit or in the value (1<<n).
- To select gpios 1, 7, 23
+ To select GPIO 1, 7, 23
bits = (1<<1) | (1<<7) | (1<<23)
. .
frequency: 0-40000
- Defines the frequency to be used for PWM on a gpio.
+ Defines the frequency to be used for PWM on a GPIO.
The closest permitted frequency will be used.
func:
A user supplied callback function.
gpio: 0-53
- A Broadcom numbered gpio. All the user gpios are in the range 0-31.
+ A Broadcom numbered GPIO. All the user GPIO are in the range 0-31.
- There are 54 General Purpose Input Outputs (gpios) named gpio0
+ There are 54 General Purpose Input Outputs (GPIO) named gpio0
through gpio53.
They are split into two banks. Bank 1 consists of gpio0
through gpio31. Bank 2 consists of gpio32 through gpio53.
- All the gpios which are safe for the user to read and write are in
- bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
- have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+ All the GPIO which are safe for the user to read and write are in
+ bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+ have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
See [*get_hardware_revision*].
- The user gpios are marked with an X in the following table.
+ The user GPIO are marked with an X in the following table.
. .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
. .
gpio_off:
- A mask used to select gpios to be operated on. See [*bits*].
+ A mask used to select GPIO to be operated on. See [*bits*].
- This mask selects the gpios to be switched off at the start
+ This mask selects the GPIO to be switched off at the start
of a pulse.
gpio_on:
- A mask used to select gpios to be operated on. See [*bits*].
+ A mask used to select GPIO to be operated on. See [*bits*].
- This mask selects the gpios to be switched on at the start
+ This mask selects the GPIO to be switched on at the start
of a pulse.
handle: 0-
mode:
- 1.The operational mode of a gpio, normally INPUT or OUTPUT.
+ 1.The operational mode of a GPIO, normally INPUT or OUTPUT.
ALT0 = 4
ALT1 = 5
should return, default 8192.
SCL:
- The user gpio to use for the clock when bit banging I2C.
+ The user GPIO to use for the clock when bit banging I2C.
script:
The text of a script to store on the pigpio daemon.
A number referencing a script created by [*store_script*].
SDA:
- The user gpio to use for data when bit banging I2C.
+ The user GPIO to use for data when bit banging I2C.
ser_flags: 32 bit
No serial flags are currently defined.
An unsigned 32 bit number.
user_gpio: 0-31
- A Broadcom numbered gpio.
+ A Broadcom numbered GPIO.
- All the user gpios are in the range 0-31.
+ All the user GPIO are in the range 0-31.
- Not all the gpios within this range are usable, some are reserved
+ Not all the GPIO within this range are usable, some are reserved
for system use.
See [*gpio*].
One of [*wave_send_once*], [*wave_send_repeat*].
wdog_timeout: 0-60000
- Defines a gpio watchdog timeout in milliseconds. If no level
- change is detected on the gpio for timeout millisecond a watchdog
+ Defines a GPIO watchdog timeout in milliseconds. If no level
+ change is detected on the GPIO for timeout millisecond a watchdog
timeout report is issued (with level TIMEOUT).
word_val: 0-65535
default AUTO
.IP "\fB-b value\fP"
-gpio sample buffer in milliseconds
+GPIO sample buffer in milliseconds
100-10000
default 120
.IP "\fB-x mask\fP"
-gpios which may be updated
-A 54 bit mask with (1<<n) set if the user may update gpio #n.
-default is the set of user gpios for the board revision
+GPIO which may be updated
+A 54 bit mask with (1<<n) set if the user may update GPIO #n.
+default is the set of user GPIO for the board revision
.br
.br
.br
-All gpios may be read.
+All GPIO may be read.
.br
.br
-Only the user gpios for the board type or those specified by the -x option may be updated.
+Only the user GPIO for the board type or those specified by the -x option may be updated.
.br
.br
.br
-gpio mode set
+GPIO mode set
.br
-gpio pull/up down
+GPIO pull/up down
.br
-gpio write
+GPIO write
.br
-gpio set PWM (including range and frequency)
+GPIO set PWM (including range and frequency)
.br
-gpio set servo
+GPIO set servo
.br
.br
In addition the bank clear and set commands, and the wave commands will only
-affect updateable gpios.
+affect updateable GPIO.
.br
.br
.br
-The activity LED (green) may be written (gpio 16 for type 1 and 2
-boards, gpio 47 for type 3 boards)
+The activity LED (green) may be written (GPIO 16 for type 1 and 2
+boards, GPIO 47 for type 3 boards)
.br
.br
-The power LED (red) may be written on type 3 boards (gpio 35).
+The power LED (red) may be written on type 3 boards (GPIO 35).
.br
.br
-The high USB power mode gpio may be written (gpio 38 for type 3 boards).
+The high USB power mode GPIO may be written (GPIO 38 for type 3 boards).
.SH SEE ALSO
.br
pigpiod_if is a C library for the Raspberry which allows control
-of the gpios via the socket interface to the pigpio daemon.
+of the GPIO via the socket interface to the pigpio daemon.
.br
.br
.br
.br
-o PWM on any of gpios 0-31
+o PWM on any of GPIO 0-31
.br
.br
-o servo pulses on any of gpios 0-31
+o servo pulses on any of GPIO 0-31
.br
.br
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
.br
.br
.br
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
.br
.br
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
.br
.br
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
.br
.br
.br
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
.br
.br
.br
-.SS gpios
+.SS GPIO
.br
.br
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
.br
.IP "\fBint set_mode(unsigned gpio, unsigned mode)\fP"
.IP "" 4
-Set the gpio mode.
+Set the GPIO mode.
.br
.IP "\fBint get_mode(unsigned gpio)\fP"
.IP "" 4
-Get the gpio mode.
+Get the GPIO mode.
.br
.br
.br
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
.IP "\fBint set_pull_up_down(unsigned gpio, unsigned pud)\fP"
.IP "" 4
-Set or clear the gpio pull-up/down resistor.
+Set or clear the GPIO pull-up/down resistor.
.br
.IP "\fBint gpio_read(unsigned gpio)\fP"
.IP "" 4
-Read the gpio level.
+Read the GPIO level.
.br
.br
.br
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
.IP "\fBint gpio_write(unsigned gpio, unsigned level)\fP"
.IP "" 4
-Write the gpio level.
+Write the GPIO level.
.br
.br
.br
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
.IP "\fBint set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle)\fP"
.IP "" 4
-Start (non-zero dutycycle) or stop (0) PWM pulses on the gpio.
+Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
.br
.IP "\fBint get_PWM_dutycycle(unsigned user_gpio)\fP"
.IP "" 4
-Return the PWM dutycycle in use on a gpio.
+Return the PWM dutycycle in use on a GPIO.
.br
.br
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see \fBget_PWM_range\fP).
+for the GPIO (see \fBget_PWM_range\fP).
.br
.br
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
.IP "\fBint set_PWM_range(unsigned user_gpio, unsigned range)\fP"
.IP "" 4
-Set the range of PWM values to be used on the gpio.
+Set the range of PWM values to be used on the GPIO.
.br
.br
.br
-If PWM is currently active on the gpio its dutycycle will be
+If PWM is currently active on the GPIO its dutycycle will be
scaled to reflect the new range.
.br
.br
The real range, the number of steps between fully off and fully on
-for each of the 18 available gpio frequencies is
+for each of the 18 available GPIO frequencies is
.br
.IP "\fBint get_PWM_range(unsigned user_gpio)\fP"
.IP "" 4
-Get the range of PWM values being used on the gpio.
+Get the range of PWM values being used on the GPIO.
.br
.br
.br
-Returns the dutycycle range used for the gpio if OK,
+Returns the dutycycle range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.br
.br
-If a hardware clock or hardware PWM is active on the gpio the
+If a hardware clock or hardware PWM is active on the GPIO the
reported range will be 1000000 (1M).
.IP "\fBint get_PWM_real_range(unsigned user_gpio)\fP"
.IP "" 4
-Get the real underlying range of PWM values being used on the gpio.
+Get the real underlying range of PWM values being used on the GPIO.
.br
.br
.br
-Returns the real range used for the gpio if OK,
+Returns the real range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.br
.br
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
.br
.IP "\fBint set_PWM_frequency(unsigned user_gpio, unsigned frequency)\fP"
.IP "" 4
-Set the frequency (in Hz) of the PWM to be used on the gpio.
+Set the frequency (in Hz) of the PWM to be used on the GPIO.
.br
.br
.br
-Each gpio can be independently set to one of 18 different
+Each GPIO can be independently set to one of 18 different
PWM frequencies.
.br
.br
-If PWM is currently active on the gpio it will be switched
+If PWM is currently active on the GPIO it will be switched
off and then back on at the new frequency.
.br
.IP "\fBint get_PWM_frequency(unsigned user_gpio)\fP"
.IP "" 4
-Get the frequency of PWM being used on the gpio.
+Get the frequency of PWM being used on the GPIO.
.br
.br
.br
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
\fBset_PWM_frequency\fP.
.br
.br
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by \fBhardware_clock\fP.
.br
.br
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by \fBhardware_PWM\fP.
.br
.br
-Returns the frequency (in hertz) used for the gpio if OK,
+Returns the frequency (in hertz) used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.IP "\fBint set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth)\fP"
.IP "" 4
-Start (500-2500) or stop (0) servo pulses on the gpio.
+Start (500-2500) or stop (0) servo pulses on the GPIO.
.br
.br
.br
-E.g. If you want to update a servo connected to gpio 25 at 400Hz
+E.g. If you want to update a servo connected to GPIO 25 at 400Hz
.br
.IP "\fBint get_servo_pulsewidth(unsigned user_gpio)\fP"
.IP "" 4
-Return the servo pulsewidth in use on a gpio.
+Return the servo pulsewidth in use on a GPIO.
.br
.br
.br
-A notification is a method for being notified of gpio state
+A notification is a method for being notified of GPIO state
changes via a pipe.
.br
.EX
handle: 0-31 (as returned by \fBnotify_open\fP)
.br
- bits: a mask indicating the gpios to be notified.
+ bits: a mask indicating the GPIO to be notified.
.br
.EE
.br
.br
-The notification sends state changes for each gpio whose
+The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
.br
.IP "\fBint set_watchdog(unsigned user_gpio, unsigned timeout)\fP"
.IP "" 4
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
.br
.br
.br
-Only one watchdog may be registered per gpio.
+Only one watchdog may be registered per GPIO.
.br
.br
.br
-If no level change has been detected for the gpio for timeout
-milliseconds any notification for the gpio has a report written
+If no level change has been detected for the GPIO for timeout
+milliseconds any notification for the GPIO has a report written
to the fifo with the flags set to indicate a watchdog timeout.
.br
.br
The \fBcallback\fP and \fBcallback_ex\fP functions interpret the flags
-and will call registered callbacks for the gpio with level TIMEOUT.
+and will call registered callbacks for the GPIO with level TIMEOUT.
.IP "\fBint set_glitch_filter(unsigned user_gpio, unsigned steady)\fP"
.IP "" 4
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
.br
.br
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least \fBsteady\fP microseconds. The
level is then reported. Level changes of less than \fBsteady\fP
microseconds are ignored.
.IP "\fBint set_noise_filter(unsigned user_gpio, unsigned steady, unsigned active)\fP"
.IP "" 4
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
.br
.br
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for \fBsteady\fP microseconds is detected. Level changes
-on the gpio are then reported for \fBactive\fP microseconds after
+on the GPIO are then reported for \fBactive\fP microseconds after
which the process repeats.
.br
.IP "\fBuint32_t read_bank_1(void)\fP"
.IP "" 4
-Read the levels of the bank 1 gpios (gpios 0-31).
+Read the levels of the bank 1 GPIO (GPIO 0-31).
.br
.br
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<n).
+GPIO is logic 1. GPIO n has bit value (1<<n).
.IP "\fBuint32_t read_bank_2(void)\fP"
.IP "" 4
-Read the levels of the bank 2 gpios (gpios 32-53).
+Read the levels of the bank 2 GPIO (GPIO 32-53).
.br
.br
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<(n-32)).
+GPIO is logic 1. GPIO n has bit value (1<<(n-32)).
.IP "\fBint clear_bank_1(uint32_t bits)\fP"
.IP "" 4
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
.br
.br
.EX
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be cleared.
.br
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint clear_bank_2(uint32_t bits)\fP"
.IP "" 4
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.br
.EX
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be cleared.
.br
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint set_bank_1(uint32_t bits)\fP"
.IP "" 4
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
.br
.br
.EX
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be set.
.br
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint set_bank_2(uint32_t bits)\fP"
.IP "" 4
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.br
.EX
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be set.
.br
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint hardware_clock(unsigned gpio, unsigned clkfreq)\fP"
.IP "" 4
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
.br
.br
.br
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.EX
4 clock 0 All models
.br
-5 clock 1 A+/B+/Pi2 and compute module only (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
.br
-6 clock 2 A+/B+/Pi2 and compute module only
+6 clock 2 All models but A and B
.br
-20 clock 0 A+/B+/Pi2 and compute module only
+20 clock 0 All models but A and B
.br
-21 clock 1 All models but Rev.2 B (reserved for system use)
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
.br
.br
.br
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
.IP "\fBint hardware_PWM(unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)\fP"
.IP "" 4
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
.br
.br
.br
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.br
.EX
-12 PWM channel 0 A+/B+/Pi2 and compute module only
+12 PWM channel 0 All models but A and B
.br
-13 PWM channel 1 A+/B+/Pi2 and compute module only
+13 PWM channel 1 All models but A and B
.br
18 PWM channel 0 All models
.br
-19 PWM channel 1 A+/B+/Pi2 and compute module only
+19 PWM channel 1 All models but A and B
.br
.br
.br
.br
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see \fBgpio\fP).
.br
.br
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
.br
.br
.br
-1) the gpios to be switched on at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
.br
-2) the gpios to be switched off at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
.br
3) the delay in microseconds before the next pulse.
.br
.IP "\fBint gpio_trigger(unsigned user_gpio, unsigned pulseLen, unsigned level)\fP"
.IP "" 4
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
.br
.IP "\fBint bb_serial_read_open(unsigned user_gpio, unsigned baud, unsigned data_bits)\fP"
.IP "" 4
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
.br
.IP "\fBint bb_serial_read_close(unsigned user_gpio)\fP"
.IP "" 4
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
.br
.IP "\fBint bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud)\fP"
.IP "" 4
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
.br
.br
o clock stretching
.br
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
.br
.br
.br
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
.IP "\fBint bb_i2c_close(unsigned SDA)\fP"
.IP "" 4
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with \fBbb_i2c_open\fP.
.br
.br
.EX
-SDA: 0-31, the SDA gpio used in a prior call to \fBbb_i2c_open\fP
+SDA: 0-31, the SDA GPIO used in a prior call to \fBbb_i2c_open\fP
.br
.EE
.br
.br
-An auxiliary SPI device is available on the A+/B+/Pi2 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.
+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.
.br
.br
.EX
-spi_channel: 0-1 (0-2 for A+/B+/Pi2 auxiliary device).
+spi_channel: 0-1 (0-2 for the auxiliary SPI device).
.br
baud: 32K-125M (values above 30M are unlikely to work).
.br
.br
.br
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
.br
.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
.br
.br
.br
-The callback is called with the gpio, edge, and tick, whenever the
-gpio has the identified edge.
+The callback is called with the GPIO, edge, and tick, whenever the
+GPIO has the identified edge.
.IP "\fBint callback_ex(unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
.IP "" 4
.br
.br
-The callback is called with the gpio, edge, tick, and user, whenever
-the gpio has the identified edge.
+The callback is called with the GPIO, edge, tick, and user, whenever
+the GPIO has the identified edge.
.br
.IP "\fBint wait_for_edge(unsigned user_gpio, unsigned edge, double timeout)\fP"
.IP "" 4
-This function waits for edge on the gpio for up to timeout
+This function waits for edge on the GPIO for up to timeout
seconds.
.br
.br
.IP "\fBbits\fP" 0
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
.br
.br
.IP "\fBedge\fP" 0
-Used to identify a gpio level transition of interest. A rising edge is
+Used to identify a GPIO level transition of interest. A rising edge is
a level change from 0 to 1. A falling edge is a level change from 1 to 0.
.br
.br
.IP "\fBfrequency\fP: 0-" 0
-The number of times a gpio is swiched on and off per second. This
-can be set per gpio and may be as little as 5Hz or as much as
-40KHz. The gpio will be on for a proportion of the time as defined
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
.br
.br
.IP "\fBgpio\fP" 0
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
.br
.br
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
gpio53.
.br
.br
.br
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
.br
.br
.br
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
.br
.br
.IP "\fBlevel\fP" 0
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
.br
.br
.br
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See \fBset_watchdog\fP.
.br
.br
.IP "\fBmode\fP: 0-7" 0
-The operational mode of a gpio, normally INPUT or OUTPUT.
+The operational mode of a GPIO, normally INPUT or OUTPUT.
.br
.br
.IP "\fBpud\fP: 0-2" 0
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
.EX
.br
.IP "\fBSCL\fP" 0
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
.br
.br
.IP "\fBSDA\fP" 0
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
.br
.br
.IP "\fBtimeout\fP" 0
-A gpio watchdog timeout in milliseconds.
+A GPIO watchdog timeout in milliseconds.
.EX
PI_MIN_WDOG_TIMEOUT 0
.br
.IP "\fBuser_gpio\fP" 0
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
.br
#include "pigpio.h"
-#define PIGPIOD_IF_VERSION 21
+#define PIGPIOD_IF_VERSION 22
/*TEXT
USE THE MORE VERSATILE pigpiod_if2 LIBRARY.
pigpiod_if is a C library for the Raspberry which allows control
-of the gpios via the socket interface to the pigpio daemon.
+of the GPIO via the socket interface to the pigpio daemon.
*Features*
-o PWM on any of gpios 0-31
+o PWM on any of GPIO 0-31
-o servo pulses on any of gpios 0-31
+o servo pulses on any of GPIO 0-31
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
o callbacks at timed intervals
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
o the construction of output waveforms with microsecond timing
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
o a simple interface to start and stop new threads
o creating and running scripts on the pigpio daemon
-*gpios*
+*GPIO*
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
*Notes*
BEGINNER
-set_mode Set a gpio mode
-get_mode Get a gpio mode
+set_mode Set a GPIO mode
+get_mode Get a GPIO mode
-set_pull_up_down Set/clear gpio pull up/down resistor
+set_pull_up_down Set/clear GPIO pull up/down resistor
-gpio_read Read a gpio
-gpio_write Write a gpio
+gpio_read Read a GPIO
+gpio_write Write a GPIO
-set_PWM_dutycycle Start/stop PWM pulses on a gpio
-get_PWM_dutycycle Get the PWM dutycycle in use on a gpio
+set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
-set_servo_pulsewidth Start/stop servo pulses on a gpio
-get_servo_pulsewidth Get the servo pulsewidth in use on a gpio
+set_servo_pulsewidth Start/stop servo pulses on a GPIO
+get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
-callback Create gpio level change callback
-callback_ex Create gpio level change callback
+callback Create GPIO level change callback
+callback_ex Create GPIO level change callback
callback_cancel Cancel a callback
-wait_for_edge Wait for gpio level change
+wait_for_edge Wait for GPIO level change
INTERMEDIATE
-gpio_trigger Send a trigger pulse to a gpio.
+gpio_trigger Send a trigger pulse to a GPIO.
-set_watchdog Set a watchdog on a gpio.
+set_watchdog Set a watchdog on a GPIO.
-set_PWM_range Configure PWM range for a gpio
-get_PWM_range Get configured PWM range for a gpio
+set_PWM_range Configure PWM range for a GPIO
+get_PWM_range Get configured PWM range for a GPIO
-set_PWM_frequency Configure PWM frequency for a gpio
-get_PWM_frequency Get configured PWM frequency for a gpio
+set_PWM_frequency Configure PWM frequency for a GPIO
+get_PWM_frequency Get configured PWM frequency for a GPIO
-read_bank_1 Read all gpios in bank 1
-read_bank_2 Read all gpios in bank 2
+read_bank_1 Read all GPIO in bank 1
+read_bank_2 Read all GPIO in bank 2
-clear_bank_1 Clear selected gpios in bank 1
-clear_bank_2 Clear selected gpios in bank 2
+clear_bank_1 Clear selected GPIO in bank 1
+clear_bank_2 Clear selected GPIO in bank 2
-set_bank_1 Set selected gpios in bank 1
-set_bank_2 Set selected gpios in bank 2
+set_bank_1 Set selected GPIO in bank 1
+set_bank_2 Set selected GPIO in bank 2
start_thread Start a new thread
stop_thread Stop a previously started thread
ADVANCED
-get_PWM_real_range Get underlying PWM range for a gpio
+get_PWM_real_range Get underlying PWM range for a GPIO
notify_open Request a notification handle
-notify_begin Start notifications for selected gpios
+notify_begin Start notifications for selected GPIO
notify_pause Pause notifications
notify_close Close a notification
-bb_serial_read_open Opens a gpio for bit bang serial reads
-bb_serial_read Reads bit bang serial data from a gpio
-bb_serial_read_close Closes a gpio for bit bang serial reads
+bb_serial_read_open Opens a GPIO for bit bang serial reads
+bb_serial_read Reads bit bang serial data from a GPIO
+bb_serial_read_close Closes a GPIO for bit bang serial reads
bb_serial_invert Invert serial logic (1 invert, 0 normal)
-hardware_clock Start hardware clock on supported gpios
-hardware_PWM Start hardware PWM on supported gpios
+hardware_clock Start hardware clock on supported GPIO
+hardware_PWM Start hardware PWM on supported GPIO
-set_glitch_filter Set a glitch filter on a gpio
-set_noise_filter Set a noise filter on a gpio
+set_glitch_filter Set a glitch filter on a GPIO
+set_noise_filter Set a noise filter on a GPIO
SCRIPTS
i2c_zip Performs multiple I2C transactions
-bb_i2c_open Opens gpios for bit banging I2C
-bb_i2c_close Closes gpios for bit banging I2C
+bb_i2c_open Opens GPIO for bit banging I2C
+bb_i2c_close Closes GPIO for bit banging I2C
bb_i2c_zip Performs multiple bit banged I2C transactions
SPI
/*F*/
int set_mode(unsigned gpio, unsigned mode);
/*D
-Set the gpio mode.
+Set the GPIO mode.
. .
gpio: 0-53.
/*F*/
int get_mode(unsigned gpio);
/*D
-Get the gpio mode.
+Get the GPIO mode.
. .
gpio: 0-53.
. .
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
D*/
/*F*/
int set_pull_up_down(unsigned gpio, unsigned pud);
/*D
-Set or clear the gpio pull-up/down resistor.
+Set or clear the GPIO pull-up/down resistor.
. .
gpio: 0-53.
/*F*/
int gpio_read(unsigned gpio);
/*D
-Read the gpio level.
+Read the GPIO level.
. .
gpio:0-53.
. .
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
D*/
/*F*/
int gpio_write(unsigned gpio, unsigned level);
/*D
-Write the gpio level.
+Write the GPIO level.
. .
gpio: 0-53.
Notes
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
D*/
/*F*/
int set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle);
/*D
-Start (non-zero dutycycle) or stop (0) PWM pulses on the gpio.
+Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
. .
user_gpio: 0-31.
/*F*/
int get_PWM_dutycycle(unsigned user_gpio);
/*D
-Return the PWM dutycycle in use on a gpio.
+Return the PWM dutycycle in use on a GPIO.
. .
user_gpio: 0-31.
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see [*get_PWM_range*]).
+for the GPIO (see [*get_PWM_range*]).
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
D*/
/*F*/
int set_PWM_range(unsigned user_gpio, unsigned range);
/*D
-Set the range of PWM values to be used on the gpio.
+Set the range of PWM values to be used on the GPIO.
. .
user_gpio: 0-31.
Notes
-If PWM is currently active on the gpio its dutycycle will be
+If PWM is currently active on the GPIO its dutycycle will be
scaled to reflect the new range.
The real range, the number of steps between fully off and fully on
-for each of the 18 available gpio frequencies is
+for each of the 18 available GPIO frequencies is
. .
25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6),
/*F*/
int get_PWM_range(unsigned user_gpio);
/*D
-Get the range of PWM values being used on the gpio.
+Get the range of PWM values being used on the GPIO.
. .
user_gpio: 0-31.
. .
-Returns the dutycycle range used for the gpio if OK,
+Returns the dutycycle range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
-If a hardware clock or hardware PWM is active on the gpio the
+If a hardware clock or hardware PWM is active on the GPIO the
reported range will be 1000000 (1M).
D*/
/*F*/
int get_PWM_real_range(unsigned user_gpio);
/*D
-Get the real underlying range of PWM values being used on the gpio.
+Get the real underlying range of PWM values being used on the GPIO.
. .
user_gpio: 0-31.
. .
-Returns the real range used for the gpio if OK,
+Returns the real range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
D*/
/*F*/
int set_PWM_frequency(unsigned user_gpio, unsigned frequency);
/*D
-Set the frequency (in Hz) of the PWM to be used on the gpio.
+Set the frequency (in Hz) of the PWM to be used on the GPIO.
. .
user_gpio: 0-31.
may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
sample rate is set when the C pigpio library is started.
-Each gpio can be independently set to one of 18 different
+Each GPIO can be independently set to one of 18 different
PWM frequencies.
-If PWM is currently active on the gpio it will be switched
+If PWM is currently active on the GPIO it will be switched
off and then back on at the new frequency.
. .
/*F*/
int get_PWM_frequency(unsigned user_gpio);
/*D
-Get the frequency of PWM being used on the gpio.
+Get the frequency of PWM being used on the GPIO.
. .
user_gpio: 0-31.
. .
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
[*set_PWM_frequency*].
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by [*hardware_clock*].
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by [*hardware_PWM*].
-Returns the frequency (in hertz) used for the gpio if OK,
+Returns the frequency (in hertz) used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
D*/
/*F*/
int set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth);
/*D
-Start (500-2500) or stop (0) servo pulses on the gpio.
+Start (500-2500) or stop (0) servo pulses on the GPIO.
. .
user_gpio: 0-31.
Doing this allows you to use units of microseconds when setting
the servo pulsewidth.
-E.g. If you want to update a servo connected to gpio 25 at 400Hz
+E.g. If you want to update a servo connected to GPIO 25 at 400Hz
. .
set_PWM_frequency(25, 400);
/*F*/
int get_servo_pulsewidth(unsigned user_gpio);
/*D
-Return the servo pulsewidth in use on a gpio.
+Return the servo pulsewidth in use on a GPIO.
. .
user_gpio: 0-31.
Returns a handle greater than or equal to zero if OK,
otherwise PI_NO_HANDLE.
-A notification is a method for being notified of gpio state
+A notification is a method for being notified of GPIO state
changes via a pipe.
Pipes are only accessible from the local machine so this function
. .
handle: 0-31 (as returned by [*notify_open*])
- bits: a mask indicating the gpios to be notified.
+ bits: a mask indicating the GPIO to be notified.
. .
Returns 0 if OK, otherwise PI_BAD_HANDLE.
-The notification sends state changes for each gpio whose
+The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
Notes
/*F*/
int set_watchdog(unsigned user_gpio, unsigned timeout);
/*D
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
. .
user_gpio: 0-31.
The watchdog is nominally in milliseconds.
-Only one watchdog may be registered per gpio.
+Only one watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
-If no level change has been detected for the gpio for timeout
-milliseconds any notification for the gpio has a report written
+If no level change has been detected for the GPIO for timeout
+milliseconds any notification for the GPIO has a report written
to the fifo with the flags set to indicate a watchdog timeout.
The [*callback*] and [*callback_ex*] functions interpret the flags
-and will call registered callbacks for the gpio with level TIMEOUT.
+and will call registered callbacks for the GPIO with level TIMEOUT.
D*/
/*F*/
int set_glitch_filter(unsigned user_gpio, unsigned steady);
/*D
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least [*steady*] microseconds. The
level is then reported. Level changes of less than [*steady*]
microseconds are ignored.
/*F*/
int set_noise_filter(unsigned user_gpio, unsigned steady, unsigned active);
/*D
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for [*steady*] microseconds is detected. Level changes
-on the gpio are then reported for [*active*] microseconds after
+on the GPIO are then reported for [*active*] microseconds after
which the process repeats.
. .
/*F*/
uint32_t read_bank_1(void);
/*D
-Read the levels of the bank 1 gpios (gpios 0-31).
+Read the levels of the bank 1 GPIO (GPIO 0-31).
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<n).
+GPIO is logic 1. GPIO n has bit value (1<<n).
D*/
/*F*/
uint32_t read_bank_2(void);
/*D
-Read the levels of the bank 2 gpios (gpios 32-53).
+Read the levels of the bank 2 GPIO (GPIO 32-53).
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<(n-32)).
+GPIO is logic 1. GPIO n has bit value (1<<(n-32)).
D*/
/*F*/
int clear_bank_1(uint32_t bits);
/*D
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
. .
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
to be cleared.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int clear_bank_2(uint32_t bits);
/*D
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
to be cleared.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int set_bank_1(uint32_t bits);
/*D
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
. .
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
to be set.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int set_bank_2(uint32_t bits);
/*D
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
to be set.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int hardware_clock(unsigned gpio, unsigned clkfreq);
/*D
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
. .
Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
4 clock 0 All models
-5 clock 1 A+/B+/Pi2 and compute module only (reserved for system use)
-6 clock 2 A+/B+/Pi2 and compute module only
-20 clock 0 A+/B+/Pi2 and compute module only
-21 clock 1 All models but Rev.2 B (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
+6 clock 2 All models but A and B
+20 clock 0 All models but A and B
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
32 clock 0 Compute module only
34 clock 0 Compute module only
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
D*/
/*F*/
int hardware_PWM(unsigned gpio, unsigned PWMfreq, uint32_t PWMduty);
/*D
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
NOTE: Any waveform started by [*wave_send_once*], [*wave_send_repeat*],
PI_NOT_HPWM_GPIO, PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ,
or PI_HPWM_ILLEGAL.
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
-12 PWM channel 0 A+/B+/Pi2 and compute module only
-13 PWM channel 1 A+/B+/Pi2 and compute module only
+12 PWM channel 0 All models but A and B
+13 PWM channel 1 All models but A and B
18 PWM channel 0 All models
-19 PWM channel 1 A+/B+/Pi2 and compute module only
+19 PWM channel 1 All models but A and B
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
If the hardware revision can not be found or is not a valid
hexadecimal number the function returns 0.
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see [*gpio*]).
There are at least three types of board.
(if any).
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
If the added waveform is intended to start after or within the existing
waveform then the first pulse should consist solely of a delay.
The fields specify
-1) the gpios to be switched on at the start of the pulse.
-2) the gpios to be switched off at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
3) the delay in microseconds before the next pulse.
Any or all the fields can be zero. It doesn't make any sense to
/*F*/
int gpio_trigger(unsigned user_gpio, unsigned pulseLen, unsigned level);
/*D
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
. .
/*F*/
int bb_serial_read_open(unsigned user_gpio, unsigned baud, unsigned data_bits);
/*D
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
. .
user_gpio: 0-31.
/*F*/
int bb_serial_read_close(unsigned user_gpio);
/*D
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
. .
user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
/*F*/
int bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud);
/*D
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
Bit banging I2C allows for certain operations which are not possible
o baud rates as low as 50
o repeated starts
o clock stretching
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
. .
SDA: 0-31
NOTE:
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
D*/
/*F*/
int bb_i2c_close(unsigned SDA);
/*D
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with [*bb_i2c_open*].
. .
-SDA: 0-31, the SDA gpio used in a prior call to [*bb_i2c_open*]
+SDA: 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*]
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
be used to modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
-An auxiliary SPI device is available on the A+/B+/Pi2 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.
+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.
. .
-spi_channel: 0-1 (0-2 for A+/B+/Pi2 auxiliary device).
+spi_channel: 0-1 (0-2 for the auxiliary SPI device).
baud: 32K-125M (values above 30M are unlikely to work).
spi_flags: see below.
. .
px is 0 if CEx is active low (default) and 1 for active high.
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
SPI device only.
The function returns a callback id if OK, otherwise pigif_bad_malloc,
pigif_duplicate_callback, or pigif_bad_callback.
-The callback is called with the gpio, edge, and tick, whenever the
-gpio has the identified edge.
+The callback is called with the GPIO, edge, and tick, whenever the
+GPIO has the identified edge.
D*/
/*F*/
The function returns a callback id if OK, otherwise pigif_bad_malloc,
pigif_duplicate_callback, or pigif_bad_callback.
-The callback is called with the gpio, edge, tick, and user, whenever
-the gpio has the identified edge.
+The callback is called with the GPIO, edge, tick, and user, whenever
+the GPIO has the identified edge.
D*/
/*F*/
int wait_for_edge(unsigned user_gpio, unsigned edge, double timeout);
/*D
-This function waits for edge on the gpio for up to timeout
+This function waits for edge on the GPIO for up to timeout
seconds.
. .
A value of 0 or 1.
bits::
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
A convenient way to set bit n is to or in (1<<n).
0 is off and range is fully on.
edge::
-Used to identify a gpio level transition of interest. A rising edge is
+Used to identify a GPIO level transition of interest. A rising edge is
a level change from 0 to 1. A falling edge is a level change from 1 to 0.
. .
A function.
frequency::0-
-The number of times a gpio is swiched on and off per second. This
-can be set per gpio and may be as little as 5Hz or as much as
-40KHz. The gpio will be on for a proportion of the time as defined
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
gpio::
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
gpio53.
They are split into two banks. Bank 1 consists of gpio0 through
gpio31. Bank 2 consists of gpio32 through gpio53.
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
See [*get_hardware_revision*].
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
. .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
A flag used to set normal or inverted bit bang serial data level logic.
level::
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
. .
PI_OFF 0
PI_HIGH 1
. .
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See [*set_watchdog*].
. .
. .
mode::0-7
-The operational mode of a gpio, normally INPUT or OUTPUT.
+The operational mode of a GPIO, normally INPUT or OUTPUT.
. .
PI_INPUT 0
A thread identifier.
pud::0-2
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
. .
PI_PUD_OFF 0
A pointer to a buffer to receive data.
SCL::
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
*script::
A pointer to the text of a script.
An id of a stored script as returned by [*store_script*].
SDA::
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
seconds::
The number of seconds.
thread.
timeout::
-A gpio watchdog timeout in milliseconds.
+A GPIO watchdog timeout in milliseconds.
. .
PI_MIN_WDOG_TIMEOUT 0
PI_MAX_WDOG_TIMEOUT 60000
A whole number >= 0.
user_gpio::
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
See [*gpio*].
.br
pigpiod_if2 is a C library for the Raspberry which allows control
-of the gpios via the socket interface to the pigpio daemon.
+of the GPIO via the socket interface to the pigpio daemon.
.br
.br
.br
.br
-o PWM on any of gpios 0-31
+o PWM on any of GPIO 0-31
.br
.br
-o servo pulses on any of gpios 0-31
+o servo pulses on any of GPIO 0-31
.br
.br
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
.br
.br
.br
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
.br
.br
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
.br
.br
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
.br
.br
.br
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
.br
.br
.br
-.SS gpios
+.SS GPIO
.br
.br
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
.br
.IP "\fBint set_mode(int pi, unsigned gpio, unsigned mode)\fP"
.IP "" 4
-Set the gpio mode.
+Set the GPIO mode.
.br
.IP "\fBint get_mode(int pi, unsigned gpio)\fP"
.IP "" 4
-Get the gpio mode.
+Get the GPIO mode.
.br
.br
.br
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
.IP "\fBint set_pull_up_down(int pi, unsigned gpio, unsigned pud)\fP"
.IP "" 4
-Set or clear the gpio pull-up/down resistor.
+Set or clear the GPIO pull-up/down resistor.
.br
.IP "\fBint gpio_read(int pi, unsigned gpio)\fP"
.IP "" 4
-Read the gpio level.
+Read the GPIO level.
.br
.br
.br
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
.IP "\fBint gpio_write(int pi, unsigned gpio, unsigned level)\fP"
.IP "" 4
-Write the gpio level.
+Write the GPIO level.
.br
.br
.br
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
.IP "\fBint set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle)\fP"
.IP "" 4
-Start (non-zero dutycycle) or stop (0) PWM pulses on the gpio.
+Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
.br
.IP "\fBint get_PWM_dutycycle(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Return the PWM dutycycle in use on a gpio.
+Return the PWM dutycycle in use on a GPIO.
.br
.br
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see \fBget_PWM_range\fP).
+for the GPIO (see \fBget_PWM_range\fP).
.br
.br
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
.IP "\fBint set_PWM_range(int pi, unsigned user_gpio, unsigned range)\fP"
.IP "" 4
-Set the range of PWM values to be used on the gpio.
+Set the range of PWM values to be used on the GPIO.
.br
.br
.br
-If PWM is currently active on the gpio its dutycycle will be
+If PWM is currently active on the GPIO its dutycycle will be
scaled to reflect the new range.
.br
.br
The real range, the number of steps between fully off and fully on
-for each of the 18 available gpio frequencies is
+for each of the 18 available GPIO frequencies is
.br
.IP "\fBint get_PWM_range(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Get the range of PWM values being used on the gpio.
+Get the range of PWM values being used on the GPIO.
.br
.br
.br
-Returns the dutycycle range used for the gpio if OK,
+Returns the dutycycle range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.br
.br
-If a hardware clock or hardware PWM is active on the gpio the
+If a hardware clock or hardware PWM is active on the GPIO the
reported range will be 1000000 (1M).
.IP "\fBint get_PWM_real_range(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Get the real underlying range of PWM values being used on the gpio.
+Get the real underlying range of PWM values being used on the GPIO.
.br
.br
.br
-Returns the real range used for the gpio if OK,
+Returns the real range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.br
.br
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
.br
.br
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
.br
.IP "\fBint set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency)\fP"
.IP "" 4
-Set the frequency (in Hz) of the PWM to be used on the gpio.
+Set the frequency (in Hz) of the PWM to be used on the GPIO.
.br
.br
.br
-Each gpio can be independently set to one of 18 different
+Each GPIO can be independently set to one of 18 different
PWM frequencies.
.br
.br
-If PWM is currently active on the gpio it will be switched
+If PWM is currently active on the GPIO it will be switched
off and then back on at the new frequency.
.br
.IP "\fBint get_PWM_frequency(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Get the frequency of PWM being used on the gpio.
+Get the frequency of PWM being used on the GPIO.
.br
.br
.br
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
\fBset_PWM_frequency\fP.
.br
.br
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by \fBhardware_clock\fP.
.br
.br
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by \fBhardware_PWM\fP.
.br
.br
-Returns the frequency (in hertz) used for the gpio if OK,
+Returns the frequency (in hertz) used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
.IP "\fBint set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth)\fP"
.IP "" 4
-Start (500-2500) or stop (0) servo pulses on the gpio.
+Start (500-2500) or stop (0) servo pulses on the GPIO.
.br
.br
.br
-E.g. If you want to update a servo connected to gpio 25 at 400Hz
+E.g. If you want to update a servo connected to GPIO 25 at 400Hz
.br
.IP "\fBint get_servo_pulsewidth(int pi, unsigned user_gpio)\fP"
.IP "" 4
-Return the servo pulsewidth in use on a gpio.
+Return the servo pulsewidth in use on a GPIO.
.br
.br
.br
-A notification is a method for being notified of gpio state
+A notification is a method for being notified of GPIO state
changes via a pipe.
.br
.br
handle: 0-31 (as returned by \fBnotify_open\fP)
.br
- bits: a mask indicating the gpios to be notified.
+ bits: a mask indicating the GPIO to be notified.
.br
.EE
.br
.br
-The notification sends state changes for each gpio whose
+The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
.br
.IP "\fBint set_watchdog(int pi, unsigned user_gpio, unsigned timeout)\fP"
.IP "" 4
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
.br
.br
.br
-Only one watchdog may be registered per gpio.
+Only one watchdog may be registered per GPIO.
.br
.br
.br
-If no level change has been detected for the gpio for timeout
-milliseconds any notification for the gpio has a report written
+If no level change has been detected for the GPIO for timeout
+milliseconds any notification for the GPIO has a report written
to the fifo with the flags set to indicate a watchdog timeout.
.br
.br
The \fBcallback\fP and \fBcallback_ex\fP functions interpret the flags
-and will call registered callbacks for the gpio with level TIMEOUT.
+and will call registered callbacks for the GPIO with level TIMEOUT.
.IP "\fBint set_glitch_filter(int pi, unsigned user_gpio, unsigned steady)\fP"
.IP "" 4
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
.br
.br
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least \fBsteady\fP microseconds. The
level is then reported. Level changes of less than
\fBsteady\fP microseconds are ignored.
.IP "\fBint set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)\fP"
.IP "" 4
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
.br
.br
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for \fBsteady\fP microseconds is detected. Level changes
-on the gpio are then reported for \fBactive\fP microseconds after
+on the GPIO are then reported for \fBactive\fP microseconds after
which the process repeats.
.br
.IP "\fBuint32_t read_bank_1(int pi)\fP"
.IP "" 4
-Read the levels of the bank 1 gpios (gpios 0-31).
+Read the levels of the bank 1 GPIO (GPIO 0-31).
.br
.br
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<n).
+GPIO is logic 1. GPIO n has bit value (1<<n).
.IP "\fBuint32_t read_bank_2(int pi)\fP"
.IP "" 4
-Read the levels of the bank 2 gpios (gpios 32-53).
+Read the levels of the bank 2 GPIO (GPIO 32-53).
.br
.br
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<(n-32)).
+GPIO is logic 1. GPIO n has bit value (1<<(n-32)).
.IP "\fBint clear_bank_1(int pi, uint32_t bits)\fP"
.IP "" 4
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
.br
.EX
pi: 0- (as returned by \fBpigpio_start\fP).
.br
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be cleared.
.br
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint clear_bank_2(int pi, uint32_t bits)\fP"
.IP "" 4
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.EX
pi: 0- (as returned by \fBpigpio_start\fP).
.br
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be cleared.
.br
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint set_bank_1(int pi, uint32_t bits)\fP"
.IP "" 4
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
.br
.EX
pi: 0- (as returned by \fBpigpio_start\fP).
.br
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be set.
.br
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint set_bank_2(int pi, uint32_t bits)\fP"
.IP "" 4
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
.br
.EX
pi: 0- (as returned by \fBpigpio_start\fP).
.br
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
.br
to be set.
.br
.br
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
.IP "\fBint hardware_clock(int pi, unsigned gpio, unsigned clkfreq)\fP"
.IP "" 4
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
.br
.br
.br
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.EX
4 clock 0 All models
.br
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
.br
-6 clock 2 A+/B+/Pi2/Zero and compute module only
+6 clock 2 All models but A and B
.br
-20 clock 0 A+/B+/Pi2/Zero and compute module only
+20 clock 0 All models but A and B
.br
-21 clock 1 All models but Rev.2 B (reserved for system use)
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
.br
.br
.br
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
.IP "\fBint hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)\fP"
.IP "" 4
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
.br
.br
.br
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
.br
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.br
.EX
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
.br
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+13 PWM channel 1 All models but A and B
.br
18 PWM channel 0 All models
.br
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
.br
.br
.br
.br
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see \fBgpio\fP).
.br
.br
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
.br
.br
.br
-1) the gpios to be switched on at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
.br
-2) the gpios to be switched off at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
.br
3) the delay in microseconds before the next pulse.
.br
.EE
+.IP "\fBint wave_tx_at(int pi)\fP"
+.IP "" 4
+This function returns the id of the waveform currently being
+transmitted.
+
+.br
+
+.br
+
+.EX
+pi: 0- (as returned by \fBpigpio_start\fP).
+.br
+
+.EE
+
+.br
+
+.br
+Returns the waveform id or one of the following special values:
+
+.br
+
+.br
+PI_WAVE_NOT_FOUND (9998) - transmitted wave not found.
+.br
+PI_NO_TX_WAVE (9999) - no wave being transmitted.
+
.IP "\fBint wave_tx_busy(int pi)\fP"
.IP "" 4
This function checks to see if a waveform is currently being
.IP "\fBint gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)\fP"
.IP "" 4
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
.br
.IP "\fBint bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits)\fP"
.IP "" 4
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
.br
.IP "\fBint bb_serial_read_close(int pi, unsigned user_gpio)\fP"
.IP "" 4
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
.br
.IP "\fBint bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud)\fP"
.IP "" 4
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
.br
.br
o clock stretching
.br
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
.br
.br
.br
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
.IP "\fBint bb_i2c_close(int pi, unsigned SDA)\fP"
.IP "" 4
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with \fBbb_i2c_open\fP.
.br
.EX
pi: 0- (as returned by \fBpigpio_start\fP).
.br
-SDA: 0-31, the SDA gpio used in a prior call to \fBbb_i2c_open\fP
+SDA: 0-31, the SDA GPIO used in a prior call to \fBbb_i2c_open\fP
.br
.EE
.br
.br
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero 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.
+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.
.br
.EX
pi: 0- (as returned by \fBpigpio_start\fP).
.br
-spi_channel: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
+spi_channel: 0-1 (0-2 for the auxiliary device).
.br
baud: 32K-125M (values above 30M are unlikely to work).
.br
.br
.br
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
.br
.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
.br
.br
+.br
+The \fBspi_read\fP, \fBspi_write\fP, and \fBspi_xfer\fP functions
+transfer data packed into 1, 2, or 4 bytes according to
+the word size in bits.
+
+.br
+
+.br
+For bits 1-8 there will be one byte per character.
+.br
+For bits 9-16 there will be two bytes per character.
+.br
+For bits 17-32 there will be four bytes per character.
+
+.br
+
+.br
+E.g. to transfer 32 12-bit words buf should contain 64 bytes
+and count should be 64.
+
+.br
+
.br
The other bits in flags should be set to zero.
.br
.br
-The callback is called with the gpio, edge, and tick, whenever the
-gpio has the identified edge.
+The callback is called with the GPIO, edge, and tick, whenever the
+GPIO has the identified edge.
.IP "\fBint callback_ex(int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
.IP "" 4
.br
.br
-The callback is called with the gpio, edge, tick, and user, whenever
-the gpio has the identified edge.
+The callback is called with the GPIO, edge, tick, and user, whenever
+the GPIO has the identified edge.
.IP "\fBint callback_cancel(unsigned callback_id)\fP"
.IP "" 4
.IP "\fBint wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout)\fP"
.IP "" 4
-This function waits for edge on the gpio for up to timeout
+This function waits for edge on the GPIO for up to timeout
seconds.
.br
.br
.IP "\fBbits\fP" 0
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
.br
.br
.IP "\fBedge\fP" 0
-Used to identify a gpio level transition of interest. A rising edge is
+Used to identify a GPIO level transition of interest. A rising edge is
a level change from 0 to 1. A falling edge is a level change from 1 to 0.
.br
.br
.IP "\fBfrequency\fP: 0-" 0
-The number of times a gpio is swiched on and off per second. This
-can be set per gpio and may be as little as 5Hz or as much as
-40KHz. The gpio will be on for a proportion of the time as defined
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
.br
.br
.IP "\fBgpio\fP" 0
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
.br
.br
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
gpio53.
.br
.br
.br
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
.br
.br
.br
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
.br
.br
.IP "\fBlevel\fP" 0
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
.br
.br
.br
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See \fBset_watchdog\fP.
.br
.br
.IP "\fBmode\fP" 0
-1. The operational mode of a gpio, normally INPUT or OUTPUT.
+1. The operational mode of a GPIO, normally INPUT or OUTPUT.
.br
.br
.IP "\fBpud\fP: 0-2" 0
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
.EX
.br
.IP "\fBSCL\fP" 0
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
.br
.br
.IP "\fBSDA\fP" 0
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
.br
.br
.IP "\fBtimeout\fP" 0
-A gpio watchdog timeout in milliseconds.
+A GPIO watchdog timeout in milliseconds.
.EX
PI_MIN_WDOG_TIMEOUT 0
.br
.IP "\fBuser_gpio\fP" 0
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
.br
For more information, please refer to <http://unlicense.org/>
*/
-/* PIGPIOD_IF2_VERSION 3 */
+/* PIGPIOD_IF2_VERSION 5 */
#include <stdio.h>
#include <stdlib.h>
(pi, PI_CMD_WVCHA, 0, 0, bufSize, 1, ext, 1);
}
+int wave_tx_at(int pi)
+ {return pigpio_command(pi, PI_CMD_WVTAT, 0, 0, 1);}
+
int wave_tx_busy(int pi)
{return pigpio_command(pi, PI_CMD_WVBSY, 0, 0, 1);}
#include "pigpio.h"
-#define PIGPIOD_IF2_VERSION 3
+#define PIGPIOD_IF2_VERSION 5
/*TEXT
pigpiod_if2 is a C library for the Raspberry which allows control
-of the gpios via the socket interface to the pigpio daemon.
+of the GPIO via the socket interface to the pigpio daemon.
*Features*
-o PWM on any of gpios 0-31
+o PWM on any of GPIO 0-31
-o servo pulses on any of gpios 0-31
+o servo pulses on any of GPIO 0-31
-o callbacks when any of gpios 0-31 change state
+o callbacks when any of GPIO 0-31 change state
o callbacks at timed intervals
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
o the construction of output waveforms with microsecond timing
-o rudimentary permission control over gpios
+o rudimentary permission control over GPIO
o a simple interface to start and stop new threads
o creating and running scripts on the pigpio daemon
-*gpios*
+*GPIO*
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
*Notes*
BEGINNER
-set_mode Set a gpio mode
-get_mode Get a gpio mode
+set_mode Set a GPIO mode
+get_mode Get a GPIO mode
-set_pull_up_down Set/clear gpio pull up/down resistor
+set_pull_up_down Set/clear GPIO pull up/down resistor
-gpio_read Read a gpio
-gpio_write Write a gpio
+gpio_read Read a GPIO
+gpio_write Write a GPIO
-set_PWM_dutycycle Start/stop PWM pulses on a gpio
-get_PWM_dutycycle Get the PWM dutycycle in use on a gpio
+set_PWM_dutycycle Start/stop PWM pulses on a GPIO
+get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
-set_servo_pulsewidth Start/stop servo pulses on a gpio
-get_servo_pulsewidth Get the servo pulsewidth in use on a gpio
+set_servo_pulsewidth Start/stop servo pulses on a GPIO
+get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
-callback Create gpio level change callback
-callback_ex Create gpio level change callback
+callback Create GPIO level change callback
+callback_ex Create GPIO level change callback
callback_cancel Cancel a callback
-wait_for_edge Wait for gpio level change
+wait_for_edge Wait for GPIO level change
INTERMEDIATE
-gpio_trigger Send a trigger pulse to a gpio.
+gpio_trigger Send a trigger pulse to a GPIO.
-set_watchdog Set a watchdog on a gpio.
+set_watchdog Set a watchdog on a GPIO.
-set_PWM_range Configure PWM range for a gpio
-get_PWM_range Get configured PWM range for a gpio
+set_PWM_range Configure PWM range for a GPIO
+get_PWM_range Get configured PWM range for a GPIO
-set_PWM_frequency Configure PWM frequency for a gpio
-get_PWM_frequency Get configured PWM frequency for a gpio
+set_PWM_frequency Configure PWM frequency for a GPIO
+get_PWM_frequency Get configured PWM frequency for a GPIO
-read_bank_1 Read all gpios in bank 1
-read_bank_2 Read all gpios in bank 2
+read_bank_1 Read all GPIO in bank 1
+read_bank_2 Read all GPIO in bank 2
-clear_bank_1 Clear selected gpios in bank 1
-clear_bank_2 Clear selected gpios in bank 2
+clear_bank_1 Clear selected GPIO in bank 1
+clear_bank_2 Clear selected GPIO in bank 2
-set_bank_1 Set selected gpios in bank 1
-set_bank_2 Set selected gpios in bank 2
+set_bank_1 Set selected GPIO in bank 1
+set_bank_2 Set selected GPIO in bank 2
start_thread Start a new thread
stop_thread Stop a previously started thread
ADVANCED
-get_PWM_real_range Get underlying PWM range for a gpio
+get_PWM_real_range Get underlying PWM range for a GPIO
notify_open Request a notification handle
-notify_begin Start notifications for selected gpios
+notify_begin Start notifications for selected GPIO
notify_pause Pause notifications
notify_close Close a notification
-bb_serial_read_open Opens a gpio for bit bang serial reads
-bb_serial_read Reads bit bang serial data from a gpio
-bb_serial_read_close Closes a gpio for bit bang serial reads
+bb_serial_read_open Opens a GPIO for bit bang serial reads
+bb_serial_read Reads bit bang serial data from a GPIO
+bb_serial_read_close Closes a GPIO for bit bang serial reads
bb_serial_invert Invert serial logic (1 invert, 0 normal)
-hardware_clock Start hardware clock on supported gpios
-hardware_PWM Start hardware PWM on supported gpios
+hardware_clock Start hardware clock on supported GPIO
+hardware_PWM Start hardware PWM on supported GPIO
-set_glitch_filter Set a glitch filter on a gpio
-set_noise_filter Set a noise filter on a gpio
+set_glitch_filter Set a glitch filter on a GPIO
+set_noise_filter Set a noise filter on a GPIO
SCRIPTS
wave_chain Transmits a chain of waveforms
+wave_tx_at Returns the current transmitting waveform
wave_tx_busy Checks to see if the waveform has ended
wave_tx_stop Aborts the current waveform
i2c_zip Performs multiple I2C transactions
-bb_i2c_open Opens gpios for bit banging I2C
-bb_i2c_close Closes gpios for bit banging I2C
+bb_i2c_open Opens GPIO for bit banging I2C
+bb_i2c_close Closes GPIO for bit banging I2C
bb_i2c_zip Performs multiple bit banged I2C transactions
SPI
/*F*/
int set_mode(int pi, unsigned gpio, unsigned mode);
/*D
-Set the gpio mode.
+Set the GPIO mode.
. .
pi: 0- (as returned by [*pigpio_start*]).
/*F*/
int get_mode(int pi, unsigned gpio);
/*D
-Get the gpio mode.
+Get the GPIO mode.
. .
pi: 0- (as returned by [*pigpio_start*]).
gpio: 0-53.
. .
-Returns the gpio mode if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
D*/
/*F*/
int set_pull_up_down(int pi, unsigned gpio, unsigned pud);
/*D
-Set or clear the gpio pull-up/down resistor.
+Set or clear the GPIO pull-up/down resistor.
. .
pi: 0- (as returned by [*pigpio_start*]).
/*F*/
int gpio_read(int pi, unsigned gpio);
/*D
-Read the gpio level.
+Read the GPIO level.
. .
pi: 0- (as returned by [*pigpio_start*]).
gpio:0-53.
. .
-Returns the gpio level if OK, otherwise PI_BAD_GPIO.
+Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
D*/
/*F*/
int gpio_write(int pi, unsigned gpio, unsigned level);
/*D
-Write the gpio level.
+Write the GPIO level.
. .
pi: 0- (as returned by [*pigpio_start*]).
Notes
-If PWM or servo pulses are active on the gpio they are switched off.
+If PWM or servo pulses are active on the GPIO they are switched off.
D*/
/*F*/
int set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle);
/*D
-Start (non-zero dutycycle) or stop (0) PWM pulses on the gpio.
+Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
/*F*/
int get_PWM_dutycycle(int pi, unsigned user_gpio);
/*D
-Return the PWM dutycycle in use on a gpio.
+Return the PWM dutycycle in use on a GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see [*get_PWM_range*]).
+for the GPIO (see [*get_PWM_range*]).
-If a hardware clock is active on the gpio the reported dutycycle
+If a hardware clock is active on the GPIO the reported dutycycle
will be 500000 (500k) out of 1000000 (1M).
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
D*/
/*F*/
int set_PWM_range(int pi, unsigned user_gpio, unsigned range);
/*D
-Set the range of PWM values to be used on the gpio.
+Set the range of PWM values to be used on the GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
Notes
-If PWM is currently active on the gpio its dutycycle will be
+If PWM is currently active on the GPIO its dutycycle will be
scaled to reflect the new range.
The real range, the number of steps between fully off and fully on
-for each of the 18 available gpio frequencies is
+for each of the 18 available GPIO frequencies is
. .
25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6),
/*F*/
int get_PWM_range(int pi, unsigned user_gpio);
/*D
-Get the range of PWM values being used on the gpio.
+Get the range of PWM values being used on the GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
user_gpio: 0-31.
. .
-Returns the dutycycle range used for the gpio if OK,
+Returns the dutycycle range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
-If a hardware clock or hardware PWM is active on the gpio the
+If a hardware clock or hardware PWM is active on the GPIO the
reported range will be 1000000 (1M).
D*/
/*F*/
int get_PWM_real_range(int pi, unsigned user_gpio);
/*D
-Get the real underlying range of PWM values being used on the gpio.
+Get the real underlying range of PWM values being used on the GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
user_gpio: 0-31.
. .
-Returns the real range used for the gpio if OK,
+Returns the real range used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
D*/
/*F*/
int set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency);
/*D
-Set the frequency (in Hz) of the PWM to be used on the gpio.
+Set the frequency (in Hz) of the PWM to be used on the GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
sample rate is set when the C pigpio library is started.
-Each gpio can be independently set to one of 18 different
+Each GPIO can be independently set to one of 18 different
PWM frequencies.
-If PWM is currently active on the gpio it will be switched
+If PWM is currently active on the GPIO it will be switched
off and then back on at the new frequency.
. .
/*F*/
int get_PWM_frequency(int pi, unsigned user_gpio);
/*D
-Get the frequency of PWM being used on the gpio.
+Get the frequency of PWM being used on the GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
user_gpio: 0-31.
. .
-For normal PWM the frequency will be that defined for the gpio by
+For normal PWM the frequency will be that defined for the GPIO by
[*set_PWM_frequency*].
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by [*hardware_clock*].
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by [*hardware_PWM*].
-Returns the frequency (in hertz) used for the gpio if OK,
+Returns the frequency (in hertz) used for the GPIO if OK,
otherwise PI_BAD_USER_GPIO.
D*/
/*F*/
int set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth);
/*D
-Start (500-2500) or stop (0) servo pulses on the gpio.
+Start (500-2500) or stop (0) servo pulses on the GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
Doing this allows you to use units of microseconds when setting
the servo pulsewidth.
-E.g. If you want to update a servo connected to gpio 25 at 400Hz
+E.g. If you want to update a servo connected to GPIO 25 at 400Hz
. .
set_PWM_frequency(25, 400);
/*F*/
int get_servo_pulsewidth(int pi, unsigned user_gpio);
/*D
-Return the servo pulsewidth in use on a gpio.
+Return the servo pulsewidth in use on a GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
Returns a handle greater than or equal to zero if OK,
otherwise PI_NO_HANDLE.
-A notification is a method for being notified of gpio state
+A notification is a method for being notified of GPIO state
changes via a pipe.
Pipes are only accessible from the local machine so this function
. .
pi: 0- (as returned by [*pigpio_start*]).
handle: 0-31 (as returned by [*notify_open*])
- bits: a mask indicating the gpios to be notified.
+ bits: a mask indicating the GPIO to be notified.
. .
Returns 0 if OK, otherwise PI_BAD_HANDLE.
-The notification sends state changes for each gpio whose
+The notification sends state changes for each GPIO whose
corresponding bit in bits is set.
Notes
/*F*/
int set_watchdog(int pi, unsigned user_gpio, unsigned timeout);
/*D
-Sets a watchdog for a gpio.
+Sets a watchdog for a GPIO.
. .
pi: 0- (as returned by [*pigpio_start*]).
The watchdog is nominally in milliseconds.
-Only one watchdog may be registered per gpio.
+Only one watchdog may be registered per GPIO.
The watchdog may be cancelled by setting timeout to 0.
-If no level change has been detected for the gpio for timeout
-milliseconds any notification for the gpio has a report written
+If no level change has been detected for the GPIO for timeout
+milliseconds any notification for the GPIO has a report written
to the fifo with the flags set to indicate a watchdog timeout.
The [*callback*] and [*callback_ex*] functions interpret the flags
-and will call registered callbacks for the gpio with level TIMEOUT.
+and will call registered callbacks for the GPIO with level TIMEOUT.
D*/
/*F*/
int set_glitch_filter(int pi, unsigned user_gpio, unsigned steady);
/*D
-Sets a glitch filter on a gpio.
+Sets a glitch filter on a GPIO.
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least [*steady*] microseconds. The
level is then reported. Level changes of less than
[*steady*] microseconds are ignored.
int set_noise_filter(
int pi, unsigned user_gpio, unsigned steady, unsigned active);
/*D
-Sets a noise filter on a gpio.
+Sets a noise filter on a GPIO.
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for [*steady*] microseconds is detected. Level changes
-on the gpio are then reported for [*active*] microseconds after
+on the GPIO are then reported for [*active*] microseconds after
which the process repeats.
. .
/*F*/
uint32_t read_bank_1(int pi);
/*D
-Read the levels of the bank 1 gpios (gpios 0-31).
+Read the levels of the bank 1 GPIO (GPIO 0-31).
. .
pi: 0- (as returned by [*pigpio_start*]).
. .
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<n).
+GPIO is logic 1. GPIO n has bit value (1<<n).
D*/
/*F*/
uint32_t read_bank_2(int pi);
/*D
-Read the levels of the bank 2 gpios (gpios 32-53).
+Read the levels of the bank 2 GPIO (GPIO 32-53).
. .
pi: 0- (as returned by [*pigpio_start*]).
. .
The returned 32 bit integer has a bit set if the corresponding
-gpio is logic 1. Gpio n has bit value (1<<(n-32)).
+GPIO is logic 1. GPIO n has bit value (1<<(n-32)).
D*/
/*F*/
int clear_bank_1(int pi, uint32_t bits);
/*D
-Clears gpios 0-31 if the corresponding bit in bits is set.
+Clears GPIO 0-31 if the corresponding bit in bits is set.
. .
pi: 0- (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
to be cleared.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int clear_bank_2(int pi, uint32_t bits);
/*D
-Clears gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
pi: 0- (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
to be cleared.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int set_bank_1(int pi, uint32_t bits);
/*D
-Sets gpios 0-31 if the corresponding bit in bits is set.
+Sets GPIO 0-31 if the corresponding bit in bits is set.
. .
pi: 0- (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
to be set.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int set_bank_2(int pi, uint32_t bits);
/*D
-Sets gpios 32-53 if the corresponding bit (0-21) in bits is set.
+Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
. .
pi: 0- (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding gpio is
+bits: a bit mask with 1 set if the corresponding GPIO is
to be set.
. .
Returns 0 if OK, otherwise PI_SOME_PERMITTED.
A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the gpios.
+allowed to write to one or more of the GPIO.
D*/
/*F*/
int hardware_clock(int pi, unsigned gpio, unsigned clkfreq);
/*D
-Starts a hardware clock on a gpio at the specified frequency.
+Starts a hardware clock on a GPIO at the specified frequency.
Frequencies above 30MHz are unlikely to work.
. .
Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
4 clock 0 All models
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
-6 clock 2 A+/B+/Pi2/Zero and compute module only
-20 clock 0 A+/B+/Pi2/Zero and compute module only
-21 clock 1 All models but Rev.2 B (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
+6 clock 2 All models but A and B
+20 clock 0 All models but A and B
+21 clock 1 All models but A and Rev.2 B (reserved for system use)
32 clock 0 Compute module only
34 clock 0 Compute module only
Access to clock 1 is protected by a password as its use will likely
crash the Pi. The password is given by or'ing 0x5A000000 with the
-gpio number.
+GPIO number.
D*/
/*F*/
int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty);
/*D
-Starts hardware PWM on a gpio at the specified frequency and dutycycle.
+Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
Frequencies above 30MHz are unlikely to work.
NOTE: Any waveform started by [*wave_send_**] or [*wave_chain*]
PI_NOT_HPWM_GPIO, PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ,
or PI_HPWM_ILLEGAL.
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
-The gpio must be one of the following.
+The GPIO must be one of the following.
. .
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
+13 PWM channel 1 All models but A and B
18 PWM channel 0 All models
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
40 PWM channel 0 Compute module only
41 PWM channel 1 Compute module only
If the hardware revision can not be found or is not a valid
hexadecimal number the function returns 0.
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see [*gpio*]).
There are at least three types of board.
(if any).
Merging allows the waveform to be built in parts, that is the settings
-for gpio#1 can be added, and then gpio#2 etc.
+for GPIO#1 can be added, and then GPIO#2 etc.
If the added waveform is intended to start after or within the existing
waveform then the first pulse should consist solely of a delay.
The fields specify
-1) the gpios to be switched on at the start of the pulse.
-2) the gpios to be switched off at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
3) the delay in microseconds before the next pulse.
Any or all the fields can be zero. It doesn't make any sense to
D*/
+/*F*/
+int wave_tx_at(int pi);
+/*D
+This function returns the id of the waveform currently being
+transmitted.
+
+. .
+pi: 0- (as returned by [*pigpio_start*]).
+. .
+
+Returns the waveform id or one of the following special values:
+
+PI_WAVE_NOT_FOUND (9998) - transmitted wave not found.
+PI_NO_TX_WAVE (9999) - no wave being transmitted.
+D*/
+
/*F*/
int wave_tx_busy(int pi);
/*D
/*F*/
int gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level);
/*D
-This function sends a trigger pulse to a gpio. The gpio is set to
+This function sends a trigger pulse to a GPIO. The GPIO is set to
level for pulseLen microseconds and then reset to not level.
. .
/*F*/
int bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits);
/*D
-This function opens a gpio for bit bang reading of serial data.
+This function opens a GPIO for bit bang reading of serial data.
. .
pi: 0- (as returned by [*pigpio_start*]).
/*F*/
int bb_serial_read_close(int pi, unsigned user_gpio);
/*D
-This function closes a gpio for bit bang reading of serial data.
+This function closes a GPIO for bit bang reading of serial data.
. .
pi: 0- (as returned by [*pigpio_start*]).
/*F*/
int bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud);
/*D
-This function selects a pair of gpios for bit banging I2C at a
+This function selects a pair of GPIO for bit banging I2C at a
specified baud rate.
Bit banging I2C allows for certain operations which are not possible
o baud rates as low as 50
o repeated starts
o clock stretching
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
. .
pi: 0- (as returned by [*pigpio_start*]).
NOTE:
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
D*/
/*F*/
int bb_i2c_close(int pi, unsigned SDA);
/*D
-This function stops bit banging I2C on a pair of gpios previously
+This function stops bit banging I2C on a pair of GPIO previously
opened with [*bb_i2c_open*].
. .
pi: 0- (as returned by [*pigpio_start*]).
-SDA: 0-31, the SDA gpio used in a prior call to [*bb_i2c_open*]
+SDA: 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*]
. .
Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
be used to modify the default behaviour of 4-wire operation, mode 0,
active low chip select.
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero 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.
+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.
. .
pi: 0- (as returned by [*pigpio_start*]).
-spi_channel: 0-1 (0-2 for A+/B+/Pi2/Zero auxiliary device).
+spi_channel: 0-1 (0-2 for the auxiliary device).
baud: 32K-125M (values above 30M are unlikely to work).
spi_flags: see below.
. .
px is 0 if CEx is active low (default) and 1 for active high.
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
SPI device only.
bbbbbb defines the word size in bits (0-32). The default (0)
sets 8 bits per word. Auxiliary SPI device only.
+The [*spi_read*], [*spi_write*], and [*spi_xfer*] functions
+transfer data packed into 1, 2, or 4 bytes according to
+the word size in bits.
+
+For bits 1-8 there will be one byte per character.
+For bits 9-16 there will be two bytes per character.
+For bits 17-32 there will be four bytes per character.
+
+E.g. to transfer 32 12-bit words buf should contain 64 bytes
+and count should be 64.
+
The other bits in flags should be set to zero.
D*/
The function returns a callback id if OK, otherwise pigif_bad_malloc,
pigif_duplicate_callback, or pigif_bad_callback.
-The callback is called with the gpio, edge, and tick, whenever the
-gpio has the identified edge.
+The callback is called with the GPIO, edge, and tick, whenever the
+GPIO has the identified edge.
D*/
/*F*/
The function returns a callback id if OK, otherwise pigif_bad_malloc,
pigif_duplicate_callback, or pigif_bad_callback.
-The callback is called with the gpio, edge, tick, and user, whenever
-the gpio has the identified edge.
+The callback is called with the GPIO, edge, tick, and user, whenever
+the GPIO has the identified edge.
D*/
/*F*/
/*F*/
int wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout);
/*D
-This function waits for edge on the gpio for up to timeout
+This function waits for edge on the GPIO for up to timeout
seconds.
. .
A value of 0 or 1.
bits::
-A value used to select gpios. If bit n of bits is set then gpio n is
+A value used to select GPIO. If bit n of bits is set then GPIO n is
selected.
A convenient way to set bit n is to or in (1<<n).
0 is off and range is fully on.
edge::
-Used to identify a gpio level transition of interest. A rising edge is
+Used to identify a GPIO level transition of interest. A rising edge is
a level change from 0 to 1. A falling edge is a level change from 1 to 0.
. .
A function.
frequency::0-
-The number of times a gpio is swiched on and off per second. This
-can be set per gpio and may be as little as 5Hz or as much as
-40KHz. The gpio will be on for a proportion of the time as defined
+The number of times a GPIO is swiched on and off per second. This
+can be set per GPIO and may be as little as 5Hz or as much as
+40KHz. The GPIO will be on for a proportion of the time as defined
by its dutycycle.
gpio::
-A Broadcom numbered gpio, in the range 0-53.
+A Broadcom numbered GPIO, in the range 0-53.
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
gpio53.
They are split into two banks. Bank 1 consists of gpio0 through
gpio31. Bank 2 consists of gpio32 through gpio53.
-All the gpios which are safe for the user to read and write are in
-bank 1. Not all gpios in bank 1 are safe though. Type 1 boards
-have 17 safe gpios. Type 2 boards have 21. Type 3 boards have 26.
+All the GPIO which are safe for the user to read and write are in
+bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
+have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
See [*get_hardware_revision*].
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
. .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
A flag used to set normal or inverted bit bang serial data level logic.
level::
-The level of a gpio. Low or High.
+The level of a GPIO. Low or High.
. .
PI_OFF 0
PI_HIGH 1
. .
-There is one exception. If a watchdog expires on a gpio the level will be
+There is one exception. If a watchdog expires on a GPIO the level will be
reported as PI_TIMEOUT. See [*set_watchdog*].
. .
. .
mode::
-1. The operational mode of a gpio, normally INPUT or OUTPUT.
+1. The operational mode of a GPIO, normally INPUT or OUTPUT.
. .
PI_INPUT 0
A thread identifier.
pud::0-2
-The setting of the pull up/down resistor for a gpio, which may be off,
+The setting of the pull up/down resistor for a GPIO, which may be off,
pull-up, or pull-down.
. .
PI_PUD_OFF 0
A pointer to a buffer to receive data.
SCL::
-The user gpio to use for the clock when bit banging I2C.
+The user GPIO to use for the clock when bit banging I2C.
*script::
A pointer to the text of a script.
An id of a stored script as returned by [*store_script*].
SDA::
-The user gpio to use for data when bit banging I2C.
+The user GPIO to use for data when bit banging I2C.
seconds::
The number of seconds.
thread.
timeout::
-A gpio watchdog timeout in milliseconds.
+A GPIO watchdog timeout in milliseconds.
. .
PI_MIN_WDOG_TIMEOUT 0
PI_MAX_WDOG_TIMEOUT 60000
A whole number >= 0.
user_gpio::
-0-31, a Broadcom numbered gpio.
+0-31, a Broadcom numbered GPIO.
See [*gpio*].
.br
-The socket and pipe interfaces allow control of the gpios by passing
+The socket and pipe interfaces allow control of the GPIO by passing
messages to the running pigpio library.
.br
.br
.SS Features
.br
-o PWM on any of gpios 0-31
+o PWM on any of GPIO 0-31
.br
-o servo pulses on any of gpios 0-31
+o servo pulses on any of GPIO 0-31
.br
-o reading/writing all of the gpios in a bank as one operation
+o reading/writing all of the GPIO in a bank as one operation
.br
-o individually setting gpio modes, reading and writing
+o individually setting GPIO modes, reading and writing
.br
-o notifications when any of gpios 0-31 change state
+o notifications when any of GPIO 0-31 change state
.br
o the construction of output waveforms with microsecond timing
o creating and running scripts on the pigpio daemon
.br
-.SS gpios
+.SS GPIO
.br
-ALL gpios are identified by their Broadcom number.
+ALL GPIO are identified by their Broadcom number.
.br
.SS Usage
.br
-.IP "\fBBC1 bits\fP - Clear specified gpios in bank 1"
+.IP "\fBBC1 bits\fP - Clear specified GPIO in bank 1"
.IP "" 4
-This command clears (sets low) the gpios specified by \fBbits\fP in bank 1.
-Bank 1 consists of gpios 0-31.
+This command clears (sets low) the GPIO specified by \fBbits\fP in bank 1.
+Bank 1 consists of GPIO 0-31.
.br
Upon success nothing is returned. On error a negative status code
.br
.EX
-$ pigs bc1 0x400010 # clear gpios 4 (1<<4) and 22 (1<<22)
+$ pigs bc1 0x400010 # clear GPIO 4 (1<<4) and 22 (1<<22)
.br
.br
-$ pigs bc1 32 # clear gpio 5 (1<<5)
+$ pigs bc1 32 # clear GPIO 5 (1<<5)
.br
-42
.br
-ERROR: no permission to update one or more gpios
+ERROR: no permission to update one or more GPIO
.br
.EE
.br
-.IP "\fBBC2 bits\fP - Clear specified gpios in bank 2"
+.IP "\fBBC2 bits\fP - Clear specified GPIO in bank 2"
.IP "" 4
-This command clears (sets low) the gpios specified by \fBbits\fP in bank 2.
-Bank 2 consists of gpios 32-53.
+This command clears (sets low) the GPIO specified by \fBbits\fP in bank 2.
+Bank 2 consists of GPIO 32-53.
.br
Upon success nothing is returned. On error a negative status code
.br
.EX
-$ pigs bc2 0x8000 # clear gpio 47 (activity LED on A+/B+/Pi2)
+$ pigs bc2 0x8000 # clear GPIO 47 (activity LED on A+/B+/Pi2/Pi3)
.br
.br
-$ pigs bc2 1 # clear gpio 32 (first in bank 2)
+$ pigs bc2 1 # clear GPIO 32 (first in bank 2)
.br
-42
.br
-ERROR: no permission to update one or more gpios
+ERROR: no permission to update one or more GPIO
.br
.EE
.IP "\fBBI2CO sda scl b\fP - Open bit bang I2C"
.IP "" 4
-This command signals that gpios \fBsda\fP and \fBscl\fP are to be used
+This command signals that GPIO \fBsda\fP and \fBscl\fP are to be used
for bit banging I2C at \fBb\fP baud.
.br
.br
o clock stretching
.br
-o I2C on any pair of spare gpios
+o I2C on any pair of spare GPIO
.br
The baud rate may be between 50 and 500000 bits per second.
.br
-The gpios used for SDA and SCL must have pull-ups to 3V3 connected. As
+The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
.br
.br
-.IP "\fBBR1 \fP - Read bank 1 gpios"
+.IP "\fBBR1 \fP - Read bank 1 GPIO"
.IP "" 4
-This command read gpios 0-31 (bank 1) and returns the levels as a
+This command read GPIO 0-31 (bank 1) and returns the levels as a
32-bit hexadecimal value.
.br
.br
-.IP "\fBBR2 \fP - Read bank 2 gpios"
+.IP "\fBBR2 \fP - Read bank 2 GPIO"
.IP "" 4
-This command read gpios 32-53 (bank 2) and returns the levels as a
+This command read GPIO 32-53 (bank 2) and returns the levels as a
32-bit hexadecimal value.
.br
.br
-.IP "\fBBS1 bits\fP - Set specified gpios in bank 1"
+.IP "\fBBS1 bits\fP - Set specified GPIO in bank 1"
.IP "" 4
-This command sets (sets high) the gpios specified by \fBbits\fP in bank 1.
-Bank 1 consists of gpios 0-31.
+This command sets (sets high) the GPIO specified by \fBbits\fP in bank 1.
+Bank 1 consists of GPIO 0-31.
.br
Upon success nothing is returned. On error a negative status code
.br
.EX
-$ pigs bs1 16 # set gpio 4 (1<<4)
+$ pigs bs1 16 # set GPIO 4 (1<<4)
.br
.br
-$ pigs bs1 1 # set gpio 1 (1<<0)
+$ pigs bs1 1 # set GPIO 1 (1<<0)
.br
-42
.br
-ERROR: no permission to update one or more gpios
+ERROR: no permission to update one or more GPIO
.br
.EE
.br
-.IP "\fBBS2 bits\fP - Set specified gpios in bank 2"
+.IP "\fBBS2 bits\fP - Set specified GPIO in bank 2"
.IP "" 4
-This command sets (sets high) the gpios specified by \fBbits\fP in bank 2.
-Bank 2 consists of gpios 32-53.
+This command sets (sets high) the GPIO specified by \fBbits\fP in bank 2.
+Bank 2 consists of GPIO 32-53.
.br
Upon success nothing is returned. On error a negative status code
.br
.EX
-$ pigs bs2 0x40 # set gpio 38 (enable high current mode A+/B+/Pi2)
+$ pigs bs2 0x40 # set GPIO 38 (enable high current mode A+/B+/Pi2/Pi3)
.br
.br
-$ pigs bs2 1 # set gpio 32 (first in bank 2)
+$ pigs bs2 1 # set GPIO 32 (first in bank 2)
.br
-42
.br
-ERROR: no permission to update one or more gpios
+ERROR: no permission to update one or more GPIO
.br
.EE
.br
-.IP "\fBFG u stdy\fP - Set a glitch filter on a gpio"
+.IP "\fBFG u stdy\fP - Set a glitch filter on a GPIO"
.IP "" 4
.br
-Level changes on the gpio are not reported unless the level
+Level changes on the GPIO are not reported unless the level
has been stable for at least \fBstdy\fP microseconds. The
level is then reported. Level changes of less than \fBstdy\fP
microseconds are ignored.
.br
-.IP "\fBFN u stdy actv\fP - Set a noise filter on a gpio"
+.IP "\fBFN u stdy actv\fP - Set a noise filter on a GPIO"
.IP "" 4
.br
-Level changes on the gpio are ignored until a level which has
+Level changes on the GPIO are ignored until a level which has
been stable for \fBstdy\fP microseconds is detected. Level
-changes on the gpio are then reported for \fBactv\fP microseconds
+changes on the GPIO are then reported for \fBactv\fP microseconds
after which the process repeats.
.br
.br
-.IP "\fBGDC u\fP - Get gpio PWM dutycycle"
+.IP "\fBGDC u\fP - Get GPIO PWM dutycycle"
.IP "" 4
.br
-This command returns the PWM dutycycle in use on gpio \fBu\fP.
+This command returns the PWM dutycycle in use on GPIO \fBu\fP.
.br
Upon success the dutycycle is returned. On error a negative
.br
For normal PWM the dutycycle will be out of the defined range
-for the gpio (see \fBPRG\fP).
+for the GPIO (see \fBPRG\fP).
.br
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
dutycycle will be 500000 (500k) out of 1000000 (1M).
.br
-If hardware PWM is active on the gpio the reported dutycycle
+If hardware PWM is active on the GPIO the reported dutycycle
will be out of a 1000000 (1M).
.br
.br
-92
.br
-ERROR: gpio is not in use for PWM
+ERROR: GPIO is not in use for PWM
.br
.EE
.br
-.IP "\fBGPW u\fP - Get gpio servo pulsewidth"
+.IP "\fBGPW u\fP - Get GPIO servo pulsewidth"
.IP "" 4
.br
-This command returns the servo pulsewidth in use on gpio \fBu\fP.
+This command returns the servo pulsewidth in use on GPIO \fBu\fP.
.br
Upon success the servo pulsewidth is returned. On error a negative
.br
-93
.br
-ERROR: gpio is not in use for servo pulses
+ERROR: GPIO is not in use for servo pulses
.br
.EE
.IP "\fBHC g cf\fP - Set hardware clock frequency"
.IP "" 4
-This command sets the hardware clock associated with gpio \fBg\fP to
+This command sets the hardware clock associated with GPIO \fBg\fP to
frequency \fBcf\fP. Frequencies above 30MHz are unlikely to work.
.br
.br
.EX
-$ pigs hc 4 5000 # start a 5 KHz clock on gpio 4 (clock 0)
+$ pigs hc 4 5000 # start a 5 KHz clock on GPIO 4 (clock 0)
.br
.br
-$ pigs hc 5 5000000 # start a 5 MHz clcok on gpio 5 (clock 1)
+$ pigs hc 5 5000000 # start a 5 MHz clcok on GPIO 5 (clock 1)
.br
-99
.br
.EE
.br
-The same clock is available on multiple gpios. The latest
-frequency setting will be used by all gpios which share a clock.
+The same clock is available on multiple GPIO. The latest
+frequency setting will be used by all GPIO which share a clock.
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.EX
4 clock 0 All models
-5 clock 1 A+/B+/Pi2/Zero and compute module only (reserved for system use)
-6 clock 2 A+/B+/Pi2/Zero and compute module only
-20 clock 0 A+/B+/Pi2/Zero and compute module only
-21 clock 1 All models but Type 2 (reserved for system use)
+5 clock 1 All models but A and B (reserved for system use)
+6 clock 2 All models but A and B
+20 clock 0 All models but A and B
+21 clock 1 All models but A and B (Rev. 2) (reserved for system use)
.EE
.br
Access to clock 1 is protected by a password as its use will
likely crash the Pi. The password is given by or'ing 0x5A000000
-with the gpio number.
+with the GPIO number.
.br
.IP "\fBHP g pf pdc\fP - Set hardware PWM frequency and dutycycle"
.IP "" 4
-This command sets the hardware PWM associated with gpio \fBg\fP to
+This command sets the hardware PWM associated with GPIO \fBg\fP to
frequency \fBpf\fP with dutycycle \fBpdc\fP. Frequencies above 30MHz
are unlikely to work.
.EE
.br
-The same PWM channel is available on multiple gpios. The latest
-frequency and dutycycle setting will be used by all gpios which
+The same PWM channel is available on multiple GPIO. The latest
+frequency and dutycycle setting will be used by all GPIO which
share a PWM channel.
.br
-The gpio must be one of the following.
+The GPIO must be one of the following.
.br
.EX
-12 PWM channel 0 A+/B+/Pi2/Zero and compute module only
-13 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+12 PWM channel 0 All models but A and B
+13 PWM channel 1 All models but A and B
18 PWM channel 0 All models
-19 PWM channel 1 A+/B+/Pi2/Zero and compute module only
+19 PWM channel 1 All models but A and B
.EE
number the command returns 0.
.br
-The revision number can be used to determine the assignment of gpios
+The revision number can be used to determine the assignment of GPIO
to pins (see \fBg\fP).
.br
.br
-.IP "\fBM/MODES g m\fP - Set gpio mode"
+.IP "\fBM/MODES g m\fP - Set GPIO mode"
.IP "" 4
.br
-This command sets gpio \fBg\fP to mode \fBm\fP, typically input (read)
+This command sets GPIO \fBg\fP to mode \fBm\fP, typically input (read)
or output (write).
.br
will be returned.
.br
-Each gpio can be configured to be in one of 8 different modes. The modes
+Each GPIO can be configured to be in one of 8 different modes. The modes
are named Input, Output, ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5.
.br
.br
-.IP "\fBMG/MODEG g\fP - Get gpio mode"
+.IP "\fBMG/MODEG g\fP - Get GPIO mode"
.IP "" 4
.br
-This command returns the current mode of gpio \fBg\fP.
+This command returns the current mode of GPIO \fBg\fP.
.br
-Upon success the value of the gpio mode is returned.
+Upon success the value of the GPIO mode is returned.
On error a negative status code will be returned.
.br
will be returned.
.br
-The notification gets state changes for each gpio specified by \fBbits\fP.
+The notification gets state changes for each GPIO specified by \fBbits\fP.
.br
.br
.EX
-$ pigs nb 0 -1 # Shorthand for gpios 0-31.
+$ pigs nb 0 -1 # Shorthand for GPIO 0-31.
.br
-$ pigs nb 0 0xf0 # Get notifications for gpios 4-7.
+$ pigs nb 0 0xf0 # Get notifications for GPIO 4-7.
.br
.br
This command requests a free notification handle.
.br
-A notification is a method for being notified of gpio state changes via a pipe.
+A notification is a method for being notified of GPIO state changes via a pipe.
.br
Upon success the command returns a handle greater than or equal to zero.
.br
-.IP "\fBP/PWM u v\fP - Set gpio PWM value"
+.IP "\fBP/PWM u v\fP - Set GPIO PWM value"
.IP "" 4
.br
-This command starts PWM on gpio \fBu\fP with dutycycle \fBv\fP. The dutycycle
+This command starts PWM on GPIO \fBu\fP with dutycycle \fBv\fP. The dutycycle
varies from 0 (off) to range (fully on). The range defaults to 255.
.br
.br
.EX
-$ pigs p 4 64 # Start PWM on gpio 4 with 25% dutycycle
+$ pigs p 4 64 # Start PWM on GPIO 4 with 25% dutycycle
.br
$ pigs p 4 128 # 50%
.br
.br
-.IP "\fBPFG u\fP - Get gpio PWM frequency"
+.IP "\fBPFG u\fP - Get GPIO PWM frequency"
.IP "" 4
.br
-This command returns the PWM frequency in Hz used for gpio \fBu\fP.
+This command returns the PWM frequency in Hz used for GPIO \fBu\fP.
.br
Upon success the PWM frequency is returned. On error a negative
status code will be returned.
.br
-For normal PWM the frequency will be that defined for the gpio
+For normal PWM the frequency will be that defined for the GPIO
by \fBPFS\fP.
.br
-If a hardware clock is active on the gpio the reported frequency
+If a hardware clock is active on the GPIO the reported frequency
will be that set by \fBHC\fP.
.br
-If hardware PWM is active on the gpio the reported frequency
+If hardware PWM is active on the GPIO the reported frequency
will be that set by \fBHP\fP.
.br
.br
$ pigs pfg 34
.br
-ERROR: gpio not 0-31
+ERROR: GPIO not 0-31
.br
-2
.br
.br
-.IP "\fBPFS u v\fP - Set gpio PWM frequency"
+.IP "\fBPFS u v\fP - Set GPIO PWM frequency"
.IP "" 4
-This command sets the PWM frequency \fBv\fP to be used for gpio \fBu\fP.
+This command sets the PWM frequency \fBv\fP to be used for GPIO \fBu\fP.
.br
The numerically closest frequency to \fBv\fP will be selected.
or 10 microseconds (default 5).
.br
-Each gpio can be independently set to one of 18 different PWM frequencies.
+Each GPIO can be independently set to one of 18 different PWM frequencies.
.br
-If PWM is currently active on the gpio it will be switched off and then
+If PWM is currently active on the GPIO it will be switched off and then
back on at the new frequency.
.br
.br
-.IP "\fBPRG u\fP - Get gpio PWM range"
+.IP "\fBPRG u\fP - Get GPIO PWM range"
.IP "" 4
.br
-This command returns the dutycycle range for gpio \fBu\fP.
+This command returns the dutycycle range for GPIO \fBu\fP.
.br
Upon success the range is returned. On error a negative status code
will be returned.
.br
-If a hardware clock or hardware PWM is active on the gpio the reported
+If a hardware clock or hardware PWM is active on the GPIO the reported
range will be 1000000 (1M).
.br
.br
-.IP "\fBPRRG u\fP - Get gpio PWM real range"
+.IP "\fBPRRG u\fP - Get GPIO PWM real range"
.IP "" 4
.br
-This command returns the real underlying range used by gpio \fBu\fP.
+This command returns the real underlying range used by GPIO \fBu\fP.
.br
-If a hardware clock is active on the gpio the reported
+If a hardware clock is active on the GPIO the reported
real range will be 1000000 (1M).
.br
-If hardware PWM is active on the gpio the reported real range
+If hardware PWM is active on the GPIO the reported real range
will be approximately 250M divided by the set PWM frequency.
.br
.br
-.IP "\fBPRS u v\fP - Set gpio PWM range"
+.IP "\fBPRS u v\fP - Set GPIO PWM range"
.IP "" 4
.br
-This command sets the dutycycle range \fBv\fP to be used for gpio \fBu\fP.
+This command sets the dutycycle range \fBv\fP to be used for GPIO \fBu\fP.
Subsequent uses of command \fBP/PWM\fP will use a dutycycle between 0 (off)
and \fBv\fP (fully on).
.br
-Upon success the real underlying range used by the gpio is returned.
+Upon success the real underlying range used by the GPIO is returned.
On error a negative status code will be returned.
.br
-If PWM is currently active on the gpio its dutycycle will be scaled to
+If PWM is currently active on the GPIO its dutycycle will be scaled to
reflect the new range.
.br
.br
-.IP "\fBPUD g p\fP - Set gpio pull up/down"
+.IP "\fBPUD g p\fP - Set GPIO pull up/down"
.IP "" 4
.br
-This command sets the internal pull/up down for gpio \fBg\fP to mode \fBp\fP.
+This command sets the internal pull/up down for GPIO \fBg\fP to mode \fBp\fP.
.br
Upon success nothing is returned. On error a negative status code
.br
.EX
-$ pigs pud 4 d # Set pull-down on gpio 4.
+$ pigs pud 4 d # Set pull-down on GPIO 4.
.br
-$ pigs pud 4 u # Set pull-up on gpio 4.
+$ pigs pud 4 u # Set pull-up on GPIO 4.
.br
-$ pigs pud 4 o # No pull-up/down on gpio 4.
+$ pigs pud 4 o # No pull-up/down on GPIO 4.
.br
.EE
.br
-.IP "\fBR/READ g\fP - Read gpio level"
+.IP "\fBR/READ g\fP - Read GPIO level"
.IP "" 4
.br
-This reads the current level of gpio \fBg\fP.
+This reads the current level of GPIO \fBg\fP.
.br
Upon success the current level is returned. On error a negative status code
.br
.EX
-$ pigs r 17 # Get level of gpio 17.
+$ pigs r 17 # Get level of GPIO 17.
.br
0
.br
.br
-$ pigs r 4 # Get level of gpio 4.
+$ pigs r 4 # Get level of GPIO 4.
.br
1
.br
.br
-.IP "\fBS/SERVO u v\fP - Set gpio servo pulsewidth"
+.IP "\fBS/SERVO u v\fP - Set GPIO servo pulsewidth"
.IP "" 4
.br
-This command starts servo pulses of \fBv\fP microseconds on gpio \fBu\fP.
+This command starts servo pulses of \fBv\fP microseconds on GPIO \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
.br
This example causes an on pulse of 1500 microseconds duration to be
-transmitted on gpio 17 at a rate of 50 times per second.
+transmitted on GPIO 17 at a rate of 50 times per second.
.br
-This will command a servo connected to gpio 17 to rotate to its mid-point.
+This will command a servo connected to GPIO 17 to rotate to its mid-point.
.br
.br
-.IP "\fBSLR u num\fP - Read bit bang serial data from gpio"
+.IP "\fBSLR u num\fP - Read bit bang serial data from GPIO"
.IP "" 4
.br
This command returns up to \fBnum\fP bytes of bit bang serial data
-read from gpio \fBu\fP.
+read from GPIO \fBu\fP.
.br
Upon success the count of returned bytes followed by the bytes themselves
is returned. On error a negative status code will be returned.
.br
-The gpio \fBu\fP should have been initialised with the \fBSLRO\fP command.
+The GPIO \fBu\fP should have been initialised with the \fBSLRO\fP command.
.br
The bytes returned for each character depend upon the number of
.br
-.IP "\fBSLRC u\fP - Close gpio for bit bang serial data"
+.IP "\fBSLRC u\fP - Close GPIO for bit bang serial data"
.IP "" 4
.br
-This command closes gpio \fBu\fP for reading bit bang serial data.
+This command closes GPIO \fBu\fP for reading bit bang serial data.
.br
Upon success nothing is returned. On error a negative status code
.br
-38
.br
-ERROR: no serial read in progress on gpio
+ERROR: no serial read in progress on GPIO
.br
.EE
.br
This command sets the logic level for reading bit bang serial data
-on gpio \fBu\fP.
+on GPIO \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
.br
.EX
-$ pigs slri 17 1 # invert logic on gpio 17
+$ pigs slri 17 1 # invert logic on GPIO 17
.br
.br
-$ pigs slri 23 0 # use normal logic on gpio 23
+$ pigs slri 23 0 # use normal logic on GPIO 23
.br
.EE
.br
-.IP "\fBSLRO u b db\fP - Open gpio for bit bang serial data"
+.IP "\fBSLRO u b db\fP - Open GPIO for bit bang serial data"
.IP "" 4
.br
-This command opens gpio \fBu\fP for reading bit bang serial data
+This command opens GPIO \fBu\fP for reading bit bang serial data
at \fBb\fP baud and \fBdb\fP data bits.
.br
.br
-50
.br
-ERROR: gpio already in use
+ERROR: GPIO already in use
.br
.EE
are unlikely to work.
.br
-An auxiliary SPI device is available on the A+/B+/Pi2/Zero 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.
+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.
.br
The flags consists of the least significant 22 bits.
px is 0 if CEx is active low (default) and 1 for active high.
.br
-ux is 0 if the CEx gpio is reserved for SPI (default) and 1 otherwise.
+ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI. The
-auxiliary device is only present on the A+/B+/Pi2/Zero.
+A is 0 for the standard SPI device, 1 for the auxiliary SPI.
.br
W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
bbbbbb defines the word size in bits (0-32). The default (0)
sets 8 bits per word. Auxiliary SPI device only.
+.br
+The \fBSPIR\fP, \fBSPIW\fP, and \fBSPIX\fP commands transfer data
+packed into 1, 2, or 4 bytes according to the word size in bits.
+
+.br
+For bits 1-8 there will be one byte per character.
+.br
+For bits 9-16 there will be two bytes per character.
+.br
+For bits 17-32 there will be four bytes per character.
+
+.br
+E.g. 32 12-bit words will be transferred in 64 bytes.
+
.br
The other bits in flags should be set to zero.
.br
This command sends a trigger pulse of \fBpl\fP microseconds at level \fBL\fP
-to gpio \fBu\fP.
+to GPIO \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
will be returned.
.br
-The gpio is set to not level at the end of the pulse.
+The GPIO is set to not level at the end of the pulse.
.br
.br
-.IP "\fBW/WRITE g L\fP - Write gpio level"
+.IP "\fBW/WRITE g L\fP - Write GPIO level"
.IP "" 4
.br
-This command sets gpio \fBg\fP to level \fBL\fP. The level may be 0
+This command sets GPIO \fBg\fP to level \fBL\fP. The level may be 0
(low, off, clear) or 1 (high, on, set).
.br
.br
-.IP "\fBWDOG u v\fP - Set gpio watchdog"
+.IP "\fBWDOG u v\fP - Set GPIO watchdog"
.IP "" 4
.br
-This command sets a watchdog of \fBv\fP milliseconds on gpio \fBu\fP.
+This command sets a watchdog of \fBv\fP milliseconds on GPIO \fBu\fP.
.br
Upon success nothing is returned. On error a negative status code
The watchdog is nominally in milliseconds.
.br
-One watchdog may be registered per gpio.
+One watchdog may be registered per GPIO.
.br
The watchdog may be cancelled by setting timeout to 0.
.br
-If no level change has been detected for the gpio for timeout milliseconds:-
+If no level change has been detected for the GPIO for timeout milliseconds:-
.br
-any notification for the gpio has a report written to the fifo with
+any notification for the GPIO has a report written to the fifo with
the flags set to indicate a watchdog timeout.
.br
.br
This example causes a report to be written to any notification pipes
-listening on gpio 23 whenever gpio 23 changes state or approximately
+listening on GPIO 23 whenever GPIO 23 changes state or approximately
every 9000 ms.
.br
.IP "" 4
.br
-This command adds 1 one or more triplets \fBtrips\fP of gpios on, gpios off,
+This command adds 1 one or more triplets \fBtrips\fP of GPIO on, GPIO off,
delay to the existing waveform (if any).
.br
.br
This command adds a waveform representing serial data \fBbvs\fP to
-gpio \fBu\fP at \fBb\fP baud to the existing waveform (if any).
+GPIO \fBu\fP at \fBb\fP baud to the existing waveform (if any).
The serial data starts \fBo\fP microseconds from the start of the
waveform.
.br
+.IP "\fBWVTAT \fP - Returns the current transmitting waveform"
+.IP "" 4
+
+.br
+This command returns the id of the waveform currently
+being transmitted.
+
+.br
+Returns the waveform id or one of the following special
+values:
+
+.br
+9998 - transmitted wave not found
+.br
+9999 - no wave being transmitted
+
+.br
+
+\fBExample\fP
+.br
+
+.EX
+$ pigs wvtat
+.br
+9999
+.br
+
+.EE
+
+.br
+
.IP "\fBWVBSY \fP - Check if waveform is being transmitted"
.IP "" 4
A pulse specifies
.br
-1) the gpios to be switched on at the start of the pulse.
+1) the GPIO to be switched on at the start of the pulse.
.br
-2) the gpios to be switched off at the start of the pulse.
+2) the GPIO to be switched off at the start of the pulse.
.br
3) the delay in microseconds before the next pulse.
.br
.IP "\fBbits\fP - a bit mask" 0
-A mask is used to select one or more gpios. A gpio is selected
-if bit (1<<gpio) is set in the mask.
+A mask is used to select one or more GPIO. A GPIO is selected
+if bit (1<<GPIO) is set in the mask.
.br
-E.g. a mask of 6 (binary 110) select gpios 1 and 2, a mask of
-0x103 (binary 100000011) selects gpios 0, 1, and 8.
+E.g. a mask of 6 (binary 110) select GPIO 1 and 2, a mask of
+0x103 (binary 100000011) selects GPIO 0, 1, and 8.
.br
.br
-.IP "\fBg\fP - gpio (0-53)" 0
-The command expects a gpio.
+.IP "\fBg\fP - GPIO (0-53)" 0
+The command expects a GPIO.
.br
-There are 54 General Purpose Input Outputs (gpios) named gpio0 through gpio53.
+There are 54 General Purpose Input Outputs (GPIO) named gpio0 through gpio53.
.br
They are split into two banks. Bank 1 consists of gpio0 through gpio31.
Bank 2 consists of gpio32 through gpio53.
.br
-All the gpios which are safe for the user to read and write are in bank 1.
-Not all gpios in bank 1 are safe though. Type 1 boards have 17 safe gpios.
+All the GPIO which are safe for the user to read and write are in bank 1.
+Not all GPIO in bank 1 are safe though. Type 1 boards have 17 safe GPIO.
Type 2 boards have 21. Type 3 boards have 26.
.br
See \fBHWVER\fP.
.br
-The user gpios are marked with an X in the following table.
+The user GPIO are marked with an X in the following table.
.br
.EE
.br
-You are not prevented from writing to unsafe gpios. The consequences
+You are not prevented from writing to unsafe GPIO. The consequences
of doing so range from no effect, to a crash, or corrupted data.
.br
.br
.IP "\fBL\fP - level (0-1)" 0
-The command expects a gpio level.
+The command expects a GPIO level.
.br
The command expects a mode character.
.br
-Each gpio can be configured to be in one of 8 different modes. The modes
+Each GPIO can be configured to be in one of 8 different modes. The modes
are named Input, Output, ALT0, ALT1, ALT2, ALT3, ALT4, and ALT5.
.br
The command expects a PUD character.
.br
-Each gpio can be configured to use or not use an internal pull up or
+Each GPIO can be configured to use or not use an internal pull up or
pull down resistor. This is useful to provide a default state for inputs.
.br
.br
-.IP "\fBscl\fP - user gpio (0-31)" 0
-The command expects the number of the gpio to be used for SCL
+.IP "\fBscl\fP - user GPIO (0-31)" 0
+The command expects the number of the GPIO to be used for SCL
when bit banging I2C.
.br
-.IP "\fBsda\fP - user gpio (0-31)" 0
-The command expects the number of the gpio to be used for SDA
+.IP "\fBsda\fP - user GPIO (0-31)" 0
+The command expects the number of the GPIO to be used for SDA
when bit banging I2C.
.br
.br
.IP "\fBtrips\fP - triplets" 0
-The command expects 1 or more triplets of gpios on, gpios off, delay.
+The command expects 1 or more triplets of GPIO on, GPIO off, delay.
.br
E.g. 0x400000 0 100000 0 0x400000 900000 defines two pulses as follows
.br
.EX
- gpios on gpios off delay
-0x400000 (gpio 22) 0 (None) 100000 (1/10th s)
- 0 (None) 0x400000 (gpio 22) 900000 (9/10th s)
+ GPIO on GPIO off delay
+0x400000 (GPIO 22) 0 (None) 100000 (1/10th s)
+ 0 (None) 0x400000 (GPIO 22) 900000 (9/10th s)
.EE
.br
-.IP "\fBu\fP - user gpio (0-31)" 0
-The command expects the number of a user gpio.
+.IP "\fBu\fP - user GPIO (0-31)" 0
+The command expects the number of a user GPIO.
.br
-A number of commands are restricted to gpios in bank 1,
+A number of commands are restricted to GPIO in bank 1,
in particular the PWM commands, the servo command,
the watchdog command, and the notification command.
.br
It is your responsibility to ensure that the PWM and servo commands
-are only used on safe gpios.
+are only used on safe GPIO.
.br
See \fBg\fP
.br
.SS Example
.br
-A trivial example might be useful. Suppose you want to toggle a gpio
+A trivial example might be useful. Suppose you want to toggle a GPIO
on and off as fast as possible.
.br
.br
tag 999 names the current position in the script.
.br
-w 22 1 writes 1 to gpio 22.
+w 22 1 writes 1 to GPIO 22.
.br
-w 22 0 writes 0 to gpio 22.
+w 22 0 writes 0 to GPIO 22.
.br
dcr p0 decrements parameter 0.
.br
SUB x Subtract x from accumulator A-=x; F=A
SYS str Run external script (/opt/pigpio/cgi/str) system(str); F=A
TAG L Label the current script position N/A
-WAIT x Wait for a gpio in x to change state A=wait(x); F=A
+WAIT x Wait for a GPIO in x to change state A=wait(x); F=A
X y1 y2 Exchange contents of registers y1 and y2 t=*y1;*y1=*y2;*y2=t
XA y Exchange contents of accumulator and register t=A;A=*y;*y=t
XOR x Xor x with accumulator A^=x; F=A
specified y is assumed to be a variable.
.br
-The WAIT command parameter is a bit-mask with 1 set for gpios of interest.
+The WAIT command parameter is a bit-mask with 1 set for GPIO of interest.
.br
The SYS script receives two unsigned parameters: the accumulator A and
-the current gpio levels.
+the current GPIO levels.
.br
from distutils.core import setup
setup(name='pigpio',
- version='1.27',
+ version='1.29',
author='joan',
author_email='joan@abyz.co.uk',
maintainer='joan',
if [[ $s = "" ]]; then echo "BS2 ok"; else echo "BS2 fail ($s)"; fi
s=$(pigs h)
-if [[ ${#s} = 4544 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
+if [[ ${#s} = 4593 ]]; then echo "HELP ok"; else echo "HELP fail (${#s})"; fi
s=$(pigs hwver)
if [[ $s -ne 0 ]]; then echo "HWVER ok"; else echo "HWVER fail ($s)"; fi
echo "h" >/dev/pigpio
read -t 1 s </dev/pigout
read -t 1 s </dev/pigout
-if [[ $s = "BC1 bits Clear gpios in bank 1" ]]
+if [[ $s = "BC1 bits Clear GPIO in bank 1" ]]
then echo "HELP-a ok"
else echo "HELP-a fail ($s)"
fi
echo "help" >/dev/pigpio
read -t 1 s </dev/pigout
read -t 1 s </dev/pigout
-if [[ $s = "BC1 bits Clear gpios in bank 1" ]]
+if [[ $s = "BC1 bits Clear GPIO in bank 1" ]]
then echo "HELP-b ok"
else echo "HELP-b fail ($s)"
fi