Added selector SPI Speed 4/8Mhz

This commit is contained in:
maxxir_w
2019-03-25 07:55:07 +04:00
parent 8af605422d
commit 58c7930671
7 changed files with 65 additions and 23 deletions

View File

@@ -41,6 +41,10 @@ static FATFS Fatfs; //File system object for each logical drive. >= 2
#define IP_WORK
//SPI CLOCK 4 or 8Mhz
#define SPI_4_MHZ
//#define SPI_8_MHZ
extern unsigned long millis(void);
extern int freeRam (void);

View File

@@ -30,6 +30,8 @@
#include <avr/io.h>
#include "spi.h"
#include "globals.h"
//#include "contiki-conf.h"
/*
@@ -77,7 +79,13 @@ spi_init(void)
/* Enables SPI, selects "master", clock rate FCK / 4 - 4Mhz, and SPI mode 0 */
SPCR = _BV(SPE) | _BV(MSTR);
//SPSR = _BV(SPI2X); //FCK / 2 - 8Mhz
#if defined(SPI_8_MHZ)
SPSR = _BV(SPI2X); //FCK / 2 - 8Mhz
#elif defined (SPI_4_MHZ)
SPSR = 0x0; //FCK / 4 - 4Mhz
#else
SPSR = 0x0; //FCK / 4 - 4Mhz
#endif
}