mirror of https://github.com/arendst/Tasmota.git
Prep for ESP32-C3 ph3
This commit is contained in:
parent
17e6890809
commit
765e0e922d
|
@ -72,6 +72,14 @@ void ILI9488_InitDriver()
|
|||
bppin=Pin(GPIO_BACKLIGHT);
|
||||
}
|
||||
|
||||
#ifdef ESP8266
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 13
|
||||
#undef HW_SPI_MISO
|
||||
#define HW_SPI_MISO 12
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 14
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 23
|
||||
|
@ -79,14 +87,7 @@ void ILI9488_InitDriver()
|
|||
#define HW_SPI_MISO 19
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 18
|
||||
#else
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 13
|
||||
#undef HW_SPI_MISO
|
||||
#define HW_SPI_MISO 12
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 14
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
// init renderer, must use hardware spi
|
||||
if (PinUsed(GPIO_SSPI_CS) && (Pin(GPIO_SSPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SSPI_SCLK)==HW_SPI_CLK)) {
|
||||
|
@ -102,7 +103,6 @@ void ILI9488_InitDriver()
|
|||
ili9488->begin();
|
||||
renderer = ili9488;
|
||||
renderer->DisplayInit(DISPLAY_INIT_MODE,Settings.display_size,Settings.display_rotate,Settings.display_font);
|
||||
renderer->dim(Settings.display_dimmer);
|
||||
|
||||
#ifdef SHOW_SPLASH
|
||||
// Welcome text
|
||||
|
|
|
@ -59,6 +59,14 @@ void RA8876_InitDriver()
|
|||
fg_color = RA8876_WHITE;
|
||||
bg_color = RA8876_BLACK;
|
||||
|
||||
#ifdef ESP8266
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 13
|
||||
#undef HW_SPI_MISO
|
||||
#define HW_SPI_MISO 12
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 14
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 23
|
||||
|
@ -66,14 +74,7 @@ void RA8876_InitDriver()
|
|||
#define HW_SPI_MISO 19
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 18
|
||||
#else
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 13
|
||||
#undef HW_SPI_MISO
|
||||
#define HW_SPI_MISO 12
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 14
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
// init renderer, must use hardware spi
|
||||
if (PinUsed(GPIO_SSPI_CS) && (Pin(GPIO_SSPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SSPI_MISO)==HW_SPI_MISO) && (Pin(GPIO_SSPI_SCLK)==HW_SPI_CLK)) {
|
||||
|
|
|
@ -95,17 +95,18 @@ void ST7789_InitDriver()
|
|||
cs=Pin(GPIO_SPI_CS);
|
||||
}
|
||||
|
||||
#ifdef ESP8266
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 13
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 14
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 23
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 18
|
||||
#else
|
||||
#undef HW_SPI_MOSI
|
||||
#define HW_SPI_MOSI 13
|
||||
#undef HW_SPI_CLK
|
||||
#define HW_SPI_CLK 14
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
// init renderer, may use hardware spi
|
||||
//if (PinUsed(GPIO_SPI_CS) && (Pin(GPIO_SPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SPI_CLK)==HW_SPI_CLK) && PinUsed(GPIO_SPI_DC)) {
|
||||
|
@ -121,7 +122,6 @@ void ST7789_InitDriver()
|
|||
st7789->init(Settings.display_width,Settings.display_height);
|
||||
renderer = st7789;
|
||||
renderer->DisplayInit(DISPLAY_INIT_MODE,Settings.display_size,Settings.display_rotate,Settings.display_font);
|
||||
renderer->dim(Settings.display_dimmer);
|
||||
|
||||
#ifdef SHOW_SPLASH
|
||||
// Welcome text
|
||||
|
|
|
@ -150,9 +150,10 @@ void Sm16716ModuleSelected(void)
|
|||
if (PinUsed(GPIO_PWM1, i)) {
|
||||
#ifdef ESP8266
|
||||
pinMode(Pin(GPIO_PWM1, i), OUTPUT);
|
||||
#else // ESP32
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
analogAttach(Pin(GPIO_PWM1, i), i);
|
||||
#endif
|
||||
#endif // ESP32
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -463,20 +463,21 @@ void TInfoInit(void)
|
|||
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: always enabled"));
|
||||
}
|
||||
|
||||
#if defined (ESP8266)
|
||||
#ifdef ESP8266
|
||||
// Allow GPIO3 AND GPIO13 with hardware fallback to 2
|
||||
TInfoSerial = new TasmotaSerial(rx_pin, -1, 2);
|
||||
//pinMode(rx_pin, INPUT_PULLUP);
|
||||
#else
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
TInfoSerial = new TasmotaSerial(rx_pin, -1, 1);
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
// Trick here even using SERIAL_7E1 or TS_SERIAL_7E1
|
||||
// this is not working, need to call SetSerialConfig after
|
||||
if (TInfoSerial->begin(baudrate)) {
|
||||
|
||||
|
||||
#if defined (ESP8266)
|
||||
#ifdef ESP8266
|
||||
if (TInfoSerial->hardwareSerial() ) {
|
||||
ClaimSerial();
|
||||
|
||||
|
@ -491,10 +492,10 @@ void TInfoInit(void)
|
|||
} else {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using software serial"));
|
||||
}
|
||||
|
||||
#elif defined (ESP32)
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using ESP32 hardware serial"));
|
||||
#endif
|
||||
#endif // ESP32
|
||||
// Init teleinfo
|
||||
tinfo.init(tinfo_mode);
|
||||
// Attach needed callbacks
|
||||
|
|
|
@ -253,16 +253,17 @@ void SyncACDimmer(void)
|
|||
timelag_ClockCycles = ((ac_zero_cross_dimmer.dimm_timeClockCycles + ac_zero_cross_dimmer.tobe_cycle_timeClockCycles) - timelag_ClockCycles)%ac_zero_cross_dimmer.tobe_cycle_timeClockCycles;
|
||||
delayMicroseconds(clockCyclesToMicroseconds(timelag_ClockCycles));
|
||||
|
||||
#ifdef ESP8266
|
||||
#ifdef ESP8266
|
||||
pinMode(Pin(GPIO_PWM1, i), OUTPUT);
|
||||
// short fire to ensure not to hit next sinus curve. 0.78% of duty cycle (10ms) ~4µs
|
||||
uint32_t high = ac_zero_cross_dimmer.current_cycle_ClockCycles / 256;
|
||||
uint32_t low = ac_zero_cross_dimmer.current_cycle_ClockCycles - high;
|
||||
// Find the first GPIO being generated by checking GCC's find-first-set (returns 1 + the bit of the first 1 in an int32_t
|
||||
startWaveformClockCycles(Pin(GPIO_PWM1, i), high, low, 0, -1, 0, true);
|
||||
#else // ESP32
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
analogWrite(Pin(GPIO_PWM1, i), 5);
|
||||
#endif // ESP8266 - ESP32
|
||||
#endif // ESP32
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CNT: [%d] dimm_time_CCs %d, current_cycle_CC: %d, timelag %lu, lastcc %lu, currentSteps %d, curr %d"), i, ac_zero_cross_dimmer.dimm_timeClockCycles,ac_zero_cross_dimmer.current_cycle_ClockCycles , timelag_ClockCycles, ac_zero_cross_dimmer.currentCycleCount, ac_zero_cross_dimmer.currentSteps, Light.fade_cur_10[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,13 @@
|
|||
#ifdef ESP8266
|
||||
#define ANALOG_RESOLUTION 10 // 12 = 4095, 11 = 2047, 10 = 1023
|
||||
#define ANALOG_RANGE 1023 // 4095 = 12, 2047 = 11, 1023 = 10
|
||||
#else // ESP32
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
#undef ANALOG_RESOLUTION
|
||||
#define ANALOG_RESOLUTION 12 // 12 = 4095, 11 = 2047, 10 = 1023
|
||||
#undef ANALOG_RANGE
|
||||
#define ANALOG_RANGE 4095 // 4095 = 12, 2047 = 11, 1023 = 10
|
||||
#endif // ESP8266 or ESP32
|
||||
#endif // ESP32
|
||||
|
||||
#define TO_CELSIUS(x) ((x) - 273.15)
|
||||
#define TO_KELVIN(x) ((x) + 273.15)
|
||||
|
|
|
@ -99,9 +99,10 @@ uint8_t twi_buff[64];
|
|||
|
||||
#ifdef ESP8266
|
||||
twi_readFrom(SPS30_ADDR,twi_buff,dlen,1);
|
||||
#else
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
Wire.readTransmission(SPS30_ADDR,twi_buff,dlen,1, NULL);
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
uint8_t bind=0;
|
||||
while (bind<dlen) {
|
||||
|
|
|
@ -471,11 +471,12 @@ const uint8_t *meter_p;
|
|||
uint8_t meter_spos[MAX_METERS];
|
||||
|
||||
// software serial pointers
|
||||
#ifdef ESP8266
|
||||
TasmotaSerial *meter_ss[MAX_METERS];
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
HardwareSerial *meter_ss[MAX_METERS];
|
||||
#else
|
||||
TasmotaSerial *meter_ss[MAX_METERS];
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
// serial buffers, may be made larger depending on telegram lenght
|
||||
#ifndef SML_BSIZ
|
||||
|
@ -2177,15 +2178,16 @@ init10:
|
|||
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,1,TMSBSIZ);
|
||||
}
|
||||
#else
|
||||
#ifdef ESP8266
|
||||
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,0,TMSBSIZ);
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
meter_ss[meters] = new HardwareSerial(uart_index);
|
||||
if (uart_index==0) { ClaimSerial(); }
|
||||
uart_index--;
|
||||
if (uart_index<0) uart_index=0;
|
||||
meter_ss[meters]->setRxBufferSize(TMSBSIZ);
|
||||
#else
|
||||
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,0,TMSBSIZ);
|
||||
#endif
|
||||
#endif // ESP32
|
||||
#endif
|
||||
|
||||
SerialConfig smode = SERIAL_8N1;
|
||||
|
@ -2198,9 +2200,7 @@ init10:
|
|||
smode = SERIAL_8E2;
|
||||
}
|
||||
}
|
||||
#ifdef ESP32
|
||||
meter_ss[meters]->begin(meter_desc_p[meters].params, smode, meter_desc_p[meters].srcpin, meter_desc_p[meters].trxpin);
|
||||
#else
|
||||
#ifdef ESP8266
|
||||
if (meter_ss[meters]->begin(meter_desc_p[meters].params)) {
|
||||
meter_ss[meters]->flush();
|
||||
}
|
||||
|
@ -2209,7 +2209,10 @@ init10:
|
|||
ClaimSerial();
|
||||
//Serial.setRxBufferSize(512);
|
||||
}
|
||||
#endif
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
meter_ss[meters]->begin(meter_desc_p[meters].params, smode, meter_desc_p[meters].srcpin, meter_desc_p[meters].trxpin);
|
||||
#endif // ESP32
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2221,7 +2224,16 @@ uint32_t SML_SetBaud(uint32_t meter, uint32_t br) {
|
|||
if (meter<1 || meter>meters_used) return 0;
|
||||
meter--;
|
||||
if (!meter_ss[meter]) return 0;
|
||||
|
||||
#ifdef ESP8266
|
||||
if (meter_ss[meter]->begin(br)) {
|
||||
meter_ss[meter]->flush();
|
||||
}
|
||||
if (meter_ss[meter]->hardwareSerial()) {
|
||||
if (meter_desc_p[meter].type=='M') {
|
||||
Serial.begin(br, SERIAL_8E1);
|
||||
}
|
||||
}
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
meter_ss[meter]->flush();
|
||||
meter_ss[meter]->updateBaudRate(br);
|
||||
|
@ -2231,16 +2243,7 @@ uint32_t SML_SetBaud(uint32_t meter, uint32_t br) {
|
|||
} else {
|
||||
meter_ss[meter]->begin(br,SERIAL_8N1,meter_desc_p[meter].srcpin,meter_desc_p[meter].trxpin);
|
||||
}*/
|
||||
#else
|
||||
if (meter_ss[meter]->begin(br)) {
|
||||
meter_ss[meter]->flush();
|
||||
}
|
||||
if (meter_ss[meter]->hardwareSerial()) {
|
||||
if (meter_desc_p[meter].type=='M') {
|
||||
Serial.begin(br, SERIAL_8E1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // ESP32
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue