4.2.4 Atmel tinyAVR with SPI Interface
For the tinyAVR microcontrollers with built in SPI module, the LED Driver Library contains tinyAVR SPI drivers to interface with Atmel LED driver chips like the Atmel MSL2160. The following code section contains the built-in SPI definitions.
#elif defined(TINYAVR) && defined(SPI)
#include "tiny_avr_spi_driver.h"
//This is the SCK divider setting as defined by SPR[1:0]
#define SPI_CLK_DIVIDER 4 //Must be 4,16,64,128
//This is the SPI2X bit setting which, if set, doubles the SCK.
#define SPI_CLK_DOUBLE 1 //Must be 1 or 0
#define SPI_DIR_REG DDRC //!< SPI port direction register.
#define SPI_PORT PORTC //!< SPI port output register.
#define SPI_SCK PC1 //!< SPI clock I/O pin.
#define SPI_MISO PC2 //!< SPI data input pin.
#define SPI_MOSI PC4 //!< SPI data output pin.
#define SPI_SS PC0 //!< Atmel LED driver CSB pin
- SPI_CLOCK_DIVIDER and SPI_CLK_DOUBLE determine the SCK frequency according the equation below
- Use clock divider value of {4, 16, 64, or 128} and clock double value 0 or 1
- SPI_DIR_REG defines the SPI port direction register
- SPI_PORT defines the SPI port output register
- SPI_SCK defines the SCK pin
- SPI_MISO defines the MISO pin
- SPI_MOSI defines the MOSI pin
- SPI_SS defines the Slave select pin which is connected to MSL CSB pin
