From 2aa96dd1290b48d43f8b70188e9591e8bbf6c9d0 Mon Sep 17 00:00:00 2001 From: Pascal Langer Date: Mon, 15 Jun 2020 23:34:56 +0200 Subject: [PATCH] SX1276: indent with tabs --- Multiprotocol/Multiprotocol.h | 2 +- Multiprotocol/SX1276_SPI.ino | 78 ++++++++++++++++++----------------- Multiprotocol/iface_sx1276.h | 6 +++ 3 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 8d2986a..598bc7b 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 1 -#define VERSION_PATCH_LEVEL 19 +#define VERSION_PATCH_LEVEL 20 //****************** // Protocols diff --git a/Multiprotocol/SX1276_SPI.ino b/Multiprotocol/SX1276_SPI.ino index 5085673..0e8e5d0 100644 --- a/Multiprotocol/SX1276_SPI.ino +++ b/Multiprotocol/SX1276_SPI.ino @@ -1,6 +1,8 @@ #ifdef SX1276_INSTALLED #include "iface_sx1276.h" +bool SX1276_Mode_LoRa=false; + void SX1276_WriteReg(uint8_t address, uint8_t data) { SPI_CSN_off; @@ -44,35 +46,35 @@ uint8_t SX1276_Reset() bool SX1276_DetectChip() //to be called after reset, verfies the chip has been detected { - #define MaxAttempts 5 - uint8_t i = 0; - bool chipFound = false; - while ((i < MaxAttempts) && !chipFound) - { - uint8_t ChipVersion = SX1276_ReadReg(0x42); - if (ChipVersion == 0x12) - { - debugln("SX1276 reg version=%d", ChipVersion); - chipFound = true; - } - else - { - debug("SX1276 not found! attempts: %d", i); - debug(" of "); - debugln("%d SX1276 reg version=%d", MaxAttempts, ChipVersion); - i++; - } - } - if (!chipFound) - { - debugln("SX1276 not detected!!!"); - return false; - } - else - { - debugln("Found SX1276 Device!"); - return true; - } + #define SX1276_Detect_MaxAttempts 5 + uint8_t i = 0; + bool chipFound = false; + while ((i < SX1276_Detect_MaxAttempts) && !chipFound) + { + uint8_t ChipVersion = SX1276_ReadReg(SX1276_42_VERSION); + if (ChipVersion == 0x12) + { + debugln("SX1276 reg version=%d", ChipVersion); + chipFound = true; + } + else + { + debug("SX1276 not found! attempts: %d", i); + debug(" of "); + debugln("%d SX1276 reg version=%d", SX1276_Detect_MaxAttempts, ChipVersion); + i++; + } + } + if (!chipFound) + { + debugln("SX1276 not detected!!!"); + return false; + } + else + { + debugln("Found SX1276 Device!"); + return true; + } } void SX1276_SetTxRxMode(uint8_t mode) @@ -100,6 +102,8 @@ void SX1276_SetMode(bool lora, bool low_freq_mode, uint8_t mode) { uint8_t data = 0x00; + SX1276_Mode_LoRa=lora; + if(lora) { data = data | (1 << 7); @@ -137,15 +141,13 @@ void SX1276_ConfigModem1(uint8_t bandwidth, uint8_t coding_rate, bool implicit_h SX1276_WriteReg(SX1276_1D_MODEMCONFIG1, data); - if (bandwidth == SX1276_MODEM_CONFIG1_BW_500KHZ) //datasheet errata reconmendation http://caxapa.ru/thumbs/972894/SX1276_77_8_ErrataNote_1.1_STD.pdf - { - SX1276_WriteReg(0x36, 0x02); - SX1276_WriteReg(0x3a, 0x64); - } - else - { - SX1276_WriteReg(0x36, 0x03); - } + if (bandwidth == SX1276_MODEM_CONFIG1_BW_500KHZ) //datasheet errata reconmendation http://caxapa.ru/thumbs/972894/SX1276_77_8_ErrataNote_1.1_STD.pdf + { + SX1276_WriteReg(SX1276_36_LORA_REGHIGHBWOPTIMIZE1, 0x02); + SX1276_WriteReg(SX1276_3A_LORA_REGHIGHBWOPTIMIZE2, 0x64); + } + else + SX1276_WriteReg(SX1276_36_LORA_REGHIGHBWOPTIMIZE1, 0x03); } void SX1276_ConfigModem2(uint8_t spreading_factor, bool tx_continuous_mode, bool rx_payload_crc_on) diff --git a/Multiprotocol/iface_sx1276.h b/Multiprotocol/iface_sx1276.h index bd69896..ef7124d 100644 --- a/Multiprotocol/iface_sx1276.h +++ b/Multiprotocol/iface_sx1276.h @@ -40,6 +40,12 @@ enum SX1276_4D_PADAC = 0x4D }; +enum +{ + SX1276_36_LORA_REGHIGHBWOPTIMIZE1 = 0x36, + SX1276_3A_LORA_REGHIGHBWOPTIMIZE2 = 0x3A +}; + enum { SX1276_OPMODE_SLEEP = 0,