A CMOS sensor based on single photon avalanche diode for distance measurement applications