Forum Discussion
Altera_Forum
Honored Contributor
16 years agoNios2 SPI
Hi, I'm having some trouble reading from my IO expander with the SPI core from Altera :confused: Can anybody provide me with an example on how to issue a correct read to the spi inter...
Altera_Forum
Honored Contributor
16 years agoI ended up using the standard NIOS spi command like this:
Write :
wdata = 0x40; // Write command of the chip
wdata = 0x09; // register adr
wdata = 0x2; // value
alt_avalon_spi_command(SPI0_BASE, 0,
3,
wdata,
0,
rdata,
0);
Read :
wdata = 0x41; // read command
wdata = 0x12; // register adr
ID = 0;
alt_avalon_spi_command(SPI0_BASE, 0,
2,
wdata,
2, // reading 2 bytes
rdata, // store bytes here
0);
Hope this helps :)