Implementing SPI on the UNIX port

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Implementing SPI on the UNIX port

Post by Turbinenreiter » Sat Jan 28, 2017 10:15 pm

I started implementing SPI on the UNIX port for the Raspberry Pi, but I'm not having much luck.

I get this compiler error:

Code: Select all

machine_spi.c:205:5: error: initialization from incompatible pointer type [-Werror]
     .init = mp_machine_lspi_init,
But the code looks exactly like it does in the other SPI implementations.

Code: Select all

STATIC void mp_machine_lspi_init(mp_obj_base_t *self_in, mp_int_t baud)

...

STATIC const mp_machine_spi_p_t mp_machine_spi_p = {
    .init = mp_machine_lspi_init,
    .deinit = NULL,
    .transfer = machine_spi_transfer,
};
Any ideas?

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Implementing SPI on the UNIX port

Post by deshipu » Sat Jan 28, 2017 10:22 pm

You need the macro that actually defines the mp function, which is usually just below the function.

Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Re: Implementing SPI on the UNIX port

Post by Turbinenreiter » Sun Jan 29, 2017 10:17 am

It's not there in extmod/machine_spi.c where I copied from either.

line 289, 330:
https://github.com/micropython/micropyt ... hine_spi.c

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Implementing SPI on the UNIX port

Post by deshipu » Sun Jan 29, 2017 11:21 am

Ah, but that expects a completely different function signature than what you have.

Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Re: Implementing SPI on the UNIX port

Post by Turbinenreiter » Sun Jan 29, 2017 11:53 am

Yeah, that makes sense. I thought I could use it without arguments to quickly test it, didn't think about it actually having a defined interface.

I'm going to try a different route today, doing it in Python, based on this: https://github.com/vsergeev/python-periphery

Turbinenreiter
Posts: 288
Joined: Sun May 04, 2014 8:54 am

Re: Implementing SPI on the UNIX port

Post by Turbinenreiter » Sun Jan 29, 2017 3:43 pm

So python-periphery _works_.
There is some modifications to be done, mostly because of ctypes vs. uctypes also some weirdness with ioctl.

I have to press on with other work (I need to finish a paper, and I wanted to have this running for that), but as soon as I have time I will seriously look into implementing machine for unix based on python-periphery.

Post Reply