SPI Slave - Rabbit RCM5400W

Hello!
My name is Felipe.

I need to use the module as a SPI-Slave.

Anyone have some example codes ?

My connections are:

  • MISO - PC0
  • MOSI - PC1
  • SS - PE0
  • SCLK - PD0

My question is: How can I configure this SPI libs to work with those pins. How I set in the code to read the SPI Clock from PD0 pin?

What I have by now is:


#class auto
#use RCM54xxW.LIB

#define SPI_SER_D
#define SPI_CLK_DIVISOR             10
#define SPI_RX_PORT                 SPI_RX_PC
#define SPI_SLAVE
#define SPI_SLAVE_CS_REG 				PDDR
#define SPI_SLAVE_CS_BIT				0
#use "SPITecnalia.lib"
nodebug
void msDelay(unsigned int delay)
{
    auto unsigned long done_time;
    done_time = MS_TIMER + delay;
    while( (long) (MS_TIMER - done_time) < 0 );
}

void main()
{
  char tx[3];
  char rx[2];
  char regist;
  int resp=0;
  tx[0] = 'A';
  tx[1] = 'B';
  tx[2] = 'C';
  brdInit();
  SPIinit();

  WrPortI(SDCR, &SDCRShadow, 0x09);
  WrPortI(PEDDR, &PEDDRShadow, 0);

  while(1)
  {
    regist = BitRdPortI(PEDR,0);
    resp=(int)regist;
    if(resp==0)
	resp  = SPIRead(rx, 1);
  }
}

THANKS!