E45_TTL_100, Lora transceiver, tested on KL25Z connection with E45 via RS232. Power 100 mW, 868 MHz, range 2 km

Dependencies:   MODSERIAL mbed

Files at this revision

API Documentation at this revision

Comitter:
GerritPathuis
Date:
Sat Feb 17 16:24:58 2018 +0000
Parent:
2:329d3f88af27
Child:
4:1249c317e7f3
Commit message:
Waits replaced by loops

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Feb 17 10:10:11 2018 +0000
+++ b/main.cpp	Sat Feb 17 16:24:58 2018 +0000
@@ -17,7 +17,7 @@
 InterruptIn aux(PTD4);              // AUX the E45 radio
 DigitalOut m1(PTA12,PullUp);        // M1 the E45 radio
 DigitalOut m0(PTA4, PullUp);        // M0 the E45 radio
-DigitalOut myled(LED1);             // Kl25x led1
+DigitalOut myled(LED_BLUE);         // KL25x BLUE led
 
 
 void flank_up()
@@ -30,7 +30,7 @@
     myled=0;    //Falling Edge Detected
 }
 
-void timer_func()        // Send something every 3s
+void timer_func()        // Send something every 3 seconds
 {
     if (myled == 1)  {   // AUX is high (Buffer empty), send something
         wait_ms(3);
@@ -43,11 +43,13 @@
     }
 }
 
-
 int main()
 {
+    int count=0;
+
     pc.baud(115200);
-    e45.baud(9600);
+    e45.baud(9600);                         // Default for E45
+    e45.format(8, SerialBase::None, 1);     // Default for E45
     pc.puts("\n\r\nE45-TTL-100 LORA\n\r");
 
     aux.rise(&flank_up);       //Service RISING EDGE Interrupt
@@ -55,22 +57,25 @@
 
     // select mode
     // Transparant Transmission
-    m0= 0;
-    m1= 0;
+    if (myled ==1) {        //Check ready or not
+        while(myled==0) {   //Wait when not yet ready
+            count++;
+            if (count > 2000000) {
+                count=0;
+                pc.puts("Wait for AUX Rising edge ");
+            }
+        }
+    }
+    wait_ms(2);
+    m0= 0;      //Set transparant mode
+    m1= 0;      //Set transparant mode
     wait_ms(1);
 
-    // wait for E45 to be ready
-    while(myled==0) {
-        pc.puts("Wait for E45 reset\n\r");
-        wait_ms(20);
-    }
-    wait_ms(2);
+    pc.puts("E45 is now ready to send and receive \n\r");
     timer.attach(&timer_func, 3.0);
-    pc.puts("E45 is now ready to send and receive \n\r");
 
     while(1) {
         if (myled == 0)  {   // AUX is low, Chars received
-            wait_ms(3);
             while(myled==0) {
                 if (e45.readable()) {
                     pc.putc(e45.getc()); //send to pc
@@ -79,3 +84,4 @@
         }
     }
 }
+