-
Notifications
You must be signed in to change notification settings - Fork 13.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
Reading GPIO16 on power up #8783
Comments
pinMode?
Just use Arduino API? GPIO16 is a separate thing, yes, see our Otherwise, you'd have to use SDK headers as reference for GPIO access Also see espressif's RTOS esp8266 component for a much more coherent header and register<->struct API |
Should #7979 get merged:
The right thing to do will be to overwrite the weak symbol |
Let's drill down deeper, though.
@joehui Did you take into consideration the changes in release 3.0.0, since which WiFi is disabled by default? According to https://www.espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf, is the parameter value Fast-forward to #7979, |
Our intended functionality is that ONLY when GPIO16 is connected to HIGH (button pressed) during bootup, we would enable RF calibration.
This is the code we have now, which seems to work.
// Reduce powerup current base on whether GPIO16 is pressed on power upRF_PRE_INIT()
{
gpio16_input_conf(); //config GPIO16 to input
if (0==gpio16_input_get()) //if setup button is left alone (not pressed)
system_phy_set_powerup_option(2); //disable RF calibration (else go ahead with calibration)
}
===============
Below is the code for gpio16_input_conf() and gpio16_input_get().
//-------------------------------------
void ICACHE_FLASH_ATTR gpio16_output_conf(void)
{
WRITE_PERI_REG(PAD_XPD_DCDC_CONF,
(READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC to output rtc_gpio0
WRITE_PERI_REG(RTC_GPIO_CONF,
(READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable
WRITE_PERI_REG(RTC_GPIO_ENABLE,
(READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1); //out enable
}
//-------------------------------------void ICACHE_FLASH_ATTR gpio16_output_set(uint8 value)
{
WRITE_PERI_REG(RTC_GPIO_OUT,
(READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(value & 1));
}
//-------------------------------------void ICACHE_FLASH_ATTR gpio16_input_conf(void)
{
WRITE_PERI_REG(PAD_XPD_DCDC_CONF,
(READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); // mux configuration for XPD_DCDC and rtc_gpio0 connection
WRITE_PERI_REG(RTC_GPIO_CONF,
(READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); //mux configuration for out enable
WRITE_PERI_REG(RTC_GPIO_ENABLE,
READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe); //out disable
}
//-------------------------------------
uint8 ICACHE_FLASH_ATTR gpio16_input_get(void)
{
return (uint8)(READ_PERI_REG(RTC_GPIO_IN_DATA) & 1);
}
On Sunday, March 12, 2023 at 05:12:16 PM GMT+8, Dirk O. Kaar ***@***.***> wrote:
Let's drill down deeper, though.
First, an MCVE that will actually compile:
// This Arduino code is specific to the ESP8266
#include "user_interface.h"
RF_PRE_INIT()
{
system_phy_set_powerup_option(2);
// ...
}
void setup()
{
}
void loop()
{
}
@joehui Did you take into consideration the changes in release 3.0.0, since which WiFi is disabled by default? According to https://www.espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf, is the parameter value 2 really what you want?
Fast-forward to #7979, system_phy_set_powerup_option(2) is default anyway, which only calibrates VDD33 because WiFi is assumed to be disabled. So there's no need to even overwrite __get_rf_powerup_mode() at all. Should WiFi be required, I don't know that it is safe to elide the calibration of TX power (system_phy_set_powerup_option 0, 1, or 3).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@joehui |
Sorry, here's the code again.
|
Basic Infos
We are working on something that requires me to detect the state of GPIO16 inside user_rf_pre_init() - more specifically, in RF_PRE_INIT() in Arduino IDE.
Platform
Settings in IDE
Problem Description
We tried the following code, but it always returns me the same value:
We tried various APIs in NONOS_SDK, but none worked. For other GPIOs, we were able to do something like:
before we setup the GPIO. But for GPIO16, there is no equivalent.
We understand that GPIO16 is part of the RTC system and is handled differently but we cannot find the appropriate example or documentation on reading GPIO16.
Help would be greatly appreciated!
Joseph
The text was updated successfully, but these errors were encountered: