LoRa/WiFi Gateway Code, MAX32620FTHR Side

Committer:
gov1
Date:
Tue Jul 31 16:36:17 2018 +0000
Revision:
0:b24cccf38c35
LoRa/WiFi Gateway Code, MAX32620FTHR Side

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gov1 0:b24cccf38c35 1 #ifndef LORA_H
gov1 0:b24cccf38c35 2 #define LORA_H
gov1 0:b24cccf38c35 3
gov1 0:b24cccf38c35 4 #include "mbed.h"
gov1 0:b24cccf38c35 5
gov1 0:b24cccf38c35 6 #define LORA_DEFAULT_SS_PIN P5_4
gov1 0:b24cccf38c35 7 #define LORA_DEFAULT_RESET_PIN P5_5
gov1 0:b24cccf38c35 8 #define LORA_DEFAULT_DIO0_PIN P3_3
gov1 0:b24cccf38c35 9
gov1 0:b24cccf38c35 10 #define PA_OUTPUT_RFO_PIN 0
gov1 0:b24cccf38c35 11 #define PA_OUTPUT_PA_BOOST_PIN 1
gov1 0:b24cccf38c35 12
gov1 0:b24cccf38c35 13 class LoRaClass: public Stream
gov1 0:b24cccf38c35 14 {
gov1 0:b24cccf38c35 15 public:
gov1 0:b24cccf38c35 16 LoRaClass();
gov1 0:b24cccf38c35 17
gov1 0:b24cccf38c35 18 int begin(long frequency);
gov1 0:b24cccf38c35 19 void end();
gov1 0:b24cccf38c35 20
gov1 0:b24cccf38c35 21 int beginPacket(int implicitHeader = false);
gov1 0:b24cccf38c35 22 int endPacket();
gov1 0:b24cccf38c35 23
gov1 0:b24cccf38c35 24 int parsePacket(int size = 0);
gov1 0:b24cccf38c35 25 int packetRssi();
gov1 0:b24cccf38c35 26 float packetSnr();
gov1 0:b24cccf38c35 27
gov1 0:b24cccf38c35 28 void onReceive(void(*callback)(int));
gov1 0:b24cccf38c35 29
gov1 0:b24cccf38c35 30 void receive(int size = 0);
gov1 0:b24cccf38c35 31 void idle();
gov1 0:b24cccf38c35 32 void sleep();
gov1 0:b24cccf38c35 33
gov1 0:b24cccf38c35 34 void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN);
gov1 0:b24cccf38c35 35 void setFrequency(long frequency);
gov1 0:b24cccf38c35 36 void setSpreadingFactor(int sf);
gov1 0:b24cccf38c35 37 void setSignalBandwidth(long sbw);
gov1 0:b24cccf38c35 38 void setCodingRate4(int denominator);
gov1 0:b24cccf38c35 39 void setPreambleLength(long length);
gov1 0:b24cccf38c35 40 void setSyncWord(int sw);
gov1 0:b24cccf38c35 41 void enableCrc();
gov1 0:b24cccf38c35 42 void disableCrc();
gov1 0:b24cccf38c35 43
gov1 0:b24cccf38c35 44 // deprecated
gov1 0:b24cccf38c35 45 void crc() {
gov1 0:b24cccf38c35 46 enableCrc();
gov1 0:b24cccf38c35 47 }
gov1 0:b24cccf38c35 48 void noCrc() {
gov1 0:b24cccf38c35 49 disableCrc();
gov1 0:b24cccf38c35 50 }
gov1 0:b24cccf38c35 51
gov1 0:b24cccf38c35 52 uint8_t random();
gov1 0:b24cccf38c35 53
gov1 0:b24cccf38c35 54 void dumpRegisters(Stream& out);
gov1 0:b24cccf38c35 55
gov1 0:b24cccf38c35 56 //protected:
gov1 0:b24cccf38c35 57 // from Print
gov1 0:b24cccf38c35 58 virtual int _putc(int value);
gov1 0:b24cccf38c35 59 virtual int _getc();
gov1 0:b24cccf38c35 60
gov1 0:b24cccf38c35 61 int available();
gov1 0:b24cccf38c35 62 int peek();
gov1 0:b24cccf38c35 63
gov1 0:b24cccf38c35 64 private:
gov1 0:b24cccf38c35 65 void explicitHeaderMode();
gov1 0:b24cccf38c35 66 void implicitHeaderMode();
gov1 0:b24cccf38c35 67
gov1 0:b24cccf38c35 68 void handleDio0Rise();
gov1 0:b24cccf38c35 69
gov1 0:b24cccf38c35 70 uint8_t readRegister(uint8_t address);
gov1 0:b24cccf38c35 71 void writeRegister(uint8_t address, uint8_t value);
gov1 0:b24cccf38c35 72 uint8_t singleTransfer(uint8_t address, uint8_t value);
gov1 0:b24cccf38c35 73
gov1 0:b24cccf38c35 74 static void onDio0Rise();
gov1 0:b24cccf38c35 75
gov1 0:b24cccf38c35 76 private:
gov1 0:b24cccf38c35 77 SPI &spi;
gov1 0:b24cccf38c35 78 DigitalOut _ss;
gov1 0:b24cccf38c35 79 DigitalOut _reset;
gov1 0:b24cccf38c35 80 InterruptIn _dio0;
gov1 0:b24cccf38c35 81 int _frequency;
gov1 0:b24cccf38c35 82 int _packetIndex;
gov1 0:b24cccf38c35 83 int _implicitHeaderMode;
gov1 0:b24cccf38c35 84 void (*_onReceive)(int);
gov1 0:b24cccf38c35 85 };
gov1 0:b24cccf38c35 86
gov1 0:b24cccf38c35 87 extern LoRaClass LoRa;
gov1 0:b24cccf38c35 88
gov1 0:b24cccf38c35 89 #endif