|
@@ -28,117 +28,117 @@ static const DigitalPort LCD_E = DigitalPort::D17 ;
|
|
|
|
|
|
|
|
|
static void driveHighE (void) {
|
|
|
- digitalWrite (LCD_E, true) ;
|
|
|
+ digitalWrite (LCD_E, true) ;
|
|
|
}
|
|
|
|
|
|
static void driveLowE (void) {
|
|
|
- digitalWrite (LCD_E, false) ;
|
|
|
+ digitalWrite (LCD_E, false) ;
|
|
|
}
|
|
|
|
|
|
static void driveHighRS (void) {
|
|
|
- digitalWrite (LCD_RS, true) ;
|
|
|
+ digitalWrite (LCD_RS, true) ;
|
|
|
}
|
|
|
|
|
|
static void driveLowRS (void) {
|
|
|
- digitalWrite (LCD_RS, false) ;
|
|
|
+ digitalWrite (LCD_RS, false) ;
|
|
|
}
|
|
|
|
|
|
static void setD4 (const bool inValue) {
|
|
|
- digitalWrite (LCD_D4, inValue) ;
|
|
|
+ digitalWrite (LCD_D4, inValue) ;
|
|
|
}
|
|
|
|
|
|
static void setD5 (const bool inValue) {
|
|
|
- digitalWrite (LCD_D5, inValue) ;
|
|
|
+ digitalWrite (LCD_D5, inValue) ;
|
|
|
}
|
|
|
|
|
|
static void setD6 (const bool inValue) {
|
|
|
- digitalWrite (LCD_D6, inValue) ;
|
|
|
+ digitalWrite (LCD_D6, inValue) ;
|
|
|
}
|
|
|
|
|
|
static void setD7 (const bool inValue) {
|
|
|
- digitalWrite (LCD_D7, inValue) ;
|
|
|
+ digitalWrite (LCD_D7, inValue) ;
|
|
|
}
|
|
|
|
|
|
static void programLcd4BitDataBusOutput (const uint8_t inValue) {
|
|
|
- setD4 ((inValue & 0x01) != 0) ;
|
|
|
- setD5 ((inValue & 0x02) != 0) ;
|
|
|
- setD6 ((inValue & 0x04) != 0) ;
|
|
|
- setD7 ((inValue & 0x08) != 0) ;
|
|
|
+ setD4 ((inValue & 0x01) != 0) ;
|
|
|
+ setD5 ((inValue & 0x02) != 0) ;
|
|
|
+ setD6 ((inValue & 0x04) != 0) ;
|
|
|
+ setD7 ((inValue & 0x08) != 0) ;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void write4BitCommand_initMode (INIT_MODE_ const uint8_t inCommand) {
|
|
|
- busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
- driveLowRS () ;
|
|
|
- programLcd4BitDataBusOutput (inCommand) ;
|
|
|
- driveHighE () ;
|
|
|
- busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
- driveLowE () ;
|
|
|
+ busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
+ driveLowRS () ;
|
|
|
+ programLcd4BitDataBusOutput (inCommand) ;
|
|
|
+ driveHighE () ;
|
|
|
+ busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
+ driveLowE () ;
|
|
|
}
|
|
|
|
|
|
static void write8bitCommand_initMode (INIT_MODE_ const uint8_t inCommand) {
|
|
|
- busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
- driveLowRS () ;
|
|
|
- programLcd4BitDataBusOutput ((uint8_t) (inCommand >> 4)) ;
|
|
|
- driveHighE () ;
|
|
|
- busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
- driveLowE () ;
|
|
|
- busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
- programLcd4BitDataBusOutput (inCommand) ;
|
|
|
- driveHighE () ;
|
|
|
- busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
- driveLowE () ;
|
|
|
+ busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
+ driveLowRS () ;
|
|
|
+ programLcd4BitDataBusOutput ((uint8_t) (inCommand >> 4)) ;
|
|
|
+ driveHighE () ;
|
|
|
+ busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
+ driveLowE () ;
|
|
|
+ busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
+ programLcd4BitDataBusOutput (inCommand) ;
|
|
|
+ driveHighE () ;
|
|
|
+ busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
+ driveLowE () ;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setupLCD (INIT_MODE) {
|
|
|
-
|
|
|
- pinMode (LCD_D4, DigitalMode::OUTPUT) ;
|
|
|
- pinMode (LCD_D5, DigitalMode::OUTPUT) ;
|
|
|
- pinMode (LCD_D6, DigitalMode::OUTPUT) ;
|
|
|
- pinMode (LCD_D7, DigitalMode::OUTPUT) ;
|
|
|
- pinMode (LCD_RS, DigitalMode::OUTPUT) ;
|
|
|
- pinMode (LCD_E, DigitalMode::OUTPUT) ;
|
|
|
-
|
|
|
- busyWaitDuring_initMode (MODE_ 15) ;
|
|
|
-
|
|
|
- write4BitCommand_initMode (MODE_ 0x3) ;
|
|
|
-
|
|
|
- busyWaitDuring_initMode (MODE_ 5) ;
|
|
|
-
|
|
|
- write4BitCommand_initMode (MODE_ 0x3) ;
|
|
|
-
|
|
|
- busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
-
|
|
|
- write4BitCommand_initMode (MODE_ 0x3) ;
|
|
|
-
|
|
|
- write4BitCommand_initMode (MODE_ 0x2) ;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- write8bitCommand_initMode (MODE_ 0x28) ;
|
|
|
-
|
|
|
- write8bitCommand_initMode (MODE_ 0x08) ;
|
|
|
-
|
|
|
- write8bitCommand_initMode (MODE_ 0x01) ;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- write8bitCommand_initMode (MODE_ 0x06) ;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- write8bitCommand_initMode (MODE_ 0x1C) ;
|
|
|
-
|
|
|
- write8bitCommand_initMode (MODE_ 0x02) ;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- write8bitCommand_initMode (MODE_ 0x0C) ;
|
|
|
+
|
|
|
+ pinMode (LCD_D4, DigitalMode::OUTPUT) ;
|
|
|
+ pinMode (LCD_D5, DigitalMode::OUTPUT) ;
|
|
|
+ pinMode (LCD_D6, DigitalMode::OUTPUT) ;
|
|
|
+ pinMode (LCD_D7, DigitalMode::OUTPUT) ;
|
|
|
+ pinMode (LCD_RS, DigitalMode::OUTPUT) ;
|
|
|
+ pinMode (LCD_E, DigitalMode::OUTPUT) ;
|
|
|
+
|
|
|
+ busyWaitDuring_initMode (MODE_ 15) ;
|
|
|
+
|
|
|
+ write4BitCommand_initMode (MODE_ 0x3) ;
|
|
|
+
|
|
|
+ busyWaitDuring_initMode (MODE_ 5) ;
|
|
|
+
|
|
|
+ write4BitCommand_initMode (MODE_ 0x3) ;
|
|
|
+
|
|
|
+ busyWaitDuring_initMode (MODE_ 1) ;
|
|
|
+
|
|
|
+ write4BitCommand_initMode (MODE_ 0x3) ;
|
|
|
+
|
|
|
+ write4BitCommand_initMode (MODE_ 0x2) ;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ write8bitCommand_initMode (MODE_ 0x28) ;
|
|
|
+
|
|
|
+ write8bitCommand_initMode (MODE_ 0x08) ;
|
|
|
+
|
|
|
+ write8bitCommand_initMode (MODE_ 0x01) ;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ write8bitCommand_initMode (MODE_ 0x06) ;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ write8bitCommand_initMode (MODE_ 0x1C) ;
|
|
|
+
|
|
|
+ write8bitCommand_initMode (MODE_ 0x02) ;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ write8bitCommand_initMode (MODE_ 0x0C) ;
|
|
|
}
|
|
|
|
|
|
MACRO_INIT_ROUTINE (setupLCD) ;
|
|
@@ -146,38 +146,38 @@ MACRO_INIT_ROUTINE (setupLCD) ;
|
|
|
|
|
|
|
|
|
static void write8bitCommand (USER_MODE_ const uint8_t inCommand) {
|
|
|
- busyWaitDuring (MODE_ 1) ;
|
|
|
- driveLowRS () ;
|
|
|
- programLcd4BitDataBusOutput ((uint8_t) (inCommand >> 4)) ;
|
|
|
- driveHighE () ;
|
|
|
- busyWaitDuring (MODE_ 1) ;
|
|
|
- driveLowE () ;
|
|
|
- busyWaitDuring (MODE_ 1) ;
|
|
|
- programLcd4BitDataBusOutput (inCommand) ;
|
|
|
- driveHighE () ;
|
|
|
- busyWaitDuring (MODE_ 1) ;
|
|
|
- driveLowE () ;
|
|
|
+ busyWaitDuring (MODE_ 1) ;
|
|
|
+ driveLowRS () ;
|
|
|
+ programLcd4BitDataBusOutput ((uint8_t) (inCommand >> 4)) ;
|
|
|
+ driveHighE () ;
|
|
|
+ busyWaitDuring (MODE_ 1) ;
|
|
|
+ driveLowE () ;
|
|
|
+ busyWaitDuring (MODE_ 1) ;
|
|
|
+ programLcd4BitDataBusOutput (inCommand) ;
|
|
|
+ driveHighE () ;
|
|
|
+ busyWaitDuring (MODE_ 1) ;
|
|
|
+ driveLowE () ;
|
|
|
}
|
|
|
|
|
|
|
|
|
static void writeData (USER_MODE_ const uint8_t inData) {
|
|
|
- busyWaitDuring (MODE_ 1) ;
|
|
|
- driveHighRS () ;
|
|
|
- programLcd4BitDataBusOutput (inData >> 4) ;
|
|
|
- driveHighE () ;
|
|
|
- busyWaitDuring (MODE_ 1) ;
|
|
|
- driveLowE () ;
|
|
|
- busyWaitDuring (MODE_ 1) ;
|
|
|
- programLcd4BitDataBusOutput (inData) ;
|
|
|
- driveHighE () ;
|
|
|
- busyWaitDuring (MODE_ 1) ;
|
|
|
- driveLowE () ;
|
|
|
+ busyWaitDuring (MODE_ 1) ;
|
|
|
+ driveHighRS () ;
|
|
|
+ programLcd4BitDataBusOutput (inData >> 4) ;
|
|
|
+ driveHighE () ;
|
|
|
+ busyWaitDuring (MODE_ 1) ;
|
|
|
+ driveLowE () ;
|
|
|
+ busyWaitDuring (MODE_ 1) ;
|
|
|
+ programLcd4BitDataBusOutput (inData) ;
|
|
|
+ driveHighE () ;
|
|
|
+ busyWaitDuring (MODE_ 1) ;
|
|
|
+ driveLowE () ;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void clearScreen (USER_MODE) {
|
|
|
- write8bitCommand (MODE_ 0x01) ;
|
|
|
+ write8bitCommand (MODE_ 0x01) ;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -186,99 +186,99 @@ void clearScreen (USER_MODE) {
|
|
|
|
|
|
|
|
|
void gotoLineColumn (USER_MODE_ const uint32_t inLine, const uint32_t inColumn) {
|
|
|
- static const uint8_t tab [4] = {0, 64, 20, 84} ;
|
|
|
- if ((inLine < 4) && (inColumn < 20)) {
|
|
|
- write8bitCommand (MODE_ tab [inLine] + inColumn + 0x80U) ;
|
|
|
- }
|
|
|
+ static const uint8_t tab [4] = {0, 64, 20, 84} ;
|
|
|
+ if ((inLine < 4) && (inColumn < 20)) {
|
|
|
+ write8bitCommand (MODE_ tab [inLine] + inColumn + 0x80U) ;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void printString (USER_MODE_ const char * inString) {
|
|
|
- if (NULL != inString) {
|
|
|
- while ('\0' != *inString) {
|
|
|
- writeData (MODE_ *inString) ;
|
|
|
- inString ++ ;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (NULL != inString) {
|
|
|
+ while ('\0' != *inString) {
|
|
|
+ writeData (MODE_ *inString) ;
|
|
|
+ inString ++ ;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void printChar (USER_MODE_ const char inChar) {
|
|
|
- writeData (MODE_ inChar) ;
|
|
|
+ writeData (MODE_ inChar) ;
|
|
|
}
|
|
|
|
|
|
void printSpaces (USER_MODE_ const uint32_t inCount) {
|
|
|
- uint32_t count = inCount ;
|
|
|
- while (count > 0) {
|
|
|
- printChar (MODE_ ' ') ;
|
|
|
- count -- ;
|
|
|
- }
|
|
|
+ uint32_t count = inCount ;
|
|
|
+ while (count > 0) {
|
|
|
+ printChar (MODE_ ' ') ;
|
|
|
+ count -- ;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void printUnsigned (USER_MODE_ const uint32_t inValue) {
|
|
|
- uint32_t divisor = 1000 * 1000 * 1000 ;
|
|
|
- uint32_t value = inValue ;
|
|
|
- bool isPrinting = false ;
|
|
|
- while (divisor > 0) {
|
|
|
- if (isPrinting || (value >= divisor)) {
|
|
|
- printChar (MODE_ '0' + value / divisor) ;
|
|
|
- value %= divisor ;
|
|
|
- isPrinting = true ;
|
|
|
- }
|
|
|
- divisor /= 10 ;
|
|
|
- }
|
|
|
- if (!isPrinting) {
|
|
|
- printChar (MODE_ '0') ;
|
|
|
- }
|
|
|
+ uint32_t divisor = 1000 * 1000 * 1000 ;
|
|
|
+ uint32_t value = inValue ;
|
|
|
+ bool isPrinting = false ;
|
|
|
+ while (divisor > 0) {
|
|
|
+ if (isPrinting || (value >= divisor)) {
|
|
|
+ printChar (MODE_ '0' + value / divisor) ;
|
|
|
+ value %= divisor ;
|
|
|
+ isPrinting = true ;
|
|
|
+ }
|
|
|
+ divisor /= 10 ;
|
|
|
+ }
|
|
|
+ if (!isPrinting) {
|
|
|
+ printChar (MODE_ '0') ;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void printUnsigned64 (USER_MODE_ const uint64_t inValue) {
|
|
|
- char buffer [20] ;
|
|
|
- buffer [19] = '\0' ;
|
|
|
- buffer [18] = (inValue % 10) + '0' ;
|
|
|
- uint32_t idx = 18 ;
|
|
|
- uint64_t v = inValue / 10 ;
|
|
|
- while (v != 0) {
|
|
|
- idx -- ;
|
|
|
- buffer [idx] = (v % 10) + '0' ;
|
|
|
- v /= 10 ;
|
|
|
- }
|
|
|
- printString (MODE_ & buffer [idx]) ;
|
|
|
+ char buffer [20] ;
|
|
|
+ buffer [19] = '\0' ;
|
|
|
+ buffer [18] = (inValue % 10) + '0' ;
|
|
|
+ uint32_t idx = 18 ;
|
|
|
+ uint64_t v = inValue / 10 ;
|
|
|
+ while (v != 0) {
|
|
|
+ idx -- ;
|
|
|
+ buffer [idx] = (v % 10) + '0' ;
|
|
|
+ v /= 10 ;
|
|
|
+ }
|
|
|
+ printString (MODE_ & buffer [idx]) ;
|
|
|
}
|
|
|
|
|
|
void printSigned (USER_MODE_ const int32_t inValue) {
|
|
|
- if (inValue < 0) {
|
|
|
- printChar (MODE_ '-') ;
|
|
|
- printUnsigned (MODE_ (uint32_t) -inValue) ;
|
|
|
- }else{
|
|
|
- printUnsigned (MODE_ (uint32_t) inValue) ;
|
|
|
- }
|
|
|
+ if (inValue < 0) {
|
|
|
+ printChar (MODE_ '-') ;
|
|
|
+ printUnsigned (MODE_ (uint32_t) -inValue) ;
|
|
|
+ }else{
|
|
|
+ printUnsigned (MODE_ (uint32_t) inValue) ;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void printHex1 (USER_MODE_ const uint32_t inValue) {
|
|
|
- const uint32_t v = inValue & 0xF ;
|
|
|
- if (v < 10) {
|
|
|
- printChar (MODE_ '0' + v) ;
|
|
|
- }else{
|
|
|
- printChar (MODE_ 'A' + v - 10) ;
|
|
|
- }
|
|
|
+ const uint32_t v = inValue & 0xF ;
|
|
|
+ if (v < 10) {
|
|
|
+ printChar (MODE_ '0' + v) ;
|
|
|
+ }else{
|
|
|
+ printChar (MODE_ 'A' + v - 10) ;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void printHex2 (USER_MODE_ const uint32_t inValue) {
|
|
|
- printHex1 (MODE_ inValue >> 4) ;
|
|
|
- printHex1 (MODE_ inValue) ;
|
|
|
+ printHex1 (MODE_ inValue >> 4) ;
|
|
|
+ printHex1 (MODE_ inValue) ;
|
|
|
}
|
|
|
|
|
|
void printHex4 (USER_MODE_ const uint32_t inValue) {
|
|
|
- printHex2 (MODE_ inValue >> 8) ;
|
|
|
- printHex2 (MODE_ inValue) ;
|
|
|
+ printHex2 (MODE_ inValue >> 8) ;
|
|
|
+ printHex2 (MODE_ inValue) ;
|
|
|
}
|
|
|
|
|
|
void printHex8 (USER_MODE_ const uint32_t inValue) {
|
|
|
- printHex4 (MODE_ inValue >> 16) ;
|
|
|
- printHex4 (MODE_ inValue) ;
|
|
|
+ printHex4 (MODE_ inValue >> 16) ;
|
|
|
+ printHex4 (MODE_ inValue) ;
|
|
|
}
|
|
|
|
|
|
void printHex16 (USER_MODE_ const uint64_t inValue) {
|
|
|
- printHex8 (MODE_ (uint32_t) (inValue >> 32)) ;
|
|
|
- printHex8 (MODE_ (uint32_t) inValue) ;
|
|
|
+ printHex8 (MODE_ (uint32_t) (inValue >> 32)) ;
|
|
|
+ printHex8 (MODE_ (uint32_t) inValue) ;
|
|
|
}
|
|
|
|