mirror of https://github.com/arendst/Tasmota.git
make Tasmota compatible for Arduino espressif32 based on IDF 5.2.2 (#21723)
Co-authored-by: Christian Baars <Baars@gmx.de>
This commit is contained in:
parent
59fc68026b
commit
b1422ff6b5
|
@ -152,7 +152,7 @@ void TasmotaSerial::setTransmitEnablePin(int tx_enable_pin) {
|
|||
bool TasmotaSerial::freeUart(void) {
|
||||
for (uint32_t i = SOC_UART_NUM -1; i >= 0; i--) {
|
||||
if (0 == bitRead(tasmota_serial_uart_bitmap, i)) {
|
||||
m_uart = i;
|
||||
m_uart = uart_port_t(i);
|
||||
bitSet(tasmota_serial_uart_bitmap, m_uart);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ class TasmotaSerial : public Stream {
|
|||
uint32_t m_speed;
|
||||
uint32_t m_config;
|
||||
HardwareSerial *TSerial;
|
||||
int m_uart = 0;
|
||||
uart_port_t m_uart = uart_port_t(0);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ bool NtpServer::beginListening()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool NtpServer::processOneRequest(uint32_t utc, uint32_t millisecs)
|
||||
bool NtpServer::processOneRequest(uint32_t utc, uint32_t millisecs)
|
||||
{
|
||||
// millisecs is millis() at the time of the last iTOW reception, where iTOW%1000 == 0
|
||||
uint32_t refMillis = millis()-millisecs;
|
||||
|
@ -33,7 +33,7 @@ bool NtpServer::processOneRequest(uint32_t utc, uint32_t millisecs)
|
|||
}
|
||||
|
||||
bool processed = false;
|
||||
|
||||
|
||||
int packetDataSize = timeServerPort_.parsePacket();
|
||||
if (packetDataSize && packetDataSize >= NtpPacket::PACKET_SIZE)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ bool NtpServer::processOneRequest(uint32_t utc, uint32_t millisecs)
|
|||
// TODO: verify packet.
|
||||
|
||||
// Populate response.
|
||||
packet.swapEndian();
|
||||
packet.swapEndian();
|
||||
packet.leapIndicator(0);
|
||||
packet.versionNumber(4);
|
||||
packet.mode(4);
|
||||
|
@ -73,16 +73,17 @@ bool NtpServer::processOneRequest(uint32_t utc, uint32_t millisecs)
|
|||
packet.originTimestampFraction = packet.transmitTimestampFraction;
|
||||
packet.receiveTimestampSeconds = recvSecs;
|
||||
packet.receiveTimestampFraction = recvFract;
|
||||
|
||||
|
||||
// ...and the transmit time.
|
||||
// the latency has been between 135 and 175 microseconds in internal testing, so we harcode 150
|
||||
uint32_t transFract = recvFract+(150*(10^3)/(2^32)); // microsec/((10^3)/(2^32))
|
||||
// the latency has been between 135 and 175 microseconds in internal testing, so we hardcode 150
|
||||
constexpr uint32_t latency = (150*1000) / (1LL << 32);
|
||||
uint32_t transFract = recvFract + latency;
|
||||
if (recvFract>transFract){
|
||||
recvSecs++; //overflow
|
||||
}
|
||||
packet.transmitTimestampSeconds = recvSecs;
|
||||
packet.transmitTimestampFraction = transFract;
|
||||
|
||||
packet.transmitTimestampFraction = transFract;
|
||||
|
||||
// Now transmit the response to the client.
|
||||
packet.swapEndian();
|
||||
|
||||
|
@ -91,7 +92,7 @@ bool NtpServer::processOneRequest(uint32_t utc, uint32_t millisecs)
|
|||
timeServerPort_.endPacket();
|
||||
|
||||
processed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
|
@ -96,6 +96,10 @@ public:
|
|||
|
||||
int connect(const char *host, uint16_t port) override;
|
||||
|
||||
int connect(IPAddress ip, uint16_t port, int32_t timeout) { return connect(ip, port, 0);}
|
||||
|
||||
int connect(const char *host, uint16_t port, int32_t timeout) { return connect(host, port, 0);}
|
||||
|
||||
uint8_t connected() override;
|
||||
|
||||
void validate(const char *host, uint16_t port);
|
||||
|
|
|
@ -183,5 +183,19 @@ typedef int SerConfu8;
|
|||
|
||||
#define STATION_IF 0
|
||||
|
||||
|
||||
// ESP32 needed define to support IDF 5.2 based Arduino builds
|
||||
|
||||
// Name has changed
|
||||
#ifdef LCD_CAM_LCD_UPDATE_M
|
||||
#define LCD_CAM_LCD_UPDATE_REG LCD_CAM_LCD_UPDATE_M
|
||||
#endif // LCD_CAM_LCD_UPDATE_M
|
||||
|
||||
// IDF 5.2 has changed counting UART channels, SOC_UART_NUM includes now LP UARTS too
|
||||
#ifdef SOC_UART_HP_NUM
|
||||
#undef SOC_UART_NUM
|
||||
#define SOC_UART_NUM SOC_UART_HP_NUM
|
||||
#endif
|
||||
|
||||
#endif // ESP32
|
||||
#endif // __ESP8266TOESP32_H__
|
||||
|
|
|
@ -77,7 +77,8 @@ lib_extra_dirs = ${library.lib_extra_dirs}
|
|||
|
||||
[env:tasmota32_base]
|
||||
; *** Uncomment next lines ";" to enable development Tasmota Arduino version ESP32
|
||||
;platform = https://github.com/tasmota/platform-espressif32.git
|
||||
;platform = https://github.com/Jason2866/platform-espressif32/releases/download/2024.07.20/platform-espressif32.zip
|
||||
|
||||
;platform_packages = framework-arduinoespressif32 @
|
||||
; framework-arduino-solo1 @
|
||||
; framework-arduino-ITEAD @
|
||||
|
|
|
@ -166,7 +166,11 @@ void CrashDumpClear(void)
|
|||
// extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack, uint32_t stack_end )
|
||||
// esp_err_t IRAM_ATTR esp_backtrace_print(int depth)
|
||||
|
||||
#if defined __has_include && __has_include("xtensa_api.h")
|
||||
#include "xtensa_api.h"
|
||||
#else
|
||||
#include "freertos/xtensa_api.h"
|
||||
#endif
|
||||
#include "esp_debug_helpers.h"
|
||||
#include "esp_cpu_utils.h"
|
||||
extern "C" {
|
||||
|
|
Loading…
Reference in New Issue