Skip to content
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

Untalk / Unlisten flag clearing code #40

Open
afrb2 opened this issue Sep 3, 2023 · 4 comments
Open

Untalk / Unlisten flag clearing code #40

afrb2 opened this issue Sep 3, 2023 · 4 comments

Comments

@afrb2
Copy link

afrb2 commented Sep 3, 2023

This code handling UNT and UNL seems to set its flags in a strange way

AR488.ino line 2382

if (ustat & 0x01) {
if (!device_unl_h()) ustat &= 0x01; // Clears bit if UNL was not required
}

/***** Try to untalk bus *****/
if (ustat & 0x01) { // ? 0x2
if (!device_unt_h()) ustat &= 0x02; // Clears bit if UNT was not required
}

Second one would appear should if(ustat & 0x2) and to clear the bit maybe an XOR rather than &= ? Don't think the bit clearing is very important though!

@Twilight-Logic
Copy link
Owner

Thank you for spotting that. You are correct. It should be checking the second bit and should read:

if (ustat & 02) {
    if (!device_unt_h()) ustat &= 0x02; // Clears bit if UNT was not required
}

I will fix it in the next release.

@afrb2
Copy link
Author

afrb2 commented Sep 5, 2023 via email

@Twilight-Logic
Copy link
Owner

Sorry, yes, my typo. That should have bveen '0x2' and not '02'.

You are also correct that it should be ustat &= ~02, or else, as you point out, we can simply toggle the bit with ^= 0x2 because we already know that it is set.

I will make the necessary changes in the code.
Thanks.

@Twilight-Logic
Copy link
Owner

This should be fixed in version 0.51.29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants