2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 #define LCD_PORT PORTB
28 ao_lcd_port_set_bits(uint8_t bits)
31 printf("\tLCD data %x RS %d R/W %d E %d\n",
33 (bits & (1 << PIN_RS)) ? 1 : 0,
34 (bits & (1 << PIN_RW)) ? 1 : 0,
35 (bits & (1 << PIN_E)) ? 1 : 0);
40 if (bits & (1 << PIN_RW))
41 printf("\tLCD input %x\n", PINB);
46 ao_lcd_port_get_nibble(uint8_t rs)
48 uint8_t data = (rs ? (1 << PIN_RS) : 0) | (1 << PIN_RW);
51 DDRB = (1 << PIN_RS) | (1 << PIN_E) | (1 << PIN_RW);
52 ao_lcd_port_set_bits(data);
53 ao_lcd_port_set_bits(data | (1 << PIN_E));
55 ao_lcd_port_set_bits(data);
60 ao_lcd_port_put_nibble(uint8_t rs, uint8_t data)
62 data = (data & 0xf) | (rs ? (1 << PIN_RS) : 0);
63 DDRB = (0xf) | (1 << PIN_RS) | (1 << PIN_E) | (1 << PIN_RW);
64 ao_lcd_port_set_bits(data);
65 ao_lcd_port_set_bits(data | (1 << PIN_E));
66 ao_lcd_port_set_bits(data);
70 ao_lcd_port_init(void)
72 DDRB = (1 << PIN_RS) | (1 << PIN_E) | (1 << PIN_RW);