May 2021 Tests
Dependencies: SX127x sx12xx_hal
Revision 2:2ab3ddbe5e7f, committed 2021-05-09
- Comitter:
- lightshow
- Date:
- Sun May 09 19:58:45 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_app.json | Show annotated file Show diff for this revision Revisions of this file |
diff -r b277f5a65c1c -r 2ab3ddbe5e7f main.cpp --- a/main.cpp Thu Mar 21 10:22:46 2019 +0000 +++ b/main.cpp Sun May 09 19:58:45 2021 +0000 @@ -1,39 +1,76 @@ #include "radio.h" - +#define MASK_XXXXXXX_ 15 // 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 #elif defined(SX126x_H) #define BW_KHZ 500 #define SPREADING_FACTOR 10 - #define CF_HZ 915000000 - #define TX_DBM (Radio::chipType == CHIP_TYPE_SX1262 ? 20 : 14) + #define CF_HZ 913000000 #elif defined(SX128x_H) #define BW_KHZ 200 #define SPREADING_FACTOR 7 #define CF_HZ 2487000000 - #define TX_DBM 6 #endif -/******************** Setup radio transmitter ****************************/ +DigitalOut myled(LED1); +DigitalOut signalPin[8] = {PB_1,PB_15,D4,D7,D5,PB_14,D9,D14}; - -volatile bool txDone; +/**********************************************************************/ void txDoneCB() { - txDone = true; } void rxDoneCB(uint8_t size, float rssi, float snr) { -} + unsigned i; + printf("%.1fdBm snr:%.1fdB\t", rssi, snr); + uint8_t maxShift = 7; + + myled.write(!myled.read()); // toggle LED - // Define radio events for transmitter + //write first received byte as state of pins + uint8_t byte = Radio::radio.rx_buf[0]; + uint8_t tempByte = byte; + uint8_t bit[8] = {0}; + for (int i = 0; i<8; i++) + { + tempByte = tempByte << (maxShift - i); + tempByte = tempByte >> (maxShift); + tempByte = tempByte << i; + if(tempByte)bit[i] = 1; + else bit[i] = 0; + tempByte = byte; + } + printf("\n\r"); + printf("byte: %d",byte); + for (int i = 0; i<8; i++) + { + printf("bit%d: %d\n\r",i,bit[i]); + } + + for (int i = 0; i<8; i++) + { + signalPin[i] = bit[i]; + } + ThisThread::sleep_for(200); + for (int i = 0; i<8; i++) + { + signalPin[i] = 0; + } + + + // Display payload packet information + + for (i = 0; i < size; i++) { + printf("%02d ", Radio::radio.rx_buf[i]); // Changed to "%02d \n" + } + printf("\r\n\n"); +} const RadioEvents_t rev = { /* Dio0_top_half */ NULL, @@ -48,47 +85,29 @@ }; int main() -{ - uint8_t seq = 0; // Set initial transmit sequence to 0 - - printf("\r\nreset-tx "); +{ + + // POR & Reset debug message + + printf("\r\nreset-rx\r\n"); - // Start radio transmitter after POR or reset - Radio::Init(&rev); - //Set radio properties for transmitter - + // Radio Start + Radio::Standby(); Radio::LoRaModemConfig(BW_KHZ, SPREADING_FACTOR, 1); Radio::SetChannel(CF_HZ); - // Set transmitter output power - - Radio::set_tx_dbm(TX_DBM); - - // Setup transmit packet payload -> preambleLen, fixLen, crcOn, invIQ + // preambleLen, fixLen, crcOn, invIQ Radio::LoRaPacketConfig(8, false, true, false); - printf("\n"); - - printf("%02d \r\n\n", seq); - - for (;;) { - Radio::radio.tx_buf[0] = seq; // set payload - txDone = false; - Radio::Send(10, 0, 0, 0); // begin transmission of payload + // Start radio receiver, wait for packets from transmitter - while (!txDone) { - Radio::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 - - } -} + Radio::Rx(0); + + for (;;) { + Radio::service(); + } +} \ No newline at end of file
diff -r b277f5a65c1c -r 2ab3ddbe5e7f mbed_app.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_app.json Sun May 09 19:58:45 2021 +0000 @@ -0,0 +1,10 @@ +{ +"config": { + "thread_stack_size": { + "value": 2048 + }, + "main_stack_size": { + "value": 2048 + } + } +} \ No newline at end of file