Skip to content

Commit 92fa02e

Browse files
Change 12- to 16-bit scaling to match other ports
Result is identical, implementation just resembles other ports instead of being all 1337 about it.
1 parent c3f5819 commit 92fa02e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ports/mimxrt10xx/common-hal/analogio/AnalogIn.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
8181

8282
}
8383

84-
// Stretch 12-bit ADC reading to 16 bits via 24-bit interim result
85-
return (ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP) * 0x1001) >> 8;
84+
uint16_t value = ADC_GetChannelConversionValue(self->pin->adc, ADC_CHANNEL_GROUP);
85+
86+
// Stretch 12-bit ADC reading to 16-bit range
87+
return (value << 4) | (value >> 8);
8688
}
8789

8890
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {

0 commit comments

Comments
 (0)