Skip to content

Commit 9f6ebf3

Browse files
authored
Merge pull request #4310 from kamtom480/spresense_analogin
spresense: return valid reference voltage
2 parents 2651e15 + 7c921b8 commit 9f6ebf3

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,18 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
114114

115115
// Reference voltage is a fixed value which is depending on the board.
116116
// e.g.)
117-
// - Reference Voltage of A4 and A5 pins on Main Board is 0.7V.
118-
// - Reference Voltage of A0 ~ A5 pins on External Interface board
119-
// is selected 3.3V or 5.0V by a IO Volt jumper pin.
117+
// - Reference Voltage of A2 and A3 pins on Main Board is 0.7V.
118+
// - Reference Voltage of A0 ~ A5 pins on External Interface board is 5.0V
120119
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {
121-
return 0.0f;
120+
float voltage;
121+
122+
if (self->number == 2 || self->number == 3) {
123+
voltage = 0.0f;
124+
} else {
125+
voltage = 5.0f;
126+
}
127+
128+
return voltage;
122129
}
123130

124131
void analogin_reset(void) {

ports/cxd56/mpconfigport.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ USB_MSC_EP_NUM_IN = 4
1010
# Number of USB endpoint pairs.
1111
USB_NUM_EP = 6
1212

13+
# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
14+
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
15+
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
1316
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
1417

18+
# Longints can be implemented as mpz, as longlong, or not
19+
LONGINT_IMPL = MPZ
20+
1521
CIRCUITPY_AUDIOBUSIO = 0
1622
CIRCUITPY_AUDIOIO = 0
1723
CIRCUITPY_CAMERA = 1

0 commit comments

Comments
 (0)