mirror of https://github.com/ARMmbed/mbed-os.git
ESP8266: prevents doing reset twice in a row, unnecessary
parent
706dd39569
commit
2d6b63d5a2
|
@ -404,12 +404,7 @@ bool ESP8266Interface::_get_firmware_ok()
|
||||||
nsapi_error_t ESP8266Interface::_init(void)
|
nsapi_error_t ESP8266Interface::_init(void)
|
||||||
{
|
{
|
||||||
if (!_initialized) {
|
if (!_initialized) {
|
||||||
_hw_reset();
|
if (_reset() != NSAPI_ERROR_OK) {
|
||||||
|
|
||||||
if (!_esp.at_available()) {
|
|
||||||
return NSAPI_ERROR_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
if (!_esp.reset()) {
|
|
||||||
return NSAPI_ERROR_DEVICE_ERROR;
|
return NSAPI_ERROR_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
if (!_esp.echo_off()) {
|
if (!_esp.echo_off()) {
|
||||||
|
@ -436,7 +431,7 @@ nsapi_error_t ESP8266Interface::_init(void)
|
||||||
return NSAPI_ERROR_OK;
|
return NSAPI_ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESP8266Interface::_hw_reset()
|
nsapi_error_t ESP8266Interface::_reset()
|
||||||
{
|
{
|
||||||
if (_rst_pin.is_connected()) {
|
if (_rst_pin.is_connected()) {
|
||||||
_rst_pin.rst_assert();
|
_rst_pin.rst_assert();
|
||||||
|
@ -445,7 +440,17 @@ void ESP8266Interface::_hw_reset()
|
||||||
wait_ms(2); // Documentation says 200 us should have been enough, but experimentation shows that 1ms was not enough
|
wait_ms(2); // Documentation says 200 us should have been enough, but experimentation shows that 1ms was not enough
|
||||||
_esp.flush();
|
_esp.flush();
|
||||||
_rst_pin.rst_deassert();
|
_rst_pin.rst_deassert();
|
||||||
|
} else {
|
||||||
|
_esp.flush();
|
||||||
|
if (!_esp.at_available()) {
|
||||||
|
return NSAPI_ERROR_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
if (!_esp.reset()) {
|
||||||
|
return NSAPI_ERROR_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _esp.at_available() ? NSAPI_ERROR_OK : NSAPI_ERROR_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct esp8266_socket {
|
struct esp8266_socket {
|
||||||
|
|
|
@ -365,10 +365,10 @@ private:
|
||||||
|
|
||||||
// Driver's state
|
// Driver's state
|
||||||
int _initialized;
|
int _initialized;
|
||||||
|
nsapi_error_t _connect_retval;
|
||||||
bool _get_firmware_ok();
|
bool _get_firmware_ok();
|
||||||
nsapi_error_t _init(void);
|
nsapi_error_t _init(void);
|
||||||
void _hw_reset();
|
nsapi_error_t _reset();
|
||||||
nsapi_error_t _connect_retval;
|
|
||||||
|
|
||||||
//sigio
|
//sigio
|
||||||
struct {
|
struct {
|
||||||
|
|
Loading…
Reference in New Issue