A SPAD-Based Configurable Photon Counting System