Contents Up Previous Next

HiPi::Wiring

This module is a thin wrapper around the excellent WiringPi library by Gordon Henderson. You can see full description and examples of using the library at:

https://projects.drogon.net/raspberry-pi/wiringpi/

The HiPi::Wiring module is built against a static build of the wiringPi library. A small patch is applied to the wiringPi source that is discussed here in the Wiring Pi Patch note.

Exported Constants

use HiPi::Wiring qw( :wiring );

The following constants are exported by this module under the :wiring tag

tag :wiring

    WPI_NUM_PINS
    WPI_MODE_PINS
    WPI_MODE_GPIO
    WPI_MODE_GPIO_SYS
    WPI_MODE_PIFACE
    WPI_INPUT 
    WPI_OUTPUT
    WPI_PWM_OUTPUT
    WPI_LOW
    WPI_HIGH
    WPI_PUD_OFF
    WPI_PUD_DOWN
    WPI_PUD_UP
    WPI_PWM_MODE_MS
    WPI_PWM_MODE_BAL
    WPI_NES_RIGHT
    WPI_NES_LEFT
    WPI_NES_DOWN
    WPI_NES_UP
    WPI_NES_START
    WPI_NES_SELECT
    WPI_NES_B
    WPI_NES_A

Wrapped Methods from the WiringPi Libary

    HiPi::Wiring::wiringPiSetup()
    HiPi::Wiring::wiringPiSetupSys()
    HiPi::Wiring::wiringPiSetupGpio()
    HiPi::Wiring::wiringPiSetupPiFace()
    HiPi::Wiring::piBoardRev()
    HiPi::Wiring::wpiPinToGpio(wpiPin)
    HiPi::Wiring::wpiPin()
    HiPi::Wiring::wiringPiSetupPiFaceForGpioProg()
    HiPi::Wiring::pinMode(pin, mode)
    HiPi::Wiring::pullUpDnControl(pin, pud)
    HiPi::Wiring::digitalWrite(pin, value)
    HiPi::Wiring::digitalWriteByte(value)
    HiPi::Wiring::pwmWrite(pin, value)
    HiPi::Wiring::setPadDrive(group, value)
    HiPi::Wiring::digitalRead(pin)
    HiPi::Wiring::delayMicroseconds(howLong)
    HiPi::Wiring::pwmSetMode(mode)
    HiPi::Wiring::pwmSetRange(range)
    HiPi::Wiring::pwmSetClock(divisor)
    HiPi::Wiring::waitForInterrupt(pin, mS)
    
    HiPi::Wiring::piLock(key)
    HiPi::Wiring::piUnlock(key)
    
    HiPi::Wiring::piHiPri(pri)
    
    HiPi::Wiring::delay(howLong)
    HiPi::Wiring::millis()
    
    HiPi::Wiring::gertboardAnalogWrite(chan, value)
    HiPi::Wiring::gertboardAnalogRead(chan)
    HiPi::Wiring::gertboardSPISetup()
    
    HiPi::Wiring::lcdHome(fd)
    HiPi::Wiring::lcdClear(fd)
    HiPi::Wiring::lcdPosition(fd, x, y)
    HiPi::Wiring::lcdPutchar(fd, data)
    HiPi::Wiring::lcdPuts(fd, putstring)
    HiPi::Wiring::lcdInit (rows, cols, bits, rs, strb, d0, d1, d2, d3, d4, d5, d6, d7)
    
    HiPi::Wiring::setupNesJoystick (dPin, cPin, lPin)
    HiPi::Wiring::readNesJoystick (joystick)
        
    HiPi::Wiring::softPwmCreate(pin, value, range)
    HiPi::Wiring::softPwmWrite(pin, value)
    
    HiPi::Wiring::softServoWrite(pin, value)
    HiPi::Wiring::softServoSetup(p0, p1, p2, p3, p4, p5, p6, p7)
    
    HiPi::Wiring::softToneCreate(pin)
    HiPi::Wiring::softToneWrite(pin, frewq)
 
    HiPi::Wiring::wiringPiI2CRead(fd)
    HiPi::Wiring::wiringPiI2CReadReg8(fd, reg)
    HiPi::Wiring::wiringPiI2CReadReg16(fd, reg)
    HiPi::Wiring::wiringPiI2CWrite(fd, data)
    HiPi::Wiring::wiringPiI2CWriteReg8(fd, reg, data)

    HiPi::Wiring::wiringPiI2CWriteReg16(fd, reg, data)
    HiPi::Wiring::wiringPiI2CSetup(devId)
 
    HiPi::Wiring::wiringPiSPIGetFd(channel)
    HiPi::Wiring::wiringPiSPIDataRW(channel, data, len)

    HiPi::Wiring::wiringPiSPISetup(channel, speed)
 
    HiPi::Wiring::serialOpen(device, baud)
    HiPi::Wiring::serialClose(fd)
    HiPi::Wiring::serialFlush(fd)
    HiPi::Wiring::serialPutchar(fd, c)
    HiPi::Wiring::serialPuts(fd, s)
    HiPi::Wiring::serialDataAvail(fd)
    HiPi::Wiring::serialGetchar(fd)
    
    HiPi::Wiring::shiftIn(dPin, cPin, order)
    HiPi::Wiring::shiftOut(dPin, cPin, order, val)

WiringPi Methods not wrapped

  wiringPiISR(int pin, int mode, void (*function)(void))
  piThreadCreate (void *(*fn)(void *))

The wiringPi library offers the above functions to C programmers for the automatic creation of threads when polling for interrupts. In Perl it would be better to implement your own interrupt handling using a combination of 'select', IO::Poll and the Perl threads module if desired. In many application designs 'select' or IO::Poll may be all that you need

  serialPrintf(int fd, char *message, ...)
  lcdPrintf(int fd, char *message, ...)

The *Printf functions are not implemented. Use sprintf to format strings in Perl before passing to the appropriate wiringPi function.





Contents Up Previous Next


HiPi Modules Copyright © 2013 Mark Dootson