Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b5ee7dd

Browse files
Convert hall read to use hal/idf (espressif#5268)
Fixes espressif#4866
1 parent 1060293 commit b5ee7dd

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

‎cores/esp32/esp32-hal-adc.c‎

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -245,28 +245,12 @@ void __analogSetVRefPin(uint8_t pin){
245245
__analogVRefPin = pin;
246246
}
247247

248-
int __hallRead() //hall sensor without LNA
248+
int __hallRead() //hall sensor using idf read
249249
{
250-
int Sens_Vp0;
251-
int Sens_Vn0;
252-
int Sens_Vp1;
253-
int Sens_Vn1;
254-
255250
pinMode(36, ANALOG);
256251
pinMode(39, ANALOG);
257-
SET_PERI_REG_MASK(SENS_SAR_TOUCH_CTRL1_REG, SENS_XPD_HALL_FORCE_M); // hall sens force enable
258-
SET_PERI_REG_MASK(RTC_IO_HALL_SENS_REG, RTC_IO_XPD_HALL); // xpd hall
259-
SET_PERI_REG_MASK(SENS_SAR_TOUCH_CTRL1_REG, SENS_HALL_PHASE_FORCE_M); // phase force
260-
CLEAR_PERI_REG_MASK(RTC_IO_HALL_SENS_REG, RTC_IO_HALL_PHASE); // hall phase
261-
Sens_Vp0 = __analogRead(36);
262-
Sens_Vn0 = __analogRead(39);
263-
SET_PERI_REG_MASK(RTC_IO_HALL_SENS_REG, RTC_IO_HALL_PHASE);
264-
Sens_Vp1 = __analogRead(36);
265-
Sens_Vn1 = __analogRead(39);
266-
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 0, SENS_FORCE_XPD_SAR_S);
267-
CLEAR_PERI_REG_MASK(SENS_SAR_TOUCH_CTRL1_REG, SENS_XPD_HALL_FORCE);
268-
CLEAR_PERI_REG_MASK(SENS_SAR_TOUCH_CTRL1_REG, SENS_HALL_PHASE_FORCE);
269-
return (Sens_Vp1 - Sens_Vp0) - (Sens_Vn1 - Sens_Vn0);
252+
__analogSetWidth(12);
253+
return hall_sensor_read();
270254
}
271255
#endif
272256

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /