Hi Tim!
Maybe this will help you. Below are two very simple functions (first for write one byte data and second to read one byte data):
void fnWrite_command(unsigned char ucCommand)
{
GPIODATA_D &= ~CS_LINE; // CS low state
SSIDR_0 = ucCommand; // send 8-bit command
//if you want to send more bytes add more lines SSIDR_0 = comand;
while (SSISR_0 & (SSI_BSY | SSI_RNE)) { // wait for transfer to complete and clear rx buffer
volatile unsigned long ulDummy = SSIDR_0;
}
GPIODATA_D |= CS_LINE;
}
unsigned char fnRead_command()
{
unsigned char ucValue;
GPIODATA_D &= ~CS_LINE; // CS low state
SSIDR_0 = 0x00; //dummy writes to generate clock
//SSIDR_0 = 0x00; //if you want to read more bytes add more line SSIDR_0 = 0x00;
while (SSISR_0 & SSI_BSY) {};
ucValue = (unsigned char)SSIDR_0;
while (SSISR_0 & (SSI_BSY | SSI_RNE)) { // wait for transfer to complete and clear rx buffer
volatile unsigned long ulDummy = SSIDR_0;
}
GPIODATA_D |= CS_LINE;
return ucValue;
}
Best regards,
robo