Results 1 to 6 of 6

Thread: rpi i2c

  1. #1
    Join Date
    Mar 2005
    Posts
    724

    Default rpi i2c

    quick question does g6 support the rpi builtin i2c controller I am in the process of redesigning my HAM and Server monitoring system using i2c sensors and was hoping to run it through girder instead of python.

    specifically the sda and scl pins as i want to be able to access the i2c adc and port expabder using girder if i can provide other info i can provide let me know

    Thanks,
    Yonu
    Last edited by yonu; September 29th, 2015 at 10:40 PM.

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    Unfortunately currently it uses the filesystem access method. Would the wiringPi library give you what you need? If so I'll create a wrapper for that.
    Ron
    No support through PM

  3. #3
    Join Date
    Mar 2005
    Posts
    724

    Default

    If I read the stuff on wiringpi it may work I have not used the wiringpi package before.

  4. #4
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    I've released an add-on to Girder RPI to use the wiringPi library. Please reference the library by clicking on headings below. Implemented so far:

    Setup

    • int setup (void) ;
    • int setupGpio (void) ;
    • int setupPhys (void) ;
    • int setupSys (void) ;


    Core
    • void pinMode (int pin, int mode) ;
    • void pullUpDnControl (int pin, int pud) ;
    • void digitalWrite (int pin, int value) ;
    • void pwmWrite (int pin, int value) ;
    • int digitalRead (int pin) ;


    Raspberry Pi Specifics
    • void digitalWriteByte (int value) ;
    • void pwmSetMode (int mode) ;
    • void pwmSetRange (unsigned int range) ;
    • void pwmSetClock (int divisor) ;
    • int piBoardRev (void) ;
    • int wpiPinToGpio (int wPiPin) ;
    • int physPinToGpio (int physPin) ;


    SPI Library

    • int SPISetup (int channel, int speed) ;
    • int SPIDataRW (int channel, unsigned char *data, int len) ;


    I2C Library

    • int I2CSetup (int devId) ;
    • int I2CRead (int fd) ;
    • int I2CWrite (int fd, int data) ;
    • int I2CWriteReg8 (int fd, int reg, int data) ;
    • int I2CWriteReg16 (int fd, int reg, int data) ;
    • int I2CReadReg8 (int fd, int reg) ;
    • int I2CReadReg16 (int fd, int reg) ;


    Installation
    This code lives in the girder-libluawiringpi deb.

    Code:
    sudo apt-get update
    sudo apt-get install girder-libluawiringpi wiringpi
    Example Code

    Code:
    if not luaWiringPi then     
         require('luaWiringPi')
         luaWiringPi.setup()
     end
     
    
     local w = luaWiringPi
     
    
     
    
     table.print(w)
     
    
     
    
     w.pinMode(1, w.OUTPUT)
     w.digitalWrite(1, w.HIGH)
     
    
     print("i2C setup", w.I2CSetup(1))
    Last edited by Ron; September 30th, 2015 at 01:53 PM.
    Ron
    No support through PM

  5. #5
    Join Date
    Mar 2005
    Posts
    724

    Default

    Thanks I will test it out asson as the parts arrive. out of curiosity how will girder handle events from the wrapper such as GPIO events ?

    Thanks,
    Yonu

  6. #6
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,550

    Default

    Currently these are not yet implemented. I will add them in the next release. Unfortunately the library while it allows to register a callback doesn't allow for a user_data parameter. (this makes things harder on the user of the library).
    Ron
    No support through PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •