eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.37k stars 614 forks source link

FTDI : Combine GPIO and SPI #625

Open GuzMp opened 7 years ago

GuzMp commented 7 years ago

Hi,

I use FT4222 with SPI and know I want to use also GPIO3 as Interrupt. So first I tried both separately, it works correctly but after if I use both in a same code, it fail at nivel of x = mraa_gpio_init(515); I can't init both in a same code ?

My code :

mraa_init();
spi = mraa_spi_init(512);
mraa_spi_mode(spi, MRAA_SPI_MODE0);
mraa_spi_frequency(spi, 5000000);

mraa_gpio_context x;
x = mraa_gpio_init(515);

if (x == NULL) {
        printf("Echec\n");
            return 1;
}

mraa_gpio_dir(x, MRAA_GPIO_IN);
mraa_gpio_edge_t edge = MRAA_GPIO_EDGE_BOTH;
mraa_gpio_isr(x, edge, &DecaDuino::isr0, NULL);

It's possible to combine both ?

Syslog error :

_Dec 27 17:26:59 teosit-System-Product-Name libmraa[12311]: libmraa version v1.5.1 initialised by user 'root' with EUID 0 Dec 27 17:26:59 teosit-System-Product-Name libmraa[12311]: Platform not supported, not initialising Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: FT_GetDeviceInfoList returned 2 devices Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: mraa_ftdi_ft4222_init completed successfully Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: FT4222_GetVersion 42220200 01030178 Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: libmraa initialised for platform 'Unknown platform + FTDI FT4222' of type 98 Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: spi512_init: Using sub platform Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: spiinit: Selected bus 0 Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: SPI MODE : 1363677943 Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: gpio515: init: Using sub platform Dec 27 17:27:00 teosit-System-Product-Name libmraa[12311]: gpio515: init: Sub platform not initialised

Thank you.

arfoll commented 7 years ago

Something v.odd there, on your branch are you sure you don't corrupt the suplatform board struct when you initialise the spi bus or something? There must be a bug somewhere as this works for I2c + gpio...

whbruce commented 7 years ago

Has anyone tested FT4222 SPI capability? I wrote most of the FT4222 code but couldn't test SPI operation and I didn't have any suitable hardware.

arfoll commented 7 years ago

It's in the branch for now in @guzmp's fork. To test spi is easy if it does full duplex, just short mosi to miso. Or walk down to the upm guys and steal a sensor ;-)

On 29 Dec 2016 20:39, "Henry Bruce" notifications@github.com wrote:

Has anyone tested FT4222 SPI capability? I wrote most of the FT4222 code but couldn't test SPI operation and I didn't have any suitable hardware.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/intel-iot-devkit/mraa/issues/625#issuecomment-269690011, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfZZjedZmGDBk7svL4XTZiO9Y_YJbUgks5rNBp9gaJpZM4LWX-V .

alext-mkrs commented 7 years ago

Is this still actual?

alext-mkrs commented 7 years ago

Ping...

whbruce commented 7 years ago

It seems that @GuzMp has got most of the way towards adding SPI support to FTDI sub platform but fallen at the last hurdle. I don't believe this a bug, more a request for help. I've starred his repo and will take a look, but won;t be able to get to this for some time. I'd tag this as "feature request" and "help needed".

alext-mkrs commented 7 years ago

Thanks! Tagged.