Exemple #1
0
void GetCoordinates (void) 
{

  Coordinates[0] = 0;
  Coordinates[1] = 0;
  Coordinates[2] = 0;

  for (n=0; n < NSAMPLE; n++)
  {
        // Third Step: Start the conversion
        AT91F_ADC_StartConversion (AT91C_BASE_ADC);
        // Waiting Stop Of conversion by pulling the status bit
        while (!((AT91F_ADC_GetStatus (AT91C_BASE_ADC)) & (1<<CHANNEL5)));
        // Read the ADC output value
        Coordinates[0]     += AT91F_ADC_GetConvertedDataCH4 (AT91C_BASE_ADC);

        // Third Step: Start the conversion
        AT91F_ADC_StartConversion (AT91C_BASE_ADC);
        // Waiting Stop Of conversion by pulling the status bit
        while (!((AT91F_ADC_GetStatus (AT91C_BASE_ADC)) & (1<<CHANNEL6)));
        // Read the ADC output value
        Coordinates[1]     += AT91F_ADC_GetConvertedDataCH5 (AT91C_BASE_ADC);

         // Third Step: Start the conversion
        AT91F_ADC_StartConversion (AT91C_BASE_ADC);
        // Waiting Stop Of conversion by pulling the status bit
        while (!((AT91F_ADC_GetStatus (AT91C_BASE_ADC)) & (1<<CHANNEL7)));
        // Read the ADC output value
        Coordinates[2]     += AT91F_ADC_GetConvertedDataCH6 (AT91C_BASE_ADC);
  }
}
Exemple #2
0
void ADC_Start(unsigned char ch)
{
	AT91F_ADC_EnableChannel (AT91C_BASE_ADC, (1<<ch)); 
	AT91F_ADC_StartConversion (AT91C_BASE_ADC);
	while (!((AT91F_ADC_GetStatus (AT91C_BASE_ADC)) & (1<<ch)));
	AT91F_ADC_DisableChannel (AT91C_BASE_ADC, (1<<ch)); 
}