mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	
						commit
						d3788d3ee4
					
				| @ -34,7 +34,7 @@ uint32_t digitalRead(uint32_t dwPin); | ||||
| typedef void (*voidFuncPtr)(void); | ||||
| void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode); | ||||
| 
 | ||||
| #elif ARDUINO_ARCH_SAMD | ||||
| #elif ARDUINO_ARCH_SAMD || ARDUINO_ARCH_STM32 | ||||
| #include <Arduino.h> | ||||
| 
 | ||||
| #define getbyte(x,n) (*(((uint8_t*)&(x))+n)) | ||||
|  | ||||
| @ -1723,8 +1723,9 @@ double float16FromPayload(const uint8_t* payload, int index) | ||||
| } | ||||
| float float32FromPayload(const uint8_t* payload, int index) | ||||
| { | ||||
|     uint32_t area = unsigned32FromPayload(payload, index); | ||||
|     return *((float*)&area); | ||||
|     union { float f; uint32_t i; } area; | ||||
|     area.i = unsigned32FromPayload(payload, index); | ||||
|     return area.f; | ||||
| } | ||||
| int64_t signed64FromPayload(const uint8_t* payload, int index) | ||||
| { | ||||
| @ -1815,8 +1816,9 @@ void float16ToPayload(uint8_t* payload, size_t payload_length, int index, double | ||||
| } | ||||
| void float32ToPayload(uint8_t* payload, size_t payload_length, int index, double value, uint32_t mask) | ||||
| { | ||||
|     float num = value; | ||||
|     unsigned32ToPayload(payload, payload_length, index, *((uint32_t*)&num), mask); | ||||
|     union { float f; uint32_t i; } num; | ||||
|     num.f = value; | ||||
|     unsigned32ToPayload(payload, payload_length, index, num.i, mask); | ||||
| } | ||||
| void signed64ToPayload(uint8_t* payload, size_t payload_length, int index, int64_t value, uint64_t mask) | ||||
| { | ||||
|  | ||||
| @ -19,7 +19,7 @@ enum ComFlag | ||||
| 
 | ||||
| class GroupObject; | ||||
| 
 | ||||
| #ifdef __linux__ | ||||
| #if __has_include(<functional>) | ||||
| #include <functional> | ||||
| typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler; | ||||
| #else | ||||
|  | ||||
| @ -59,7 +59,7 @@ extern void delayMicroseconds (unsigned int howLong); | ||||
| #define PKTLEN   0x06         // Packet length
 | ||||
| #define PKTCTRL1 0x07         // Packet automation control
 | ||||
| #define PKTCTRL0 0x08         // Packet automation control
 | ||||
| #define DADDR    0x09         // Device address
 | ||||
| #define DEVADDR  0x09         // Device address
 | ||||
| #define CHANNR   0x0A         // Channel number
 | ||||
| #define FSCTRL1  0x0B         // Frequency synthesizer control
 | ||||
| #define FSCTRL0  0x0C         // Frequency synthesizer control
 | ||||
|  | ||||
| @ -15,24 +15,37 @@ | ||||
|     #else | ||||
|         #error "No medium type specified for platform Arduino_SAMD! Please set MEDIUM_TYPE! (TP:0, RF:2, IP:5)" | ||||
|     #endif | ||||
|     #define ICACHE_RAM_ATTR | ||||
| #elif ARDUINO_ARCH_ESP8266 | ||||
|     // predefined global instance for IP only
 | ||||
|     KnxFacade<EspPlatform, Bau57B0> knx; | ||||
| #elif ARDUINO_ARCH_ESP32 | ||||
|     // predefined global instance for IP only
 | ||||
|     KnxFacade<Esp32Platform, Bau57B0> knx; | ||||
|     // predefined global instance for TP or IP
 | ||||
|     #ifdef MEDIUM_TYPE | ||||
|         #if MEDIUM_TYPE == 0 | ||||
|             KnxFacade<Esp32Platform, Bau07B0> knx; | ||||
|         #elif MEDIUM_TYPE == 5 | ||||
|             KnxFacade<Esp32Platform, Bau57B0> knx; | ||||
|         #else | ||||
|             #error "Only TP and IP supported for Arduino ESP32 platform!" | ||||
|         #endif | ||||
|     #else | ||||
|         // Compatibility
 | ||||
|         KnxFacade<Esp32Platform, Bau57B0> knx; | ||||
|         //#error "No medium type specified for platform Arduino ESP32! Please set MEDIUM_TYPE! (TP:0, RF:2, IP:5)"
 | ||||
|     #endif | ||||
| #elif ARDUINO_ARCH_STM32 | ||||
|     KnxFacade<Stm32Platform, Bau07B0> knx; | ||||
| #elif __linux__ | ||||
|     // no predefined global instance
 | ||||
|     #define ICACHE_RAM_ATTR | ||||
| #endif | ||||
| 
 | ||||
| #ifndef __linux__ | ||||
| uint32_t lastpressed=0; | ||||
| #ifndef ICACHE_RAM_ATTR | ||||
|     #define ICACHE_RAM_ATTR | ||||
| #endif | ||||
| ICACHE_RAM_ATTR void buttonUp() | ||||
| { | ||||
|     #ifndef __linux__ | ||||
|     static uint32_t lastpressed=0; | ||||
|     if (millis() - lastpressed > 200){ | ||||
|         knx._toogleProgMode = true; | ||||
|         lastpressed = millis(); | ||||
|  | ||||
| @ -17,7 +17,11 @@ | ||||
| #elif ARDUINO_ARCH_ESP32 | ||||
|    #define LED_BUILTIN 13 | ||||
|    #include "esp32_platform.h" | ||||
|    #include "knx/bau07B0.h" | ||||
|    #include "knx/bau57B0.h" | ||||
| #elif ARDUINO_ARCH_STM32 | ||||
|    #include "stm32_platform.h" | ||||
|    #include "knx/bau07B0.h" | ||||
| #else | ||||
|    #define LED_BUILTIN 0 | ||||
|    #include "linux_platform.h" | ||||
| @ -331,8 +335,21 @@ template <class P, class B> class KnxFacade : private SaveRestore | ||||
|     // predefined global instance for IP only
 | ||||
|     extern KnxFacade<EspPlatform, Bau57B0> knx; | ||||
| #elif ARDUINO_ARCH_ESP32 | ||||
|     // predefined global instance for IP only
 | ||||
|     extern KnxFacade<Esp32Platform, Bau57B0> knx; | ||||
|     // predefined global instance for TP or IP
 | ||||
|     #ifdef MEDIUM_TYPE | ||||
|         #if MEDIUM_TYPE == 0 | ||||
|             extern KnxFacade<Esp32Platform, Bau07B0> knx; | ||||
|         #elif MEDIUM_TYPE == 5 | ||||
|             extern KnxFacade<Esp32Platform, Bau57B0> knx; | ||||
|         #else | ||||
|             #error "Only TP and IP supported for Arduino ESP32 platform!" | ||||
|         #endif | ||||
|     #else | ||||
|         #error "No medium type specified for Arduino ESP32 platform! Please set MEDIUM_TYPE! (TP:0, RF:2, IP:5)" | ||||
|     #endif | ||||
| #elif ARDUINO_ARCH_STM32 | ||||
|     // predefined global instance for TP only
 | ||||
|     extern KnxFacade<Stm32Platform, Bau07B0> knx; | ||||
| #elif __linux__ | ||||
|     // no predefined global instance
 | ||||
| #endif | ||||
							
								
								
									
										42
									
								
								src/stm32_platform.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/stm32_platform.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | ||||
| #include "stm32_platform.h" | ||||
| 
 | ||||
| #ifdef ARDUINO_ARCH_STM32 | ||||
| #include <EEPROM.h> | ||||
| #include "knx/bits.h" | ||||
| 
 | ||||
| Stm32Platform::Stm32Platform() : ArduinoPlatform(&Serial2), eepromPtr(nullptr), eepromSize(0) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| Stm32Platform::Stm32Platform( HardwareSerial* s) : ArduinoPlatform(s), eepromPtr(nullptr), eepromSize(0) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| Stm32Platform::~Stm32Platform() | ||||
| { | ||||
| 	delete [] eepromPtr; | ||||
| } | ||||
| 
 | ||||
| void Stm32Platform::restart() | ||||
| { | ||||
|     NVIC_SystemReset(); | ||||
| } | ||||
| 
 | ||||
| uint8_t * Stm32Platform::getEepromBuffer(uint16_t size) | ||||
| { | ||||
| 	delete [] eepromPtr;	 | ||||
| 	eepromPtr = new uint8_t[size]; | ||||
| 	for (uint16_t i = 0; i < size; ++i) | ||||
| 		eepromPtr[i] = EEPROM[i]; | ||||
| 	return eepromPtr; | ||||
| } | ||||
| 
 | ||||
| void Stm32Platform::commitToEeprom() | ||||
| { | ||||
| 	if(eepromPtr == nullptr) | ||||
| 		return; | ||||
| 	for (uint16_t i = 0; i < eepromSize; ++i) | ||||
| 		EEPROM.update(i, eepromPtr[i]); | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										22
									
								
								src/stm32_platform.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/stm32_platform.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| #ifdef ARDUINO_ARCH_STM32 | ||||
| #include "arduino_platform.h" | ||||
| 
 | ||||
| class Stm32Platform : public ArduinoPlatform | ||||
| { | ||||
| public: | ||||
|     Stm32Platform(); | ||||
|     Stm32Platform( HardwareSerial* s); | ||||
|     ~Stm32Platform(); | ||||
| 
 | ||||
|     // basic stuff
 | ||||
|     void restart(); | ||||
|      | ||||
|     //memory
 | ||||
|     uint8_t* getEepromBuffer(uint16_t size); | ||||
|     void commitToEeprom(); | ||||
| private: | ||||
| 	uint8_t *eepromPtr; | ||||
| 	uint16_t eepromSize; | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user