-
Notifications
You must be signed in to change notification settings - Fork 3k
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
ESP8266: Add configurations for reset control #11331
Conversation
"help": "Polarity of RESET pin for the modem. [0/1]", | ||
"value": 0 | ||
}, | ||
"rst-assert-time": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the time unit here? I suggest to call this rst-assert-time-us
or something similar and adjust to whatever unit is needed in the code, for example ThisThread::sleep_for(MBED_CONF_ESP8266_RST_ASSERT_TIME_US/100);
If this is in system ticks, we can call it rst-assert-time-ticks
.
@VeijoPesonen , any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to know the reason why this needs to be made configurable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VeijoPesonen rst-pin-polarity
and rst-assert-time
originally are to achieve what #11299 is at. Also restate on the top.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michalpasztamobica Change to rst-assert-time-us
and adjust related code.
ThisThread::sleep_for(MBED_CONF_ESP8266_RST_ASSERT_TIME_US / 1000);
@ccli8 , would you also like to add a target override section for M2351, so that the configs you wanted to set are automatically available without modifications to |
@@ -21,6 +21,14 @@ | |||
"help": "RESET pin for the modem, defaults to Not Connected", | |||
"value": null | |||
}, | |||
"rst-pin-polarity": { | |||
"help": "Polarity of RESET pin for the modem. [0/1]", | |||
"value": 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful to make use of the "options" field here to require either 0 or 1 as value here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teetak01 Where can I reference "options" field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michalpasztamobica Thanks.
@teetak01 Use options
for rst-pin-polarity
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0/1 isn't very meaningful. Have some reference to "active high" and/or "active low". CF UARTSerial::set_data_carrier_detect
(although I see its doxygen comment is nonsense, sigh).
@ccli8 The PR description should give the reason for these changes. |
@ccli8, thank you for your changes. |
25fd174
to
bd5704b
Compare
@michalpasztamobica Added. But M2351 is under target renaming. This PR must rely on #11288 for M2351 new target name confirmed. |
"rst" : "PD_7", | ||
"rts" : "PD_3", | ||
"cts" : "PD_2", | ||
"rst-pin-polarity" : "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you didn't change the rst-assert-time-us
configuration I second @VeijoPesonen 's remark - is this really necessary? If so - why not get the config for your target in here?
In general, I don't mind getting the module more configurable, but if the reset assertion time is a constant, it should stay that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michalpasztamobica Add rst-assert-time-us
override for M2351. Its value follows our BSP sample code.
bd5704b
to
1864279
Compare
Not a fan of this. Pin configurations are supposed to be program/run-time configurable. And if there is an ESP8266 built-in to this target with custom wiring, then it should be using that run-time configuration to return an appropriately-configured |
}, | ||
"rst-assert-time-us": { | ||
"help": "Assert time of reset for the modem in us.", | ||
"value": 2000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in microseconds, when it's really interpreted as "2 ticks", meaning "at least 1000us"? If this is going to be microseconds, then it should be set to 200, and the code should be rounding that up to 2 ticks: (us + 999) / 1000 + 1
= (us + 1999) / 1000
.
But again, why is it configurable? Why would this differ between hardware? If the 3000 number for your target is correct, may as well always use it? (How many real microseconds is that supposed to represent? 2000?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original code is 2 ms:
ThisThread::sleep_for(2);
So I change to:
ThisThread::sleep_for(MBED_CONF_ESP8266_RST_ASSERT_TIME_US / 1000);
where MBED_CONF_ESP8266_RST_ASSERT_TIME_US
defaults to 2000 us.
But it seems the code doesn't follow the doc.
Configuring MBED_CONF_ESP8266_RST_ASSERT_TIME_US
to 3000 for M2351 is for power on/off control. Its discussion starts from #11299.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but the point is that it isn't trying to delay for 2000us. It's trying to delay for at least 200us. If you wanted a 2000us delay, it would have to wait for 3 ticks.
Using microseconds as the unit, strongly suggests you're fishing for some sort of microsecond precision, so I would immediately question the code as written - pointing out that sleep_for(time_us / 1000)
may wait for only 1000us, not the 2000us specified. (Or worse, if 1500us was requested, it could wait for 0).
If this isn't really the ESP8266's reset pin, but a module power pin, then it would be better to add a new setting for the new pin, rather than hijack the code thinking that it's driving reset. That would be in line with what we're doing for all the cellular modems - one "soft" power line which is the device's own "button", and one "hard" which is a power control.
@ccli8, thank you for your changes. |
Create #11343 to replace this one |
Close via #11343 |
Description
This PR is a replacement for #11299. By adding configurations for reset pin polarity and reset assert time in ESP8266 driver, the original reset logic
_rst_pin.rst_assert()
/_rst_pin.rst_deassert()
can extend to support power on/off control for the ESP8266 module. This is what #11299 wants to achieve.This PR adds ESP8266 configurations:
Related PR
Replacement for #11299
Rely on #11288
Pull request type
Reviewers
@michalpasztamobica