Modifying APM code to read analog sensors

Hi everyone,

I would like to modify the APM firmware to read data from external analog sensors connected to the analog ports (A0-A4). I wrote an Arduino script which works on a basic Arduino board, but I want to include the piece of code in the firmware. I started going through the firmware and I am lost trying to figure out where to modify it.

Could someone guide me which portion of the code to look at and modify to read data from the analog ports. It would be very helpful if someone could point me to an example.


Usercode.pde is a good place to start.