which can be quite jittery on a PI. The header includes pigpio.h and pigpiod_if2.h
To use pigpiod_if2, you need to ensure that the pigpoid is already running with sudo pigpiodo hardware timed PWM on any of GPIO 0-31
o hardware timed servo pulses on any of GPIO 0-31
o callbacks when any of GPIO 0-31 change state
o callbacks at timed intervals
o reading/writing all of the GPIO in a bank as one operation
o individually setting GPIO modes, reading and writing
o notifications when any of GPIO 0-31 change state
o the construction of output waveforms with microsecond timing
o rudimentary permission control over GPIO
o a simple interface to start and stop new threads
o I2C, SPI, and serial link wrappers
o creating and running scripts on the pigpio daemon
*GPIO*
ALL GPIO are identified by their Broadcom number.
*Notes*
The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals.
and as an example of controlling a servo
Code: Select all
IncludeFile "pigpiodf2.pbi"
gpio=4
pi = pigpio_start(0,0) ;pigpoid on local host
If pi = 0
If set_mode(pi,gpio,#PI_OUTPUT) = 0;
For a= 500 To 2500 Step 100
set_servo_pulsewidth(pi, gpio,a);
Debug get_servo_pulsewidth(pi,gpio)
Delay(200)
Next
EndIf
set_servo_pulsewidth(pi,gpio,0);
pigpio_stop(pi)
EndIf
The headers
Code: Select all
; /*
; This is free And unencumbered software released into the public domain.
;
; Anyone is free To copy, modify, publish, use, compile, sell, Or
; distribute this software, either in source code form Or As a compiled
; binary, For any purpose, commercial Or non-commercial, And by any
; means.
;
; In jurisdictions that recognize copyright laws, the author Or authors
; of this software dedicate any And all copyright interest in the
; software To the public domain. We make this dedication For the benefit
; of the public at large And To the detriment of our heirs And
; successors. We intend this dedication To be an overt act of
; relinquishment in perpetuity of all present And future rights To this
; software under copyright law.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
; EXPRESS Or IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES OF
; MERCHANTABILITY, FITNESS For A PARTICULAR PURPOSE And NONINFRINGEMENT.
; IN NO EVENT SHALL THE AUTHORS BE LIABLE For ANY CLAIM, DAMAGES Or
; OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT Or OTHERWISE,
; ARISING FROM, OUT OF Or IN CONNECTION With THE SOFTWARE Or THE USE Or
; OTHER DEALINGS IN THE SOFTWARE.
;
; For more information, please refer To <http://unlicense.org/>
; */
; pigpiod_if2 is a C library For the Raspberry which allows control
; of the GPIO via the socket Interface To the pigpio daemon.
;
; *Features*
;
; o hardware timed PWM on any of GPIO 0-31
;
; o hardware timed servo pulses on any of GPIO 0-31
;
; o callbacks when any of GPIO 0-31 change state
;
; o callbacks at timed intervals
;
; o reading/writing all of the GPIO in a bank As one operation
;
; o individually setting GPIO modes, reading And writing
;
; o notifications when any of GPIO 0-31 change state
;
; o the construction of output waveforms With microsecond timing
;
; o rudimentary permission control over GPIO
;
; o a simple Interface To start And stop new threads
;
; o I2C, SPI, And serial link wrappers
;
; o creating And running scripts on the pigpio daemon
;
; *GPIO*
;
; ALL GPIO are identified by their Broadcom number.
;
; *Notes*
;
; The PWM And servo pulses are timed using the DMA And PWM/PCM peripherals.
;
; *Usage*
;
; Include <pigpiod_if2.h> in your source files.
;
; Assuming your source is in prog.c use the following command To build
;
; . .
; gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt
; . .
;
; To run make sure the pigpio daemon is running
;
; . .
; sudo pigpiod
;
; ./prog # sudo is Not required To run programs linked To pigpiod_if2
; . .
;
; For examples see x_pigpiod_if2.c within the pigpio archive file.
;
; *Notes*
;
; All the functions which Return an int Return < 0 on error
;
; TEXT*/
;
; /*OVERVIEW
;
; ESSENTIAL
;
; pigpio_start Connects To a pigpio daemon
; pigpio_stop Disconnects from a pigpio daemon
;
; BASIC
;
; set_mode Set a GPIO mode
; get_mode Get a GPIO mode
;
; set_pull_up_down Set/clear GPIO pull up/down resistor
;
; gpio_read Read a GPIO
; gpio_write Write a GPIO
;
; PWM_(overrides_servo_commands_on_same_GPIO)
;
; set_PWM_dutycycle Start/stop PWM pulses on a GPIO
; set_PWM_frequency Configure PWM frequency For a GPIO
; set_PWM_range Configure PWM range For a GPIO
;
; get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
; get_PWM_frequency Get configured PWM frequency For a GPIO
; get_PWM_range Get configured PWM range For a GPIO
;
; get_PWM_real_range Get underlying PWM range For a GPIO
;
; Servo_(overrides_PWM_commands_on_same_GPIO)
;
; set_servo_pulsewidth Start/stop servo pulses on a GPIO
;
; get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
;
; INTERMEDIATE
;
; gpio_trigger Send a trigger pulse To a GPIO.
;
; set_watchdog Set a watchdog on a GPIO.
;
; read_bank_1 Read all GPIO in bank 1
; read_bank_2 Read all GPIO in bank 2
;
; clear_bank_1 Clear selected GPIO in bank 1
; clear_bank_2 Clear selected GPIO in bank 2
;
; set_bank_1 Set selected GPIO in bank 1
; set_bank_2 Set selected GPIO in bank 2
;
; callback Create GPIO level change callback
; callback_ex Create GPIO level change callback, extended
;
; callback_cancel Cancel a callback
;
; wait_for_edge Wait For GPIO level change
;
; start_thread Start a new thread
; stop_thread Stop a previously started thread
;
; ADVANCED
;
; notify_open Request a notification handle
; notify_begin Start notifications For selected GPIO
; notify_pause Pause notifications
; notify_close Close a notification
;
; hardware_clock Start hardware clock on supported GPIO
;
; hardware_PWM Start hardware PWM on supported GPIO
;
; set_glitch_filter Set a glitch filter on a GPIO
; set_noise_filter Set a noise filter on a GPIO
;
; set_pad_strength Sets a pads drive strength
; get_pad_strength Gets a pads drive strength
;
; shell_ Executes a shell command
;
; Custom
;
; custom_1 User custom function 1
; custom_2 User custom function 2
;
; Events
;
; event_callback Sets a callback For an event
; event_callback_ex Sets a callback For an event, extended
;
; event_callback_cancel Cancel an event callback
;
; event_trigger Triggers an event
;
; wait_for_event Wait For an event
;
; Scripts
;
; store_script Store a script
; run_script Run a stored script
; update_script Set a scripts parameters
; script_status Get script status And parameters
; stop_script Stop a running script
; delete_script Delete a stored script
;
; I2C
;
; i2c_open Opens an I2C device
; i2c_close Closes an I2C device
;
; i2c_write_quick smbus write quick
;
; i2c_read_byte smbus Read byte
; i2c_write_byte smbus write byte
;
; i2c_read_byte_data smbus Read byte Data
; i2c_write_byte_data smbus write byte Data
;
; i2c_read_word_data smbus Read word Data
; i2c_write_word_data smbus write word Data
;
; i2c_read_block_data smbus Read block Data
; i2c_write_block_data smbus write block Data
;
; i2c_read_i2c_block_data smbus Read I2C block Data
; i2c_write_i2c_block_data smbus write I2C block Data
;
; i2c_read_device Reads the raw I2C device
; i2c_write_device Writes the raw I2C device
;
; i2c_process_call smbus process call
; i2c_block_process_call smbus block process call
;
; i2c_zip Performs multiple I2C transactions
;
; I2C_BIT_BANG
;
; bb_i2c_open Opens GPIO For bit banging I2C
; bb_i2c_close Closes GPIO For bit banging I2C
;
; bb_i2c_zip Performs bit banged I2C transactions
;
; I2C/SPI_SLAVE
;
; bsc_xfer I2C/SPI As slave transfer
; bsc_i2c I2C As slave transfer
;
; SERIAL
;
; serial_open Opens a serial device
; serial_close Closes a serial device
;
; serial_read_byte Reads a byte from a serial device
; serial_write_byte Writes a byte To a serial device
;
; serial_read Reads bytes from a serial device
; serial_write Writes bytes To a serial device
;
; serial_data_available Returns number of bytes ready To be Read
;
; SERIAL_BIT_BANG_(read_only)
;
; bb_serial_read_open Opens a GPIO For bit bang serial reads
; bb_serial_read_close Closes a GPIO For bit bang serial reads
;
; bb_serial_invert Invert serial logic (1 invert, 0 normal)
;
; bb_serial_read Reads bit bang serial Data from a GPIO
;
; SPI
;
; spi_open Opens a SPI device
; spi_close Closes a SPI device
;
; spi_read Reads bytes from a SPI device
; spi_write Writes bytes To a SPI device
; spi_xfer Transfers bytes With a SPI device
;
; SPI_BIT_BANG
;
; bb_spi_open Opens GPIO For bit banging SPI
; bb_spi_close Closes GPIO For bit banging SPI
;
; bb_spi_xfer Transfers bytes With bit banging SPI
;
; FILES
;
; file_open Opens a file
; file_close Closes a file
;
; file_read Reads bytes from a file
; file_write Writes bytes To a file
;
; file_seek Seeks To a position within a file
;
; file_list List files which match a pattern
;
; WAVES
;
; wave_clear Deletes all waveforms
;
; wave_add_new Starts a new waveform
; wave_add_generic Adds a series of pulses To the waveform
; wave_add_serial Adds serial Data To the waveform
;
; wave_create Creates a waveform from added Data
; wave_create_and_pad Creates a waveform of fixed size from added Data
; wave_delete Deletes one Or more waveforms
;
; wave_send_once Transmits a waveform once
; wave_send_repeat Transmits a waveform repeatedly
; wave_send_using_mode Transmits a waveform in the chosen mode
;
; wave_chain Transmits a chain of waveforms
;
; wave_tx_at Returns the current transmitting waveform
;
; wave_tx_busy Checks To see If the waveform has ended
;
; wave_tx_stop Aborts the current waveform
;
; wave_get_cbs Length in cbs of the current waveform
; wave_get_high_cbs Length of longest waveform so far
; wave_get_max_cbs Absolute maximum allowed cbs
;
; wave_get_micros Length in micros of the current waveform
; wave_get_high_micros Length of longest waveform so far
; wave_get_max_micros Absolute maximum allowed micros
;
; wave_get_pulses Length in pulses of the current waveform
; wave_get_high_pulses Length of longest waveform so far
; wave_get_max_pulses Absolute maximum allowed pulses
;
; UTILITIES
;
; get_current_tick Get current tick (microseconds)
;
; get_hardware_revision Get hardware revision
; get_pigpio_version Get the pigpio version
; pigpiod_if_version Get the pigpiod_if2 version
;
; pigpio_error Get a text description of an error code.
;
; time_sleep Sleeps For a float number of seconds
; time_time Float number of seconds since the epoch
;
; OVERVIEW*/
;#427 "/usr/incude/pigpio.h"
;-structures
Structure gpioHeader_t
func.u;
size.u;
EndStructure;
Structure gpioExtent_t;
size.l;
*ptr;
uData.l;
EndStructure;
Structure gpioSample_t;
tick.l;
level.l;
EndStructure;
Structure gpioReport_t;
seqno.u;
fags.u;
tick.l
level.l
EndStructure;
Structure gpioPulse_t;
gpioOn.l
gpioOff.l
usDelay.l
EndStructure;
Structure rawWave_t
qpioOn.l
gpioOff.l
usDelay.l
flags.l
EndStructure;
;;#485 "/usr/incude/pigpio.h"
Structure rawWaveInfo_t;
botCB.u;
topCB.u;
botOO.u;
topOO.u;
deleted.u;
numCB.u;
numBOO.u;
numTOO.u;
EndStructure;
Structure rawSPI_t
clk.l
mosi.l
miso.l
ss_po.l
ss_us.l
clk_po.l
clk_pha.l
clk_us.l
EndStructure;
Structure rawCbs_t;
info.l
src.l
dst.l
length.l
stride.l
nNext.l
pad.l[2]
EndStructure;
Structure pi_i2c_msg_t;
addr.w;
fags.w;
len.w;
*buf;
EndStructure;
Structure bsc_xfer_t;
control.l
rxCnt.l
rxBuf.a[512];
txCnt.l
txBuf.a[512];
EndStructure;
;-gpio prototypes
PrototypeC gpioAlertFunc_t(gpio,level,tick);
PrototypeC gpioAlertFuncEx_t(gpio,level,tick, *userdata);
PrototypeC eventFunc_t(event,tick);
PrototypeC eventFuncEx_t(event,tick, *userdata);
PrototypeC gpioISRFunc_t(gpio,level,tick);
PrototypeC gpioISRFuncEx_t(gpio,level,tick, *userdata);
PrototypeC gpioTimerFunc_t();
PrototypeC gpioTimerFuncEx_t( *userdata);
PrototypeC gpioSignalFunc_t(signum);
PrototypeC gpioSignalFuncEx_t(signum, *userdata);
PrototypeC gpioGetSamplesFunc_t(*samples.gpioSample_t,numSamples);
PrototypeC gpioGetSamplesFuncEx_t(*samples.gpioSample_t,numSamples, *userdata);
PrototypeC gpioThreadFunc_t();
;-Import pigpio
ImportC "-lpigpio"
;#959 "/usr/incude/pigpio.h"
gpioInitialise();
;#988 "/usr/incude/pigpio.h"
gpioTerminate();
;#1006 "/usr/incude/pigpio.h"
gpioSetMode(gpio,mode);
;#1032 "/usr/incude/pigpio.h"
gpioGetMode(gpio);
;#1052 "/usr/incude/pigpio.h"
gpioSetPullUpDown(gpio,pud);
;#1074 "/usr/incude/pigpio.h"
gpioRead(gpio);
;#1093 "/usr/incude/pigpio.h"
gpioWrite(gpio,level);
;#1115 "/usr/incude/pigpio.h"
gpioPWM(user_gpio,dutycycle);
;#1146 "/usr/incude/pigpio.h"
gpioGetPWMdutycycle(user_gpio);
;#1171 "/usr/incude/pigpio.h"
gpioSetPWMrange(user_gpio,range);
;#1206 "/usr/incude/pigpio.h"
gpioGetPWMrange(user_gpio);
;#1225 "/usr/incude/pigpio.h"
gpioGetPWMrealRange(user_gpio);
;#1247 "/usr/incude/pigpio.h"
gpioSetPWMfrequency(user_gpio,frequency);
;#1304 "/usr/incude/pigpio.h"
gpioGetPWMfrequency(user_gpio);
;#1329 "/usr/incude/pigpio.h"
gpioServo(user_gpio, pulsewidth);
;#1388 "/usr/incude/pigpio.h"
gpioGetServoPulsewidth(user_gpio);
;#1402 "/usr/incude/pigpio.h"
gpioSetAlertFunc(user_gpio,*f.gpioAlertFunc_t);
;#1483 "/usr/incude/pigpio.h"
gpioSetAlertFuncEx(user_gpio,*f.gpioAlertFuncEx_t,*userdata=0);
;#1526 "/usr/incude/pigpio.h"
gpioSetISRFunc(gpio,edge,timeout,*f.gpioISRFunc_t);
;#1591 "/usr/incude/pigpio.h"
gpioSetISRFuncEx(gpio,edge,timeout,*f.gpioISRFuncEx_t,*userdata=0);
;#1639 "/usr/incude/pigpio.h"
gpioNotifyOpen();
;#1684 "/usr/incude/pigpio.h"
gpioNotifyOpenWithSize(bufSize);
;#1696 "/usr/incude/pigpio.h"
gpioNotifyBegin(handle,bits);
;#1758 "/usr/incude/pigpio.h"
gpioNotifyPause(handle);
;#1778 "/usr/incude/pigpio.h"
gpioNotifyClose(handle);
;#1796 "/usr/incude/pigpio.h"
gpioWaveClear();
;#1810 "/usr/incude/pigpio.h"
gpioWaveAddNew();
;#1826 "/usr/incude/pigpio.h"
gpioWaveAddGeneric(numPulses,*pulses.gpioPulse_t);
;#1885 "/usr/incude/pigpio.h"
gpioWaveAddSerial(user_gpio,baud,data_bits,stop_bits,offset,numBytes,*buf);
;#1949 "/usr/incude/pigpio.h"
gpioWaveCreate();
;#2004 "/usr/incude/pigpio.h"
gpioWaveCreatePad(pctCB,pctBOOl,pctTOOl);
;#2047 "/usr/incude/pigpio.h"
gpioWaveDelete(wave_id);
;#2071 "/usr/incude/pigpio.h"
gpioWaveTxSend(wave_id, wave_mode);
;#2095 "/usr/incude/pigpio.h"
gpioWaveChain(*buf,bufSize);
;#2193 "/usr/incude/pigpio.h"
gpioWaveTxAt();
;#2206 "/usr/incude/pigpio.h"
gpioWaveTxBusy();
;#2216 "/usr/incude/pigpio.h"
gpioWaveTxStop();
;#2227 "/usr/incude/pigpio.h"
gpioWaveGetMicros();
gpioWaveGetHighMicros();
gpioWaveGetMaxMicros();
gpioWaveGetPulses();
gpioWaveGetHighPulses();
gpioWaveGetMaxPulses();
gpioWaveGetCbs();
gpioWaveGetHighCbs();
gpioWaveGetMaxCbs();
gpioSerialReadOpen(user_gpio, baud, data_bits);
;#2318 "/usr/incude/pigpio.h"
gpioSerialReadInvert(user_gpio, invert);
;#2339 "/usr/incude/pigpio.h"
gpioSerialRead(user_gpio,*buf,bufSize.i);
;#2363 "/usr/incude/pigpio.h"
gpioSerialReadClose(user_gpio);
;#2375 "/usr/incude/pigpio.h"
i2cOpen(i2cBus, i2cAddr, i2cFags);
;#2418 "/usr/incude/pigpio.h"
i2cCose(handle);
;#2431 "/usr/incude/pigpio.h"
i2cWriteQuick(handle, bit);
;#2452 "/usr/incude/pigpio.h"
i2cWriteByte(handle, bVal);
;#2472 "/usr/incude/pigpio.h"
i2cReadByte(handle);
;#2491 "/usr/incude/pigpio.h"
i2cWriteByteData(handle, i2cReg, bVal);
;#2513 "/usr/incude/pigpio.h"
i2cWriteWordData(handle, i2cReg, wVal);
;#2535 "/usr/incude/pigpio.h"
i2cReadByteData(handle, i2cReg);
;#2556 "/usr/incude/pigpio.h"
i2cReadWordData(handle, i2cReg);
;#2577 "/usr/incude/pigpio.h"
i2cProcessCall(handle, i2cReg, wVal);
;#2600 "/usr/incude/pigpio.h"
i2cWriteBlockData(handle, i2cReg,*buf, count);
;#2625 "/usr/incude/pigpio.h"
i2cReadBockData(handle, i2cReg,*buf);
;#2650 "/usr/incude/pigpio.h"
i2cBockProcessCall(handle, i2cReg,*buf, count);
;#2680 "/usr/incude/pigpio.h"
i2cReadI2CBlockData(handle, i2cReg,*buf, count);
;#2704 "/usr/incude/pigpio.h"
i2cWriteI2CBlockData(handle, i2cReg,*buf, count);
;#2726 "/usr/incude/pigpio.h"
i2cReadDevice(handle,*buf, count);
;#2746 "/usr/incude/pigpio.h"
i2cWriteDevice(handle,*buf, count);
;#2765 "/usr/incude/pigpio.h"
i2cSwitchCombined(setting);
;#2780 "/usr/incude/pigpio.h"
i2cSegments(handle,*seg.pi_i2c_msg_t,numSegs);
;#2795 "/usr/incude/pigpio.h"
i2cZip(handle,*inBuf,inlen,*outBuf,outlen);
;#2855 "/usr/incude/pigpio.h"
bbI2COpen(SDA, SC, baud);
;#2884 "/usr/incude/pigpio.h"
bbI2CClose(SDA);
;#2897 "/usr/incude/pigpio.h"
bbI2CZip(SDA,*inBuf,inlen,*outBuf,outlen);
;#2968 "/usr/incude/pigpio.h"
bscXfer(*bsc_xfer);
;#3115 "/usr/incude/pigpio.h"
bbSPIOpen(CS, MISO, MOSI, SCK,baud, spiFags);
;#3171 "/usr/incude/pigpio.h"
bbSPIClose(CS);
;#3184 "/usr/incude/pigpio.h"
bbSPIXfer(CS,*inBuf,*outBuf,count);
;#3270 "/usr/incude/pigpio.h"
spiOpen(spiChan, baud, spiFags);
;#3362 "/usr/incude/pigpio.h"
spiClose(handle);
;#3375 "/usr/incude/pigpio.h"
spiRead(handle,*buf, count);
;#3392 "/usr/incude/pigpio.h"
spiWrite(handle,*buf, count);
;#3408 "/usr/incude/pigpio.h"
spiXfer(handle,*txBuf,*rxBuf, count);
;#3427 "/usr/incude/pigpio.h"
serOpen(*sertty, baud, serFags);
;#3451 "/usr/incude/pigpio.h"
serClose(handle);
;#3463 "/usr/incude/pigpio.h"
serWriteByte(handle, bVal);
;#3476 "/usr/incude/pigpio.h"
serReadByte(handle);
;#3491 "/usr/incude/pigpio.h"
serWrite(handle,*buf, count);
;#3508 "/usr/incude/pigpio.h"
serRead(handle,*buf, count);
;#3527 "/usr/incude/pigpio.h"
serDataAvaiabe(handle);
;#3542 "/usr/incude/pigpio.h"
gpioTrigger(user_gpio, pulselen,level);
;#3559 "/usr/incude/pigpio.h"
gpioSetWatchdog(user_gpio, timeout);
;#3603 "/usr/incude/pigpio.h"
gpioNoiseFilter(user_gpio, steady, active);
;#3635 "/usr/incude/pigpio.h"
gpioGlitchFilter(user_gpio, steady);
;#3665 "/usr/incude/pigpio.h"
gpioSetGetSamplesFunc(*f.gpioGetSamplesFunc_t,bits);
;#3694 "/usr/incude/pigpio.h"
gpioSetGetSamplesFuncEx(*f.gpioGetSamplesFuncEx_t,bits,*userdata);
;#3719 "/usr/incude/pigpio.h"
gpioSetTimerFunc(timer, millis,*f.gpioTimerFunc_t);
;#3750 "/usr/incude/pigpio.h"
gpioSetTimerFuncEx(timer,millis,*f.gpioTimerFuncEx_t,*userdata);
;#3774 "/usr/incude/pigpio.h"
gpioStartThread(*f.gpioThreadFunc_t,*userdata);
;#3828 "/usr/incude/pigpio.h"
gpioStopThread(*pth);
;#3843 "/usr/incude/pigpio.h"
gpioStoreScript(*script);
;#3859 "/usr/incude/pigpio.h"
gpioRunScript(script_id, numPar,*param);
;#3879 "/usr/incude/pigpio.h"
gpioUpdateScript(script_id, numPar,*param);
;#3900 "/usr/incude/pigpio.h"
gpioScriptStatus(script_id,*param);
;#3928 "/usr/incude/pigpio.h"
gpioStopScript(script_id);
;#3941 "/usr/incude/pigpio.h"
gpioDeleteScript(script_id);
;#3954 "/usr/incude/pigpio.h"
gpioSetSignalFunc(signum,*f.gpioSignalFunc_t);
;#3977 "/usr/incude/pigpio.h"
gpioSetSignalFuncEx(signum,*f.gpioSignalFuncEx_t,*userdata);
;#4000 "/usr/incude/pigpio.h"
gpioRead_Bits_0_31();
gpioRead_Bits_32_53();
gpioWrite_Bits_0_31_Clear(bits);
;#4032 "/usr/incude/pigpio.h"
gpioWrite_Bits_32_53_Clear(bits);
;#4045 "/usr/incude/pigpio.h"
gpioWrite_Bits_0_31_Set(bits);
;#4058 "/usr/incude/pigpio.h"
gpioWrite_Bits_32_53_Set(bits);
;#4075 "/usr/incude/pigpio.h"
gpioHardwareCock(gpio, ckfreq);
;#4113 "/usr/incude/pigpio.h"
gpioHardwarePWM(gpio, PWMfreq, PWMduty);
;#4165 "/usr/incude/pigpio.h"
gpioTime(timetype, *seconds, *micros);
;#4194 "/usr/incude/pigpio.h"
gpioSleep(timetype, seconds, micros);
;#4229 "/usr/incude/pigpio.h"
gpioDelay(micros);
;#4244 "/usr/incude/pigpio.h"
gpioTick();
;#4275 "/usr/incude/pigpio.h"
gpioHardwareRevision();
;#4303 "/usr/incude/pigpio.h"
gpioVersion();
gpioGetPad(pad);
;#4332 "/usr/incude/pigpio.h"
gpioSetPad(pad, padStrength);
;#4354 "/usr/incude/pigpio.h"
eventMonitor(handle, bits);
;#4383 "/usr/incude/pigpio.h"
eventSetFunc(event, *f.eventFunc_t);
;#4403 "/usr/incude/pigpio.h"
eventSetFuncEx(event,*f.eventFuncEx_t,*userdata);
;#4427 "/usr/incude/pigpio.h"
eventTrigger(event);
;#4453 "/usr/incude/pigpio.h"
shell(*scriptName,*scriptString);
;#4494 "/usr/incude/pigpio.h"
;-pragma GCC diagnostic push
;-pragma GCC diagnostic ignored "-Wcomment"
fileOpen(*file.p-UTF8, mode);
;#4604 "/usr/incude/pigpio.h"
;-pragma GCC diagnostic pop
fileClose(handle);
;#4624 "/usr/incude/pigpio.h"
fileWrite(handle,*buf, count);
;#4653 "/usr/incude/pigpio.h"
fileRead(handle,*buf, count);
;#4676 "/usr/incude/pigpio.h"
_FileSeek(handle,seekOffset, seekFrom) As "FileSeek"
;#4700 "/usr/incude/pigpio.h"
;-pragma GCC diagnostic push
;-pragma GCC diagnostic ignored "-Wcomment"
filelist(*fpat.p-UTF8,*buf, count);
;#4756 "/usr/incude/pigpio.h"
;-pragma GCC diagnostic pop
gpioCfgBufferSize(cfgMillis);
;#4795 "/usr/incude/pigpio.h"
gpioCfgClock(cfgMicros, cfgPeripheral, cfgSource);
;#4832 "/usr/incude/pigpio.h"
gpioCfgDMAchannel(DMAchannel);
;#4847 "/usr/incude/pigpio.h"
gpioCfgDMAchannels(primaryChannel, secondaryChannel);
;#4881 "/usr/incude/pigpio.h"
gpioCfgPermissions(updateMask.q);
;#4908 "/usr/incude/pigpio.h"
gpioCfgSocketPort(port);
;#4923 "/usr/incude/pigpio.h"
gpioCfgInterfaces(ifFlags);
;#4946 "/usr/incude/pigpio.h"
gpioCfgMemAlloc(memAllocMode);
;#4966 "/usr/incude/pigpio.h"
gpioCfgNetAddr(numSockAddr, *sockAddr);
;#4981 "/usr/incude/pigpio.h"
gpioCfgGetInternals();
gpioCfgSetInternals(cfgVal);
;#5001 "/usr/incude/pigpio.h"
gpioCustom1(arg1, arg2,*argx, argc);
;#5019 "/usr/incude/pigpio.h"
gpioCustom2(arg1,*argx, argc,*retBuf,retMax);
;#5043 "/usr/incude/pigpio.h"
rawWaveAddSPI(*spi,offset,spiSS,*buf,spiTxBits,spiBitFirst,spiBitast,spiBits);
;#5074 "/usr/incude/pigpio.h"
rawWaveAddGeneric(numPuses,*pulses);
;#5102 "/usr/incude/pigpio.h"
rawWaveCB();
rawWaveCBAdr(cbNum);
;#5122 "/usr/incude/pigpio.h"
rawWaveGetOO(pos);
;#5135 "/usr/incude/pigpio.h"
rawWaveSetOO(pos, Val);
;#5148 "/usr/incude/pigpio.h"
rawWaveGetOut(pos);
;#5163 "/usr/incude/pigpio.h"
rawWaveSetOut(pos, Val);
;#5178 "/usr/incude/pigpio.h"
rawWaveGetIn(pos);
;#5193 "/usr/incude/pigpio.h"
rawWaveSetIn(pos, Val);
;#5208 "/usr/incude/pigpio.h"
rawWaveInfo(wave_id);
;#5220 "/usr/incude/pigpio.h"
getBitInBytes(bitPos,*buf,numBits);
;#5234 "/usr/incude/pigpio.h"
putBitInBytes(bitPos,*buf,bit);
;#5247 "/usr/incude/pigpio.h"
time_time.d();
time_sleep(seconds.d);
;#5265 "/usr/incude/pigpio.h"
rawDumpWave();
;#5274 "/usr/incude/pigpio.h"
rawDumpScript(script_id);
EndImport
;#32 "/usr/incude/pigpiod_if2.h" 2
;#351 "/usr/incude/pigpiod_if2.h"
;-if2 prototypes
PrototypeC CBFunc_t(pi,user_gpio,level,tick);
PrototypeC CBFuncEx_t(pi,user_gpio, level,tick,*userdata);
PrototypeC evtCBFunc_t(pi,event,tick);
PrototypeC evtCBFuncEx_t(pi,event,tick,*userdata);
;-Import pigpiod_if2
ImportC "-lpigpiod_if2"
;#384 "/usr/incude/pigpiod_if2.h"
pigpio_error(errnum);
;#394 "/usr/incude/pigpiod_if2.h"
pigpiod_if_version();
start_thread(*thread_func.gpioThreadFunc_t,*userdata);
;#418 "/usr/incude/pigpiod_if2.h"
stop_thread(*pth);
;#432 "/usr/incude/pigpiod_if2.h"
pigpio_start(*addrStr,*portStr);
;#456 "/usr/incude/pigpiod_if2.h"
pigpio_stop(pi);
;#467 "/usr/incude/pigpiod_if2.h"
set_mode(pi,gpio,mode);
;#483 "/usr/incude/pigpiod_if2.h"
get_mode(pi,gpio);
;#496 "/usr/incude/pigpiod_if2.h"
set_pull_up_down(pi, gpio,pud);
;#511 "/usr/incude/pigpiod_if2.h"
gpio_read(pi,gpio);
;#524 "/usr/incude/pigpiod_if2.h"
gpio_write(pi,gpio,level);
;#543 "/usr/incude/pigpiod_if2.h"
set_PWM_dutycycle(pi,user_gpio,dutycycle);
;#562 "/usr/incude/pigpiod_if2.h"
get_PWM_dutycycle(pi,user_gpio);
;#585 "/usr/incude/pigpiod_if2.h"
set_PWM_range(pi,user_gpio,range);
;#616 "/usr/incude/pigpiod_if2.h"
get_PWM_range(pi,user_gpio);
;#633 "/usr/incude/pigpiod_if2.h"
get_PWM_real_range(pi, user_gpio);
;#654 "/usr/incude/pigpiod_if2.h"
set_PWM_frequency(pi, user_gpio, frequency);
;#704 "/usr/incude/pigpiod_if2.h"
get_PWM_frequency(pi, user_gpio);
;#727 "/usr/incude/pigpiod_if2.h"
set_servo_pulsewidth(pi, user_gpio, pulsewidth);
;#777 "/usr/incude/pigpiod_if2.h"
get_servo_pulsewidth(pi, user_gpio);
;#790 "/usr/incude/pigpiod_if2.h"
notify_open(pi);
;#816 "/usr/incude/pigpiod_if2.h"
notify_begin(pi, handle, bits);
;#867 "/usr/incude/pigpiod_if2.h"
notify_pause(pi, handle);
;#883 "/usr/incude/pigpiod_if2.h"
notify_close(pi, handle);
;#897 "/usr/incude/pigpiod_if2.h"
set_watchdog(pi, user_gpio, timeout);
;#923 "/usr/incude/pigpiod_if2.h"
set_glitch_fiter(pi, user_gpio, steady);
;#951 "/usr/incude/pigpiod_if2.h"
set_noise_fiter(pi, user_gpio, steady, active);
;#982 "/usr/incude/pigpiod_if2.h"
read_bank_1(pi);
;#995 "/usr/incude/pigpiod_if2.h"
read_bank_2(pi);
;#1008 "/usr/incude/pigpiod_if2.h"
clear_bank_1(pi, bits);
;#1025 "/usr/incude/pigpiod_if2.h"
clear_bank_2(pi, bits);
;#1042 "/usr/incude/pigpiod_if2.h"
set_bank_1(pi, bits);
;#1059 "/usr/incude/pigpiod_if2.h"
set_bank_2(pi, bits);
;#1077 "/usr/incude/pigpiod_if2.h"
hardware_clock(pi, gpio, clkfreq);
;#1117 "/usr/incude/pigpiod_if2.h"
hardware_PWM(pi, gpio, PWMfreq, PWMduty);
;#1172 "/usr/incude/pigpiod_if2.h"
get_current_tick(pi);
;#1188 "/usr/incude/pigpiod_if2.h"
get_hardware_revision(pi);
;#1215 "/usr/incude/pigpiod_if2.h"
get_pigpio_version(pi);
;#1226 "/usr/incude/pigpiod_if2.h"
wave_clear(pi);
;#1239 "/usr/incude/pigpiod_if2.h"
wave_add_new(pi);
;#1253 "/usr/incude/pigpiod_if2.h"
wave_add_generic(pi, numPulses, *pulses.gpioPulse_t);
;#1277 "/usr/incude/pigpiod_if2.h"
wave_add_serial(pi, user_gpio, baud, data_bits,stop_bits, offset, numBytes,*str);
;#1319 "/usr/incude/pigpiod_if2.h"
wave_create(pi);
;#1378 "/usr/incude/pigpiod_if2.h"
wave_create_and_pad(pi, percent);
;#1421 "/usr/incude/pigpiod_if2.h"
wave_delete(pi, wave_id);
;#1446 "/usr/incude/pigpiod_if2.h"
wave_send_once(pi, wave_id);
;#1464 "/usr/incude/pigpiod_if2.h"
wave_send_repeat(pi, wave_id);
;#1483 "/usr/incude/pigpiod_if2.h"
wave_send_using_mode(pi, wave_id, mode);
;#1514 "/usr/incude/pigpiod_if2.h"
wave_chain(pi,*buf, bufSize);
;#1610 "/usr/incude/pigpiod_if2.h"
wave_tx_at(pi);
;#1626 "/usr/incude/pigpiod_if2.h"
wave_tx_busy(pi);
;#1639 "/usr/incude/pigpiod_if2.h"
wave_tx_stop(pi);
;#1653 "/usr/incude/pigpiod_if2.h"
wave_get_micros(pi);
;#1664 "/usr/incude/pigpiod_if2.h"
wave_get_high_micros(pi);
;#1675 "/usr/incude/pigpiod_if2.h"
wave_get_max_micros(pi);
;#1686 "/usr/incude/pigpiod_if2.h"
wave_get_pulses(pi);
;#1696 "/usr/incude/pigpiod_if2.h"
wave_get_high_pulses(pi);
;#1707 "/usr/incude/pigpiod_if2.h"
wave_get_max_pulses(pi);
;#1717 "/usr/incude/pigpiod_if2.h"
wave_get_cbs(pi);
;#1728 "/usr/incude/pigpiod_if2.h"
wave_get_high_cbs(pi);
;#1739 "/usr/incude/pigpiod_if2.h"
wave_get_max_cbs(pi);
;#1750 "/usr/incude/pigpiod_if2.h"
gpio_trigger(pi, user_gpio, pulselen, level);
;#1767 "/usr/incude/pigpiod_if2.h"
store_script(pi,*script);
;#1783 "/usr/incude/pigpiod_if2.h"
run_script(pi, script_id, numPar, *param);
;#1802 "/usr/incude/pigpiod_if2.h"
update_script(pi, script_id, numPar, *param);
;#1823 "/usr/incude/pigpiod_if2.h"
script_status(pi, script_id, *param);
;#1851 "/usr/incude/pigpiod_if2.h"
stop_script(pi, script_id);
;#1864 "/usr/incude/pigpiod_if2.h"
delete_script(pi, script_id);
;#1877 "/usr/incude/pigpiod_if2.h"
bb_serial_read_open(pi, user_gpio, baud, data_bits);
;#1899 "/usr/incude/pigpiod_if2.h"
bb_serial_read(pi, user_gpio,*buf,bufSize.i);
;#1923 "/usr/incude/pigpiod_if2.h"
bb_serial_read_close(pi, user_gpio);
;#1936 "/usr/incude/pigpiod_if2.h"
bb_serial_invert(pi, user_gpio, invert);
;#1950 "/usr/incude/pigpiod_if2.h"
i2c_open(pi, i2c_bus, i2c_addr, i2c_flags);
;#1993 "/usr/incude/pigpiod_if2.h"
i2c_close(pi, hande);
;#2006 "/usr/incude/pigpiod_if2.h"
i2c_write_quick(pi, handle, bit);
;#2027 "/usr/incude/pigpiod_if2.h"
i2c_write_byte(pi, handle, bVal);
;#2047 "/usr/incude/pigpiod_if2.h"
i2c_read_byte(pi, handle);
;#2066 "/usr/incude/pigpiod_if2.h"
i2c_write_byte_data(pi, handle, i2c_reg, bVal);
;#2089 "/usr/incude/pigpiod_if2.h"
i2c_write_word_data(pi, handle, i2c_reg, wVal);
;#2112 "/usr/incude/pigpiod_if2.h"
i2c_read_byte_data(pi, handle, i2c_reg);
;#2133 "/usr/incude/pigpiod_if2.h"
i2c_read_word_data(pi, handle, i2c_reg);
;#2155 "/usr/incude/pigpiod_if2.h"
i2c_process_call(pi, handle, i2c_reg, wVal);
;#2178 "/usr/incude/pigpiod_if2.h"
i2c_write_block_data(pi, handle, i2c_reg,*buf, count);
;#2203 "/usr/incude/pigpiod_if2.h"
i2c_read_block_data(pi, handle, i2c_reg,*buf);
;#2228 "/usr/incude/pigpiod_if2.h"
i2c_block_process_call(pi, handle, i2c_reg,*buf, count);
;#2259 "/usr/incude/pigpiod_if2.h"
i2c_read_i2c_block_data(pi, handle, i2c_reg,*buf, count);
;#2284 "/usr/incude/pigpiod_if2.h"
i2c_write_i2c_block_data(pi, handle, i2c_reg,*buf, count);
;#2307 "/usr/incude/pigpiod_if2.h"
i2c_read_device(pi, handle,*buf, count);
;#2327 "/usr/incude/pigpiod_if2.h"
i2c_write_device(pi, handle,*buf, count);
;#2347 "/usr/incude/pigpiod_if2.h"
i2c_zip(pi,handle,*inBuf,inlen,*outBuf,outlen);
;#2410 "/usr/incude/pigpiod_if2.h"
bb_i2c_open(pi, SDA, SC, baud);
;#2440 "/usr/incude/pigpiod_if2.h"
bb_i2c_close(pi, SDA);
;#2454 "/usr/incude/pigpiod_if2.h"
bb_i2c_zip(pi,SDA,*inBuf,inlen,*outBuf,outlen);
;#2527 "/usr/incude/pigpiod_if2.h"
bb_spi_open(pi,CS, MISO, MOSI, SCK,baud, spi_fags);
;#2585 "/usr/incude/pigpiod_if2.h"
bb_spi_close(pi, CS);
;#2599 "/usr/incude/pigpiod_if2.h"
bb_spi_xfer(pi,CS,*txBuf,*rxBuf,count);
;#2684 "/usr/incude/pigpiod_if2.h"
spi_open(pi, spi_channel, baud, spi_flags);
;#2777 "/usr/incude/pigpiod_if2.h"
spi_close(pi, handle);
;#2790 "/usr/incude/pigpiod_if2.h"
spi_read(pi, handle,*buf, count);
;#2807 "/usr/incude/pigpiod_if2.h"
spi_write(pi, handle,*buf, count);
;#2824 "/usr/incude/pigpiod_if2.h"
spi_xfer(pi, handle,*txBuf,*rxBuf, count);
;#2844 "/usr/incude/pigpiod_if2.h"
serial_open(pi,*ser_tty, baud, ser_fags);
;#2869 "/usr/incude/pigpiod_if2.h"
serial_close(pi, handle);
;#2882 "/usr/incude/pigpiod_if2.h"
serial_write_byte(pi, handle, bVal);
;#2896 "/usr/incude/pigpiod_if2.h"
serial_read_byte(pi, handle);
;#2912 "/usr/incude/pigpiod_if2.h"
serial_write(pi, handle,*buf, count);
;#2929 "/usr/incude/pigpiod_if2.h"
serial_read(pi, handle,*buf, count);
;#2948 "/usr/incude/pigpiod_if2.h"
serial_data_available(pi, handle);
;#2963 "/usr/incude/pigpiod_if2.h"
custom_1(pi, arg1, arg2,*argx, argc);
;#2982 "/usr/incude/pigpiod_if2.h"
custom_2(pi,arg1,*argx,argc,*retBuf,retMax);
;#3006 "/usr/incude/pigpiod_if2.h"
get_pad_strength(pi, pad);
;#3029 "/usr/incude/pigpiod_if2.h"
set_pad_strength(pi, pad, padStrength);
;#3053 "/usr/incude/pigpiod_if2.h"
shell_(pi,*scriptName,*scriptString);
;#3095 "/usr/incude/pigpiod_if2.h"
;-pragma GCC diagnostic push
;-pragma GCC diagnostic ignored "-Wcomment"
file_open(pi,*file, mode);
;#3208 "/usr/incude/pigpiod_if2.h"
;-pragma GCC diagnostic pop
file_close(pi, handle);
;#3229 "/usr/incude/pigpiod_if2.h"
file_write(pi, handle,*buf, count);
;#3258 "/usr/incude/pigpiod_if2.h"
file_read(pi, handle,*buf, count);
;#3284 "/usr/incude/pigpiod_if2.h"
file_seek(pi, handle,seekOffset,seekFrom);
;#3309 "/usr/incude/pigpiod_if2.h"
;-pragma GCC diagnostic push
;-pragma GCC diagnostic ignored "-Wcomment"
file_list(pi,*fpat,*buf, count);
;#3366 "/usr/incude/pigpiod_if2.h"
;-pragma GCC diagnostic pop
callback(pi, user_gpio, edge,*f.CBFunc_t);
;#3434 "/usr/incude/pigpiod_if2.h"
callback_ex(pi, user_gpio, edge, *f.CBFuncEx_t,*userdata);
;#3471 "/usr/incude/pigpiod_if2.h"
callback_cancel(callback_id);
;#3483 "/usr/incude/pigpiod_if2.h"
wait_for_edge(pi, user_gpio, edge,timeout.d);
;#3506 "/usr/incude/pigpiod_if2.h"
bsc_xfer(pi,*bscxfer);
;#3654 "/usr/incude/pigpiod_if2.h"
bsc_i2c(pi, i2c_addr,*bscxfer);
;#3694 "/usr/incude/pigpiod_if2.h"
event_callback(pi, event,*f.evtCBFunc_t);
;#3712 "/usr/incude/pigpiod_if2.h"
event_callback_ex(pi, event, *f.evtCBFuncEx_t,*userdata);
;#3731 "/usr/incude/pigpiod_if2.h"
event_callback_cancel(callback_id);
;#3744 "/usr/incude/pigpiod_if2.h"
wait_for_event(pi,event,timeout.d);
;#3760 "/usr/incude/pigpiod_if2.h"
event_trigger(pi,event);
;#4364 "/usr/incude/pigpiod_if2.h"
EndImport
;-enums
#pigif_bad_send = -2000
#pigif_bad_recv = -2001
#pigif_bad_getaddrinfo = -2002
#pigif_bad_connect = -2003
#pigif_bad_socket = -2004
#pigif_bad_noib = -2005
#pigif_dupicate_caback = -2006
#pigif_bad_maoc = -2007
#pigif_bad_caback = -2008
#pigif_notify_faied = -2009
#pigif_caback_not_found = -2010
#pigif_unconnected_pi = -2011
#pigif_too_many_pis = -2012
;/* gpio: 0-53 */
#PI_MIN_GPIO= 0
#PI_MAX_GPIO= 53
;/* user_gpio: 0-31 */
#PI_MAX_USER_GPIO =31
;/* level: 0-1 */
#PI_OFF= 0
#PI_ON= 1
#PI_CLEAR= 0
#PI_SET= 1
#PI_LOW= 0
#PI_HIGH= 1
;/* level: only reported For GPIO time-out, see gpioSetWatchdog */
#PI_TIMEOUT= 2
;/* mode: 0-7 */
#PI_INPUT= 0
#PI_OUTPUT= 1
#PI_ALT0= 4
#PI_ALT1= 5
#PI_ALT2= 6
#PI_ALT3= 7
#PI_ALT4= 3
#PI_ALT5= 2
;/* pud: 0-2 */
#PI_PUD_OFF= 0
#PI_PUD_DOWN= 1
#PI_PUD_UP= 2
;/* dutycycle: 0-range */
#PI_DEFAULT_DUTYCYCLE_RANGE= 255
;/* range: 25-40000 */
#PI_MIN_DUTYCYCLE_RANGE= 25
#PI_MAX_DUTYCYCLE_RANGE= 40000
;/* pulsewidth: 0, 500-2500 */
#PI_SERVO_OFF= 0
#PI_MIN_SERVO_PULSEWIDTH= 500
#PI_MAX_SERVO_PULSEWIDTH= 2500
;/* hardware PWM */
#PI_HW_PWM_MIN_FREQ= 1
#PI_HW_PWM_MAX_FREQ= 125000000
#PI_HW_PWM_MAX_FREQ_2711= 187500000
#PI_HW_PWM_RANGE= 1000000
;/* hardware clock */
#PI_HW_CLK_MIN_FREQ= 4689
#PI_HW_CLK_MIN_FREQ_2711= 13184
#PI_HW_CLK_MAX_FREQ= 250000000
#PI_HW_CLK_MAX_FREQ_2711= 375000000
#PI_NOTIFY_SLOTS= 32
#PI_NTFY_FLAGS_EVENT= (1 <<7)
#PI_NTFY_FLAGS_ALIVE= (1 <<6)
#PI_NTFY_FLAGS_WDOG= (1 <<5)
Macro PI_NTFY_FLAGS_BIT(x)
(((x)<<0)&31)
EndMacro
#PI_WAVE_BLOCKS= 4
#PI_WAVE_MAX_PULSES = #PI_WAVE_BLOCKS * 3000
#PI_WAVE_MAX_CHARS = #PI_WAVE_BLOCKS * 300
#PI_BB_I2C_MIN_BAUD = 50
#PI_BB_I2C_MAX_BAUD = 500000
#PI_BB_SPI_MIN_BAUD = 50
#PI_BB_SPI_MAX_BAUD =250000
#PI_BB_SER_MIN_BAUD = 50
#PI_BB_SER_MAX_BAUD =250000
#PI_BB_SER_NORMAL =0
#PI_BB_SER_INVERT =1
#PI_WAVE_MIN_BAUD = 50
#PI_WAVE_MAX_BAUD =1000000
#PI_SPI_MIN_BAUD = 32000
#PI_SPI_MAX_BAUD =125000000
#PI_MIN_WAVE_DATABITS =1
#PI_MAX_WAVE_DATABITS =32
#PI_MIN_WAVE_HALFSTOPBITS =2
#PI_MAX_WAVE_HALFSTOPBITS =8
#PI_WAVE_MAX_MICROS = 30 * 60 * 1000000;) /* half an hour */
#PI_MAX_WAVES =250
#PI_MAX_WAVE_CYCLES =65535
#PI_MAX_WAVE_DELAY = 65535
#PI_WAVE_COUNT_PAGES =10
;/* wave tx mode */
#PI_WAVE_MODE_ONE_SHOT = 0
#PI_WAVE_MODE_REPEAT = 1
#PI_WAVE_MODE_ONE_SHOT_SYNC =2
#PI_WAVE_MODE_REPEAT_SYNC = 3
;/* special wave at Return values */
#PI_WAVE_NOT_FOUND = 9998; /* Transmitted wave Not found. */
#PI_NO_TX_WAVE = 9999 ;/* No wave being transmitted. */
;/* Files, I2C, SPI, SER */
#PI_FILE_SLOTS =16
#PI_I2C_SLOTS =512
#PI_SPI_SLOTS =32
#PI_SER_SLOTS =16
#PI_MAX_I2C_ADDR = $7F
#PI_NUM_AUX_SPI_CHANNEL = 3
#PI_NUM_STD_SPI_CHANNEL =2
#PI_MAX_I2C_DEVICE_COUNT =(1<<16)
#PI_MAX_SPI_DEVICE_COUNT =(1<<16)
;/* max pi_i2c_msg_t per transaction */
#PI_I2C_RDRW_IOCTL_MAX_MSGS = 42
;/* flags For i2cTransaction, pi_i2c_msg_t */
#PI_I2C_M_WR = $0000 ;/* write Data */
#PI_I2C_M_RD = $0001 ;/* Read Data */
#PI_I2C_M_TEN = $0010 ;/* ten bit chip address */
#PI_I2C_M_RECV_LEN = $0400 ;/* length will be first received byte */
#PI_I2C_M_NO_RD_ACK = $0800 ;/* If I2C_FUNC_PROTOCOL_MANGLING */
#PI_I2C_M_IGNORE_NAK = $1000 ;/* If I2C_FUNC_PROTOCOL_MANGLING */
#PI_I2C_M_REV_DIR_ADDR= $2000 ;/* If I2C_FUNC_PROTOCOL_MANGLING */
#PI_I2C_M_NOSTART = $4000 ;/* If I2C_FUNC_PROTOCOL_MANGLING */
;/* bbI2CZip And i2cZip commands */
#PI_I2C_END = 0
#PI_I2C_ESC = 1
#PI_I2C_START = 2
#PI_I2C_COMBINED_ON = 2
#PI_I2C_STOP = 3
#PI_I2C_COMBINED_OFF =3
#PI_I2C_ADDR = 4
#PI_I2C_FLAGS = 5
#PI_I2C_READ = 6
#PI_I2C_WRITE = 7
;/* SPI */
Macro PI_SPI_FLAGS_BITLEN(x)
((x&63)<<16)
EndMacro
Macro PI_SPI_FLAGS_RX_LSB(x)
((x&1)<<15)
EndMacro
Macro PI_SPI_FLAGS_TX_LSB(x)
((x&1)<<14)
EndMacro
Macro PI_SPI_FLAGS_3WREN(x)
((x&15)<<10)
EndMacro
Macro PI_SPI_FLAGS_3WIRE(x)
((x&1)<<9)
EndMacro
Macro PI_SPI_FLAGS_AUX_SPI(x)
((x&1)<<8)
EndMacro
Macro PI_SPI_FLAGS_RESVD(x)
((x&7)<<5)
EndMacro
Macro PI_SPI_FLAGS_CSPOLS(x)
((x&7)<<2)
EndMacro
Macro PI_SPI_FLAGS_MODE(x)
((x&3))
EndMacro
;/* BSC registers */
#BSC_DR = 0
#BSC_RSR = 1
#BSC_SLV = 2
#BSC_CR = 3
#BSC_FR = 4
#BSC_IFLS = 5
#BSC_IMSC = 6
#BSC_RIS = 7
#BSC_MIS = 8
#BSC_ICR = 9
#BSC_DMACR = 10
#BSC_TDR = 11
#BSC_GPUSTAT = 12
#BSC_HCTRL = 13
#BSC_DEBUG_I2C =14
#BSC_DEBUG_SPI= 15
#BSC_CR_TESTFIFO =2048
#BSC_CR_RXE =512
#BSC_CR_TXE =256
#BSC_CR_BRK =128
#BSC_CR_CPOL = 16
#BSC_CR_CPHA = 8
#BSC_CR_I2C = 4
#BSC_CR_SPI = 2
#BSC_CR_EN = 1
#BSC_FR_RXBUSY =32
#BSC_FR_TXFE = 16
#BSC_FR_RXFF = 8
#BSC_FR_TXFF = 4
#BSC_FR_RXFE = 2
#BSC_FR_TXBUSY = 1
;/* BSC GPIO */
#BSC_SDA = 18
#BSC_MOSI = 20
#BSC_SCL_SCLK =19
#BSC_MISO = 18
#BSC_CE_N = 21
#BSC_SDA_2711 = 10
#BSC_MOSI_2711 = 9
#BSC_SCL_SCLK_2711 =11
#BSC_MISO_2711 = 10
#BSC_CE_N_2711 = 8
;/* Longest busy delay */
#PI_MAX_BUSY_DELAY =100
;/* timeout: 0-60000 */
#PI_MIN_WDOG_TIMEOUT =0
#PI_MAX_WDOG_TIMEOUT =60000
;/* timer: 0-9 */
#PI_MIN_TIMER =0
#PI_MAX_TIMER =9
;/* millis: 10-60000 */
#PI_MIN_MS =10
#PI_MAX_MS =60000
#PI_MAX_SCRIPTS = 32
#PI_MAX_SCRIPT_TAGS = 50
#PI_MAX_SCRIPT_VARS = 150
#PI_MAX_SCRIPT_PARAMS =10
;/* script status */
#PI_SCRIPT_INITING =0
#PI_SCRIPT_HALTED = 1
#PI_SCRIPT_RUNNING= 2
#PI_SCRIPT_WAITING= 3
#PI_SCRIPT_FAILED = 4
;/* signum: 0-63 */
#PI_MIN_SIGNUM =0
#PI_MAX_SIGNUM =63
;/* timetype: 0-1 */
#PI_TIME_RELATIVE =0
#PI_TIME_ABSOLUTE =1
#PI_MAX_MICS_DELAY =1000000 ;/* 1 second */
#PI_MAX_MILS_DELAY =60000 ;/* 60 seconds */
;/* cfgMillis */
#PI_BUF_MILLIS_MIN =100
#PI_BUF_MILLIS_MAX =10000
;/* cfgMicros: 1, 2, 4, 5, 8, Or 10 */
;/* cfgPeripheral: 0-1 */
#PI_CLOCK_PWM =0
#PI_CLOCK_PCM =1
;/* DMA channel: 0-15, 15 is unset */
#PI_MIN_DMA_CHANNEL =0
#PI_MAX_DMA_CHANNEL =15
;/* port */
#PI_MIN_SOCKET_PORT =1024
#PI_MAX_SOCKET_PORT =32000
;/* ifFlags: */
#PI_DISABLE_FIFO_IF = 1
#PI_DISABLE_SOCK_IF = 2
#PI_LOCALHOST_SOCK_IF= 4
#PI_DISABLE_ALERT = 8
;/* memAllocMode */
#PI_MEM_ALLOC_AUTO = 0
#PI_MEM_ALLOC_PAGEMAP= 1
#PI_MEM_ALLOC_MAILBOX= 2
;/* filters */
#PI_MAX_STEADY = 300000
#PI_MAX_ACTIVE =1000000
;/* gpioCfgInternals */
#PI_CFG_DBG_LEVEL=0; 0 /* bits 0-3 */
#PI_CFG_ALERT_FREQ =4; 4 /* bits 4-7 */
#PI_CFG_RT_PRIORITY = (1<<8)
#PI_CFG_STATS = (1<<9)
#PI_CFG_NOSIGHANDLER = (1<<10)
#PI_CFG_ILLEGAL_VAL = (1<<11)
;/* gpioISR */
#RISING_EDGE = 0
#FALLING_EDGE= 1
#EITHER_EDGE = 2
;/* pads */
#PI_MAX_PAD =2
#PI_MIN_PAD_STRENGTH =1
#PI_MAX_PAD_STRENGTH =16
;/* files */
#PI_FILE_NONE = 0
#PI_FILE_MIN = 1
#PI_FILE_READ = 1
#PI_FILE_WRITE= 2
#PI_FILE_RW = 3
#PI_FILE_APPEND= 4
#PI_FILE_CREATE= 8
#PI_FILE_TRUNC = 16
#PI_FILE_MAX = 31
#PI_FROM_START = 0
#PI_FROM_CURRENT= 1
#PI_FROM_END = 2
;/* Allowed socket connect addresses */
#MAX_CONNECT_ADDRESSES =256
;/* events */
#PI_MAX_EVENT =31
;/* Event auto generated on BSC slave activity */
#PI_EVENT_BSC= 31
;/*DEF_S Socket Command Codes*/
#PI_CMD_MODES = 0
#PI_CMD_MODEG = 1
#PI_CMD_PUD = 2
#PI_CMD_READ = 3
#PI_CMD_WRITE= 4
#PI_CMD_PWM = 5
#PI_CMD_PRS = 6
#PI_CMD_PFS = 7
#PI_CMD_SERVO= 8
#PI_CMD_WDOG = 9
#PI_CMD_BR1 = 10
#PI_CMD_BR2 = 11
#PI_CMD_BC1 = 12
#PI_CMD_BC2 = 13
#PI_CMD_BS1 = 14
#PI_CMD_BS2 = 15
#PI_CMD_TICK = 16
#PI_CMD_HWVER =17
#PI_CMD_NO = 18
#PI_CMD_NB = 19
#PI_CMD_NP = 20
#PI_CMD_NC = 21
#PI_CMD_PRG = 22
#PI_CMD_PFG = 23
#PI_CMD_PRRG = 24
#PI_CMD_HELP = 25
#PI_CMD_PIGPV= 26
#PI_CMD_WVCLR= 27
#PI_CMD_WVAG = 28
#PI_CMD_WVAS = 29
#PI_CMD_WVGO = 30
#PI_CMD_WVGOR= 31
#PI_CMD_WVBSY= 32
#PI_CMD_WVHLT= 33
#PI_CMD_WVSM = 34
#PI_CMD_WVSP = 35
#PI_CMD_WVSC = 36
#PI_CMD_TRIG = 37
#PI_CMD_PROC = 38
#PI_CMD_PROCD= 39
#PI_CMD_PROCR= 40
#PI_CMD_PROCS= 41
#PI_CMD_SLRO = 42
#PI_CMD_SLR = 43
#PI_CMD_SLRC = 44
#PI_CMD_PROCP= 45
#PI_CMD_MICS = 46
#PI_CMD_MILS = 47
#PI_CMD_PARSE= 48
#PI_CMD_WVCRE= 49
#PI_CMD_WVDEL= 50
#PI_CMD_WVTX = 51
#PI_CMD_WVTXR= 52
#PI_CMD_WVNEW= 53
#PI_CMD_I2CO= 54
#PI_CMD_I2CC= 55
#PI_CMD_I2CRD= 56
#PI_CMD_I2CWD= 57
#PI_CMD_I2CWQ= 58
#PI_CMD_I2CRS= 59
#PI_CMD_I2CWS= 60
#PI_CMD_I2CRB= 61
#PI_CMD_I2CWB= 62
#PI_CMD_I2CRW= 63
#PI_CMD_I2CWW= 64
#PI_CMD_I2CRK= 65
#PI_CMD_I2CWK= 66
#PI_CMD_I2CRI= 67
#PI_CMD_I2CWI= 68
#PI_CMD_I2CPC= 69
#PI_CMD_I2CPK= 70
#PI_CMD_SPIO = 71
#PI_CMD_SPIC = 72
#PI_CMD_SPIR = 73
#PI_CMD_SPIW = 74
#PI_CMD_SPIX = 75
#PI_CMD_SERO = 76
#PI_CMD_SERC = 77
#PI_CMD_SERRB= 78
#PI_CMD_SERWB= 79
#PI_CMD_SERR = 80
#PI_CMD_SERW = 81
#PI_CMD_SERDA= 82
#PI_CMD_GDC = 83
#PI_CMD_GPW = 84
#PI_CMD_HC = 85
#PI_CMD_HP = 86
#PI_CMD_CF1 = 87
#PI_CMD_CF2 = 88
#PI_CMD_BI2CC =89
#PI_CMD_BI2CO =90
#PI_CMD_BI2CZ =91
#PI_CMD_I2CZ = 92
#PI_CMD_WVCHA =93
#PI_CMD_SLRI = 94
#PI_CMD_CGI = 95
#PI_CMD_CSI = 96
#PI_CMD_FG = 97
#PI_CMD_FN = 98
#PI_CMD_NOIB = 99
#PI_CMD_WVTXM =100
#PI_CMD_WVTAT =101
#PI_CMD_PADS = 102
#PI_CMD_PADG = 103
#PI_CMD_FO = 104
#PI_CMD_FC = 105
#PI_CMD_FR = 106
#PI_CMD_FW = 107
#PI_CMD_FS = 108
#PI_CMD_FL = 109
#PI_CMD_SHELL =110
#PI_CMD_BSPIC =111
#PI_CMD_BSPIO =112
#PI_CMD_BSPIX =113
#PI_CMD_BSCX =114
#PI_CMD_EVM =115
#PI_CMD_EVT = 116
#PI_CMD_PROCU =117
#PI_CMD_WVCAP =118
;/*DEF_E*/
;/* pseudo commands */
#PI_CMD_SCRIPT =800
#PI_CMD_ADD = 800
#PI_CMD_AND = 801
#PI_CMD_CALL = 802
#PI_CMD_CMDR = 803
#PI_CMD_CMDW = 804
#PI_CMD_CMP = 805
#PI_CMD_DCR = 806
#PI_CMD_DCRA = 807
#PI_CMD_DIV = 808
#PI_CMD_HALT = 809
#PI_CMD_INR = 810
#PI_CMD_INRA = 811
#PI_CMD_JM = 812
#PI_CMD_JMP = 813
#PI_CMD_JNZ = 814
#PI_CMD_JP = 815
#PI_CMD_JZ = 816
#PI_CMD_TAG = 817
#PI_CMD_LD = 818
#PI_CMD_LDA = 819
#PI_CMD_LDAB = 820
#PI_CMD_MLT = 821
#PI_CMD_MOD = 822
#PI_CMD_NOP = 823
#PI_CMD_OR = 824
#PI_CMD_POP = 825
#PI_CMD_POPA = 826
#PI_CMD_PUSH = 827
#PI_CMD_PUSHA= 828
#PI_CMD_RET = 829
#PI_CMD_RL = 830
#PI_CMD_RLA = 831
#PI_CMD_RR = 832
#PI_CMD_RRA = 833
#PI_CMD_STA = 834
#PI_CMD_STAB = 835
#PI_CMD_SUB = 836
#PI_CMD_SYS = 837
#PI_CMD_WAIT = 838
#PI_CMD_X = 839
#PI_CMD_XA = 840
#PI_CMD_XOR = 841
#PI_CMD_EVTWT= 842
;/*DEF_S Error Codes*/
#PI_INIT_FAILED = -1 ; gpioInitialise failed
#PI_BAD_USER_GPIO = -2 ; GPIO Not 0-31
#PI_BAD_GPIO = -3 ; GPIO Not 0-53
#PI_BAD_MODE = -4 ; mode Not 0-7
#PI_BAD_LEVEL = -5 ; level Not 0-1
#PI_BAD_PUD = -6 ; pud Not 0-2
#PI_BAD_PULSEWIDTH = -7 ; pulsewidth Not 0 Or 500-2500
#PI_BAD_DUTYCYCLE = -8 ; dutycycle outside set range
#PI_BAD_TIMER = -9 ; timer Not 0-9
#PI_BAD_MS = -10 ; ms Not 10-60000
#PI_BAD_TIMETYPE = -11 ; timetype Not 0-1
#PI_BAD_SECONDS = -12 ; seconds < 0
#PI_BAD_MICROS = -13 ; micros Not 0-999999
#PI_TIMER_FAILED = -14 ; gpioSetTimerFunc failed
#PI_BAD_WDOG_TIMEOUT= -15 ; timeout Not 0-60000
#PI_NO_ALERT_FUNC = -16 ; DEPRECATED
#PI_BAD_CLK_PERIPH= -17 ; clock peripheral Not 0-1
#PI_BAD_CLK_SOURCE= -18 ; DEPRECATED
#PI_BAD_CLK_MICROS= -19 ; clock micros Not 1, 2, 4, 5, 8, Or 10
#PI_BAD_BUF_MILLIS= -20 ; buf millis Not 100-10000
#PI_BAD_DUTYRANGE = -21 ; dutycycle range Not 25-40000
#PI_BAD_DUTY_RANGE= -21 ; DEPRECATED (use PI_BAD_DUTYRANGE)
#PI_BAD_SIGNUM = -22 ; signum Not 0-63
#PI_BAD_PATHNAME= -23 ; can't open pathname
#PI_NO_HANDLE = -24 ; no handle available
#PI_BAD_HANDLE = -25 ; unknown handle
#PI_BAD_IF_FLAGS = -26 ; ifFlags > 4
#PI_BAD_CHANNEL = -27 ; DMA channel Not 0-15
#PI_BAD_PRIM_CHANNEL =-27 ; DMA primary channel Not 0-15
#PI_BAD_SOCKET_PORT = -28 ; socket port Not 1024-32000
#PI_BAD_FIFO_COMMAND =-29 ; unrecognized fifo command
#PI_BAD_SECO_CHANNEL= -30 ; DMA secondary channel Not 0-15
#PI_NOT_INITIALISED = -31 ; function called before gpioInitialise
#PI_INITIALISED = -32 ; function called after gpioInitialise
#PI_BAD_WAVE_MODE = -33 ; waveform mode Not 0-3
#PI_BAD_CFG_INTERNAL =-34 ; bad parameter in gpioCfgInternals call
#PI_BAD_WAVE_BAUD = -35 ; baud rate Not 50-250K(RX)/50-1M(TX)
#PI_TOO_MANY_PULSES = -36 ; waveform has too many pulses
#PI_TOO_MANY_CHARS = -37 ; waveform has too many chars
#PI_NOT_SERIAL_GPIO = -38 ; no bit bang serial Read on GPIO
#PI_BAD_SERIAL_STRUC= -39 ; bad (null) serial Structure parameter
#PI_BAD_SERIAL_BUF = -40 ; bad (null) serial buf parameter
#PI_NOT_PERMITTED = -41 ; GPIO operation Not permitted
#PI_SOME_PERMITTED = -42 ; one Or more GPIO Not permitted
#PI_BAD_WVSC_COMMND = -43 ; bad WVSC subcommand
#PI_BAD_WVSM_COMMND = -44 ; bad WVSM subcommand
#PI_BAD_WVSP_COMMND = -45 ; bad WVSP subcommand
#PI_BAD_PULSELEN = -46 ; trigger pulse length Not 1-100
#PI_BAD_SCRIPT = -47 ; invalid script
#PI_BAD_SCRIPT_ID = -48 ; unknown script id
#PI_BAD_SER_OFFSET = -49 ; add serial Data offset > 30 minutes
#PI_GPIO_IN_USE = -50 ; GPIO already in use
#PI_BAD_SERIAL_COUNT= -51 ; must Read at least a byte at a time
#PI_BAD_PARAM_NUM = -52 ; script parameter id Not 0-9
#PI_DUP_TAG = -53 ; script has duplicate tag
#PI_TOO_MANY_TAGS = -54 ; script has too many tags
#PI_BAD_SCRIPT_CMD = -55 ; illegal script command
#PI_BAD_VAR_NUM = -56 ; script variable id Not 0-149
#PI_NO_SCRIPT_ROOM = -57 ; no more room For scripts
#PI_NO_MEMORY = -58 ; can't allocate temporary memory
#PI_SOCK_READ_FAILED= -59 ; socket Read failed
#PI_SOCK_WRIT_FAILED= -60 ; socket write failed
#PI_TOO_MANY_PARAM = -61 ; too many script parameters (> 10)
#PI_NOT_HALTED = -62 ; DEPRECATED
#PI_SCRIPT_NOT_READY= -62 ; script initialising
#PI_BAD_TAG = -63 ; script has unresolved tag
#PI_BAD_MICS_DELAY = -64 ; bad MICS Delay (too large)
#PI_BAD_MILS_DELAY = -65 ; bad MILS Delay (too large)
#PI_BAD_WAVE_ID = -66 ; non existent wave id
#PI_TOO_MANY_CBS = -67 ; No more CBs For waveform
#PI_TOO_MANY_OOL = -68 ; No more OOL For waveform
#PI_EMPTY_WAVEFORM = -69 ; attempt To create an empty waveform
#PI_NO_WAVEFORM_ID = -70 ; no more waveforms
#PI_I2C_OPEN_FAILED = -71 ; can't open I2C device
#PI_SER_OPEN_FAILED = -72 ; can't open serial device
#PI_SPI_OPEN_FAILED = -73 ; can't open SPI device
#PI_BAD_I2C_BUS = -74 ; bad I2C bus
#PI_BAD_I2C_ADDR = -75 ; bad I2C address
#PI_BAD_SPI_CHANNEL = -76 ; bad SPI channel
#PI_BAD_FLAGS = -77 ; bad i2c/spi/ser open flags
#PI_BAD_SPI_SPEED = -78 ; bad SPI speed
#PI_BAD_SER_DEVICE = -79 ; bad serial device name
#PI_BAD_SER_SPEED = -80 ; bad serial baud rate
#PI_BAD_PARAM = -81 ; bad i2c/spi/ser parameter
#PI_I2C_WRITE_FAILED= -82 ; i2c write failed
#PI_I2C_READ_FAILED = -83 ; i2c Read failed
#PI_BAD_SPI_COUNT = -84 ; bad SPI count
#PI_SER_WRITE_FAILED= -85 ; ser write failed
#PI_SER_READ_FAILED = -86 ; ser Read failed
#PI_SER_READ_NO_DATA= -87 ; ser Read no Data available
#PI_UNKNOWN_COMMAND = -88 ; unknown command
#PI_SPI_XFER_FAILED = -89 ; spi xfer/Read/write failed
#PI_BAD_POINTER = -90 ; bad (NULL) pointer
#PI_NO_AUX_SPI = -91 ; no auxiliary SPI on Pi A Or B
#PI_NOT_PWM_GPIO = -92 ; GPIO is Not in use For PWM
#PI_NOT_SERVO_GPIO = -93 ; GPIO is Not in use For servo pulses
#PI_NOT_HCLK_GPIO = -94 ; GPIO has no hardware clock
#PI_NOT_HPWM_GPIO = -95 ; GPIO has no hardware PWM
#PI_BAD_HPWM_FREQ = -96 ; invalid hardware PWM frequency
#PI_BAD_HPWM_DUTY = -97 ; hardware PWM dutycycle Not 0-1M
#PI_BAD_HCLK_FREQ = -98 ; invalid hardware clock frequency
#PI_BAD_HCLK_PASS = -99 ; need password To use hardware clock 1
#PI_HPWM_ILLEGAL =-100 ; illegal, PWM in use For main clock
#PI_BAD_DATABITS =-101 ; serial Data bits Not 1-32
#PI_BAD_STOPBITS =-102 ; serial (half) stop bits Not 2-8
#PI_MSG_TOOBIG =-103 ; socket/pipe message too big
#PI_BAD_MALLOC_MODE =-104 ; bad memory allocation mode
#PI_TOO_MANY_SEGS =-105 ; too many I2C transaction segments
#PI_BAD_I2C_SEG =-106 ; an I2C transaction segment failed
#PI_BAD_SMBUS_CMD =-107 ; SMBus command Not supported by driver
#PI_NOT_I2C_GPIO =-108 ; no bit bang I2C in progress on GPIO
#PI_BAD_I2C_WLEN =-109 ; bad I2C write length
#PI_BAD_I2C_RLEN =-110 ; bad I2C Read length
#PI_BAD_I2C_CMD =-111 ; bad I2C command
#PI_BAD_I2C_BAUD =-112 ; bad I2C baud rate, Not 50-500k
#PI_CHAIN_LOOP_CNT =-113 ; bad chain loop count
#PI_BAD_CHAIN_LOOP =-114 ; empty chain loop
#PI_CHAIN_COUNTER =-115 ; too many chain counters
#PI_BAD_CHAIN_CMD =-116 ; bad chain command
#PI_BAD_CHAIN_DELAY =-117 ; bad chain delay micros
#PI_CHAIN_NESTING =-118 ; chain counters nested too deeply
#PI_CHAIN_TOO_BIG =-119 ; chain is too long
#PI_DEPRECATED =-120 ; deprecated function removed
#PI_BAD_SER_INVERT =-121 ; bit bang serial invert Not 0 Or 1
#PI_BAD_EDGE =-122 ; bad ISR edge value, Not 0-2
#PI_BAD_ISR_INIT =-123 ; bad ISR initialisation
#PI_BAD_FOREVER =-124 ; loop ForEver must be last command
#PI_BAD_FILTER =-125 ; bad filter parameter
#PI_BAD_PAD =-126 ; bad pad number
#PI_BAD_STRENGTH =-127 ; bad pad drive strength
#PI_FIL_OPEN_FAILED =-128 ; file open failed
#PI_BAD_FILE_MODE =-129 ; bad file mode
#PI_BAD_FILE_FLAG =-130 ; bad file flag
#PI_BAD_FILE_READ =-131 ; bad file Read
#PI_BAD_FILE_WRITE =-132 ; bad file write
#PI_FILE_NOT_ROPEN =-133 ; file Not open For Read
#PI_FILE_NOT_WOPEN =-134 ; file Not open For write
#PI_BAD_FILE_SEEK =-135 ; bad file seek
#PI_NO_FILE_MATCH =-136 ; no files match pattern
#PI_NO_FILE_ACCESS =-137 ; no permission To access file
#PI_FILE_IS_A_DIR =-138 ; file is a directory
#PI_BAD_SHELL_STATUS= -139 ; bad shell Return status
#PI_BAD_SCRIPT_NAME =-140 ; bad script name
#PI_BAD_SPI_BAUD =-141 ; bad SPI baud rate, Not 50-500k
#PI_NOT_SPI_GPIO =-142 ; no bit bang SPI in progress on GPIO
#PI_BAD_EVENT_ID =-143 ; bad event id
#PI_CMD_INTERRUPTED =-144 ; Used by Python
#PI_NOT_ON_BCM2711 =-145 ; Not available on BCM2711
#PI_ONLY_ON_BCM2711 =-146 ; only available on BCM2711
#PI_PIGIF_ERR_0 = -2000
#PI_PIGIF_ERR_99 = -2099
#PI_CUSTOM_ERR_0 = -3000
#PI_CUSTOM_ERR_999= -3999
;/*DEF_E*/
;/*DEF_S Defaults*/
#PI_DEFAULT_BUFFER_MILLIS = 120
#PI_DEFAULT_CLK_MICROS = 5
#PI_DEFAULT_CLK_PERIPHERAL = #PI_CLOCK_PCM
#PI_DEFAULT_IF_FLAGS = 0
#PI_DEFAULT_FOREGROUND = 0
#PI_DEFAULT_DMA_CHANNEL = 14
#PI_DEFAULT_DMA_PRIMARY_CHANNEL = 14
#PI_DEFAULT_DMA_SECONDARY_CHANNEL= 6
#PI_DEFAULT_DMA_PRIMARY_CH_2711 = 7
#PI_DEFAULT_DMA_SECONDARY_CH_2711= 6
#PI_DEFAULT_DMA_NOT_SET = 15
#PI_DEFAULT_SOCKET_PORT = 8888
*PI_DEFAULT_SOCKET_PORT_STR = UTF8("8888")
*PI_DEFAULT_SOCKET_ADDR_STR = UTF8("localhost")
#PI_DEFAULT_UPDATE_MASK_UNKNOWN = $0000000FFFFFF
#PI_DEFAULT_UPDATE_MASK_B1 = $03E7CF93
#PI_DEFAULT_UPDATE_MASK_A_B2 = $FBC7CF9C
#PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS= $0080480FFFFFF
#PI_DEFAULT_UPDATE_MASK_ZERO = $80000FFFFFF
#PI_DEFAULT_UPDATE_MASK_PI2B = $0080480FFFFFF
#PI_DEFAULT_UPDATE_MASK_PI3B = $0000000FFFFFF
#PI_DEFAULT_UPDATE_MASK_PI4B = $0000000FFFFFF
#PI_DEFAULT_UPDATE_MASK_COMPUTE = $00FFFFFFFFFFFF
#PI_DEFAULT_MEM_ALLOC_MODE = #PI_MEM_ALLOC_AUTO
#PI_DEFAULT_CFG_INTERNALS = 0
CompilerIf #PB_Compiler_IsMainFile
#GPIO = 25
Macro bswap32(var)
CompilerIf #PB_Compiler_Backend = #PB_Backend_C
!v_#var = __builtin_bswap32(v_#var);
CompilerElse
EnableASM
mov eax, var
!bswap eax
mov var,eax
DisableASM
CompilerEndIf
EndMacro
Procedure CHECK(t,st,got,expect,pc,*desc)
If got = expect
PrintN("TEST " + Str(t) + ":" + Str(st) + " " + PeekS(*desc) + " expect " + Str(expect));
Else
PrintN("TEST " + Str(t) + ":" + Str(st) + " FAILED got " + Str(got) + " " + PeekS(*desc) + " " + Str(expect));
EndIf
EndProcedure
Procedure t0(pi)
PrintN("Testing pigpiod");
PrintN("pigpio version :" + Str(get_pigpio_version(pi)));
PrintN("Hardware revision :" + Str(get_hardware_revision(pi)));
EndProcedure
Procedure t1(pi)
Protected v;
PrintN("Mode/PUD/read/write tests");
set_mode(pi, GPIO, #PI_INPUT);
v = get_mode(pi, GPIO) ;
CHECK(1, 1, v, 0, 0, @"set mode, get mode");
set_pull_up_down(pi, GPIO, #PI_PUD_UP);
v = gpio_read(pi, GPIO) ;
CHECK(1, 2, v, 1, 0, @"set pull up down, read");
set_pull_up_down(pi, GPIO, #PI_PUD_DOWN);
v = gpio_read(pi, GPIO) ;
CHECK(1, 3, v, 1, 0, @"set pull up down, read");
gpio_write(pi, GPIO, #PI_LOW);
v = get_mode(pi, GPIO) ;
CHECK(1, 4, v, 0, 0, @"write, get mode");
v = gpio_read(pi, GPIO);
CHECK(1, 5, v, 1, 0, @"read");
gpio_write(pi, GPIO, #PI_HIGH);
v = gpio_read(pi, GPIO) ;
CHECK(1, 6, v, 1, 0, @"write, read");
pigpio_stop(pi)
pi = pigpio_start(*PI_DEFAULT_SOCKET_ADDR_STR,*PI_DEFAULT_SOCKET_PORT_STR);
CHECK(1, 7,pi,0,0,@"pigpio_start with non-default arguments") ;
EndProcedure
Procedure Servo(pi,gpio)
If set_mode(pi,gpio,#PI_OUTPUT) = 0;
For a= 500 To 2500 Step 100
set_servo_pulsewidth(pi, gpio,a);
PrintN(Str(get_servo_pulsewidth(pi,gpio)))
Delay(200)
Next
EndIf
set_servo_pulsewidth(pi, gpio,0);
EndProcedure
pi = pigpio_start(0, 0)
If pi = 0
t0(pi)
t1(pi)
servo(pi,4)
pigpio_stop(pi)
PrintN("done")
EndIf
CompilerEndIf