From 46eb4d6056bbb872467fd4ad3e403ea2c0bc76b1 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 1 Mar 2016 21:41:36 +0000 Subject: [PATCH] V47 --- command.c | 80 ++++---- pigpio.3 | 429 ++++++++++++++++++++++------------------- pigpio.c | 92 ++++++++- pigpio.h | 515 +++++++++++++++++++++++++++----------------------- pigpio.py | 440 ++++++++++++++++++++++-------------------- pigpiod.1 | 32 ++-- pigpiod_if.3 | 264 +++++++++++++------------- pigpiod_if.h | 336 ++++++++++++++++---------------- pigpiod_if2.3 | 313 +++++++++++++++++------------- pigpiod_if2.c | 5 +- pigpiod_if2.h | 364 +++++++++++++++++++---------------- pigs.1 | 411 ++++++++++++++++++++++------------------ setup.py | 2 +- x_pigs | 2 +- x_pipe | 4 +- 15 files changed, 1803 insertions(+), 1486 deletions(-) diff --git a/command.c b/command.c index 32b59de..32619ba 100644 --- a/command.c +++ b/command.c @@ -26,7 +26,7 @@ For more information, please refer to */ /* -This version is for pigpio version 46+ +This version is for pigpio version 47+ */ #include @@ -172,6 +172,7 @@ cmdInfo_t cmdInfo[]= {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 @@ -235,15 +236,15 @@ cmdInfo_t cmdInfo[]= 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\ @@ -251,11 +252,11 @@ 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\ @@ -281,8 +282,8 @@ I2CWS h b SMBus Write Byte: write byte\n\ I2CWW h r word SMBus Write Word Data: write word to register\n\ I2CZ h ... I2C multiple transactions\n\ \n\ -M/MODES g mode Set gpio mode\n\ -MG/MODEG g Get gpio mode\n\ +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\ @@ -291,24 +292,24 @@ NC h Close notification\n\ NO Request a notification\n\ NP h Pause notification\n\ \n\ -P/PWM g v Set gpio PWM value\n\ +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\ @@ -316,9 +317,9 @@ SERR h n Read bytes from serial handle\n\ SERRB h Read byte from serial handle\n\ SERW h ... Write bytes to serial handle\n\ SERWB h byte Write byte to serial handle\n\ -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\ @@ -327,10 +328,10 @@ SPIW h ... SPI write bytes to handle\n\ SPIX h ... SPI transfer bytes to handle\n\ \n\ T/TICK Get current tick\n\ -TRIG g micros l Trigger level for micros on gpio\n\ +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\ @@ -345,6 +346,7 @@ WVNEW Start a new empty wave\n\ WVSC 0,1,2 Wave get DMA control block stats\n\ WVSM 0,1,2 Wave get micros stats\n\ WVSP 0,1,2 Wave get pulses stats\n\ +WVTAT Returns the current transmitting wave\n\ WVTX wid Transmit wave as one-shot\n\ WVTXM wid wmde Transmit wave using mode\n\ WVTXR wid Transmit wave repeatedly\n\ @@ -364,8 +366,8 @@ typedef struct 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"}, @@ -400,11 +402,11 @@ static errInfo_t errInfo[]= {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"}, @@ -412,7 +414,7 @@ static errInfo_t errInfo[]= {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"}, @@ -454,10 +456,10 @@ static errInfo_t errInfo[]= {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"}, @@ -470,7 +472,7 @@ static errInfo_t errInfo[]= {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"}, diff --git a/pigpio.3 b/pigpio.3 index c4dd556..cc7264d 100644 --- a/pigpio.3 +++ b/pigpio.3 @@ -4,7 +4,7 @@ ." .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 @@ -20,7 +20,7 @@ sudo ./prog .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 @@ -29,17 +29,17 @@ pigpio is a C library for the Raspberry which allows control of the gpios. .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 @@ -49,17 +49,17 @@ o callbacks at timed intervals .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 @@ -69,7 +69,7 @@ o the construction of output waveforms with microsecond timing .br .br -o rudimentary permission control over gpios +o rudimentary permission control over GPIO .br @@ -89,11 +89,11 @@ o creating and running scripts .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 @@ -250,7 +250,7 @@ gpioTerminate(); .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 @@ -296,7 +296,7 @@ gpioSetMode(22,PI_ALT0); // Set gpio22 to alternative mode 0. .IP "\fBint gpioGetMode(unsigned gpio)\fP" .IP "" 4 -Gets the gpio mode. +Gets the GPIO mode. .br @@ -311,7 +311,7 @@ gpio: 0-53 .br .br -Returns the gpio mode if OK, otherwise PI_BAD_GPIO. +Returns the GPIO mode if OK, otherwise PI_BAD_GPIO. .br @@ -333,7 +333,7 @@ if (gpioGetMode(17) != PI_ALT0) .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 @@ -374,7 +374,7 @@ gpioSetPullUpDown(23, PI_PUD_OFF); // Clear any pull-ups/downs. .IP "\fBint gpioRead(unsigned gpio)\fP" .IP "" 4 -Reads the gpio level, on or off. +Reads the GPIO level, on or off. .br @@ -389,7 +389,7 @@ gpio: 0-53 .br .br -Returns the gpio level if OK, otherwise PI_BAD_GPIO. +Returns the GPIO level if OK, otherwise PI_BAD_GPIO. .br @@ -403,14 +403,14 @@ Arduino style: digitalRead. .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 @@ -432,7 +432,7 @@ Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL. .br .br -If PWM or servo pulses are active on the gpio they are switched off. +If PWM or servo pulses are active on the GPIO they are switched off. .br @@ -453,7 +453,7 @@ gpioWrite(24, 1); // Set gpio24 high. .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 @@ -512,7 +512,7 @@ gpioPWM(23, 0); // Sets gpio23 full off. .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 @@ -534,18 +534,18 @@ PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. .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 @@ -555,7 +555,7 @@ Normal PWM range defaults to 255. .IP "\fBint gpioSetPWMrange(unsigned user_gpio, unsigned range)\fP" .IP "" 4 -Selects the dutycycle range to be used for the gpio. Subsequent calls +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 @@ -573,13 +573,13 @@ user_gpio: 0-31 .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 @@ -623,7 +623,7 @@ gpioSetPWMrange(24, 2000); // Now 2000 is fully on .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 @@ -639,7 +639,7 @@ user_gpio: 0-31 .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 @@ -656,7 +656,7 @@ r = gpioGetPWMrange(23); .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 @@ -672,13 +672,13 @@ user_gpio: 0-31 .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 @@ -695,7 +695,7 @@ rr = gpioGetPWMrealRange(17); .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 @@ -724,13 +724,13 @@ may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). .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 @@ -808,7 +808,7 @@ gpioSetPWMfrequency(25, 100000); // Set gpio25 to highest frequency. .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 @@ -824,19 +824,19 @@ user_gpio: 0-31 .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 @@ -853,7 +853,7 @@ f = gpioGetPWMfrequency(23); // Get frequency used for gpio23. .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 @@ -885,8 +885,8 @@ to move beyond its limits. .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 @@ -970,7 +970,7 @@ e.g. gpioPWM(25, 1500) will set a 1500 us pulse. .IP "\fBint gpioGetServoPulsewidth(unsigned user_gpio)\fP" .IP "" 4 -Returns the servo pulsewidth setting for the gpio. +Returns the servo pulsewidth setting for the GPIO. .br @@ -991,7 +991,7 @@ if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO. .IP "\fBint gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f)\fP" .IP "" 4 Registers a function to be called (a callback) when the specified -gpio changes state. +GPIO changes state. .br @@ -1013,12 +1013,12 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO. .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 @@ -1028,7 +1028,7 @@ The alert may be cancelled by passing NULL as the function. .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 @@ -1097,13 +1097,13 @@ void aFunction(int gpio, int level, uint32_t tick) .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 @@ -1115,7 +1115,7 @@ gpioSetAlertFunc(4F, aFunction); .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 @@ -1139,19 +1139,19 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO. .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 @@ -1161,7 +1161,7 @@ See \fBgpioSetAlertFunc\fP for further details. .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 @@ -1188,26 +1188,26 @@ or PI_BAD_ISR_INIT. .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 @@ -1220,7 +1220,7 @@ edge, timeout, or function. .br The ISR may be cancelled by passing a NULL f, in which case the -gpio is unexported. +GPIO is unexported. .br @@ -1244,7 +1244,7 @@ interrupts only a few microseconds apart). .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 @@ -1273,14 +1273,14 @@ or PI_BAD_ISR_INIT. .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 @@ -1300,7 +1300,7 @@ otherwise PI_NO_HANDLE. .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 @@ -1395,7 +1395,7 @@ This function starts notifications on a previously opened handle. .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 @@ -1408,7 +1408,7 @@ Returns 0 if OK, otherwise PI_BAD_HANDLE. .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 @@ -1450,7 +1450,7 @@ by one for each report. .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. @@ -1464,8 +1464,8 @@ after 1h12m. .br .br -level: indicates the level of each gpio. If bit 1<= 0. .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< 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 @@ -8013,15 +8062,15 @@ A 16-bit word value. .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 @@ -8047,7 +8096,7 @@ A 16-bit word value. .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 diff --git a/pigpio.c b/pigpio.c index f8a038f..039ccc5 100644 --- a/pigpio.c +++ b/pigpio.c @@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to */ -/* pigpio version 46 */ +/* pigpio version 47 */ /* include ------------------------------------------------------- */ @@ -2181,6 +2181,8 @@ static int myDoCommand(uint32_t *p, unsigned bufSize, char *buf) } break; + case PI_CMD_WVTAT: res = gpioWaveTxAt(); break; + case PI_CMD_WVTX: res = gpioWaveTxSend(p[1], PI_WAVE_MODE_ONE_SHOT); break; @@ -4789,6 +4791,53 @@ static unsigned dmaNowAtICB(void) /* ----------------------------------------------------------------------- */ +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; @@ -8560,7 +8609,7 @@ int rawWaveAddSPI( 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; @@ -8600,27 +8649,32 @@ int rawWaveAddSPI( 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<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; @@ -8649,7 +8703,7 @@ int rawWaveAddSPI( { if (getBitInBytes(tx_bit_pos, buf, spiTxBits)) { - if (!dbv) on_bits |= (1<<(spi->mosi)); + if (!dbv) on_bits |= (1<<(spi->mosi)); dbv = 1; } else @@ -9345,6 +9399,30 @@ int gpioWaveTxBusy(void) return 0; } +/*-------------------------------------------------------------------------*/ + +int gpioWaveTxAt(void) +{ + int i, cb; + + DBG(DBG_USER, ""); + + CHECK_INITED; + + cb = dmaNowAtOCB(); + + if (cb < 0) return -cb; + + for (i=0; i= waveInfo[i].botCB) && + (cb <= waveInfo[i].topCB) ) return i; + } + + return PI_WAVE_NOT_FOUND; +} + /* ----------------------------------------------------------------------- */ int gpioWaveTxStop(void) diff --git a/pigpio.h b/pigpio.h index 3be23d4..b759488 100644 --- a/pigpio.h +++ b/pigpio.h @@ -31,31 +31,31 @@ For more information, please refer to #include #include -#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 @@ -63,9 +63,9 @@ o I2C, SPI, and serial link wrappers o creating and running scripts -*gpios* +*GPIO* -ALL gpios are identified by their Broadcom number. +ALL GPIO are identified by their Broadcom number. *Credits* @@ -110,83 +110,83 @@ gpioTerminate Stop library 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 @@ -211,6 +211,8 @@ gpioWaveTxSend Transmits a waveform gpioWaveChain Transmits a chain of waveforms +gpioWaveTxAt Returns the current transmitting waveform + gpioWaveTxBusy Checks to see if the waveform has ended gpioWaveTxStop Aborts the current waveform @@ -255,8 +257,8 @@ i2cSegments Performs multiple I2C transactions 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 @@ -282,11 +284,11 @@ serDataAvailable Returns number of bytes ready to be read 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 @@ -400,7 +402,7 @@ the maximum NUM_WAVE_CBS. OOLS are used from the bottom climbing up and from the top climbing down. -The gpio on and off settings climb up from the bottom (botOOL/numBOOL). +The 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). @@ -422,9 +424,9 @@ typedef struct 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 */ @@ -507,7 +509,7 @@ typedef void *(gpioThreadFunc_t) (void *); #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 @@ -576,11 +578,8 @@ typedef void *(gpioThreadFunc_t) (void *); #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 @@ -604,6 +603,11 @@ typedef void *(gpioThreadFunc_t) (void *); #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 @@ -809,7 +813,7 @@ D*/ /*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 @@ -833,13 +837,13 @@ D*/ /*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) @@ -853,7 +857,7 @@ D*/ /*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 @@ -875,18 +879,18 @@ D*/ /*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*/ @@ -894,7 +898,7 @@ 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 @@ -903,7 +907,7 @@ level: 0,1 Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL. -If PWM or servo pulses are active on the gpio they are switched off. +If PWM or servo pulses are active on the GPIO they are switched off. Arduino style: digitalWrite @@ -916,7 +920,7 @@ D*/ /*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. . . @@ -947,7 +951,7 @@ D*/ /*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 @@ -957,12 +961,12 @@ Returns between 0 (off) and range (fully on) if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. For normal PWM the dutycycle will be out of the defined range -for the gpio (see [*gpioGetPWMrange*]). +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. @@ -972,7 +976,7 @@ D*/ /*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). . . @@ -980,10 +984,10 @@ user_gpio: 0-31 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 @@ -1007,14 +1011,14 @@ D*/ /*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). ... @@ -1026,17 +1030,17 @@ D*/ /*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. ... @@ -1048,7 +1052,7 @@ D*/ /*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 @@ -1061,10 +1065,10 @@ PI_BAD_USER_GPIO. 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: @@ -1105,20 +1109,20 @@ D*/ /*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*]. ... @@ -1130,7 +1134,7 @@ D*/ /*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). . . @@ -1146,8 +1150,8 @@ the mid-point of rotation. You can DAMAGE a servo if you command it to move beyond its limits. The following causes an on pulse of 1500 microseconds duration to be -transmitted on gpio 17 at a rate of 50 times per second. This will -command a servo connected to gpio 17 to rotate to its mid-point. +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. @@ -1189,7 +1193,7 @@ D*/ /*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 @@ -1204,7 +1208,7 @@ D*/ 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 @@ -1213,13 +1217,13 @@ 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. @@ -1251,10 +1255,10 @@ The tick value is the time stamp of the sample in microseconds, see ... 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); ... @@ -1266,7 +1270,7 @@ int gpioSetAlertFuncEx( unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata); /*D Registers a function to be called (a callback) when the specified -gpio changes state. +GPIO changes state. . . user_gpio: 0-31 @@ -1276,13 +1280,13 @@ 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*/ @@ -1293,7 +1297,7 @@ int gpioSetISRFunc( 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 @@ -1305,24 +1309,24 @@ 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 @@ -1348,7 +1352,7 @@ int gpioSetISRFuncEx( void *userdata); /*D Registers a function to be called (a callback) whenever the specified -gpio interrupt occurs. +GPIO interrupt occurs. . . user_gpio: 0-31 @@ -1361,11 +1365,11 @@ 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*/ @@ -1379,7 +1383,7 @@ This function requests a free notification handle. Returns a handle greater than or equal to zero if OK, otherwise PI_NO_HANDLE. -A notification is a method for being notified of gpio state changes +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 @@ -1435,12 +1439,12 @@ This function starts notifications on a previously opened handle. . . 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 @@ -1461,7 +1465,7 @@ by one for each report. flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags -indicate a gpio which has had a watchdog timeout; if bit 6 is set +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. @@ -1469,11 +1473,11 @@ notification activity. tick: the number of microseconds since system boot. It wraps around after 1h12m. -level: indicates the level of each gpio. If bit 1<= 0. 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< 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 @@ -5077,11 +5110,11 @@ after this command is issued. #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 @@ -5094,7 +5127,7 @@ after this command is issued. #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 diff --git a/pigpio.py b/pigpio.py index b960fdf..b6b41d0 100644 --- a/pigpio.py +++ b/pigpio.py @@ -1,7 +1,7 @@ """ 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] @@ -11,23 +11,23 @@ o the pigpio Python module can run on Windows, Macs, or Linux 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* @@ -42,7 +42,7 @@ A number of settings are determined when the pigpio daemon is started. o the sample rate (1, 2, 4, 5, 8, or 10 us, default 5 us). -o the set of 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*]). @@ -69,7 +69,7 @@ pigpio.exceptions = True *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). @@ -78,16 +78,16 @@ sudo pigpiod Your Python program must import pigpio and create one or more instances of the pigpio.pi class. This class gives access to -a specified Pi's 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 @@ -102,62 +102,62 @@ stop Stop a Pi connection 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 @@ -184,6 +184,7 @@ wave_send_using_mode Transmits a waveform in the chosen mode wave_chain Transmits a chain of waveforms +wave_tx_at Returns the current transmitting waveform wave_tx_busy Checks to see if a waveform has ended wave_tx_stop Aborts the current waveform @@ -219,8 +220,8 @@ i2c_write_device Writes the raw I2C device 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 @@ -269,11 +270,11 @@ import threading import os import atexit -VERSION = "1.27" +VERSION = "1.29" exceptions = True -# gpio levels +# GPIO levels OFF = 0 LOW = 0 @@ -285,13 +286,13 @@ SET = 1 TIMEOUT = 2 -# gpio edges +# GPIO edges RISING_EDGE = 0 FALLING_EDGE = 1 EITHER_EDGE = 2 -# gpio modes +# GPIO modes INPUT = 0 OUTPUT = 1 @@ -302,7 +303,7 @@ ALT3 = 7 ALT4 = 3 ALT5 = 2 -# gpio Pull Up Down +# GPIO Pull Up Down PUD_OFF = 0 PUD_DOWN = 1 @@ -329,6 +330,9 @@ WAVE_MODE_REPEAT =1 WAVE_MODE_ONE_SHOT_SYNC=2 WAVE_MODE_REPEAT_SYNC =3 +WAVE_NOT_FOUND = 9998 # Transmitted wave not found. +NO_TX_WAVE = 9999 # No wave being transmitted. + # pigpio command numbers _PI_CMD_MODES= 0 @@ -454,6 +458,7 @@ _PI_CMD_FG =97 _PI_CMD_FN =98 _PI_CMD_WVTXM=100 +_PI_CMD_WVAT =101 # pigpio error numbers @@ -589,8 +594,8 @@ PI_BAD_FILTER =-125 _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"], @@ -625,9 +630,9 @@ _errors=[ [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"], @@ -635,7 +640,7 @@ _errors=[ [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"], @@ -676,11 +681,11 @@ _errors=[ [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"], @@ -693,7 +698,7 @@ _errors=[ [_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"], @@ -738,8 +743,8 @@ class pulse: """ 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. """ @@ -875,9 +880,9 @@ class _callback_ADT: """ 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 @@ -963,7 +968,7 @@ class _callback_thread(threading.Thread): 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): """ @@ -1006,7 +1011,7 @@ class _callback: 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.""" @@ -1034,22 +1039,22 @@ class pi(): 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. @@ -1075,7 +1080,7 @@ class pi(): 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. @@ -1090,7 +1095,7 @@ class pi(): def read(self, gpio): """ - Returns the gpio level. + Returns the GPIO level. gpio:= 0-53. @@ -1110,12 +1115,12 @@ class pi(): 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. ... @@ -1134,7 +1139,7 @@ class pi(): 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). @@ -1154,7 +1159,7 @@ class pi(): 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. @@ -1162,12 +1167,12 @@ class pi(): 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). ... @@ -1184,7 +1189,7 @@ class pi(): 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. @@ -1199,11 +1204,11 @@ class pi(): 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). ... @@ -1217,14 +1222,14 @@ class pi(): 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. ... @@ -1237,7 +1242,7 @@ class pi(): 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 @@ -1259,19 +1264,19 @@ class pi(): 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*]. ... @@ -1288,7 +1293,7 @@ class pi(): 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), @@ -1316,7 +1321,7 @@ class pi(): 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. @@ -1338,7 +1343,7 @@ class pi(): """ 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 @@ -1366,7 +1371,7 @@ class pi(): 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. @@ -1374,8 +1379,8 @@ class pi(): tick: the number of microseconds since system boot. It wraps around after 1h12m. - level: indicates the level of each gpio. If bit 1<=0 (as returned by 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). ... @@ -1447,27 +1452,27 @@ class pi(): 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( @@ -1475,10 +1480,10 @@ class pi(): 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<= 0. .br .IP "\fBuser_gpio\fP" 0 -0-31, a Broadcom numbered gpio. +0-31, a Broadcom numbered GPIO. .br diff --git a/pigpiod_if.h b/pigpiod_if.h index 0d2fbdc..6d4f7f3 100644 --- a/pigpiod_if.h +++ b/pigpiod_if.h @@ -30,7 +30,7 @@ For more information, please refer to #include "pigpio.h" -#define PIGPIOD_IF_VERSION 21 +#define PIGPIOD_IF_VERSION 22 /*TEXT @@ -38,27 +38,27 @@ THIS LIBRARY IS DEPRECATED. NEW CODE SHOULD BE WRITTEN TO USE THE MORE VERSATILE pigpiod_if2 LIBRARY. pigpiod_if is a C library for the Raspberry which allows control -of the 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 @@ -66,9 +66,9 @@ o I2C, SPI, and serial link wrappers 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* @@ -109,68 +109,68 @@ pigpio_stop Disconnects from the pigpio daemon 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 @@ -236,8 +236,8 @@ i2c_write_device Writes the raw I2C device 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 @@ -385,7 +385,7 @@ D*/ /*F*/ int set_mode(unsigned gpio, unsigned mode); /*D -Set the gpio mode. +Set the GPIO mode. . . gpio: 0-53. @@ -400,19 +400,19 @@ D*/ /*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. @@ -426,19 +426,19 @@ D*/ /*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. @@ -450,13 +450,13 @@ or PI_NOT_PERMITTED. 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. @@ -474,7 +474,7 @@ D*/ /*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. @@ -483,19 +483,19 @@ 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. @@ -507,11 +507,11 @@ or PI_NOT_PERMITTED. 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), @@ -525,35 +525,35 @@ D*/ /*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*/ @@ -561,7 +561,7 @@ 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. @@ -575,10 +575,10 @@ The selectable frequencies depend upon the sample rate which may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The sample rate is set when the 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. . . @@ -605,29 +605,29 @@ D*/ /*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. @@ -662,7 +662,7 @@ Then set the PWM range using [*set_PWM_range*] to 1E6/Hz. Doing this allows you to use units of microseconds when setting the servo pulsewidth. -E.g. If you want to update a servo connected to gpio 25 at 400Hz +E.g. If you want to update a servo connected to GPIO 25 at 400Hz . . set_PWM_frequency(25, 400); @@ -676,7 +676,7 @@ D*/ /*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. @@ -693,7 +693,7 @@ Get a free notification handle. Returns a handle greater than or equal to zero if OK, otherwise PI_NO_HANDLE. -A notification is a method for being notified of gpio state +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 @@ -714,12 +714,12 @@ Start notifications on a previously opened handle. . . 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 @@ -765,7 +765,7 @@ D*/ /*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. @@ -777,24 +777,24 @@ or PI_BAD_WDOG_TIMEOUT. 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. @@ -813,11 +813,11 @@ D*/ /*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. . . @@ -836,90 +836,90 @@ D*/ /*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<= 0. user_gpio:: -0-31, a Broadcom numbered gpio. +0-31, a Broadcom numbered GPIO. See [*gpio*]. diff --git a/pigpiod_if2.3 b/pigpiod_if2.3 index 44fe60e..df2afe7 100644 --- a/pigpiod_if2.3 +++ b/pigpiod_if2.3 @@ -21,7 +21,7 @@ gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt .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 @@ -31,17 +31,17 @@ of the gpios via the socket interface to the pigpio daemon. .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 @@ -51,17 +51,17 @@ o callbacks at timed intervals .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 @@ -71,7 +71,7 @@ o the construction of output waveforms with microsecond timing .br .br -o rudimentary permission control over gpios +o rudimentary permission control over GPIO .br @@ -91,11 +91,11 @@ o creating and running scripts on the pigpio daemon .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 @@ -319,7 +319,7 @@ pi: 0- (as returned by \fBpigpio_start\fP). .IP "\fBint set_mode(int pi, unsigned gpio, unsigned mode)\fP" .IP "" 4 -Set the gpio mode. +Set the GPIO mode. .br @@ -345,7 +345,7 @@ or PI_NOT_PERMITTED. .IP "\fBint get_mode(int pi, unsigned gpio)\fP" .IP "" 4 -Get the gpio mode. +Get the GPIO mode. .br @@ -362,11 +362,11 @@ gpio: 0-53. .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 @@ -390,7 +390,7 @@ or PI_NOT_PERMITTED. .IP "\fBint gpio_read(int pi, unsigned gpio)\fP" .IP "" 4 -Read the gpio level. +Read the GPIO level. .br @@ -407,11 +407,11 @@ gpio:0-53. .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 @@ -441,11 +441,11 @@ Notes .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 @@ -476,7 +476,7 @@ default range of 255. .IP "\fBint get_PWM_dutycycle(int pi, unsigned user_gpio)\fP" .IP "" 4 -Return the PWM dutycycle in use on a gpio. +Return the PWM dutycycle in use on a GPIO. .br @@ -499,23 +499,23 @@ Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO. .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 @@ -545,14 +545,14 @@ Notes .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 @@ -575,7 +575,7 @@ The real value set by set_PWM_range is (dutycycle * real range) / range. .IP "\fBint get_PWM_range(int pi, unsigned user_gpio)\fP" .IP "" 4 -Get the range of PWM values being used on the gpio. +Get the range of PWM values being used on the GPIO. .br @@ -592,18 +592,18 @@ user_gpio: 0-31. .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 @@ -620,19 +620,19 @@ user_gpio: 0-31. .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 @@ -641,7 +641,7 @@ will be approximately 250M divided by the set PWM frequency. .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 @@ -673,13 +673,13 @@ sample rate is set when the C pigpio library is started. .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 @@ -726,7 +726,7 @@ off and then back on at the new frequency. .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 @@ -743,30 +743,30 @@ user_gpio: 0-31. .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 @@ -844,7 +844,7 @@ the servo pulsewidth. .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 @@ -867,7 +867,7 @@ e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse. .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 @@ -909,7 +909,7 @@ otherwise PI_NO_HANDLE. .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 @@ -941,7 +941,7 @@ Start notifications on a previously opened handle. .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 @@ -954,7 +954,7 @@ Returns 0 if OK, otherwise PI_BAD_HANDLE. .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 @@ -1034,7 +1034,7 @@ Returns 0 if OK, otherwise PI_BAD_HANDLE. .IP "\fBint set_watchdog(int pi, unsigned user_gpio, unsigned timeout)\fP" .IP "" 4 -Sets a watchdog for a gpio. +Sets a watchdog for a GPIO. .br @@ -1064,7 +1064,7 @@ The watchdog is nominally in milliseconds. .br .br -Only one watchdog may be registered per gpio. +Only one watchdog may be registered per GPIO. .br @@ -1074,24 +1074,24 @@ The watchdog may be cancelled by setting timeout to 0. .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. @@ -1123,14 +1123,14 @@ after it was first detected. .IP "\fBint set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)\fP" .IP "" 4 -Sets a noise filter on a gpio. +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 @@ -1163,7 +1163,7 @@ such reports. .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 @@ -1179,11 +1179,11 @@ pi: 0- (as returned by \fBpigpio_start\fP). .br The returned 32 bit integer has a bit set if the corresponding -gpio is logic 1. Gpio n has bit value (1<= 0. .br .IP "\fBuser_gpio\fP" 0 -0-31, a Broadcom numbered gpio. +0-31, a Broadcom numbered GPIO. .br diff --git a/pigpiod_if2.c b/pigpiod_if2.c index e5971f2..e478ddd 100644 --- a/pigpiod_if2.c +++ b/pigpiod_if2.c @@ -25,7 +25,7 @@ OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to */ -/* PIGPIOD_IF2_VERSION 3 */ +/* PIGPIOD_IF2_VERSION 5 */ #include #include @@ -874,6 +874,9 @@ int wave_chain(int pi, char *buf, unsigned bufSize) (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);} diff --git a/pigpiod_if2.h b/pigpiod_if2.h index 51846c4..f4be0f5 100644 --- a/pigpiod_if2.h +++ b/pigpiod_if2.h @@ -30,32 +30,32 @@ For more information, please refer to #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 @@ -63,9 +63,9 @@ o I2C, SPI, and serial link wrappers 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* @@ -106,68 +106,68 @@ pigpio_stop Disconnects from a pigpio daemon 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 @@ -194,6 +194,7 @@ wave_send_using_mode Transmits a waveform in the chosen mode wave_chain Transmits a chain of waveforms +wave_tx_at Returns the current transmitting waveform wave_tx_busy Checks to see if the waveform has ended wave_tx_stop Aborts the current waveform @@ -234,8 +235,8 @@ i2c_write_device Writes the raw I2C device 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 @@ -393,7 +394,7 @@ D*/ /*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*]). @@ -409,20 +410,20 @@ D*/ /*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*]). @@ -437,20 +438,20 @@ D*/ /*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*]). @@ -463,13 +464,13 @@ or PI_NOT_PERMITTED. 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*]). @@ -488,7 +489,7 @@ D*/ /*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*]). @@ -498,19 +499,19 @@ 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(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*]). @@ -523,11 +524,11 @@ or PI_NOT_PERMITTED. 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), @@ -541,37 +542,37 @@ D*/ /*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*/ @@ -579,7 +580,7 @@ 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*]). @@ -594,10 +595,10 @@ The selectable frequencies depend upon the sample rate which may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The sample rate is set when the 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. . . @@ -624,30 +625,30 @@ D*/ /*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*]). @@ -683,7 +684,7 @@ Then set the PWM range using [*set_PWM_range*] to 1E6/Hz. Doing this allows you to use units of microseconds when setting the servo pulsewidth. -E.g. If you want to update a servo connected to gpio 25 at 400Hz +E.g. If you want to update a servo connected to GPIO 25 at 400Hz . . set_PWM_frequency(25, 400); @@ -697,7 +698,7 @@ D*/ /*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*]). @@ -719,7 +720,7 @@ 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 @@ -741,12 +742,12 @@ Start notifications on a previously opened handle. . . pi: 0- (as returned by [*pigpio_start*]). handle: 0-31 (as returned by [*notify_open*]) - bits: a mask indicating the 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 @@ -794,7 +795,7 @@ D*/ /*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*]). @@ -807,24 +808,24 @@ or PI_BAD_WDOG_TIMEOUT. 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. @@ -845,11 +846,11 @@ D*/ 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. . . @@ -869,102 +870,102 @@ D*/ /*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<= 0. user_gpio:: -0-31, a Broadcom numbered gpio. +0-31, a Broadcom numbered GPIO. See [*gpio*]. diff --git a/pigs.1 b/pigs.1 index 2340e1c..b42fd40 100644 --- a/pigs.1 +++ b/pigs.1 @@ -24,7 +24,7 @@ or .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 @@ -45,19 +45,19 @@ whereas /dev/pigpio uses the pipe interface. .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 @@ -69,9 +69,9 @@ o I2C, SPI, and serial link wrappers 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 @@ -191,10 +191,10 @@ E.g. 23 is 23 decimal, 0x100 is 256 decimal, 070 is 56 decimal. .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 @@ -206,25 +206,25 @@ will be returned. .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 @@ -236,15 +236,15 @@ will be returned. .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 @@ -271,7 +271,7 @@ $ pigs bi2cc 5 .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 @@ -285,13 +285,13 @@ o repeated starts .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 @@ -380,9 +380,9 @@ End .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 @@ -400,9 +400,9 @@ $ pigs br1 .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 @@ -420,10 +420,10 @@ $ pigs br2 .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 @@ -435,25 +435,25 @@ will be returned. .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 @@ -465,15 +465,15 @@ will be returned. .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 @@ -514,11 +514,11 @@ configuration settings to \fBv\fP. .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. @@ -529,13 +529,13 @@ after it was first detected. .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 @@ -545,11 +545,11 @@ such reports. .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 @@ -557,14 +557,14 @@ status code will be returned. .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 @@ -585,18 +585,18 @@ pigs gdc 5 .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 @@ -620,7 +620,7 @@ $ pigs gpw 9 .br -93 .br -ERROR: gpio is not in use for servo pulses +ERROR: GPIO is not in use for servo pulses .br .EE @@ -650,7 +650,7 @@ $ pigs help .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 @@ -663,11 +663,11 @@ will be returned. .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 @@ -677,20 +677,20 @@ ERROR: need password to use hardware clock 1 .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 @@ -708,13 +708,13 @@ The gpio must be one of the following. .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. @@ -752,20 +752,20 @@ ERROR: hardware PWM frequency not 1-125M .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 @@ -808,7 +808,7 @@ If the hardware revision can not be found or is not a valid hexadecimal number the command returns 0. .br -The revision number can be used to determine the assignment of gpios +The revision number can be used to determine the assignment of GPIO to pins (see \fBg\fP). .br @@ -1392,11 +1392,11 @@ End .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 @@ -1404,7 +1404,7 @@ Upon success nothing is returned. On error a negative status code will be returned. .br -Each gpio can be configured to be in one of 8 different modes. The modes +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 @@ -1437,14 +1437,14 @@ $ pigs m 4 5 # ALT 5 .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 @@ -1547,7 +1547,7 @@ Upon success nothing is returned. On error a negative status code will be returned. .br -The notification gets state changes for each gpio specified by \fBbits\fP. +The notification gets state changes for each GPIO specified by \fBbits\fP. .br @@ -1555,9 +1555,9 @@ The notification gets state changes for each gpio specified by \fBbits\fP. .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 @@ -1611,7 +1611,7 @@ ERROR: unknown handle 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. @@ -1668,11 +1668,11 @@ $ pigs np 0 .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 @@ -1692,7 +1692,7 @@ The \fBPRS\fP command may be used to change the default range of 255. .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 @@ -1746,26 +1746,26 @@ Can't resolve tag 99 .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 @@ -1782,7 +1782,7 @@ $ pigs pfg 4 .br $ pigs pfg 34 .br -ERROR: gpio not 0-31 +ERROR: GPIO not 0-31 .br -2 .br @@ -1791,9 +1791,9 @@ ERROR: gpio not 0-31 .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. @@ -1808,10 +1808,10 @@ pigpiod daemon was started. The sample rate is one of 1, 2, 4, 5, 8, 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 @@ -1886,18 +1886,18 @@ $ pigs pigpv .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 @@ -2122,18 +2122,18 @@ ERROR: unknown script id .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 @@ -2177,20 +2177,20 @@ $ pigs prrg 17 .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 @@ -2229,11 +2229,11 @@ $ pigs prs 18 1000 .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 @@ -2248,22 +2248,22 @@ The mode may be pull-down (D), pull-up (U), or off (O). .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 @@ -2275,13 +2275,13 @@ will be returned. .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 @@ -2290,11 +2290,11 @@ $ pigs r 4 # Get level of gpio 4. .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 @@ -2326,10 +2326,10 @@ $ pigs SERVO 17 1500 .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 @@ -2557,19 +2557,19 @@ $ pigs serwb 0 0xf0 .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 @@ -2597,11 +2597,11 @@ $ pigs slr 15 20 .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 @@ -2621,7 +2621,7 @@ $ pigs slrc 23 .br -38 .br -ERROR: no serial read in progress on gpio +ERROR: no serial read in progress on GPIO .br .EE @@ -2633,7 +2633,7 @@ ERROR: no serial read in progress on gpio .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 @@ -2648,22 +2648,22 @@ The invert parameter \fBv\fP is 1 for inverted signal, 0 for normal. .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 @@ -2694,7 +2694,7 @@ $ pigs slro 23 19200 8 .br -50 .br -ERROR: gpio already in use +ERROR: GPIO already in use .br .EE @@ -2749,9 +2749,10 @@ Speeds between 32kbps and 125Mbps are allowed. Speeds above 30Mbps 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. @@ -2792,11 +2793,10 @@ Mode POL PHA 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 @@ -2821,6 +2821,20 @@ device only. 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. @@ -2961,14 +2975,14 @@ $ pigs t mils 1000 t .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 @@ -2991,11 +3005,11 @@ ERROR: trigger pulse > 50 microseconds .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 @@ -3025,11 +3039,11 @@ ERROR: level not 0-1 .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 @@ -3039,16 +3053,16 @@ will be returned. 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 @@ -3072,7 +3086,7 @@ $ pigs wdog 23 9000 .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 @@ -3081,7 +3095,7 @@ every 9000 ms. .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 @@ -3119,7 +3133,7 @@ $ pigs wvag 0 0 10000 0x10 0x80 1000 0x80 0x10 9000 .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. @@ -3169,6 +3183,37 @@ $ pigs wvas 7 38400 8 2 0 0x41 0x42 .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 @@ -3421,9 +3466,9 @@ A waveform comprises of one or more pulses. 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. @@ -3806,12 +3851,12 @@ The command expects 0 or 1. .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</dev/pigpio read -t 1 s /dev/pigpio read -t 1 s