AnsweredAssumed Answered

BF561 SPI Slave Mode

Question asked by TRON on Sep 24, 2009
Latest reply on Sep 29, 2009 by TRON

I am trying to get the BF561 (rev 0.5) into slave SPI mode and I am not having any luck at all on this:


static ADI_DEV_1D_BUFFER m_spi1DBuffIn;
static ADI_DEV_1D_BUFFER m_spi1DBuffOut;

u16 m_spiBuffIn[64];
u16 m_spiBuffOut[64];

        ADI_DEV_CMD_VALUE_PAIR spiConfig [] = {
             { ADI_SPI_CMD_SET_MASTER,             (void *)0        }, // we are a slave
          { ADI_SPI_CMD_SEND_ZEROS,             (void *)1        }, // send zeros when there's nothing to send
          { ADI_SPI_CMD_SET_GET_MORE_DATA,      (void *)0        }, // discard incoming data when read buffer is full
          { ADI_SPI_CMD_SET_PSSE,               (void *)1        }, // enable Slave select pin (PF0)
          { ADI_SPI_CMD_SET_MISO,               (void *)1        }, // Master In Slave Out enabled
          { ADI_SPI_CMD_SET_LSB_FIRST,          (void *)0        }, // Most Significant Bit first
          { ADI_SPI_CMD_SET_CLOCK_PHASE,        (void *)0        }, // SCK toggles from middle of cycle
          { ADI_SPI_CMD_SET_CLOCK_POLARITY,     (void *)0        }, // active high CLK
          { ADI_SPI_CMD_SET_OPEN_DRAIN_MASTER,  (void *)0        }, // leave open drain normal (no other masters on SPI bus)
          { ADI_SPI_CMD_SET_TRANSFER_TYPE_BIG_ENDIAN, (void *)0  }, // big endian
          { ADI_DEV_CMD_END,                    NULL             }  // we're done
     result = adi_dev_Open(gm_DeviceManagerHandle, &ADISPIIntEntryPoint, 0, NULL, &SPIHandle, ADI_DEV_DIRECTION_BIDIRECTIONAL, NULL, NULL, SPI_SlaveCBHandler);
          printf("SPI->adi_dev_Open(): failed, 0x%X\n", result);
     result = adi_dev_Control(SPIHandle, ADI_DEV_CMD_TABLE, spiConfig);
          printf("SPI->adi_dev_Control(): failed, 0x%X\n", result);
     // Outbound buffer
     m_spi1DBuffOut.Data              = m_spiBuffOut;
     m_spi1DBuffOut.ElementCount      = sizeof(m_spiBuffOut);
     m_spi1DBuffOut.ElementWidth      = 1;
     m_spi1DBuffOut.CallbackParameter = (void *)&m_spi1DBuffOut;
     m_spi1DBuffOut.pNext             = NULL;
     m_spi1DBuffOut.ProcessedFlag     = FALSE;

     // Inbound buffer
     m_spi1DBuffIn.Data               = m_spiBuffIn;
     m_spi1DBuffIn.ElementCount       = sizeof(m_spiBuffIn);
     m_spi1DBuffIn.ElementWidth       = 1;
     m_spi1DBuffIn.CallbackParameter  = (void *)&m_spi1DBuffIn;
     m_spi1DBuffIn.pNext              = NULL;
     m_spi1DBuffIn.ProcessedFlag      = FALSE;
     // queue both read and write buffers
     result = adi_dev_Read( SPIHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *)&m_spi1DBuffIn );
     result = adi_dev_Write(SPIHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *)&m_spi1DBuffOut);
     result = adi_dev_Control(SPIHandle, ADI_DEV_CMD_SET_DATAFLOW, (void *)true);


I am not getting any callbacks to my SPI_SlaveCBHandler() function when PF0 goes low and SPI is beening clocked 12 test bytes. I am using a FTDI USB to SPI device to generate the SPI bus signals and I can see on my logic analyizer that the SPI master is in fact doing what it is suppose to do, I'm just not getting any response from the blackfin side of things as in terms of events nor any data being manipulated in the m_spiBuffIn buffer to indicate that the SPI slave is working and receiving data.


The Blackfin's SPI has been working just fine for me recently and in the past only as a master, this is my first time trying to get it working as a SPI slave. I even looked into the VisualDSP 5.0\Blackfin\docs\drivers\spi\adi_spi_int.pdf SPI in Interrupt configuration Manual and no SPI slave examples exist. So I tried my best to figure out what all I needed to do to configure the SPI driver for slave mode and I think I got everything. See anything missing or wrong?



Note to webmaster: Please get rid of the fixed width site layout, it is annoying trying to read code or large posts such as mine above.