/********************************************************
* RFM12-Kommunikation, hardwareabhängige Routinen *
* ATtiny24-Version für fs-d (Sandkasten) *
* Wird von rf12.h eingebunden, im »namespace "rf12"« *
********************************************************/
// Empfangsdaten (für rf_poll) vorhanden?
inline bool data() {return !!(PINA&0x40);}
// !SS schalten
inline void ss_lo() {PORTA&=~0x80;}
inline void ss_hi() {PORTA|= 0x80;}
#ifdef RF12_CPP // Aufrufer == rf12.cpp?
static void spi_clock() {
#if 0
USISR = 0x40; // Dreidrahtmodus = SPI
do USICR=0x1B; while(!(USISR&0x40)); // 16 Flanken generieren
#else
USICR=0x11;
USICR=0x13;
USICR=0x11;
USICR=0x13;
USICR=0x11;
USICR=0x13;
USICR=0x11;
USICR=0x13;
USICR=0x11;
USICR=0x13;
USICR=0x11;
USICR=0x13;
USICR=0x11;
USICR=0x13;
USICR=0x11;
USICR=0x13;
#endif
}
// Daten-WORD „austauschen“
word xfer(word d) {
ss_lo(); // !SEL aktivieren
USIDR = d>>8;
spi_clock();
byte h = USIDR; // Gelesenes Datenbyte einfangen
USIDR = d; // Nächstes Datenbyte ausgeben
spi_clock();
ss_hi(); // !SEL deaktivieren
ss_lo(); // !SEL aktivieren: RGIT oder FFIT "guckt raus"
return h<<8|USIDR;
}
#endif
| Detected encoding: UTF-8 | 0
|