#include "LCD.h" #include "main.h" #include "avr_settings.h" #include "SPI.h" /************************************************ * Hauptprogramm * *************************************************/ //Variablen volatile unsigned char SPI_rx = 0; //empfangenes Byte von SPI volatile unsigned char ArrayPos = 0; //an welche Array-Position soll Byte geschrieben werden volatile unsigned char State = 0; //Varibale um zu unterscheiden was empfangenes //Byte bedeutet: 0 -> ArrayPos, 1 -> eigent. Byte unsigned char Array[79]; //Array für Display-Inhalt; char a[5]; //Hauptschleife int main(void) { Init_AVR(); //AVR initialisieren Init_SPI_Slave(); //SPI als Slave einschalten LCD_Reset(); //LCD reseten for (volatile uint8_t i = 0; i <= 79; i++) { Array[i] = 0x20; //"Array mit Leerzeichen auffüllen } LCD_Go_XY(1,1); while(1) //Hauptschleife { LCD_Refresh(); } return 0; } ///////////////////////////////////////////////// //ISR SPI Receive // //Übergabe: - // //Rückgabe: ///////////////////////////////////////////////// ISR(SPI_STC_vect){ //Daten speichern SPI_rx = SPDR; //Ende noch nicht erreicht if(SPI_rx != 0x00) { //Array-Position bereits bekannt if(State == 0x01) { //empf. Byte in Array speichern Array[ArrayPos] = SPI_rx; //Status auf 0 setzen State = 0x00; } //Array-Position noch nicht empfangen else if(State == 0x00) { //empf. Byte ist Array-Position ArrayPos = SPI_rx; //Status auf 1 setzen State = 0x01; } } //Ende erreicht else { State = 0x00; } }