Gast
#438235
Moin!
Habe hier ein ATmega 128 und möchte in C Daten über das SPI senden...
hier der Code, wie er bis jetzt ist:
void lcd_cmd(unsigned char value) {
int i;
PORT(LCD_PORT) &= ~(_BV(LCD_CS));
PORT(LCD_PORT) &= ~(_BV(LCD_SC));
PORT(LCD_PORT) &= ~(_BV(LCD_SD));
PORT(LCD_PORT) |= _BV(LCD_SC);
for(i=7;i>=0;i--) {
if(value&(_BV(i)))
PORT(LCD_PORT) |= _BV(LCD_SD);
else
PORT(LCD_PORT) &= ~(_BV(LCD_SD))
PORT(LCD_PORT) &= ~(_BV(LCD_SC));
PORT(LCD_PORT) |= _BV(LCD_SC);
}
PORT(LCD_PORT) |= _BV(LCD_CS);
}
Wie man sieht, wird das Byte in einer for-Schleife ausgegeben... aber
das ist nunmal ziemlich langsam, es gibt doch bestimmt auch einen
Befehl, der das SPI direkt benutzt, oder?
ChriZi