From 8e3805a63b98fa52d7039df677deb8ae8797d095 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 3 Nov 2018 20:44:54 +0100 Subject: [PATCH] SPI slave integration (experimental) --- include/lorawan.h | 1 + include/main.h | 2 ++ include/senddata.h | 3 +++ include/spislave.h | 1 + platformio.ini | 2 +- src/hal/ebox.h | 1 - src/hal/eboxtube.h | 1 - src/hal/fipy.h | 1 - src/hal/heltec.h | 1 - src/hal/heltecv2.h | 1 - src/hal/lolin32lite.h | 2 -- src/hal/lolin32litelora.h | 1 - src/hal/lolin32lora.h | 1 - src/hal/lopy.h | 1 - src/hal/octopus32.h | 1 - src/hal/ttgobeam.h | 1 - src/hal/ttgov1.h | 1 - src/hal/ttgov2.h | 1 - src/hal/ttgov21new.h | 1 - src/hal/ttgov21old.h | 1 - src/lorawan.cpp | 4 ++-- src/main.cpp | 1 - src/senddata.cpp | 3 +-- 23 files changed, 11 insertions(+), 22 deletions(-) diff --git a/include/lorawan.h b/include/lorawan.h index 94957c25..551597b5 100644 --- a/include/lorawan.h +++ b/include/lorawan.h @@ -29,6 +29,7 @@ void lora_send(osjob_t *job); void lora_enqueuedata(uint8_t messageType, MessageBuffer_t *message); void lora_queuereset(void); void lora_housekeeping(void); + esp_err_t lora_stack_init(); #endif \ No newline at end of file diff --git a/include/main.h b/include/main.h index f7284720..6bc1b377 100644 --- a/include/main.h +++ b/include/main.h @@ -13,5 +13,7 @@ #include "ota.h" #include "irqhandler.h" #include "led.h" +#include "spislave.h" +#include "lorawan.h" #endif \ No newline at end of file diff --git a/include/senddata.h b/include/senddata.h index 07819609..b0e470dc 100644 --- a/include/senddata.h +++ b/include/senddata.h @@ -1,6 +1,9 @@ #ifndef _SENDDATA_H #define _SENDDATA_H +#include "spislave.h" +#include "lorawan.h" + void SendData(uint8_t port); void sendPayload(void); void checkSendQueues(void); diff --git a/include/spislave.h b/include/spislave.h index 526203b9..cb342f76 100644 --- a/include/spislave.h +++ b/include/spislave.h @@ -25,6 +25,7 @@ licenses. Refer to LICENSE.txt file in repository for more details. #define _SPISLAVE_H #include "globals.h" +#include "spislave.h" esp_err_t spi_init(); diff --git a/platformio.ini b/platformio.ini index 8d08dbb2..ccdc695b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,7 +29,7 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" -release_version = 1.6.54 +release_version = 1.6.6 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose debug_level = 0 diff --git a/src/hal/ebox.h b/src/hal/ebox.h index 1f6fe3ad..201d81a7 100644 --- a/src/hal/ebox.h +++ b/src/hal/ebox.h @@ -6,7 +6,6 @@ // Hardware related definitions for ebox ESP32-bit with external connected RFM95 LoRa #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 #define HAS_LED (23) // blue LED on board diff --git a/src/hal/eboxtube.h b/src/hal/eboxtube.h index 858b7b16..35e1c649 100644 --- a/src/hal/eboxtube.h +++ b/src/hal/eboxtube.h @@ -6,7 +6,6 @@ // Hardware related definitions for ebox ESP32-bit with external connected RFM95 LoRa #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 #define HAS_LED (22) // Green LED on board diff --git a/src/hal/fipy.h b/src/hal/fipy.h index 173c1bee..fd2341d3 100644 --- a/src/hal/fipy.h +++ b/src/hal/fipy.h @@ -6,7 +6,6 @@ // Hardware related definitions for Pycom FiPy Board #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1272_radio 1 #define HAS_LED NOT_A_PIN // FiPy has no on board LED, so we use RGB LED diff --git a/src/hal/heltec.h b/src/hal/heltec.h index e33f1e34..82942dbb 100644 --- a/src/hal/heltec.h +++ b/src/hal/heltec.h @@ -6,7 +6,6 @@ // Hardware related definitions for Heltec LoRa-32 Board #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C // OLED-Display on board diff --git a/src/hal/heltecv2.h b/src/hal/heltecv2.h index 6d48f05f..6b8f83d6 100644 --- a/src/hal/heltecv2.h +++ b/src/hal/heltecv2.h @@ -6,7 +6,6 @@ // Hardware related definitions for Heltec V2 LoRa-32 Board #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C // OLED-Display on board diff --git a/src/hal/lolin32lite.h b/src/hal/lolin32lite.h index 9e9f8551..f916bc77 100644 --- a/src/hal/lolin32lite.h +++ b/src/hal/lolin32lite.h @@ -10,6 +10,4 @@ #define HAS_LED 22 // on board LED on GPIO22 #define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW -#define HAS_SPI 1 // comment out if device shall not send data via SPI - #endif \ No newline at end of file diff --git a/src/hal/lolin32litelora.h b/src/hal/lolin32litelora.h index cdb925f9..55b7e10e 100644 --- a/src/hal/lolin32litelora.h +++ b/src/hal/lolin32litelora.h @@ -18,7 +18,6 @@ #define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // RFM95 module // Pins for LORA chip SPI interface, reset line and interrupt lines diff --git a/src/hal/lolin32lora.h b/src/hal/lolin32lora.h index 9d2d5af6..62d18412 100644 --- a/src/hal/lolin32lora.h +++ b/src/hal/lolin32lora.h @@ -19,7 +19,6 @@ #define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // RFM95 module // Pins for LORA chip SPI interface, reset line and interrupt lines diff --git a/src/hal/lopy.h b/src/hal/lopy.h index bf759ec8..1f061d39 100644 --- a/src/hal/lopy.h +++ b/src/hal/lopy.h @@ -6,7 +6,6 @@ // Hardware related definitions for Pycom LoPy Board (NOT LoPy4) #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1272_radio 1 #define HAS_LED NOT_A_PIN // LoPy4 has no on board mono LED, we use on board RGB LED #define HAS_RGB_LED (0) // WS2812B RGB LED on GPIO0 diff --git a/src/hal/octopus32.h b/src/hal/octopus32.h index 5bf96f31..3ab6b525 100644 --- a/src/hal/octopus32.h +++ b/src/hal/octopus32.h @@ -17,7 +17,6 @@ //#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // RFM95 module // Pins for LORA chip SPI interface, reset line and interrupt lines diff --git a/src/hal/ttgobeam.h b/src/hal/ttgobeam.h index 3924d469..46411eb0 100644 --- a/src/hal/ttgobeam.h +++ b/src/hal/ttgobeam.h @@ -6,7 +6,6 @@ // Hardware related definitions for TTGO T-Beam board #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // HPD13A LoRa SoC #define BOARD_HAS_PSRAM // use extra 4MB external RAM diff --git a/src/hal/ttgov1.h b/src/hal/ttgov1.h index d90adef3..d9bcd847 100644 --- a/src/hal/ttgov1.h +++ b/src/hal/ttgov1.h @@ -6,7 +6,6 @@ // Hardware related definitions for TTGOv1 board #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C // OLED-Display on board diff --git a/src/hal/ttgov2.h b/src/hal/ttgov2.h index 62fc2493..afe6c3e6 100644 --- a/src/hal/ttgov2.h +++ b/src/hal/ttgov2.h @@ -6,7 +6,6 @@ // Hardware related definitions for TTGO V2 Board #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // HPD13A LoRa SoC #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C diff --git a/src/hal/ttgov21new.h b/src/hal/ttgov21new.h index 2345ea19..6ef93285 100644 --- a/src/hal/ttgov21new.h +++ b/src/hal/ttgov21new.h @@ -9,7 +9,6 @@ */ #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // HPD13A LoRa SoC #define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C diff --git a/src/hal/ttgov21old.h b/src/hal/ttgov21old.h index 76c855a3..523a967d 100644 --- a/src/hal/ttgov21old.h +++ b/src/hal/ttgov21old.h @@ -10,7 +10,6 @@ */ #define HAS_LORA 1 // comment out if device shall not send data via LoRa -#define HAS_SPI 1 // comment out if device shall not send data via SPI #define CFG_sx1276_radio 1 // HPD13A LoRa SoC #define HAS_LED NOT_A_PIN // no usable LED on board #define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature diff --git a/src/lorawan.cpp b/src/lorawan.cpp index ae0f08c0..9974663d 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -1,11 +1,11 @@ -#ifdef HAS_LORA - // Basic Config #include "lorawan.h" // Local logging Tag static const char TAG[] = "lora"; +#ifdef HAS_LORA + osjob_t sendjob; QueueHandle_t LoraSendQueue; diff --git a/src/main.cpp b/src/main.cpp index 46bf6ddf..96ba79ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,7 +48,6 @@ ESP32 hardware timers // Basic Config #include "main.h" -#include "spislave.h" configData_t cfg; // struct holds current device configuration char display_line6[16], display_line7[16]; // display buffers diff --git a/src/senddata.cpp b/src/senddata.cpp index b8edda34..78215643 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -1,6 +1,5 @@ // Basic Config -#include "globals.h" -#include "spislave.h" +#include "senddata.h" // put data to send in RTos Queues used for transmit over channels Lora and SPI void SendData(uint8_t port) {