May 2021 Tests

Dependencies:   SX127x sx12xx_hal

Files at this revision

API Documentation at this revision

Comitter:
lightshow
Date:
Sun May 09 20:00:15 2021 +0000
Parent:
1:b277f5a65c1c
Commit message:
May 2021 Tests

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
sx12xx_hal.lib Show annotated file Show diff for this revision Revisions of this file
diff -r b277f5a65c1c -r 28982c714a50 main.cpp
--- a/main.cpp	Thu Mar 21 10:22:46 2019 +0000
+++ b/main.cpp	Sun May 09 20:00:15 2021 +0000
@@ -1,12 +1,64 @@
 #include "radio.h"
 
+//InterruptIn txByte[8]={InterruptIn(D2),InterruptIn(D3),InterruptIn(D4),InterruptIn(D5),InterruptIn(D7),InterruptIn(D8),InterruptIn(D9),InterruptIn(D14)};
+InterruptIn txByte0(PB_1, PullDown);//D2,A1,PC_8 didn't work, PC_5
+InterruptIn txByte1(PB_15, PullDown);//D3 didn't work, A2 works
+InterruptIn txByte2(D4, PullDown);
+InterruptIn txByte3(D7, PullDown);
+InterruptIn txByte4(D5, PullDown);
+InterruptIn txByte5(PB_14, PullDown);//D8 didn't work, a3 works
+InterruptIn txByte6(D9, PullDown);//D9 didn't work, a4 works
+InterruptIn txByte7(PB_2, PullDown);//D14,PC_0(A6),PC_6 didn't work
+EventQueue queue(10 * EVENTS_EVENT_SIZE);
+Thread t;
+Radio loRaRadio;
+
+uint8_t ID_byte = 42;
+
+void transmit( uint8_t byte);
+
+//uint8_t old_byte = 0;
+void tx_event(void)
+{
+    printf("tx_event\n\r");
+    uint8_t byte = 0;
+
+    uint8_t bit0 = txByte0.read();
+    uint8_t bit1 = txByte1.read() << 1;
+    uint8_t bit2 = txByte2.read() << 2;
+    uint8_t bit3 = txByte3.read() << 3;
+    uint8_t bit4 = txByte4.read() << 4;
+    uint8_t bit5 = txByte5.read() << 5;
+    uint8_t bit6 = txByte6.read() << 6;
+    uint8_t bit7 = txByte7.read() << 7;
+    if(bit0 || bit1 || bit2 || bit3 || bit4 || bit5 || bit6 || bit7)
+    {
+        byte = bit0 + bit1 + bit2 + bit3 + bit4 + bit5 + bit6 + bit7;
+        transmit(byte);
+    }
+    printf("bit0 :%d,\n\r",bit0);
+    printf("bit1 :%d,\n\r",bit1);
+    printf("bit2 :%d,\n\r",bit2);
+    printf("bit3 :%d,\n\r",bit3);
+    printf("bit4 :%d,\n\r",bit4);
+    printf("bit5 :%d,\n\r",bit5);
+    printf("bit6 :%d,\n\r",bit6);
+    printf("bit7 :%d,\n\r",bit7);
+}
+
+void rise_handler(void) {
+    //printf("rise_handler in context %p\r\n", Thread::gettid());
+    queue.call(tx_event);
+
+}
+
 // Semtech radio definitions for SX127x, SX126x and SX128x
 
 #if defined(SX127x_H)
     #define BW_KHZ              500
     #define SPREADING_FACTOR    11
     #define CF_HZ               912000000
-    #define TX_DBM              20
+    #define TX_DBM              00
 #elif defined(SX126x_H)
     #define BW_KHZ              500
     #define SPREADING_FACTOR    10
