Simply speaking, the role is to detect engine crankshaft speed and Angle, determine the position of the crankshaft. And relay the results to the engine computer or other computer. The camshaft position sensor is used to determine the basic ignition time.
The engine computer uses the signal from this sensor to control engine ignition and fuel injection. Control the timing of ignition and fuel injection, and control the amount of fuel injection.