mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-10-15 04:49:54 +00:00
gps_power_control() mixed the two GPIO conventions on the same pins. It configured lines with GPIO_OUTPUT_HIGH / GPIO_OUTPUT_LOW, which Zephyr defines as physical levels, then drove the same lines with gpio_pin_set_dt(), which is logical. On a line declared GPIO_ACTIVE_LOW those are opposite, so the first call asserted the reverse of every call after it. Two lines are actually broken by this. gps-enable, on the boards declaring it active-low. Most of them reach the block named for the T1000-E rather than the "simple boards" path, because HAS_T1000_GPS_CONTROL is (HAS_GPS_VRTC || HAS_GPS_RESET || HAS_GPS_SLEEP) and a bare gps-reset alias is enough to route a board there. That block drives the enable physical HIGH unconditionally on every power-on, and power-off lands on physical HIGH too, so the line is de-asserted in both states and the module is never powered at all. gps-reset, on the six boards declaring it active-low: heltec_t096, heltec_t1, heltec_t114, thinknode_m1, heltec_wifi_lora32_v4 and _v43. The documented power-on sequence is "assert reset, hold 10 ms, release", written as GPIO_OUTPUT_HIGH then gpio_pin_set_dt(0). On an active-low line both of those are physical HIGH, so the pulse never asserts and the module starts uncontrolled -- the condition the power-off comment says this code prevents. heltec_wifi_lora32_v4's overlay documented the no-op rather than fixing it; that comment is updated here, with _v43's copy. vrtc, sleep, rtcint and resetb are converted too. Every board declaring them is active-high, so those change nothing today; they are converted so the root cause does not survive in four more places. Converting is safe by construction. gpio_pin_configure() flips the init level only when both GPIO_OUTPUT_INIT_LOGICAL and GPIO_ACTIVE_LOW are set, then strips INIT_LOGICAL, so on an active-high pin GPIO_OUTPUT_ACTIVE produces a flags word byte-identical to GPIO_OUTPUT_HIGH. Behaviour changes only where a line is declared active-low, which is only where it is currently wrong. gps_power_off_for_shutdown() had the same inversion and it mattered most there: on the active-low boards the old physical LOW asserted the enable, powering the GPS on as the device entered System OFF rather than powering it down. Its header comment also described a narrower scope than the function has, naming only the power enable where it configures vrtc, reset, sleep, rtcint and resetb as well; that is corrected here. Comments that described a level this change now drives logically are reworded to asserted/de-asserted. Comments stating genuine electrical facts, such as a pin floating LOW without its pull-up, are left as they are, since rewording those would make them wrong. Verified on hardware on a Heltec V4-R8, whose gps-enable is active-low: with this change the boot log reports "GPS power GPIO configured, set ACTIVE" and the L76K streams NMEA (210 sentences in 35 s), where without it the log reports "set HIGH" and the module never powers on. Also built for heltec_wifi_lora32_v4 and _v43 (active-low enable and reset), thinknode_m1 and heltec_t114 (active-low reset) and t1000_e (active-high throughout). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>