HD44780 update:
- howto updated - input pin readout reversed - 4bit and serialLpt init timing modified
This commit is contained in:
@@ -260,6 +260,10 @@ unsigned char lcdstat_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
// Put port back into idle state for backlight
|
||||
port_out (p->port, p->backlight_bit);
|
||||
|
||||
// And convert value back.
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
||||
// And convert value back (MSB first).
|
||||
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
((readval & SELIN) / SELIN <<3) | /* pin 13 */
|
||||
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
|
||||
((readval & BUSY) / BUSY <<1) | /* pin 11 */
|
||||
((readval & ACK) / ACK )) & ~p->stuckinputs; /* pin 10 */
|
||||
}
|
||||
|
||||
@@ -169,6 +169,10 @@ unsigned char lcdtime_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
port_out (p->port, p->backlight_bit ^ OUTMASK);
|
||||
sem_signal (semid);
|
||||
|
||||
// And convert value back.
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
||||
// And convert value back (MSB first).
|
||||
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
((readval & SELIN) / SELIN <<3) | /* pin 13 */
|
||||
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
|
||||
((readval & BUSY) / BUSY <<1) | /* pin 11 */
|
||||
((readval & ACK) / ACK )) & ~p->stuckinputs; /* pin 10 */
|
||||
}
|
||||
|
||||
@@ -97,7 +97,10 @@ hd_init_serialLpt (Driver *drvthis)
|
||||
hd44780_functions->uPause (p, 5000);
|
||||
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 150);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
|
||||
shiftreg (p, enableLines, 3);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
|
||||
shiftreg (p, enableLines, 2);
|
||||
hd44780_functions->uPause (p, 100);
|
||||
@@ -168,7 +171,14 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
p->hd44780_functions->uPause (p, 1);
|
||||
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
inputs_zero = ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) );
|
||||
|
||||
// And convert value back (MSB first).
|
||||
inputs_zero = (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
((readval & SELIN) / SELIN <<3) | /* pin 13 */
|
||||
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
|
||||
((readval & BUSY) / BUSY <<1) | /* pin 11 */
|
||||
((readval & ACK) / ACK )); /* pin 10 */
|
||||
|
||||
|
||||
if( inputs_zero == 0 ) {
|
||||
// No keys were pressed
|
||||
@@ -192,7 +202,14 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
|
||||
if( !scancode ) {
|
||||
// Read input line(s)
|
||||
readval = ~ port_in (p->port + 1) ^ INMASK;
|
||||
keybits = ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) );
|
||||
|
||||
// And convert value back (MSB first).
|
||||
keybits = (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
((readval & SELIN) / SELIN <<3) | /* pin 13 */
|
||||
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
|
||||
((readval & BUSY) / BUSY <<1) | /* pin 11 */
|
||||
((readval & ACK) / ACK )); /* pin 10 */
|
||||
|
||||
if( keybits != inputs_zero ) {
|
||||
shiftingbit = 1;
|
||||
for (shiftcount=0; shiftcount<KEYPAD_MAXX && !scancode; shiftcount++) {
|
||||
|
||||
@@ -186,6 +186,10 @@ unsigned char lcdwinamp_HD44780_readkeypad (PrivateData *p, unsigned int YData)
|
||||
// Set output back to idle state for backlight
|
||||
port_out (p->port + 2, p->backlight_bit ^ OUTMASK );
|
||||
|
||||
// And convert value back.
|
||||
return ( (readval >> 4 & 0x03) | (readval >> 5 & 0x04) | (readval >> 3 & 0x08) | (readval << 1 & 0x10) ) & ~p->stuckinputs;
|
||||
// And convert value back (MSB first).
|
||||
return (((readval & FAULT) / FAULT <<4) | /* pin 15 */
|
||||
((readval & SELIN) / SELIN <<3) | /* pin 13 */
|
||||
((readval & PAPEREND) / PAPEREND <<2) | /* pin 12 */
|
||||
((readval & BUSY) / BUSY <<1) | /* pin 11 */
|
||||
((readval & ACK) / ACK )) & ~p->stuckinputs; /* pin 10 */
|
||||
}
|
||||
|
||||
+14
-12
@@ -23,21 +23,23 @@
|
||||
/* Output data
|
||||
* Write to baseaddress+0
|
||||
*/
|
||||
// Straight-forward use, no defines needed for this...
|
||||
/* Straight-forward use, no defines needed for this... */
|
||||
|
||||
|
||||
/* Control output lines
|
||||
* Write to baseaddress+2
|
||||
*/
|
||||
#define nSTRB 0x01 /* negative logic */
|
||||
#define nSTRB 0x01 /* pin 1; negative logic */
|
||||
#define STRB 0x01
|
||||
#define nLF 0x02
|
||||
#define nLF 0x02 /* pin 14 */
|
||||
#define LF 0x02
|
||||
#define INIT 0x04 /* the only positive logic output line */
|
||||
#define nSEL 0x08
|
||||
#define INIT 0x04 /* pin 16; the only positive logic output line */
|
||||
#define nSEL 0x08 /* pin 17 */
|
||||
#define SEL 0x08
|
||||
#define ENIRQ 0x10 /* Enable IRQ via ACK line */
|
||||
#define ENBI 0x20 /* Enable bi-directional port */
|
||||
#define ENIRQ 0x10 /* Enable IRQ via ACK line (don't enable this without
|
||||
* setting up interrupt stuff too) */
|
||||
#define ENBI 0x20 /* Enable bi-directional port (is nice to play with!
|
||||
* I first didn't know a SPP could do this) */
|
||||
|
||||
#define OUTMASK 0x0B /* SEL, LF and STRB are hardware inverted */
|
||||
/* Use this mask only for the control output lines */
|
||||
@@ -47,13 +49,13 @@
|
||||
/* Control input lines
|
||||
* Read from baseaddress+1
|
||||
*/
|
||||
#define nFAULT 0x08
|
||||
#define nFAULT 0x08 /* pin 15 */
|
||||
#define FAULT 0x08
|
||||
#define SELIN 0x10
|
||||
#define PAPEREND 0x20
|
||||
#define nACK 0x40
|
||||
#define SELIN 0x10 /* pin 13 */
|
||||
#define PAPEREND 0x20 /* pin 12 */
|
||||
#define nACK 0x40 /* pin 10 */
|
||||
#define ACK 0x40
|
||||
#define BUSY 0x80
|
||||
#define BUSY 0x80 /* pin 11 */
|
||||
#define IRQ 0x02
|
||||
|
||||
#define INMASK 0x84 /* BUSY input and the IRQ indicator are inverted */
|
||||
|
||||
Reference in New Issue
Block a user