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

amc bugfix reading aea3 bitshift #420

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions emBODY/eBcode/arch-arm/embot/hw/embot_hw_chip_MA730.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ bool embot::hw::chip::MA730::Impl::read(Data &data, embot::core::relTime timeout

if(resOK == embot::hw::spi::read(_config.spi, da, timeout))
{
// TODO: verify
// AEA3 offers 14 bit of resolution
// AEA3 offers 14 bit of resolution (0-16383)
// in this way we are reading 16 bits (1 bit dummy + 14 bit valid + 1 bit zero padded). The dummy bit has been masked.
data.position = (((_databuffer[0] & 0x7F) << 8 )| _databuffer[1]);

data.position = ((_databuffer[0] & 0x7F) << 7) | (_databuffer[1] >> 1);
data.status.ok = true;
r = true;
}
Expand All @@ -193,7 +191,7 @@ void embot::hw::chip::MA730::Impl::onCompletion(void *p)
embot::hw::chip::MA730::Impl *pimpl = reinterpret_cast<embot::hw::chip::MA730::Impl*>(p);
if(nullptr != pimpl->_tmpdata)
{
pimpl->_tmpdata->position = (((pimpl->_databuffer[0] & 0x7F) << 8 )| pimpl->_databuffer[1]); // to be verified ....
pimpl->_tmpdata->position = ((pimpl->_databuffer[0] & 0x7F) << 7) | (pimpl->_databuffer[1] >> 1);
pimpl->_tmpdata->status.ok = true;
}
pimpl->_tmponcompletion.execute();
Expand Down