spi.h File Reference

Outputs SPI-like interfaces (clock+data). More...

Include dependency graph for spi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void spi_pulse_0 ()
 SPI test routine.
void spi_pulse_1 ()
 SPI test routine.
void spi_setup ()
 Setup ports and pins for SPI output.
void spi_write (uns8 data)
 Send a byte of data using software spi.
void spi_write_lsb (uns8 data)
 Send a byte of data using software spi.
void spi_write_sure (uns8 data)
 SPI write for Sure devices.

Detailed Description

Covers standard SPI-like interfaces (clock + data) and Sure Electronics displays which are a little different


Function Documentation

void spi_pulse_0 (  ) 

00090                    {
00091         change_pin(spi_data_port, spi_data_pin, 0);
00092         clear_pin(spi_clk_port, spi_clk_pin);   
00093         set_pin(spi_clk_port, spi_clk_pin); 
00094 }

void spi_pulse_1 (  ) 

00096                    {
00097         change_pin(spi_data_port, spi_data_pin, 1);
00098         clear_pin(spi_clk_port, spi_clk_pin);   
00099         set_pin(spi_clk_port, spi_clk_pin); /
00100 }

void spi_setup (  ) 

Setup ports and pins for SPI output

00069                  {
00070     clear_bit(tris_array[spi_clk_port - PORTA], spi_clk_pin);   // output
00071     clear_bit(tris_array[spi_data_port - PORTA], spi_data_pin);   // output
00072 
00073 }   

Here is the caller graph for this function:

void spi_write ( uns8  data  ) 

Sends a byte of data MSB first, data only changes on clock low

00041                           {
00042 
00043 uns8 count;
00044     for (count = 0; count < 8; count++) {
00045         clear_pin(spi_clk_port, spi_clk_pin);   // set to low
00046         change_pin(spi_data_port, spi_data_pin, data.7);
00047         data = data << 1;
00048         set_pin(spi_clk_port, spi_clk_pin); // set to low
00049     }   
00050         
00051 }

Here is the caller graph for this function:

void spi_write_lsb ( uns8  data  ) 

Sends a byte of data LSB first, data only changes on clock low

00055                               {
00056 
00057 uns8 count;
00058 
00059 
00060     for (count = 0; count < 8; count++) {
00061         clear_pin(spi_clk_port, spi_clk_pin);   // set to low
00062         change_pin(spi_data_port, spi_data_pin, data.0);
00063         data = data >> 1;
00064         set_pin(spi_clk_port, spi_clk_pin); // set to low
00065     }   
00066         
00067 }

void spi_write_sure ( uns8  data  ) 

SPI write byte for Sure devices. Sure devices do things a little differently. Data goes LSB first but data changes on clock high.

00075                                {
00076 
00077 uns8 count;
00078 uns8 data_in;
00079 
00080     data_in = data;
00081     for (count = 0; count < 8; count++) {
00082         change_pin(spi_data_port, spi_data_pin, data_in.0);
00083         clear_pin(spi_clk_port, spi_clk_pin);   
00084         set_pin(spi_clk_port, spi_clk_pin); 
00085         data_in = data_in >> 1;
00086     }   
00087 }

Here is the caller graph for this function:


Generated on Fri Aug 19 09:09:26 2011 for Pic Pack Library by  doxygen 1.6.1