altos: Need to use 16-bit counts for ao_xmem functions
[fw/altos] / src / cc1111 / ao_lcd_port.c
1 /*
2  * Copyright © 2011 Keith Packard <keithp@keithp.com>
3  *
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.
7  *
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.
12  *
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.
16  */
17
18 #include "ao.h"
19
20 static void
21 ao_lcd_port_delay(void)
22 {
23         uint8_t i;
24
25         for (i = 0; i < 100; i++)
26                 ao_arch_nop();
27 }
28
29 void
30 ao_lcd_port_put_nibble(uint8_t rs, uint8_t nibble)
31 {
32         P0 = (P0 & 0xf0) | (nibble & 0x0f);
33         P1_1 = rs;
34         P1_0 = 1;
35         ao_lcd_port_delay();
36         P1_0 = 0;
37         ao_lcd_port_delay();
38 }
39
40 void
41 ao_lcd_port_init(void)
42 {
43         /* LCD_E and LCD_RS are GPIO outputs */
44         P1DIR |= 0x03;
45         P1SEL &= ~0x03;
46
47         /* LCD D4-D7 are GPIO outputs */
48         P0DIR |= 0x0f;
49         P0SEL &= ~0x0f;
50 }