TextLCD test code for US2066 using I2C interface on W7500 platform

Dependencies:   TextLCD mbed

Fork of Serial_HelloWorld_WIZwiki-W7500 by WIZnet

Files at this revision

API Documentation at this revision

Comitter:
wim
Date:
Wed May 10 18:22:27 2017 +0000
Parent:
3:14276e409985
Commit message:
TextLCD test code for US2066 using I2C interface on W7500 platform

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 14276e409985 -r bb94badd9ebe TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Wed May 10 18:22:27 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/wim/code/TextLCD/#111ca62e8a59
diff -r 14276e409985 -r bb94badd9ebe main.cpp
--- a/main.cpp	Mon Jun 29 04:02:22 2015 +0000
+++ b/main.cpp	Wed May 10 18:22:27 2017 +0000
@@ -14,12 +14,78 @@
  * limitations under the License.
  */
 #include "mbed.h"
+#include "TextLCD.h"
  
 Serial pc(USBTX, USBRX); // tx, rx
- 
+
+DigitalOut red(LED_RED);        // PC_8
+DigitalOut green(LED_GREEN);    // PC_9
+DigitalOut blue(LED_BLUE);      // PC_5
+
+
+I2C i2c_lcd(D14, D15); //SDA, SCL = PA_10, PA_9
+char cnt = 0;   
+
+//TextLCD_I2C_N lcd(&i2c_lcd, US2066_SA0, TextLCD::LCD20x4D, NC, TextLCD::US2066_3V3); // I2C bus, slaveaddress, LCDType=LCD20x4D, BL=NC, LCDTCtrl=US2066
+TextLCD_I2C_N lcd(&i2c_lcd, US2066_SA0, TextLCD::LCD20x2, NC, TextLCD::US2066_3V3); // I2C bus, slaveaddress, LCDType=LCD20x2, BL=NC, LCDTCtrl=US2066
+   
 int main() {
-    pc.printf("Hello World!\n\r");
-    while(1) {
-        pc.putc(pc.getc() + 1); // echo input back to terminal
-    }
+  pc.printf("\n\r");  
+  pc.printf("Hello World from W7500!\n\r");
+  pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock);   
+
+//Test to fix the SystemCoreClock
+#if(0)
+#ifdef SYSCLK_EXTERN_OSC
+  pc.printf("SYSCLK_EXTERN_OSC = 1; EXTERN_XTAL = %d\n\r", EXTERN_XTAL);
+//  CRG->PLL_IFSR = CRG_PLL_IFSR_OCLK;  
+#else  
+  pc.printf("SYSCLK_EXTERN_OSC = 0; INTERN_XTAL = %d\n\r", INTERN_XTAL);
+//  CRG->PLL_IFSR = CRG_PLL_IFSR_RCLK;  
+#endif      
+  pc.printf("CRG->PLL_IFSR = 0x%0X\n\r", CRG->PLL_IFSR);
+  
+  pc.printf("CRG->PLL_FCR = 0x%0X\n\r", CRG->PLL_FCR);  
+
+uint8_t M,N,OD;
+
+  OD = (1 << (CRG->PLL_FCR & 0x01)) * (1 << ((CRG->PLL_FCR & 0x02) >> 1));
+   N = (CRG->PLL_FCR >>  8 ) & 0x3F;
+   M = (CRG->PLL_FCR >> 16) & 0x3F;
+   pc.printf("M = %d; N = %d; OD = %d\n\r", M, N, OD);  
+   
+  pc.printf("Adapt PLL\n\r");
+  wait(1.0);
+      
+  CRG->PLL_FCR = 0x060100;      
+  pc.printf("CRG->PLL_FCR = 0x%0X\n\r", CRG->PLL_FCR);      
+  SystemCoreClockUpdate();
+  pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock);   
+#endif
+
+  red = 1;  
+  green = 1;  
+  blue = 1;      
+
+  if (! i2c_lcd.write(US2066_SA0, &cnt, 1)) {
+//  if (! i2c_lcd.write(0x40, &cnt, 1)) {    
+    
+    pc.printf("Found I2C Slave Device\n\r");
+  }    
+  else {  
+    pc.printf("Ooops, cant find I2C Slave Device\n\r");
+  }
+
+  lcd.setOrient(TextLCD::Bottom);
+      
+  while(1) {
+    red = !red;
+    wait(0.5);
+    
+    lcd.printf("Hi mbed! ");    
+//    i2c_lcd.write(0x40, &cnt, 1);
+//    cnt++;
+       
+    pc.putc('#'); 
+  }
 }
\ No newline at end of file
diff -r 14276e409985 -r bb94badd9ebe mbed.bld
--- a/mbed.bld	Mon Jun 29 04:02:22 2015 +0000
+++ b/mbed.bld	Wed May 10 18:22:27 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file
+https://mbed.org/users/mbed_official/code/mbed/builds/794e51388b66
\ No newline at end of file