-
Notifications
You must be signed in to change notification settings - Fork 2
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
Is XOR operator an error on W25Qxx_ReadStatus? #1
Comments
fix W25Qxx_ReadStatus xor operator #1
Hi, as an open source author, thank you very much for using the library in your project and thanks again for the problems you found. You are right about the code "return (2 ^ ret); " in the function W25Qxx_ReadStatus. Not only can you use the pow function, but if you are using a microcontroller with a shift instruction you can also use the following : uint8_t W25Qxx_ReadStatus(void) /* Read current chip running status */
{
uint8_t ret = 0;
ret |= W25Qxx_RBit_BUSY();
ret |= W25Qxx_RBit_SUS()<<1;
return (1 << ret); /* return (pow(2, ret)) */
} Finally, thanks again, and if you find any other problems or have better ideas, I will try to reply and discuss them as soon as possible. 😊🤞 |
My pleasure! and it's true, you should implement a shift version as default, it is more optimized! |
Hello, first of all thanks for the lib!
I am implementing this lib on my project, but i have a question about W25Qxx_ReadStatus & W25Qxx_isStatus functions because i think at first it doesn't work as it should on my project. When i try to read or write the flash, it internally checks if the memory is at IDLE status, but it returns to me busy status when the status registers of W25Qxx are "idle".
The posible status of the memory are:
and the W25Qxx_ReadStatus function is:
So "ret" variable have 4 values:
But if "ret" is 0 value (idle) the xor operator (^) returns 2 (2^0 = 2) and the status returned will be "W25Qxx_STATUS_BUSY".
If xor is remplaced with a pow operator the values will be:
Where ** is pow operator
The text was updated successfully, but these errors were encountered: