Skip to content
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
7 changes: 6 additions & 1 deletion src/machine/machine_nrf52xxx.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ func (a *ADC) Get() uint16 {
resolutionAdjustment = 4 // 12bit
}

return rawValue.Get() << resolutionAdjustment
value := int16(rawValue.Get())
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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?

value := int16(rawValue.Get())

if value < 0 {
value = 0
}

return uint16(value << resolutionAdjustment)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deadprogram we do return uint16 in the end, if that's you after.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 int16, checking for 0 and then casting to uint16 after applying resolution adjustment

}

// SPI on the NRF.
Expand Down
Loading