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; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 #define LCD_PORT PORTB
29 ao_lcd_port_set_bits(uint8_t bits)
32 printf("\tLCD data %x RS %d R/W %d E %d\n",
34 (bits & (1 << PIN_RS)) ? 1 : 0,
35 (bits & (1 << PIN_RW)) ? 1 : 0,
36 (bits & (1 << PIN_E)) ? 1 : 0);
41 if (bits & (1 << PIN_RW))
42 printf("\tLCD input %x\n", PINB);
47 ao_lcd_port_get_nibble(uint8_t rs)
49 uint8_t data = (rs ? (1 << PIN_RS) : 0) | (1 << PIN_RW);
52 DDRB = (1 << PIN_RS) | (1 << PIN_E) | (1 << PIN_RW);
53 ao_lcd_port_set_bits(data);
54 ao_lcd_port_set_bits(data | (1 << PIN_E));
56 ao_lcd_port_set_bits(data);
61 ao_lcd_port_put_nibble(uint8_t rs, uint8_t data)
63 data = (data & 0xf) | (rs ? (1 << PIN_RS) : 0);
64 DDRB = (0xf) | (1 << PIN_RS) | (1 << PIN_E) | (1 << PIN_RW);
65 ao_lcd_port_set_bits(data);
66 ao_lcd_port_set_bits(data | (1 << PIN_E));
67 ao_lcd_port_set_bits(data);
71 ao_lcd_port_init(void)
73 DDRB = (1 << PIN_RS) | (1 << PIN_E) | (1 << PIN_RW);