08.01.2013 Aufrufe

Download - Projektlabor

Download - Projektlabor

Download - Projektlabor

MEHR ANZEIGEN
WENIGER ANZEIGEN

Erfolgreiche ePaper selbst erstellen

Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.

156: else<br />

157: {<br />

158: /* configure data pins as output */<br />

159: DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);<br />

160: DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);<br />

161: DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);<br />

162: DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);<br />

163:<br />

164: /* output high nibble first */<br />

165: LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);<br />

166: LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);<br />

167: LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);<br />

168: LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);<br />

169: if(data & 0x80) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);<br />

170: if(data & 0x40) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);<br />

171: if(data & 0x20) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);<br />

172: if(data & 0x10) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);<br />

173: lcd_e_toggle();<br />

174:<br />

175: /* output low nibble */<br />

176: LCD_DATA3_PORT &= ~_BV(LCD_DATA3_PIN);<br />

177: LCD_DATA2_PORT &= ~_BV(LCD_DATA2_PIN);<br />

178: LCD_DATA1_PORT &= ~_BV(LCD_DATA1_PIN);<br />

179: LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN);<br />

180: if(data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);<br />

181: if(data & 0x04) LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);<br />

182: if(data & 0x02) LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);<br />

183: if(data & 0x01) LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);<br />

184: lcd_e_toggle();<br />

185:<br />

186: /* all data pins high (inactive) */<br />

187: LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN);<br />

188: LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN);<br />

189: LCD_DATA2_PORT |= _BV(LCD_DATA2_PIN);<br />

190: LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);<br />

191: }<br />

192: }<br />

193: #else<br />

194: #define lcd_write(d,rs) if (rs) *(volatile uint8_t*)(LCD_IO_DATA) = d;<br />

else *(volatile uint8_t*)(LCD_IO_FUNCTION) = d;<br />

195: /* rs==0 -> write instruction to LCD_IO_FUNCTION */<br />

196: /* rs==1 -> write data to LCD_IO_DATA */<br />

D:\juergen\Projekt\Projekt\prog\Frequenzzaehler\lcd.c<br />

197: #endif<br />

198:<br />

199:<br />

200:<br />

/************************************************************************<br />

*<br />

201: Low-level function to read byte from LCD controller<br />

202: Input: rs 1: read data<br />

203: 0: read busy flag / address counter<br />

204: Returns: byte read from LCD controller<br />

205:<br />

*************************************************************************<br />

/<br />

206: #if LCD_IO_MODE<br />

207: static uint8_t lcd_read(uint8_t rs)<br />

208: {<br />

209: uint8_t data;<br />

210:<br />

211:<br />

212: if (rs)<br />

213: lcd_rs_high(); /* RS=1: read data */<br />

214: else<br />

215: lcd_rs_low(); /* RS=0: read busy flag */<br />

216: lcd_rw_high(); /* RW=1 read mode */<br />

217:<br />

218: if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT ==<br />

&LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )<br />

219: && ( LCD_DATA0_PIN == 0 )&& (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN<br />

230

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!