@@ -49,46 +101,79 @@
 
 int main()
 {
+        // Start the event queue
+    t.start(callback(&queue, &EventQueue::dispatch_forever));
+
+    // The 'rise' handler will execute in the context of thread 't'
+    // for(int i = 0; i < 8; i++)
+    // {
+    //     txByte[i].rise(queue.event(rise_handler));
+    // }
+    txByte0.rise(rise_handler);
+    txByte1.rise(rise_handler);
+    txByte2.rise(rise_handler);
+    txByte3.rise(rise_handler);
+    txByte4.rise(rise_handler);
+    txByte5.rise(rise_handler);
+    txByte6.rise(rise_handler);
+    txByte7.rise(rise_handler);
+
+
     uint8_t seq = 0;  //  Set initial transmit sequence to 0
  
     printf("\r\nreset-tx ");
     
     // Start radio transmitter after POR or reset
 
-    Radio::Init(&rev);
+    loRaRadio.Init(&rev);
 
     //Set radio properties for transmitter
 
-    Radio::Standby();
-    Radio::LoRaModemConfig(BW_KHZ, SPREADING_FACTOR, 1);
-    Radio::SetChannel(CF_HZ);
+    loRaRadio.Standby();
+    loRaRadio.LoRaModemConfig(BW_KHZ, SPREADING_FACTOR, 1);
+    loRaRadio.SetChannel(CF_HZ);
 
     // Set transmitter output power
 
-    Radio::set_tx_dbm(TX_DBM);
+    loRaRadio.set_tx_dbm(TX_DBM);
 
     // Setup transmit packet payload  -> preambleLen, fixLen, crcOn, invIQ
                
-    Radio::LoRaPacketConfig(8, false, true, false);
+    loRaRadio.LoRaPacketConfig(8, false, true, false);
     
     printf("\n");
     
     printf("%02d \r\n\n", seq);
 
-    for (;;) {
-        Radio::radio.tx_buf[0] = seq;  // set payload 
+    for (;;) {}
+
+        // loRaRadio.radio.tx_buf[0] = seq;  // set payload 
+        // txDone = false;
+        // loRaRadio.Send(10, 0, 0, 0);   // begin transmission of payload 
+
+        // while (!txDone) {
+        //     loRaRadio.service();
+        // }
+
+        // // Transmit payload every 500mS
+
+        // wait(0.5);  // throttle sending rate 
+        // seq++;  // change payload (increment sequence number)
+        // printf("%02d \r\n\n", seq);  // Print sequence number
+        
+        //}
+}
+
+void transmit( uint8_t byte)
+{
+        //volatile bool tx_Done;
+        loRaRadio.radio.tx_buf[0] = ID_byte;  // set payload 
+        loRaRadio.radio.tx_buf[1] = byte;  // set payload 
         txDone = false;
-        Radio::Send(10, 0, 0, 0);   // begin transmission of payload 
+        loRaRadio.Send(2, 0, 0, 0);   // begin transmission of payload 
 
         while (!txDone) {
-            Radio::service();
+            loRaRadio.service();
         }
-
-        // Transmit payload every 500mS
-
-        wait(0.5);  // throttle sending rate 
-        seq++;  // change payload (increment sequence number)
-        printf("%02d \r\n\n", seq);  // Print sequence number
-        
-        }
+        printf("transmission complete\n\r");
 }
diff -r b277f5a65c1c -r 28982c714a50 mbed-os.lib
--- a/mbed-os.lib	Thu Mar 21 10:22:46 2019 +0000
+++ b/mbed-os.lib	Sun May 09 20:00:15 2021 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#2fd0c5cfbd83fce62da6308f9d64c0ab64e1f0d6
+https://github.com/ARMmbed/mbed-os/#e4b81f67f939a0c0b11c147ce74aa367271e1279
diff -r b277f5a65c1c -r 28982c714a50 mbed_app.json
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Sun May 09 20:00:15 2021 +0000
@@ -0,0 +1,12 @@
+{
+    
+    
+"config": {
+    "thread_stack_size": {
+      "value": 2048
+    },
+    "main_stack_size": {
+      "value": 2048
+    }
+  }
+}
\ No newline at end of file
diff -r b277f5a65c1c -r 28982c714a50 sx12xx_hal.lib
--- a/sx12xx_hal.lib	Thu Mar 21 10:22:46 2019 +0000
+++ b/sx12xx_hal.lib	Sun May 09 20:00:15 2021 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/dudmuck/code/sx12xx_hal/#3303cf2867d4
+https://os.mbed.com/users/dudmuck/code/sx12xx_hal/#78c5e644d37a