CMOS distance sensor based on single photon avalanche diode