Advertisement
pleasedontcode

**LoRa SPI** rev_12

Nov 29th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **LoRa SPI**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-11-29 23:04:20
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* configure a lora gateway */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <SPI.h>
  27. #include <LoRa.h>   //https://github.com/sandeepmistry/arduino-LoRa
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void updateOutputs(void);
  33.  
  34. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  35. const uint8_t module_SX127x_DIO0_PIN_D3     = 3;
  36.  
  37. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  38. const uint8_t module_SX127x_NRESET_PIN_D2       = 2;
  39.  
  40. /***** DEFINITION OF SPI PINS *****/
  41. const uint8_t module_SX127x_SPI_PIN_MOSI_D11        = 11;
  42. const uint8_t module_SX127x_SPI_PIN_MISO_D12        = 12;
  43. const uint8_t module_SX127x_SPI_PIN_SCLK_D13        = 13;
  44. const uint8_t module_SX127x_SPI_PIN_CS_D10      = 10;
  45.  
  46. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  47. /***** used to store raw data *****/
  48. bool    module_SX127x_NRESET_PIN_D2_rawData     = 0;
  49.  
  50. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  51. /***** used to store data after characteristic curve transformation *****/
  52. float   module_SX127x_NRESET_PIN_D2_phyData     = 0.0;
  53.  
  54. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  55.  
  56. void setup(void)
  57. {
  58.     // put your setup code here, to run once:
  59.  
  60.     pinMode(module_SX127x_DIO0_PIN_D3,  INPUT);
  61.     pinMode(module_SX127x_NRESET_PIN_D2,    OUTPUT);
  62.     pinMode(module_SX127x_SPI_PIN_CS_D10,   OUTPUT);
  63.    
  64.     // start the SPI library:
  65.     SPI.begin();
  66.  
  67.     // Initialize LoRa module
  68.     LoRa.setPins(module_SX127x_SPI_PIN_CS_D10, module_SX127x_NRESET_PIN_D2, module_SX127x_DIO0_PIN_D3); // Set CS, RESET, and DIO0 pins
  69.     if (!LoRa.begin(915E6)) { // Initialize LoRa at 915 MHz
  70.         while (1); // If failed, do nothing
  71.     }
  72. }
  73.  
  74. void loop(void)
  75. {
  76.     // put your main code here, to run repeatedly:
  77.  
  78.     updateOutputs(); // Refresh output data
  79. }
  80.  
  81. void updateOutputs()
  82. {
  83.     digitalWrite(module_SX127x_NRESET_PIN_D2, module_SX127x_NRESET_PIN_D2_rawData);
  84. }
  85.  
  86. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement