mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	Add priliminar Arduino STM32 port
This commit is contained in:
		
							parent
							
								
									894a54fa7f
								
							
						
					
					
						commit
						147a3942ad
					
				| @ -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 htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) ) | ||||
| #define ntohs(x) htons(x) | ||||
|  | ||||
| @ -19,7 +19,7 @@ enum ComFlag | ||||
| 
 | ||||
| class GroupObject; | ||||
| 
 | ||||
| #ifdef __linux__ | ||||
| #if __has_include(<functional>) | ||||
| #include <functional> | ||||
| typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler; | ||||
| #else | ||||
|  | ||||
| @ -22,6 +22,8 @@ | ||||
| #elif ARDUINO_ARCH_ESP32 | ||||
|     // predefined global instance for IP only
 | ||||
|     KnxFacade<Esp32Platform, Bau57B0> knx; | ||||
| #elif ARDUINO_ARCH_STM32 | ||||
|     KnxFacade<Stm32Platform, Bau57B0> knx; | ||||
| #elif __linux__ | ||||
|     // no predefined global instance
 | ||||
|     #define ICACHE_RAM_ATTR | ||||
|  | ||||
| @ -18,6 +18,9 @@ | ||||
|    #define LED_BUILTIN 13 | ||||
|    #include "esp32_platform.h" | ||||
|    #include "knx/bau57B0.h" | ||||
| #elif ARDUINO_ARCH_STM32 | ||||
|    #include "stm32_platform.h" | ||||
|    #include "knx/bau57B0.h" | ||||
| #else | ||||
|    #define LED_BUILTIN 0 | ||||
|    #include "linux_platform.h" | ||||
| @ -331,8 +334,14 @@ template <class P, class B> class KnxFacade : private SaveRestore | ||||
|     // predefined global instance for IP only
 | ||||
|     extern KnxFacade<EspPlatform, Bau57B0> knx; | ||||
| #elif ARDUINO_ARCH_ESP32 | ||||
| <<<<<<< Updated upstream | ||||
|     // predefined global instance for IP only
 | ||||
|     extern KnxFacade<Esp32Platform, Bau57B0> knx; | ||||
| ======= | ||||
| extern KnxFacade<Esp32Platform, Bau57B0> knx; | ||||
| #elif ARDUINO_ARCH_STM32 | ||||
| extern KnxFacade<Stm32Platform, Bau57B0> knx; | ||||
| >>>>>>> Stashed changes | ||||
| #elif __linux__ | ||||
|     // no predefined global instance
 | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										43
									
								
								src/stm32_platform.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/stm32_platform.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | ||||
| #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() | ||||
| { | ||||
|     println("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 | ||||
							
								
								
									
										25
									
								
								src/stm32_platform.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/stm32_platform.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| #ifdef ARDUINO_ARCH_STM32 | ||||
| #include "arduino_platform.h" | ||||
| 
 | ||||
| 
 | ||||
| class Stm32Platform : public ArduinoPlatform | ||||
| { | ||||
|     using ArduinoPlatform::_mulitcastAddr; | ||||
|     using ArduinoPlatform::_mulitcastPort; | ||||
| 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