mirror of
https://github.com/thelsing/knx.git
synced 2025-05-16 01:16:18 +02:00
commit
d3788d3ee4
@ -34,7 +34,7 @@ uint32_t digitalRead(uint32_t dwPin);
|
|||||||
typedef void (*voidFuncPtr)(void);
|
typedef void (*voidFuncPtr)(void);
|
||||||
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
|
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
|
||||||
|
|
||||||
#elif ARDUINO_ARCH_SAMD
|
#elif ARDUINO_ARCH_SAMD || ARDUINO_ARCH_STM32
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define getbyte(x,n) (*(((uint8_t*)&(x))+n))
|
#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)
|
float float32FromPayload(const uint8_t* payload, int index)
|
||||||
{
|
{
|
||||||
uint32_t area = unsigned32FromPayload(payload, index);
|
union { float f; uint32_t i; } area;
|
||||||
return *((float*)&area);
|
area.i = unsigned32FromPayload(payload, index);
|
||||||
|
return area.f;
|
||||||
}
|
}
|
||||||
int64_t signed64FromPayload(const uint8_t* payload, int index)
|
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)
|
void float32ToPayload(uint8_t* payload, size_t payload_length, int index, double value, uint32_t mask)
|
||||||
{
|
{
|
||||||
float num = value;
|
union { float f; uint32_t i; } num;
|
||||||
unsigned32ToPayload(payload, payload_length, index, *((uint32_t*)&num), mask);
|
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)
|
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;
|
class GroupObject;
|
||||||
|
|
||||||
#ifdef __linux__
|
#if __has_include(<functional>)
|
||||||
#include <functional>
|
#include <functional>
|
||||||
typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler;
|
typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler;
|
||||||
#else
|
#else
|
||||||
|
@ -59,7 +59,7 @@ extern void delayMicroseconds (unsigned int howLong);
|
|||||||
#define PKTLEN 0x06 // Packet length
|
#define PKTLEN 0x06 // Packet length
|
||||||
#define PKTCTRL1 0x07 // Packet automation control
|
#define PKTCTRL1 0x07 // Packet automation control
|
||||||
#define PKTCTRL0 0x08 // 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 CHANNR 0x0A // Channel number
|
||||||
#define FSCTRL1 0x0B // Frequency synthesizer control
|
#define FSCTRL1 0x0B // Frequency synthesizer control
|
||||||
#define FSCTRL0 0x0C // Frequency synthesizer control
|
#define FSCTRL0 0x0C // Frequency synthesizer control
|
||||||
|
@ -15,24 +15,37 @@
|
|||||||
#else
|
#else
|
||||||
#error "No medium type specified for platform Arduino_SAMD! Please set MEDIUM_TYPE! (TP:0, RF:2, IP:5)"
|
#error "No medium type specified for platform Arduino_SAMD! Please set MEDIUM_TYPE! (TP:0, RF:2, IP:5)"
|
||||||
#endif
|
#endif
|
||||||
#define ICACHE_RAM_ATTR
|
|
||||||
#elif ARDUINO_ARCH_ESP8266
|
#elif ARDUINO_ARCH_ESP8266
|
||||||
// predefined global instance for IP only
|
// predefined global instance for IP only
|
||||||
KnxFacade<EspPlatform, Bau57B0> knx;
|
KnxFacade<EspPlatform, Bau57B0> knx;
|
||||||
#elif ARDUINO_ARCH_ESP32
|
#elif ARDUINO_ARCH_ESP32
|
||||||
// predefined global instance for IP only
|
// 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;
|
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__
|
#elif __linux__
|
||||||
// no predefined global instance
|
// no predefined global instance
|
||||||
#define ICACHE_RAM_ATTR
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __linux__
|
#ifndef ICACHE_RAM_ATTR
|
||||||
uint32_t lastpressed=0;
|
#define ICACHE_RAM_ATTR
|
||||||
#endif
|
#endif
|
||||||
ICACHE_RAM_ATTR void buttonUp()
|
ICACHE_RAM_ATTR void buttonUp()
|
||||||
{
|
{
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
|
static uint32_t lastpressed=0;
|
||||||
if (millis() - lastpressed > 200){
|
if (millis() - lastpressed > 200){
|
||||||
knx._toogleProgMode = true;
|
knx._toogleProgMode = true;
|
||||||
lastpressed = millis();
|
lastpressed = millis();
|
||||||
|
@ -17,7 +17,11 @@
|
|||||||
#elif ARDUINO_ARCH_ESP32
|
#elif ARDUINO_ARCH_ESP32
|
||||||
#define LED_BUILTIN 13
|
#define LED_BUILTIN 13
|
||||||
#include "esp32_platform.h"
|
#include "esp32_platform.h"
|
||||||
|
#include "knx/bau07B0.h"
|
||||||
#include "knx/bau57B0.h"
|
#include "knx/bau57B0.h"
|
||||||
|
#elif ARDUINO_ARCH_STM32
|
||||||
|
#include "stm32_platform.h"
|
||||||
|
#include "knx/bau07B0.h"
|
||||||
#else
|
#else
|
||||||
#define LED_BUILTIN 0
|
#define LED_BUILTIN 0
|
||||||
#include "linux_platform.h"
|
#include "linux_platform.h"
|
||||||
@ -331,8 +335,21 @@ template <class P, class B> class KnxFacade : private SaveRestore
|
|||||||
// predefined global instance for IP only
|
// predefined global instance for IP only
|
||||||
extern KnxFacade<EspPlatform, Bau57B0> knx;
|
extern KnxFacade<EspPlatform, Bau57B0> knx;
|
||||||
#elif ARDUINO_ARCH_ESP32
|
#elif ARDUINO_ARCH_ESP32
|
||||||
// predefined global instance for IP only
|
// 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;
|
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__
|
#elif __linux__
|
||||||
// no predefined global instance
|
// no predefined global instance
|
||||||
#endif
|
#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