How to use MCP23s08 SPI Driver ?

Started by maggocnx, June 13, 2013, 01:11:04 PM

Previous topic - Next topic

maggocnx

Hello,

i have a mcp23s08 io expander attached via EXT Port to my A13 Wifi Board. I was using the controller with the python example at http://olimex.wordpress.com/2013/03/08/a13-olinuxino-gpio-python-libraries/ . That showed me everything is ok with my hardware. i can read/write to the controller. But the example uses the spi port as an normal GPIO (i guess thats what called "bitbanging" ). But this to slow for my application.
Whats the next step now ? I enabled spi support in the menuconfig, also i enabled the drivers for spi_sunxi and mcp23s08.
But now i am a bit confused. It looks like the mcp23s08 and the spi_sunxi drivers are completely independent, both getting loaded. What it the use of that mxp23s08 driver in the menuconfig ? Do i need it or is just doing the sunxi driver together with spidev all the work for me.
Can anybody help me? This is my first embedded linux project ever.

vinifr

What code do you use to test spidev? Remember that spi_sunxi not support full duplex. Use

rx_buf=something;
tx_buf=0;
or
rx_buf=0;
tx_buf=something;


Another option, you can use your own spi driver like this:http://www.jumpnowtek.com/?option=com_content&view=article&id=57&Itemid=62
https://github.com/vinifr/drivers-sunxi/blob/master/radio_si4455/driver/si4455.c

jwischka

Also, recent kernel sources seem to have completely broken SPI, so I'd use caution in general. Hopefully there are some fixes, but it's hard to know when they'll filter down.

maggocnx

Hello,

i was reading a lot of code and i decided to just implement the driver myself writing to the registers myself. I dont need the spi in userspace. My scenario is like this : I have 2 MCP 23S17 connected via another multiplexer (74HC138 controlled by to other GPIO pins) to SPI 2. So it makes no sense to put it to user space. I rather want to present  my individual devices to the user.
It took some time for me to realize that  its not possible writing direct to the physical address of the registers in linux.
I used the addresses in platform.h to initialize my system, for GPIO everything is working fine. But the SPI registers seems to be not mapped to the addresses in platform.h (I was reading some registers expecting to see the default values as shown in the datasheet) but i only get back zero.

vinifr