Skip to content

Commit

Permalink
Add optional for enabling hardware flow control (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoglet67 committed May 16, 2018
1 parent 58a3a42 commit 40cdfd3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion esp_modem/esp_modem.ino 100755 → 100644
Expand Up @@ -21,6 +21,12 @@

//#defines

#define USE_HW_FLOW_CTRL // Use hardware (RTS/CTS) flow control

#ifdef USE_HW_FLOW_CTRL
#include <uart_register.h>
#endif

//#define USE_SWITCH 1 // Use a ware reset switch
//#define DEBUG 1 // Print additional debug information to serial channel
#undef DEBUG
Expand Down Expand Up @@ -63,6 +69,20 @@ uint8_t txBuf[TX_BUF_SIZE]; // Transmit Buffer
*/
void setup()
{
#ifdef USE_HW_FLOW_CTRL
// Enable flow control of Beeb -> ESP8266 data with RTS
// RTS on the EPS8266 is pin GPIO15 which is physical pin 16
// RTS on the ESP8266 is an output and should be connected to CTS on the RS423
// The ESP8266 has a 128 byte receive buffer, so a threshold of 64 is half full
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_U0RTS);
SET_PERI_REG_BITS(UART_CONF1(0), UART_RX_FLOW_THRHD, 64, UART_RX_FLOW_THRHD_S);
SET_PERI_REG_MASK(UART_CONF1(0), UART_RX_FLOW_EN);
// Enable flow control of ESP8266 -> Beeb data with CTS
// CTS on the EPS8266 is pin GPIO13 which is physical pin 7
// CTS on the ESP8266 is an input and should be connected to RTS on the RS423
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_UART0_CTS);
SET_PERI_REG_MASK(UART_CONF0(0), UART_TX_FLOW_EN);
#endif
Serial.begin(DEFAULT_BPS);
myBps = DEFAULT_BPS;

Expand Down Expand Up @@ -508,4 +528,4 @@ void loop()

// Turn off tx/rx led if it has been lit long enough to be visible
if (millis() - ledTime > LED_TIME) digitalWrite(LED_PIN, HIGH);
}
}

0 comments on commit 40cdfd3

Please sign in to comment.