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

Modify transfer16 API #72

Merged
merged 2 commits into from
Feb 21, 2022
Merged

Modify transfer16 API #72

merged 2 commits into from
Feb 21, 2022

Conversation

s1498n089
Copy link
Contributor

Modify return value of transfer16 function.

Modify return value of transfer16 function.
@S10143806H
Copy link
Contributor

S10143806H commented Feb 17, 2022

Dear @s1498n089,
Thank you for your Pull Request. We have tested and verified your PR.
Would you like to modify your code as: _data = t.val;
instead of using _data = t.msb << 8 | t.lsb;?

The reason for the above suggestion is due to both val, msb, and lsb are included in the same union structure as shown in the code below:
https://github.com/ambiot/ambd_arduino/blob/6bbf7b9075e94a3b0bc7fa26dcee920d7daf23e4/Arduino_package/hardware/libraries/SPI/SPI.cpp#L244
To know more about the union structure, please refer to this link.

Thank you again.

@M-ichae-l
Copy link
Contributor

I believe both function transfer and transfer16 return "0" for successful transfer instead of the value. So "0" is the correct return otherwise the transfer process is failed.

@s1498n089 s1498n089 closed this Feb 18, 2022
@s1498n089 s1498n089 reopened this Feb 18, 2022
@s1498n089
Copy link
Contributor Author

s1498n089 commented Feb 18, 2022

Dear @s1498n089, Thank you for your Pull Request. We have tested and verified your PR. Would you like to modify your code as: _data = t.val; instead of using _data = t.msb << 8 | t.lsb;?

The reason for the above suggestion is due to both val, msb, and lsb are included in the same union structure as shown in the code below:

https://github.com/ambiot/ambd_arduino/blob/6bbf7b9075e94a3b0bc7fa26dcee920d7daf23e4/Arduino_package/hardware/libraries/SPI/SPI.cpp#L244

To know more about the union structure, please refer to this link.
Thank you again.

Dear @S10143806H
Okay, I'll modifying the code to use union. I didn't notice it was union at the time, as I instinctively used the | operator. Thank you for the suggestion!

@ambiot ambiot merged commit 3ad3e7c into Ameba-AIoT:dev Feb 21, 2022
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

Successfully merging this pull request may close these issues.

4 participants