-
-
Notifications
You must be signed in to change notification settings - Fork 213
Closed
Labels
Description
(I've only tested this on a Pi Pico, no idea if any other boards are affected)
This breaks libraries like https://github.com/adafruit/Adafruit_TouchScreen.
Relevant part of the code (stripped down):
// X - this works fine the first time, does not work after reading Y
pinMode(_yp, INPUT);
pinMode(_ym, INPUT);
pinMode(_xp, OUTPUT);
pinMode(_xm, OUTPUT);
digitalWrite(_xp, HIGH);
digitalWrite(_xm, LOW); // does not work after analogRead in Y code
analogRead(_yp); // breaks the write below
// ...
// Y - this does not work after the read above
pinMode(_xp, INPUT);
pinMode(_xm, INPUT);
pinMode(_yp, OUTPUT);
pinMode(_ym, OUTPUT);
digitalWrite(_ym, LOW);
digitalWrite(_yp, HIGH); // does not work after analogRead above
analogRead(_xm); // breaks next X read
Removing either of the reads causes the other axis to read reasonable values. Also manually calling gpio_init
after the analogRead
works:
// X
_gpio_init(_xm); // <--
pinMode(_yp, INPUT);
pinMode(_ym, INPUT);
pinMode(_xp, OUTPUT);
pinMode(_xm, OUTPUT);
digitalWrite(_xp, HIGH);
digitalWrite(_xm, LOW);
analogRead(_yp);
// Y
_gpio_init(_yp); // <--
pinMode(_xp, INPUT);
pinMode(_xm, INPUT);
pinMode(_yp, OUTPUT);
pinMode(_ym, OUTPUT);
digitalWrite(_ym, LOW);
digitalWrite(_yp, HIGH);
analogRead(_xm);