Beispiel #1
0
int readAnalog(void* params) {
    struct analogParams* par = (struct analogParams*) params;
    ADCSetChannel(par->channel);
    ADCStartConversion();
    uint16_t adc = 0;
    while (ADCRead(&adc)) {
        NutThreadYield();
    }
    //TODO zrobić coś z adc
    //return (adc >> 1) - 183;
    return adc;
}
Beispiel #2
0
uint8_t ReadADC(uint8_t channel)
{	
	ADCSetChannel(channel);	// Set ADC channel select bits
	ADCSetAdjust(ADC_LEFTADJUST);	// Set left/right adjust bit
	
	ADCStart();
	// Wait for the AD conversion to complete
	while (!ADCDone());
	
	ADCFinish();
	
	return ADCH;
}