Fix comments.
[bertos.git] / boards / triface / hw / hw_lcd.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2003, 2004, 2005, 2008 Develer S.r.l. (http://www.develer.com/)
30  * Copyright 2001 Bernie Innocenti <bernie@codewiz.org>
31  *
32  * -->
33  *
34  * \brief LCD low-level hardware macros
35  *
36  * \version $Id$
37  *
38  * \author Bernie Innocenti <bernie@codewiz.org>
39  * \author Stefano Fedrigo <aleph@develer.com>
40  *
41  */
42
43 #ifndef HW_LCD_H
44 #define HW_LCD_H
45
46 #include "cfg/cfg_lcd.h"  /* CONFIG_LCD_4BIT */
47 #include <cfg/macros.h>   /* BV() */
48 #include <cfg/debug.h>
49
50 #include <cpu/attr.h>
51 #include <cpu/irq.h>
52 #include <cpu/types.h>
53
54 #warning TODO:This is an example implementation, you must implement it!
55
56 /**
57  * \name LCD I/O pins/ports
58  * @{
59  */
60 #define LCD_RS    /* Implement me! */
61 #define LCD_RW    /* Implement me! */
62 #define LCD_E     /* Implement me! */
63 #define LCD_DB0   /* Implement me! */
64 #define LCD_DB1   /* Implement me! */
65 #define LCD_DB2   /* Implement me! */
66 #define LCD_DB3   /* Implement me! */
67 #define LCD_DB4   /* Implement me! */
68 #define LCD_DB5   /* Implement me! */
69 #define LCD_DB6   /* Implement me! */
70 #define LCD_DB7   /* Implement me! */
71 /*@}*/
72
73 /**
74  * \name DB high nibble (DB[4-7])
75  * @{
76  */
77
78 #if CONFIG_LCD_4BIT
79         #define LCD_MASK    (LCD_DB7 | LCD_DB6 | LCD_DB5 | LCD_DB4)
80         #define LCD_SHIFT   4
81 #else
82         #define LCD_MASK (uint8_t)0xff
83         #define LCD_SHIFT 0
84 #endif
85 /*@}*/
86
87 /**
88  * \name LCD bus control macros
89  * @{
90  */
91 #define LCD_CLR_RS      /* Implement me! */
92 #define LCD_SET_RS      /* Implement me! */
93 #define LCD_CLR_RD      /* Implement me! */
94 #define LCD_SET_RD      /* Implement me! */
95 #define LCD_CLR_E       /* Implement me! */
96 #define LCD_SET_E       /* Implement me! */
97
98 /* Enter command mode */
99 #define LCD_SET_COMMAND() /* Implement me! */
100
101 /* Enter data mode */
102 #define LCD_SET_DATA() /* Implement me! */
103
104 #if CONFIG_LCD_4BIT
105         #define LCD_WRITE_H(x)  ((void)x)/* Implement me! */
106         #define LCD_WRITE_L(x)  ((void)x)/* Implement me! */
107         #define LCD_READ_H      ( 0 /* Implement me! */ )
108         #define LCD_READ_L      ( 0 /* Implement me! */ )
109 #else
110         #define LCD_WRITE(x)    ((void)x)/* Implement me! */
111         #define LCD_READ        (0 /* Implement me! */ )
112 #endif
113 /*@}*/
114
115 /** Set data bus direction to output (write to display) */
116 #define LCD_DB_OUT          /* Implement me! */
117
118 /** Set data bus direction to input (read from display) */
119 #define LCD_DB_IN           /* Implement me! */
120
121 /** Delay for write (Enable pulse width, 220ns) */
122 #define LCD_DELAY_WRITE \
123         do { \
124                 NOP; \
125                 NOP; \
126                 NOP; \
127                 NOP; \
128                 NOP; \
129         } while (0)
130
131 /** Delay for read (Data ouput delay time, 120ns) */
132 #define LCD_DELAY_READ \
133         do { \
134                 NOP; \
135                 NOP; \
136                 NOP; \
137                 NOP; \
138         } while (0)
139
140
141 INLINE void lcd_bus_init(void)
142 {
143         cpu_flags_t flags;
144         IRQ_SAVE_DISABLE(flags);
145
146         /*
147          * Here set bus pin!
148          * to init a lcd device.
149          *
150          */
151
152         /*
153          * Data bus is in output state most of the time:
154          * LCD r/w functions assume it is left in output state
155          */
156         LCD_DB_OUT;
157
158
159         IRQ_RESTORE(flags);
160 }
161
162 #endif /* HW_LCD_H */