I was trying to modify the XMOS spi master code to Mode 0, but failed.
The only way I found was to use the clocks independently and to add a delay
to one clock, but I don't like this approach.
What is a better way to do it ?
Matrix
Code: Select all
#include <xclib.h>
#include <platform.h>
out buffered port:8 sclk = XS1_PORT_1A ;
out buffered port:8 mosi = XS1_PORT_1B;
in buffered port:8 miso = XS1_PORT_1C;
clock blk1 = XS1_CLKBLK_1 ;
clock blk2 = XS1_CLKBLK_2 ;
void main()
{
configure_clock_rate (blk1 , 100 , 8);
configure_clock_rate (blk2 , 100 , 16);
configure_out_port(sclk, blk1, 0);
configure_out_port(mosi, blk2, 0);
configure_in_port(miso, blk2);
clearbuf(mosi);
clearbuf(sclk);
set_clock_rise_delay(blk1, 20);
set_clock_fall_delay(blk1, 20);
start_clock(blk2);
start_clock(blk1);
mosi <: 0xaa;
sclk <: 0x55;
sclk <: 0x55;
sync(sclk);
miso :> void;
while(1);
return 0;
}