-
Notifications
You must be signed in to change notification settings - Fork 951
nrf: fix adc read near zero #4710
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,7 +183,12 @@ func (a *ADC) Get() uint16 { | |
resolutionAdjustment = 4 // 12bit | ||
} | ||
|
||
return rawValue.Get() << resolutionAdjustment | ||
value := int16(rawValue.Get()) | ||
if value < 0 { | ||
value = 0 | ||
} | ||
|
||
return uint16(value << resolutionAdjustment) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deadprogram we do return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just repeated exact logic as we had before: casting register value to |
||
} | ||
|
||
// SPI on the NRF. | ||
|
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.
This should probably be a cast to
uint16
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.
This is how it was before, see https://github.com/tinygo-org/tinygo/pull/4701/files#diff-e8032f214fa1ae692ba79fc6179cd57e7325ec7d8da3152ff0e4223587f1a041L167
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.
Isn't that previous cast to int16?