Author Topic: Getting started with SPI devices  (Read 6727 times)

Offline k64konfused

  • Newbie
  • *
  • Posts: 25
    • View Profile
Getting started with SPI devices
« on: November 10, 2014, 07:42:31 AM »
Hi Mark, I have not been working on this project enough lately, but I think at the moment it makes the most sense for me to try to get SPI devices working.  One is still the Wiznet W5100 in case I cannot figure out how to get the Micrel chips working in uTasker (highly likely), along with an RF module.

I started by looking through the code for SPI-related #defines, and I found #define SPI_INTERFACE.  I added that to my config.h, but the uTasker project doesn't build because it looks like the implementation of fnOpenSPI(SPITABLE *pars, unsigned char driver_mode) is missing.  Can you point me to any documents that you might already have available that will get me going in the right direction?  I looked at the document for the SPI EEPROM file system, but it specifically says to *not* use it with SPI_INTERFACE, so I figured that it would not be helpful to me.  :)  Thank you!

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Getting started with SPI devices
« Reply #1 on: November 10, 2014, 06:15:48 PM »
Hi

There was an SPI driver included a long time ago but was depreciated due to the fact that SPI devices have such different protocols. SPI_FILE_SYSTEM and SPI_EEPROM_FILE_SYSTEM are now used specifically for uFileSystem in SPI based Flash and EEPROM devices.

It is recommended to look at the files
spi_flash_kinetis_atmel.h
spi_flash_kinetis_sst25.h or
spi_flash_kinetis_stmicro.h

since these show how the SPI interface can be used (based on some macros which are mapped to the SPI in question and also some details about the device used - KL and K devices have different SPI controllers for example - they are in app_hw_kinetis.h).

By copying the method used it is fairly simple to add an interface for other SPI devices (you will just need to understand about the DSPI FIFO operation but beware that the K64 has only one FIFO depth on SPI 1 and 2 [4 deep on SPI0 as is typical for K parts] which tripped me up recently!! In fact the SPI Flash files only work on SPI0 of the device at the moment!).

I am in fact just wiring up a Microchip ENC624J600 (in form of the Fast 100 Mbps Ethernet PICtail(TM) Plus Daughter Board" - http://www.microchip.com/DevelopmentTools/ProductDetails.aspx?PartNO=ac164132   and   https://www.youtube.com/watch?v=f3z4G55EMJw ) for my own SPI based Ethernet controller extension development. This is being performed in parallel with a low power wireless extension (also SPI based and aimed at IP transport) which, if successful, will open up many new possibilities.

Regards

Mark

Offline k64konfused

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Getting started with SPI devices
« Reply #2 on: November 11, 2014, 08:46:33 AM »
Ok, thank you for the heads-up, Mark!  I will look into this further...