Introduce #ifdef SPI.
It's better to separate this by function than by usage.
This commit is contained in:
parent
274f6c954b
commit
d2fcc57ed4
|
|
@ -34,6 +34,13 @@
|
|||
#undef BAUD
|
||||
#endif
|
||||
|
||||
/**
|
||||
Check wether we need SPI.
|
||||
*/
|
||||
#if (defined SD_CARD_SELECT_PIN || defined TEMP_MAX6675) && ! defined SIMULATOR
|
||||
#define SPI
|
||||
#endif
|
||||
|
||||
/**
|
||||
ACCELERATION_TEMPORAL doesn't support lookahead, yet.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
void cpu_init() {
|
||||
#ifdef PRR
|
||||
#if defined TEMP_MAX6675 || defined SD
|
||||
#if defined SPI
|
||||
PRR = MASK(PRTWI) | MASK(PRADC);
|
||||
#else
|
||||
PRR = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI);
|
||||
#endif
|
||||
#elif defined PRR0
|
||||
#if defined TEMP_MAX6675 || defined SD
|
||||
#if defined SPI
|
||||
PRR0 = MASK(PRTWI) | MASK(PRADC);
|
||||
#else
|
||||
PRR0 = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI);
|
||||
|
|
|
|||
2
mendel.c
2
mendel.c
|
|
@ -89,7 +89,7 @@ void init(void) {
|
|||
pinio_init();
|
||||
|
||||
#ifndef __ARMEL_NOTYET__
|
||||
#if defined TEMP_MAX6675 || defined SD
|
||||
#if defined SPI
|
||||
spi_init();
|
||||
#endif
|
||||
#endif /* __ARMEL_NOTYET__ */
|
||||
|
|
|
|||
|
|
@ -5,5 +5,9 @@
|
|||
#include "spi.h"
|
||||
#include "arduino.h"
|
||||
|
||||
#ifdef SPI
|
||||
|
||||
void spi_init() {
|
||||
}
|
||||
|
||||
#endif /* SPI */
|
||||
|
|
|
|||
6
spi.c
6
spi.c
|
|
@ -13,9 +13,7 @@
|
|||
*/
|
||||
#include "spi.h"
|
||||
|
||||
#include "arduino.h"
|
||||
#include "pinio.h"
|
||||
|
||||
#ifdef SPI
|
||||
|
||||
/** Initialise serial subsystem.
|
||||
|
||||
|
|
@ -44,3 +42,5 @@ void spi_init() {
|
|||
// This sets the whole SPRC register.
|
||||
spi_speed_100_400();
|
||||
}
|
||||
|
||||
#endif /* SPI */
|
||||
|
|
|
|||
7
spi.h
7
spi.h
|
|
@ -5,6 +5,8 @@
|
|||
#include "arduino.h"
|
||||
#include "pinio.h"
|
||||
|
||||
#ifdef SPI
|
||||
|
||||
// Uncomment this to double SPI frequency from (F_CPU / 4) to (F_CPU / 2).
|
||||
//#define SPI_2X
|
||||
|
||||
|
|
@ -13,8 +15,6 @@
|
|||
*/
|
||||
void spi_init(void);
|
||||
|
||||
#ifndef SIMULATOR /* Avoid inlining code on simulator. */
|
||||
|
||||
/** SPI device selection.
|
||||
|
||||
Because out famous WRITE() macro works with constant pins, only, we define
|
||||
|
|
@ -102,5 +102,6 @@ inline uint8_t spi_rw(uint8_t byte) {
|
|||
return SPDR;
|
||||
}
|
||||
|
||||
#endif /* SIMULATOR */
|
||||
#endif /* SPI */
|
||||
|
||||
#endif /* _SPI_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue