Measure on time

so joke aside, you go in a loop

highState = 0
lowState = 0

note start time t0
read start pin state

loop until pin changes state
note end time t1
add (t1 - t0) to a variable based on state 
copy t1 into t0
invert start pin state
rinse and repeat