Stefan Schuermans commited on 2012-02-12 20:46:27
Showing 2 changed files, with 45 additions and 12 deletions.
... | ... |
@@ -37,7 +37,6 @@ void lcd_set_rs(unsigned char state) |
37 | 37 |
*/ |
38 | 38 |
void lcd_set_rw(unsigned char state) |
39 | 39 |
{ |
40 |
- volatile unsigned char *p_lcd_rw = (volatile unsigned char *)0x80000103; |
|
41 | 40 |
lcd_ptr[3] = state; |
42 | 41 |
} |
43 | 42 |
|
... | ... |
@@ -100,17 +99,36 @@ void lcd_init(void) |
100 | 99 |
lcd_byte(0, 0x0C); |
101 | 100 |
lcd_byte(0, 0x01); |
102 | 101 |
cyc_cnt_delay_us(1640); |
103 |
- lcd_byte(1, 'H'); |
|
104 |
- lcd_byte(1, 'e'); |
|
105 |
- lcd_byte(1, 'l'); |
|
106 |
- lcd_byte(1, 'l'); |
|
107 |
- lcd_byte(1, 'o'); |
|
102 |
+} |
|
103 |
+ |
|
104 |
+/** |
|
105 |
+ * @brief show character |
|
106 |
+ * @param[in] line number of line (0..1) |
|
107 |
+ * @param[in] pos position in line (0..15) |
|
108 |
+ * @param[in] chr character to set |
|
109 |
+ */ |
|
110 |
+void lcd_chr(unsigned int line, unsigned int pos, char chr) |
|
111 |
+{ |
|
112 |
+ if (line > 1 || pos > 15) |
|
113 |
+ return; |
|
114 |
+ lcd_byte(0, 0x80 | line << 6 | pos); |
|
115 |
+ lcd_byte(1, chr); |
|
116 |
+} |
|
117 |
+ |
|
118 |
+/** |
|
119 |
+ * @brief show string |
|
120 |
+ * @param[in] line number of line (0..1) |
|
121 |
+ * @param[in] str string to show |
|
122 |
+ */ |
|
123 |
+void lcd_str(unsigned int line, const char *str) |
|
124 |
+{ |
|
125 |
+ if (line > 1) |
|
126 |
+ return; |
|
127 |
+ lcd_byte(0, 0x80 | line << 6); |
|
128 |
+ unsigned int cnt; |
|
129 |
+ for (cnt = 0; cnt < 16 && str[cnt] != 0; ++cnt) |
|
130 |
+ lcd_byte(1, str[cnt]); |
|
131 |
+ for (; cnt < 16; ++cnt) |
|
108 | 132 |
lcd_byte(1, ' '); |
109 |
- lcd_byte(1, 'W'); |
|
110 |
- lcd_byte(1, 'o'); |
|
111 |
- lcd_byte(1, 'r'); |
|
112 |
- lcd_byte(1, 'l'); |
|
113 |
- lcd_byte(1, 'd'); |
|
114 |
- lcd_byte(1, '!'); |
|
115 | 133 |
} |
116 | 134 |
|
... | ... |
@@ -38,5 +38,20 @@ void lcd_byte(unsigned char data, unsigned char byte); |
38 | 38 |
/** initialize LCD */ |
39 | 39 |
void lcd_init(void); |
40 | 40 |
|
41 |
+/** |
|
42 |
+ * @brief show character |
|
43 |
+ * @param[in] line number of line (0..1) |
|
44 |
+ * @param[in] pos position in line (0..15) |
|
45 |
+ * @param[in] chr character to set |
|
46 |
+ */ |
|
47 |
+void lcd_chr(unsigned int line, unsigned int pos, char chr); |
|
48 |
+ |
|
49 |
+/** |
|
50 |
+ * @brief show string |
|
51 |
+ * @param[in] line number of line (0..1) |
|
52 |
+ * @param[in] str string to show |
|
53 |
+ */ |
|
54 |
+void lcd_str(unsigned int line, const char *str); |
|
55 |
+ |
|
41 | 56 |
#endif /* #ifndef LCD_H */ |
42 | 57 |
|
43 | 58 |