Explain the function of ATP synthatase in both photosynthesis and cellular respiration.