- coding style harmonization

- check onsistency between Size & vSpan
This commit is contained in:
marschap
2007-04-04 13:52:38 +00:00
parent 3e616e4192
commit 0f0af0f381
19 changed files with 437 additions and 439 deletions
+58 -58
View File
@@ -59,12 +59,12 @@
#include <errno.h>
// Hardware specific functions
void lcdserLpt_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
void lcdserLpt_HD44780_backlight (PrivateData *p, unsigned char state);
void lcdserLpt_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
void lcdserLpt_HD44780_backlight(PrivateData *p, unsigned char state);
unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p);
void rawshift (PrivateData *p, unsigned char r);
void shiftreg (PrivateData *p, unsigned char displayID, unsigned char r);
unsigned char lcdserLpt_HD44780_scankeypad(PrivateData *p);
void rawshift(PrivateData *p, unsigned char r);
void shiftreg(PrivateData *p, unsigned char displayID, unsigned char r);
#define RS 32
#define LCDDATA 8
@@ -74,7 +74,7 @@ void shiftreg (PrivateData *p, unsigned char displayID, unsigned char r);
// Initialisation
int
hd_init_serialLpt (Driver *drvthis)
hd_init_serialLpt(Driver *drvthis)
{
PrivateData *p = (PrivateData*) drvthis->private_data;
HD44780_functions *hd44780_functions = p->hd44780_functions;
@@ -88,31 +88,31 @@ hd_init_serialLpt (Driver *drvthis)
hd44780_functions->scankeypad = lcdserLpt_HD44780_scankeypad;
// setup the lcd in 4 bit mode
shiftreg (p, enableLines, 3);
hd44780_functions->uPause (p, 15000);
shiftreg(p, enableLines, 3);
hd44780_functions->uPause(p, 15000);
shiftreg (p, enableLines, 3);
hd44780_functions->uPause (p, 5000);
shiftreg(p, enableLines, 3);
hd44780_functions->uPause(p, 5000);
shiftreg (p, enableLines, 3);
hd44780_functions->uPause (p, 100);
shiftreg(p, enableLines, 3);
hd44780_functions->uPause(p, 100);
shiftreg (p, enableLines, 3);
hd44780_functions->uPause (p, 100);
shiftreg(p, enableLines, 3);
hd44780_functions->uPause(p, 100);
shiftreg (p, enableLines, 2);
hd44780_functions->uPause (p, 100);
shiftreg(p, enableLines, 2);
hd44780_functions->uPause(p, 100);
hd44780_functions->senddata (p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
hd44780_functions->uPause (p, 40);
hd44780_functions->senddata(p, 0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
hd44780_functions->uPause(p, 40);
common_init (p, IF_8BIT);
common_init(p, IF_8BIT);
return 0;
}
void
lcdserLpt_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
lcdserLpt_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch)
{
unsigned char enableLines;
unsigned char portControl = 0;
@@ -130,24 +130,24 @@ lcdserLpt_HD44780_senddata (PrivateData *p, unsigned char displayID, unsigned ch
else
portControl = 0;
shiftreg (p, enableLines, portControl | h);
shiftreg (p, enableLines, portControl | l);
shiftreg(p, enableLines, portControl | h);
shiftreg(p, enableLines, portControl | l);
// Restore line status for backlight
port_out (p->port, p->backlight_bit );
port_out(p->port, p->backlight_bit);
}
void
lcdserLpt_HD44780_backlight (PrivateData *p, unsigned char state)
lcdserLpt_HD44780_backlight(PrivateData *p, unsigned char state)
{
// Store new state
p->backlight_bit = (state?LCDDATA:0);
// Set line status for backlight
port_out (p->port, p->backlight_bit );
port_out(p->port, p->backlight_bit);
}
unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
unsigned char lcdserLpt_HD44780_scankeypad(PrivateData *p)
{
// Unfortunately just bit shifting does not work with the 2-wire version...
@@ -169,14 +169,14 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
// (Positioning the cursor out of screen does not work either :( )
// Set cursor position
p->hd44780_functions->senddata (p, 0, RS_INSTR, POSITION | 0 );
p->hd44780_functions->uPause (p, 40);
p->hd44780_functions->senddata(p, 0, RS_INSTR, POSITION | 0);
p->hd44780_functions->uPause(p, 40);
// Clear the shiftregister, needed for 3-wire version
rawshift(p, 0);
p->hd44780_functions->uPause (p, 1);
p->hd44780_functions->uPause(p, 1);
readval = ~ port_in (p->port + 1) ^ INMASK;
readval = ~ port_in(p->port + 1) ^ INMASK;
// And convert value back (MSB first).
inputs_zero = (((readval & FAULT) / FAULT <<4) | /* pin 15 */
@@ -186,24 +186,24 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
((readval & ACK) / ACK )); /* pin 10 */
if ( inputs_zero == 0 ) {
if (inputs_zero == 0) {
// No keys were pressed
// Restore line status for backlight.
port_out (p->port, p->backlight_bit );
port_out(p->port, p->backlight_bit);
return 0;
}
// Scan the keypad while sending the first half of the command (high nibble)
for (i = 7; i >= 0; i--) { /* MSB first */
port_out (p->port, LCDDATA); /*set up data */
port_out (p->port, LCDDATA | LCDCLOCK); /*rising edge of clock */
port_out(p->port, LCDDATA); /*set up data */
port_out(p->port, LCDDATA | LCDCLOCK); /*rising edge of clock */
p->hd44780_functions->uPause (p, 1);
p->hd44780_functions->uPause(p, 1);
if ( !scancode ) {
if (!scancode) {
// Read input line(s)
readval = ~ port_in (p->port + 1) ^ INMASK;
readval = ~ port_in(p->port + 1) ^ INMASK;
// And convert value back (MSB first).
keybits = (((readval & FAULT) / FAULT <<4) | /* pin 15 */
@@ -212,10 +212,10 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
((readval & BUSY) / BUSY <<1) | /* pin 11 */
((readval & ACK) / ACK )); /* pin 10 */
if ( keybits != inputs_zero ) {
if (keybits != inputs_zero) {
shiftingbit = 1;
for (shiftcount=0; shiftcount<KEYPAD_MAXX && !scancode; shiftcount++) {
if ( (keybits ^ inputs_zero ) & shiftingbit) {
if ((keybits ^ inputs_zero) & shiftingbit) {
// Found !
scancode = ((8-i)<<4) | (shiftcount+1);
}
@@ -226,30 +226,30 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
}
// Wait for 2-wire version to clear the latch...
p->hd44780_functions->uPause (p, 6);
p->hd44780_functions->uPause(p, 6);
// And again for the second half of the command (low nibble).
// Needed for 2-wire version.
rawshift (p, 0xFF);
rawshift(p, 0xFF);
// Wait 6us for 2-wire version to clear the latch and wait for
// the data to be processed
p->hd44780_functions->uPause (p, 40);
p->hd44780_functions->uPause(p, 40);
// Restore the screen state
// Move back to home cursor position
p->hd44780_functions->senddata (p, 0, RS_INSTR, POSITION | 0 );
p->hd44780_functions->uPause (p, 40);
p->hd44780_functions->senddata(p, 0, RS_INSTR, POSITION | 0);
p->hd44780_functions->uPause(p, 40);
// Output the corect byte
p->hd44780_functions->senddata (p, 1, RS_DATA,
p->framebuf[0] );
p->hd44780_functions->senddata(p, 1, RS_DATA,
p->framebuf[0]);
// ... and second display if connected ...
if (p->numDisplays>1) {
p->hd44780_functions->senddata (p, 2, RS_DATA,
p->framebuf[ p->width * p->dispVOffset[2-1] ] );
p->hd44780_functions->senddata(p, 2, RS_DATA,
p->framebuf[ p->width * p->dispVOffset[2-1] ]);
}
p->hd44780_functions->uPause (p, 40);
p->hd44780_functions->uPause(p, 40);
// No need to restore the line for backlight, already done by senddata.
@@ -258,23 +258,23 @@ unsigned char lcdserLpt_HD44780_scankeypad (PrivateData *p)
/* this function sends r out onto the shift register */
void
rawshift (PrivateData *p, unsigned char r)
rawshift(PrivateData *p, unsigned char r)
{
int i;
for (i = 7; i >= 0; i--) { /* MSB first */
port_out (p->port, ((r >> i) & 1) * LCDDATA); /*set up data */
port_out (p->port, (((r >> i) & 1) * LCDDATA) | LCDCLOCK); /*rising edge of clock */
port_out(p->port, ((r >> i) & 1) * LCDDATA); /*set up data */
port_out(p->port, (((r >> i) & 1) * LCDDATA) | LCDCLOCK); /*rising edge of clock */
}
}
// enableLines = value on parallel port to toggle the correct display
void
shiftreg (PrivateData *p, unsigned char enableLines, unsigned char r)
shiftreg(PrivateData *p, unsigned char enableLines, unsigned char r)
{
rawshift (p, r | 0x80); // highest bit always set to 1 for Clear for 2-wire version
port_out (p->port, enableLines); // latch it, to correct display
p->hd44780_functions->uPause (p, 1);
port_out (p->port, 0); // for 3-wire version
p->hd44780_functions->uPause (p, 5); // wait for 2-wire version to clear the latch...
rawshift(p, r | 0x80); // highest bit always set to 1 for Clear for 2-wire version
port_out(p->port, enableLines); // latch it, to correct display
p->hd44780_functions->uPause(p, 1);
port_out(p->port, 0); // for 3-wire version
p->hd44780_functions->uPause(p, 5); // wait for 2-wire version to clear the latch...
}