Added JTAG use defines for ESP PROG debug

This commit is contained in:
Ray Jones 2019-10-27 11:02:49 +11:00
parent 8893abb575
commit f330d812e6
7 changed files with 70 additions and 18 deletions

View file

@ -1,5 +1,5 @@
REM Firmware
esptool.exe --chip esp32 --port COM16 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader_qio_80m.bin 0x10000 AfterburnerV3.1.5.bin 0x8000 Afterburner.partitions.bin
esptool.exe --chip esp32 --port COM5 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 boot_app0.bin 0x1000 bootloader_qio_80m.bin 0x10000 AfterburnerV3.1.5.bin 0x8000 Afterburner.partitions.bin
REM SPIFFS
esptool.exe --chip esp32 --port COM16 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_size detect 0x3d0000 spiffs.bin
esptool.exe --chip esp32 --port COM5 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_size detect 0x3d0000 spiffs.bin

View file

@ -19,11 +19,13 @@ upload_speed = 921600
;upload_port = 192.168.20.120
;upload_flags =
; --port=3232
upload_port = COM16
upload_port = COM5
upload_protocol = esptool
;monitor_speed = 115200
extra_scripts = post:add_CRC.py
; replace shitty Arduino millis with a linear time version
build_flags =
-Wl,--wrap,millis
debug_tool = esp-prog
;upload_protocol = esp-prog
debug_init_break = tbreak setup

View file

@ -182,9 +182,11 @@ CSmartError SmartError;
CKeyPad KeyPad;
CScreenManager ScreenManager;
TelnetSpy DebugPort;
#if USE_JTAG == 0
CGPIOin GPIOin;
CGPIOout GPIOout;
CGPIOalg GPIOalg;
#endif
CMQTTsetup MQTTmenu;
@ -330,10 +332,12 @@ void setup() {
// initially, ensure the GPIO outputs are not activated during startup
// (GPIO2 tends to be one with default chip startup)
#if USE_JTAG == 0
pinMode(GPIOout1_pin, OUTPUT);
pinMode(GPIOout2_pin, OUTPUT);
digitalWrite(GPIOout1_pin, LOW);
digitalWrite(GPIOout2_pin, LOW);
#endif
nvs_stats_t nvs_stats;
nvs_get_stats(NULL, &nvs_stats);
@ -446,7 +450,9 @@ void setup() {
bBTconnected = false;
Bluetooth.begin();
#if USE_JTAG == 0
setupGPIO();
#endif
#if USE_SW_WATCHDOG == 1
// create a watchdog timer
@ -513,18 +519,6 @@ void setup() {
TempSensor.getDS18B20().mapSensor(1, NVstore.getHeaterTuning().DS18B20probe[1].romCode);
TempSensor.getDS18B20().mapSensor(2, NVstore.getHeaterTuning().DS18B20probe[2].romCode);
/* bool status = bme.begin(0x76);
if (!status) {
DebugPort.println("Could not find a valid BME280 sensor, check wiring!");
}
bme.setSampling(Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::FILTER_OFF,
Adafruit_BME280::STANDBY_MS_1000);*/
// BMESensor.begin(0x76);
delay(1000); // just to hold the splash screeen for while
}
@ -1095,17 +1089,29 @@ bool getThermostatModeActive()
bool getExternalThermostatModeActive()
{
#if USE_JTAG == 0
return GPIOin.usesExternalThermostat() && (NVstore.getUserSettings().ThermostatMethod == 3);
#else
return false;
#endif
}
bool getExternalThermostatOn()
{
#if USE_JTAG == 0
return GPIOin.getState(1);
#else
return false;
#endif
}
const char* getExternalThermostatHoldTime()
{
#if USE_JTAG == 0
return GPIOin.getExtThermHoldTime();
#else
return "00:00";
#endif
}
@ -1546,6 +1552,9 @@ bool isCyclicActive()
void setupGPIO()
{
#if USE_JTAG == 1
return;
#else
if(BoardRevision == 10 || BoardRevision == 20 || BoardRevision == 21 || BoardRevision == 30) {
// some special considerations for GPIO inputs, depending upon PCB hardware
// V1.0 PCBs only expose bare inputs, which are pulled high. Active state into ESP32 is LOW.
@ -1597,10 +1606,12 @@ void setupGPIO()
GPIOout.begin(0, 0, CGPIOout1::Disabled, CGPIOout2::Disabled);
GPIOalg.begin(ADC1_CHANNEL_5, CGPIOalg::Disabled);
}
#endif
}
bool toggleGPIOout(int channel)
{
#if USE_JTAG == 0
if(channel == 0) {
if(NVstore.getUserSettings().GPIO.out1Mode == CGPIOout1::User) {
setGPIOout(channel, !getGPIOout(channel)); // toggle selected GPIO output
@ -1613,11 +1624,13 @@ bool toggleGPIOout(int channel)
return true;
}
}
#endif
return false;
}
bool setGPIOout(int channel, bool state)
{
#if USE_JTAG == 0
if(channel == 0) {
if(GPIOout.getMode1() != CGPIOout1::Disabled) {
DebugPort.printf("setGPIO: Output #%d = %d\r\n", channel+1, state);
@ -1632,14 +1645,19 @@ bool setGPIOout(int channel, bool state)
return true;
}
}
#endif
return false;
}
bool getGPIOout(int channel)
{
#if USE_JTAG == 0
bool retval = GPIOout.getState(channel);
DebugPort.printf("getGPIO: Output #%d = %d\r\n", channel+1, retval);
return retval;
#else
return false;
#endif
}
float getVersion()
@ -1718,9 +1736,11 @@ void doStreaming()
Bluetooth.check(); // check for Bluetooth activity
#if USE_JTAG == 0
GPIOin.manage();
GPIOout.manage();
GPIOalg.manage();
#endif
// manage changes in Bluetooth connection status
if(Bluetooth.isConnected()) {
@ -1743,6 +1763,7 @@ void doStreaming()
void getGPIOinfo(sGPIO& info)
{
#if USE_JTAG == 0
info.inState[0] = GPIOin.getState(0);
info.inState[1] = GPIOin.getState(1);
info.outState[0] = GPIOout.getState(0);
@ -1753,12 +1774,15 @@ void getGPIOinfo(sGPIO& info)
info.out1Mode = GPIOout.getMode1();
info.out2Mode = GPIOout.getMode2();
info.algMode = GPIOalg.getMode();
#endif
}
// hook for JSON input, simulating a GPIO key press
void simulateGPIOin(uint8_t newKey)
{
#if USE_JTAG == 0
GPIOin.simulateKey(newKey);
#endif
}
float getBatteryVoltage(bool fast)

View file

@ -27,9 +27,11 @@
#include "fonts/Icons.h"
#include "../Utility/BoardDetect.h"
#if USE_JTAG == 0
extern CGPIOout GPIOout;
extern CGPIOin GPIOin;
extern CGPIOalg GPIOalg;
#endif
static const int Line3 = 14;
static const int Line2 = 27;
@ -85,7 +87,9 @@ CGPIOInfoScreen::animate()
_drawBitmap(23, 14, StopIconInfo);
break;
}
#if USE_JTAG == 0
_drawBitmap(40, 16, GPIOin.getState(0) ? CloseIconInfo : OpenIconInfo);
#endif
switch(NVstore.getUserSettings().GPIO.in2Mode) {
case CGPIOin2::Disabled:
@ -98,9 +102,14 @@ CGPIOInfoScreen::animate()
_printMenuText(23, 27, "\352T");
break;
}
#if USE_JTAG == 0
_drawBitmap(40, 28, GPIOin.getState(1) ? CloseIconInfo : OpenIconInfo);
#endif
int bulbmode = GPIOout.getState(0);
int bulbmode = 0;
#if USE_JTAG == 0
bulbmode = GPIOout.getState(0);
#endif
static bool iconstate = false;
switch(NVstore.getUserSettings().GPIO.out1Mode) {
case CGPIOout1::Disabled:
@ -120,11 +129,14 @@ CGPIOInfoScreen::animate()
break;
}
#if USE_JTAG == 0
bulbmode = GPIOout.getState(1);
#endif
switch(NVstore.getUserSettings().GPIO.out2Mode) {
case CGPIOout2::Disabled: _drawBitmap(99, 27, CrossLgIconInfo); break;
case CGPIOout2::User:
_drawBitmap(99, 27, UserIconInfo);
_drawBitmap(110, 26, GPIOout.getState(1) ? BulbOnIconInfo : BulbOffIconInfo);
_drawBitmap(110, 26, bulbmode ? BulbOnIconInfo : BulbOffIconInfo);
break;
}
@ -135,8 +147,10 @@ CGPIOInfoScreen::animate()
_drawBitmap(23, Line1, CrossLgIconInfo);
}
else {
#if USE_JTAG == 0
sprintf(msg, "%d%%", GPIOalg.getValue() * 100 / 4096);
_printMenuText(23, Line1, msg);
#endif
}
}

