English
Language : 

AN1816 Datasheet, PDF (19/24 Pages) Freescale Semiconductor, Inc – USING THE HC912B32 TO IMPLEMENT THE DISTRIBUTED SYSTEMS INTERFACE (DSI) PROTOCOL
Freescale Semiconductor, Inc.
Appendix 1 - Source Code
SP0CR1 = 0x10; /* Enable master mode and SSOE=0, therefore SS
is GP I/O */
SP0CR1 = 0x50; /* Enable SPI system now */
}
/* This function is called by the SpiBurst function. It writes information into the
SPI data register and when the SPI transfer complete flag is set it sends back the
information received by the SPI */
short TransmitReceive(short SendByte)
{
int dummy=0;
short result;
SP0DR = SendByte;
while ((SP0SR & 0x80) == 0)
complete flag is set */
{
dummy++;
}
result = SP0DR;
return (result);
}
/* Wait until SPI transfer
/* This function sets up the SPI Burst transfer routine. It enables the MC68HC55 SPI
Peripheral by driving CS low and then transfers the required no. of bytes of data to
complete the burst transfer. It finishes by driving CS high and disabling the MC68HC55
SPI Peripheral */
void SpiBurst(int ByteCount)
{
int count;
/* CS to go LOW */
PORTS = 0x00;
/* Transmit bytes */
for (count=0; count<ByteCount; count++)
{
RBytes[count] = TransmitReceive(TBytes[count]);
}
/* CS to go HIGH */
PORTS = 0x80;
}
/* This function sets up the DSI registers */
int SetupDSI(void)
{
int ErrCnt=0;
int ChkCnt;
/* Set up DSI/D Registers */
TBytes[0] = 0x85;
/* Send 85 (write cmd to reg.
addr. 5) */
AN1816
For More Information On This Product,
19
Go to: www.freescale.com