Hallo,
ich experimentiere gerade mit einer LCD-Anzeige. Hierbei frage ich mit
dem Macro if (bit_is_set(c, 7)) ab, ob Bit7 gesetzt ist oder nicht.
Die aufrufende Funktion
1 | lcd_send(BEFEHL, LCD_CLEAR); // LCD clear
|
übergibt als Parameter 0x00 für BEFEHL und 0x01 für LCD_CLEAR.
1 | void lcd_send(uint8_t type, uint8_t c)
|
2 | {
|
3 | if (type == BEFEHL)
|
4 | cbi(LCDPORT, LCD_PIN_RS); /* RS=0: Befehl folgt ... ******/
|
5 | //PORTD &= ~(1 << LCD_PIN_RS);
|
6 | else
|
7 | sbi(LCDPORT, LCD_PIN_RS); /* RS=1: Daten folgen ... ******/
|
8 | //PORTD |= (1 << LCD_PIN_RS);
|
9 |
|
10 | /* (1) HIGH NIBBLE wird gesendet ******/
|
11 | if (bit_is_set(c, 7))
|
12 | sbi(LCDPORT, LCD_PIN_D7);
|
13 | else cbi(LCDPORT, LCD_PIN_D7);
|
Kann ich das auch anders lösen, ohne das Macro zu verwenden?