Community
cancel
Showing results for 
Search instead for 
Did you mean: 
QWang16
Novice
1,410 Views

how to implements fast GPIO path

Jump to solution

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 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( ).

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

1 Solution
Diego_V_Intel
Employee
87 Views

Hello Songer,

From the code you posted, the IOs used are 10 and 11 (Arduino footprint IOs). If you want to use those IO in C++ you have to configure the GPIO41 (IO10) and GPIO43 (IO11). The GPIO111 defines the work mode: GPIO or SPI. Please check the following document for additional details about the pin function multiplexing control: http://www.intel.com/support/edison/sb/CS-035275.htm Intel® Edison Boards — Intel® Edison Kit for Arduino* Hardware Guide.

I suppose that the message you got when you tried to export the GPIO111 was the following:

-sh: echo: write error: Device or resource busy

That message only indicates that the GPIO has been already exported, so if you try to export it again, you will get that message. You can try to export any GPIO and if you run the command again, that message will appear. This means that you can ignore the message and continue with the next commands because the GPIO is already exported.

Regards,

Diego.

View solution in original post

4 Replies
VIvan7
New Contributor III
87 Views

GPIO111 shares the pin with the SPI interface pin SPI_2_FS1 (SPI2 chip select 1).

You should change its pinmux mode to GPIO.

However, there are only 2 SPI Select pins and they are precious.

Why can't you use a different GPIO pin?

QWang16
Novice
87 Views

Hi Vincenze, thank you for the information.

Well, I am using Xadow Wearable Kit for Edison, those boards are connected through FFC and special interfaces, so sadly I don't have choice.

VIvan7
New Contributor III
87 Views

According to your schematic, GP111 is connected to SPI2.

The pin is connected to the level converter U16.

Diego_V_Intel
Employee
88 Views

Hello Songer,

From the code you posted, the IOs used are 10 and 11 (Arduino footprint IOs). If you want to use those IO in C++ you have to configure the GPIO41 (IO10) and GPIO43 (IO11). The GPIO111 defines the work mode: GPIO or SPI. Please check the following document for additional details about the pin function multiplexing control: http://www.intel.com/support/edison/sb/CS-035275.htm Intel® Edison Boards — Intel® Edison Kit for Arduino* Hardware Guide.

I suppose that the message you got when you tried to export the GPIO111 was the following:

-sh: echo: write error: Device or resource busy

That message only indicates that the GPIO has been already exported, so if you try to export it again, you will get that message. You can try to export any GPIO and if you run the command again, that message will appear. This means that you can ignore the message and continue with the next commands because the GPIO is already exported.

Regards,

Diego.

View solution in original post

Reply