A simple program to try the TESTBED evaluation KIT http://www.lextronic.fr/P22450-platine-devaluation-testbed.html

Dependencies:   mbed

Fork of TestBed-LCD20x4 by Elmicro Computer

Files at this revision

API Documentation at this revision

Comitter:
cdupaty
Date:
Thu Mar 19 10:13:29 2015 +0000
Parent:
0:7c694e032688
Commit message:
A simple program to test TESTBED evaluation KIT

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 7c694e032688 -r 15626458ee57 main.cpp
--- a/main.cpp	Tue Oct 11 08:13:19 2011 +0000
+++ b/main.cpp	Thu Mar 19 10:13:29 2015 +0000
@@ -1,32 +1,97 @@
+// essai LPC1768 sut carte TESTBED
+// http://www.lextronic.fr/P22450-platine-devaluation-testbed.html
+// test IO, ADC, serial, LCD, interrupt
+
 #include "mbed.h"
-//the library "TextLCD.h" was slightly altered to work with the GDM2004D LCD
 #include "TextLCD.h"
 
+// LED1 = P5.5  LED2 = P5.6  sur carte testbed
+// 2 Leds sur carte testBed
+DigitalOut ledG(p6);
+DigitalOut ledR(p5);
+
+// Potentiomètre sur p15 (carte testbed)
+AnalogIn pot(p15);
+
+// le port serie emulé sur la connexion USB (USBTX et USBRX), necessite un driver sous Windows
+Serial pc(USBTX, USBRX);
+
 //the object "lcd" is initialized to act as a TextLCD with 20x4 characters
 TextLCD lcd(p26, p25, p24, p23, p22, p20, p19, TextLCD::LCD20x4);
 
-int main() {
+// interruption sur BTN1
+InterruptIn btn1(p8);
+
+// IT periodique
+Ticker tempo;
+
+// prototypes fonctions d'IT
+void BTN1_interruption();
+void Rx_interruption();
+void flash_interruption();
+
+int main()
+{
     //each line of the LCD can be accessed directly using the .locate(column, line) function
     lcd.locate(0,0);
-    lcd.printf("12345678901234567890");
+    lcd.printf("Tests mbed");
     lcd.locate(0,1);
-    lcd.printf("UVWXYZabcdefghijklmn");    
-    lcd.locate(0,2);    
-    lcd.printf("ABCDEFGHIJKLMNOPQRST");
-    lcd.locate(0,3);
-    lcd.printf("12345678901234567890");    
-    wait(2);
-    
+    lcd.printf("---------");
+    lcd.locate(0,2);
+    lcd.printf("CD.01-2015");
+    lcd.locate(5,3);
+    lcd.printf("LLAP");
+    wait(1);
+
     //the LCD is cleared using function .cls()
     lcd.cls();
-    //a "\n" in a text string causes a line feed
-    lcd.printf("HELLO WORLD\n");
-    //if the end of a line is reached, the text is written to the next line automatically
-    lcd.printf("Testbed for mbed\nLCD example softwarewith altered library");
-    
-    //the endless loop keeps mbed in low power mode
-    while(1)
-    {
-    __WFI();
+    // communications
+    pc.baud(9600);
+
+    // interruption sur RX
+    pc.attach(&Rx_interruption);
+
+    // interruption sur BTN1 front descendant, appui
+    btn1.fall(&BTN1_interruption);
+
+    // IT sur timer toutes les 0,5s
+    tempo.attach_us(&flash_interruption, 500000);
+
+    while(1) {
+        lcd.locate(0,0);
+        lcd.printf("pot=%f %d   \n",pot.read(),pot.read_u16 ());
+        lcd.printf("BTN1:IT RXIT affiche\n");
+        pc.printf("pot=%f %d\n",pot.read(),pot.read_u16 ());
+        wait(0.5);
     }
+    //__WFI();
 }
+
+void BTN1_interruption()
+{
+    static char c=0;
+    if (!c) {
+        lcd.locate(5,3);
+        lcd.printf("INTERRUPTION");
+    } else {
+        lcd.locate(5,3);
+        lcd.printf("            ");
+    }
+    c=~c;
+    pc.printf("\n  ------------INTERRUPTION BTN1----------\n");
+    return;
+}
+
+void Rx_interruption()
+{
+    lcd.locate(5,3);
+    lcd.printf("%c            ",pc.getc());
+    return;
+}
+
+void flash_interruption()
+{
+    ledG=!ledG;
+    ledR=!ledG;
+    return;
+}
\ No newline at end of file