示例#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);
  }
}
示例#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)); 
}
示例#3
0
//*----------------------------------------------------------------------------
//* \fn    AT91F_ADC_IsStatusSet
//* \brief Test if ADC Status is Set
//*----------------------------------------------------------------------------
__inline unsigned int AT91F_ADC_IsStatusSet(
        AT91PS_ADC pADC,   // \arg  pointer to a ADC controller
        unsigned int flag) // \arg  flag to be tested
{
	return (AT91F_ADC_GetStatus(pADC) & flag);
}