ADC
Appearance
https://en.wikipedia.org/wiki/Goertzel_algorithm
I am wondering how well this will work for selecting a square wave. I'll try to do a demo in python.
Gay bob's idea[edit]
Just use a first difference, maybe taking it a few samples back, and see when that becomes big enough, then record that as a transition, and calculate the average difference in time between them over the period.