Skip to content

M2351: Integrate ESP8266 power on/off logic into ESP8266 driver main… #11299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

ccli8
Copy link
Contributor

@ccli8 ccli8 commented Aug 23, 2019

Description

On the NuMaker-PFM-M2351 board, the RST pin of the on-board ESP8266 module is not connected. Instead, a GPIO PD_7 is used to power on/off the module. This PR tries to integrate the power on/off logic into ESP8266 driver mainline. It has the following purposes:

  1. Application code can exempt from the power on/off logic and will get clear.
    ESP8266Interface esp(PD_1, PD_0, false, PD_3, PD_2, PD_7);
    
  2. Support reset in ESP8266 driver

Related PR

This PR relies on #11288 for M2351 target renaming.

Pull request type

[ ] Fix
[ ] Refactor
[X] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Release Notes

…line

On the NuMaker-PFM-M2351 board, the RST pin of the on-board ESP8266 module is
not connected. Instead, a GPIO PD_7 is used to power on/off the module. This
commit integrates the power control logic into ESP8266 driver mainline and has
the following purposes:

1. Application code can exempt from the power control logic.
2. Support reset in ESP8266 driver
@ciarmcom ciarmcom requested review from a team August 23, 2019 09:00
@ciarmcom
Copy link
Member

@ccli8, thank you for your changes.
@ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll wait for ipcore team to review but seeing TARGET_ in interface code does not look good to me.

@michalpasztamobica
Copy link
Contributor

I admit, I also don't fully understand this PR.
The reset pin itself can be configured in mbed_app.json. Seems that this is clear, as I don't see it overriden in the PR's code.
Now, I infer from the code that the remaining difficulty is that the pin has different polarity that the ResetPin class assumes? @ccli8 , do you know if there could be some pull-up/pull-down issue on your board? I think, depending on the exact ESP device+shield combination you may need some external pull-up resistor, to get reset to work - I am not sure about this, but maybe @VeijoPesonen know more?

@ccli8
Copy link
Contributor Author

ccli8 commented Aug 23, 2019

Board circuit is not to change.

Without this PR, application needs to write ESP8266 initialization code like:

WiFiInterface *WiFiInterface::get_target_default_instance()
{
    static DigitalOut esp_pwr_off(PD_7, 1);     // Disable power to on-board ESP8266
    static ESP8266Interface esp(PD_1, PD_0, false, PD_3, PD_2, NC);

    esp_pwr_off = 1; // Disable power to on-board ESP8266
    wait_ms(2);
    esp_pwr_off = 0; // Enable power to on-board ESP8266
}

And there is no way for ESP8266 driver to re-power the ESP8266 module through ESP8266Interface::disconnect() when the ESP8266 module misbehaves.

But with this PR, application just needs to configure ESP8266 in mbed_app.json:

            "esp8266.rx"                                : "PD_1",
            "esp8266.tx"                                : "PD_0",
            
            "esp8266.rst"                               : "PD_7",
            
            "esp8266.rts"                               : "PD_3",
            "esp8266.cts"                               : "PD_2",
            
            "esp8266.provide-default"                   : true,
            

PD_7 is power on/off pin for the ESP8266 module, and does not connect to its reset pin (board circuit). This PR borrows the ESP8266Interface::ResetPin::rst_assert() and ESP8266Interface::ResetPin::rst_deassert() code to support reset via the PD_7 pin.

@michalpasztamobica
Copy link
Contributor

michalpasztamobica commented Aug 23, 2019

If there is no way to alternate the logic elsewhere, then I suggest to add some kind of RST_PIN_POLARITY setting in mbed_lib.json, so that this can be configured per target in mbed_app.json.

EDIT: there is very similar case under discussion in #11302, where I gave a more detailed instructions. @ccli8 , please let us know if you understand the point of the changes and if you have any doubts on how to achieve them, feel free to ask.

@ccli8
Copy link
Contributor Author

ccli8 commented Aug 23, 2019

@michalpasztamobica OK. I will add RST_PIN_POLARITY like configuration into mbed_lib.json to substitute for the #if target code.

@ccli8
Copy link
Contributor Author

ccli8 commented Aug 26, 2019

Create #11331 to replace this one.

@ccli8
Copy link
Contributor Author

ccli8 commented Aug 29, 2019

Close via #11343

@ccli8 ccli8 closed this Aug 29, 2019
@cyliangtw cyliangtw deleted the nuvoton_m2351_esp8266 branch March 9, 2023 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants