It is a generalized SPI header file written for AVR with several
configurable options. For configuring the options you need to make
changes in the C source file. At present the header file is suitable
only for Hardware SPI. I will update the same for software SPI too after
some time. I have tried to make the header file readable but still if
anyone faces any issue please ping me. I will reply as soon as I come
online. Any suggestions are welcome too as I am posting my header files
ol for the first time.
Here is a quick review of the functions in the header file:-
Used to initialize SPI bus. the default values are already defined in
the source file. If you need to change any of the configuration
parameters just make changes in the source file.
Used to write data on the SPI bus. In the first parameter you need to
pass a pointer to the char array. In second parameter you need to pass
the length of the array.
Used to read data from the SPI bus. The length of data to be read is
specified as argument and a char pointer pointing to the address of the
first read byte is returned through it.
For setting the pins used for SPI following macros can be used:-
#define SPI_PORT PORTB
Set the port which will be used for the SPI Communication
#define SPI_DIR DDRB
Set the Data direction register of the Port used for SPI Communication
#define SS 0
The pin number on SPI Port which will be used as SS
#define MISO 3
The pin number on SPI Port which will be used as MISO
#define MOSI 2
The pin number on SPI Port which will be used as MOSI
#define SCK 1
The pin number on SPI Port which will be used as SCK
Your Suggestions are simply welcome
Tips: You can preview the content of files by clicking file names^_^