The routine
icp_rx() is called in the main routine, to
get the sample values periodically. The selection of Analog Input or Digital Input
is made before compilation. In case of analog input signal (done by enabling
ICP_ANALOG macro) moving average of last
n are returned. If the selection is made as
ICP_DIGITAL a queue is maintained to retrieve the oldest
reading. The flow of software is shown in the following figure.
Figure 1. Flowchart for
icp_rx()