View file

@ -329,7 +329,11 @@ CThermostatModeScreen::_adjust(int dir)
break;
case 4: // thermostat mode
_thermoMode += dir;
#if USE_JTAG == 0
wrap = GPIOin.usesExternalThermostat() ? 3 : 2;
#else
wrap = 2;
#endif
WRAPLIMITS(_thermoMode, 0, wrap);
break;
}

View file

@ -23,6 +23,8 @@
// Place Holder Config File - User config vars and defines to be moved here
#define USE_JTAG 1
//////////////////////////////////////////////////////////////////////////////
// Configure bluetooth options
// ** Recommended to use HC-05 for now **

View file

@ -21,6 +21,8 @@
#include <stdint.h>
#include <driver/adc.h>
#include "BTCConfig.h"
const uint8_t UART_Tx = 1;
const uint8_t LED_Pin = 2;
@ -30,7 +32,11 @@ const uint8_t TxEnbPin = 5;
const uint8_t Tx433MHz_pin = 12; // HSPI std pins
const uint8_t Rx433MHz_pin = 13; // "
const uint8_t GPIOout2_pin = 14; // "
#if USE_JTAG == 1
const uint8_t DS18B20_Pin = 33;
#else
const uint8_t DS18B20_Pin = 15;
#endif
const uint8_t Rx1Pin = 16;
const uint8_t Tx1Pin = 17;
const uint8_t Tx2Pin = 18;