Guten Morgen,
im Datenblatt des zB ATTiny84 heißt es:
> The USI Three-wire mode is compliant to the Serial Peripheral Interface
> (SPI) mode 0 and 1, but does not have the slave select (SS) pin
> functionality. However, this feature can be implemented in software
> if necessary. Pin names used by this mode are: DI, DO, and USCK.
Hab dann mal weiter gesucht, aber hat wohl noch niiiiiemals jemand
gemacht ;-)
Naja, meine Lösung ist folgende:
1 | uint8_t wait_for_spi_data() {
|
2 | USISR=(1<<USIOIF);
|
3 | while (!(USISR & (1<<USIOIF))) {
|
4 | if (!(PINA & (1<<PA7)))
|
5 | USISR &= ~((1<<USICNT3) | (1<<USICNT2) | (1<<USICNT1) | (1<<USICNT0));
|
6 | };
|
7 | return USIDR;
|
8 | }
|
Auf Deutsch: Wenn mein CS (in dem Fall High-Aktiv) nicht gesetzt ist,
wird der SR-Counter auf 0 gesetzt.
Ist das die übliche Vorgehensweise, wie man es machen sollte?
Viele Grüße,