EasyManua.ls Logo

Lime Microsystems LMS7002MR3 - 3 SPI Procedures; A1.1 SPI READ;WRITE Pseudo Code

Default Icon
123 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
73
A
A
p
p
p
p
e
e
n
n
d
d
i
i
x
x
1
1
SPI Procedures
A1.1 SPI READ/WRITE Pseudo Code
//----------------------------------------------------------------------------
// Write command, SPI module address, register address
// Read data
//----------------------------------------------------------------------------
void SPI_Read(unsigned int COMMAND)
{
unsigned int DATA; //We will read data there
//Write Command and Address (MSB First)
//First 1 bit (MSB) = Command
//Next 15 (LSBs) bits = Register Address
for(int i=15; i>=0; i--)
{
if(i’th bit in COMMAND is ‘1’)
{
Set Data Output line to ‘1’;
}
else
{
Set Data Output line to ‘0’;
};
Apply Rising and Falling CLK signal edges to CLK line;
};
//Read Data (MSB First)
//Note: At this point we have data MSB valid from the chip.
for(int i=15; i>=0; i--)
{
if(there is ‘1’ at the Data Input Line)
{
Set i’th bit in DATA ‘1’;
}
else
{
Set i’th bit in DATA ‘0’;
};
Apply Rising and Falling CLK signal edges to CLK line;
};
};

Table of Contents