4 Replies Latest reply on Dec 7, 2015 8:10 AM by DiegoV_Intel

    how to implements fast GPIO path

    Songer

      Hi there,

       

      I got a Xadow vibration motor board that can be simply controlled by two GPIOs.

      But after checking its schematic (http://www.seeedstudio.com/wiki/images/3/3b/Xadow-Edison_sch_v1.0.pdf) , I found that one of them, GPIO 111, is not available: "echo 111 > /sys/class/gpio/export" doesn't work and it says it's busy(Re: GPIO 111 Edison Breakout MINI).

      However, the example Arduino code provided by Xadow can make the vibration motor work.

      void setup()
      {
        vibratorInit();     //init vibrator pins
      }
      
      
      void loop()
      {
        vibratorOn();
        delay(1000);
        vibratorOff();
        delay(1000);
      }
      
      
      // blow 3 functions is about vibrator
      void vibratorInit(void) {
        pinMode(10, OUTPUT);      //10, 11 are pins os vibrator 
        pinMode(11, OUTPUT);
      }
      void vibratorOn(void) {
        digitalWrite(10, HIGH);  //turn on vibrator
        digitalWrite(11, HIGH);
      }
      void vibratorOff(void) {
        digitalWrite(10, LOW);  //turn on vibrator
        digitalWrite(11, LOW);
      }
      

       

      Looking into the detail of Edison's Aduino library, I found that in ""fast_gpio_pci.c" , there is a block of code:

      static struct fgpio_pci_info fgpio_info[] = {
        { 130, GPIO_REG_OFFSET(130) }, //IO0
        { 131, GPIO_REG_OFFSET(131) }, //IO1
        { 128, GPIO_REG_OFFSET(128) }, //IO2
        {  12, GPIO_REG_OFFSET(12) },  //IO3
        { 129, GPIO_REG_OFFSET(129) }, //IO4
        {  13, GPIO_REG_OFFSET(13) },  //IO5
        { 182, GPIO_REG_OFFSET(182) }, //IO6
        {  48, GPIO_REG_OFFSET(48) },  //IO7
        {  49, GPIO_REG_OFFSET(49) },  //IO8
        { 183, GPIO_REG_OFFSET(183) }, //IO9
        {  41, GPIO_REG_OFFSET(41) },  //IO10
        {  43, GPIO_REG_OFFSET(43) },  //IO11
        {  42, GPIO_REG_OFFSET(42) },  //IO12
        {  40, GPIO_REG_OFFSET(40) },  //IO13
        {  44, GPIO_REG_OFFSET(44) },  //IO14
        {  45, GPIO_REG_OFFSET(45) },  //IO15
        {  46, GPIO_REG_OFFSET(46) },  //IO16
        {  47, GPIO_REG_OFFSET(47) },  //IO17
        {  14, GPIO_REG_OFFSET(14) },  //IO18
        { 165, GPIO_REG_OFFSET(165) }  //IO19
      };
      

      Then I checked "gpio41" and "gpio43" in path /sys/class/gpio, yes, they were just behaving like the two expected.

      So I guess it is fast GPIO path makes it working, but I am using C++ and Eclipse, any idea to implement it in Eclipse?

       

      Songer