-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fix for wrong GPIO reg type (issue #397) #398
Conversation
dd578e6
to
8bfca93
Compare
I would appreciate some feedback ;-) |
#define portOutputRegister(P) ( ((volatile uint8_t*)(P != PC ? STD_GPIO_OUT : RTC_GPIO_OUT)) + ( ( ((int)P) == PB ) ? 1 : 0) ) | ||
#define portInputRegister(P) ( ((volatile uint8_t*)(P != PC ? STD_GPIO_IN : RTC_GPIO_IN_DATA)) + ( ( ((int)P) == PB ) ? 1 : 0) ) | ||
#define portModeRegister(P) ( ((volatile uint8_t*)(P != PC ? STD_GPIO_ENABLE : RTC_GPIO_ENABLE)) + ( ( ((int)P) == PB ) ? 1 : 0) ) // Stored bits: 0=In, 1=Out | ||
#define portOutputRegister(P) ( ((GPIO_REG_TYPE*)(P != PC ? STD_GPIO_OUT : RTC_GPIO_OUT)) + ( ( ((int)P) == PB ) ? 1 : 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.
I'm not sure what it's right correction. (uint32_t* + 1) will go out of register range.
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'm also not sure. I just changed uint8_t to uint32_t according Arduino/ESP8266 project to solve my problem #397 which works.
Originaly in Sming I have used "pseudo" sub-registers with type uint8_t* (wich cover part of original full 32-bit ESP register) to be compatible with large amount of old Arduino libraries. On other side now we have many ported libraries, and we can switch to incompatible with old Arduino 32bit register, but it need more detailed checking and refactoring. Did we have reason for that? What will be better way for end users? |
The reason for that is described here Best way how reproduce is use SSD1331 example and add for example blink code for GPIO9 and 10. |
@tprochazka makes a nice reset |
@tprochazka : @robotiko : |
@hreintke |
@robotiko Sorry for delay. I don't think that it is related. If you check digitalWrite() implementation it already using uint32 as register if I understand it correctly. |
gpio9 issue flash chip related. if you cut gpio9 to flash connection you can use gpio9. tested,confirmed. |
I have no problem with using GPIOP9 on Nodemcu 1.0 without any modification. |
is your nodemcu amica brand, do u flash dio, and if so how, can u attach On Sun, Dec 6, 2015, 19:48 Tomáš Procházka [email protected] wrote:
|
@tprochazka I read in many forums.. (many people having the same issue), that Amica modules should work due to the flash module they use, but other ESP12e.. depend on flash chip. As @alon24 pointed, What is you environment? SDK, SO, Sming version? Thanks a lot. |
I use nodekit 1.0 devkit12E from aliexpress: |
According to this: http://bbs.espressif.com/viewtopic.php?t=654, the gpio9 and gpio10 must not be physically connected to flash. |
can someone run that code on devkit 1.0? On Mon, Dec 7, 2015 at 2:57 PM, zhivko [email protected] wrote:
|
as i said before. |
I did a test on nodemcu and flash in dio mode and was NOT able to use gpio9.
|
without cutting gpio9 to flash chip connection right ? |
Exactly.
|
Hi, since the GIPIO9 issue doesn't seem to be related to this issue, please continue side conversation in the #474 |
@ALL : |
@tprochazka @robotiko @alonewolfx2 I will probably release a bugfix V2.1 release shortly and would like to have this included. |
Is any action needed from my side? |
Is there still something preventing this from merge? |
@zardam : @tprochazka : I prefer to have one PR which can be included in both NONOS and RTOS |
Outdated |
I don't understand why this was fixed in RTOS version and not here, id this is still under development, or not? |
@tprochazka Can you check if this PR is still working with the latest develop version? |
Fix itself is still working, but there are now some more examples which expecting bad variable type. This is the biggest problem of Sming. I very like it's API and whole concept, but the Wire implementation is very outdated and there are too differences against Arduino which make very difficult to use existing Arduino libraries. This is the reason why I'm now using Arduino ESP8266 implementation instead of sming. Maybe best way would be use some base code directly from the Arduino ESP 8266 and make the perfect API for working with HTTP, FTP, etc on top of it. |
Can you rebase your PR based on the latest develop and then fix all examples that are affected?
The Wire implementation was updated recently (0c2d053) and PR #1193, that will be merged after 3.3.0 is released, takes care to decrease the differences with Arduino |
8bfca93
to
c8eda92
Compare
c8eda92
to
8e02e2b
Compare
I updated my pull request, there was just one more place where was necessary to use macro GPIO_REG_TYPE. But I did not test it on the real device. |
#define portInputRegister(P) ( ((volatile uint8_t*)(P != PC ? STD_GPIO_IN : RTC_GPIO_IN_DATA)) + ( ( ((int)P) == PB ) ? 1 : 0) ) | ||
#define portModeRegister(P) ( ((volatile uint8_t*)(P != PC ? STD_GPIO_ENABLE : RTC_GPIO_ENABLE)) + ( ( ((int)P) == PB ) ? 1 : 0) ) // Stored bits: 0=In, 1=Out | ||
#define portOutputRegister(P) ( ((GPIO_REG_TYPE*)(P != PC ? STD_GPIO_OUT : RTC_GPIO_OUT)) + ( ( ((int)P) == PB ) ? 1 : 0) ) | ||
#define portInputRegister(P) ( ((GPIO_REG_TYPE*)(P != PC ? STD_GPIO_IN : RTC_GPIO_IN_DATA)) + ( ( ((int)P) == PB ) ? 1 : 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.
volatile uint8_t*
was changed to GPIO_REG_TYPE*
which is wrong. Without the volatile
keyword the compiler may optimize-out the code. Please, bring back the volatile
keyword.
@tprochazka Can you get the latest |
I think that is should be like this. (issue #397)