Fundamentals of CMOS Single-Photon Avalanche Diodes