?? adcdrv.c
字號:
/*
adcDrv.c
Read ADC value
*/
/*@+relaxquals@*/ //SPLINT avoid detecting each time a char is stored in an int
/*@+charindex@*/ //Only detect if used in a dengirus way
#include "adcDrv.h"
#include <iom88.h>
void acdDrv_init(void)
{
// Enable AD converter and set prescaler to 64 (8M Hz /64 = 125k Hz)
ADCSRA = (unsigned char)0x80 | 6;
//Make first conversation (setup ref voltage)
adcDrv_getAdc(GND);
}
unsigned int adcDrv_getAdc(enum ADCCHANNEL ch)
{
volatile unsigned char temp;
// Enable AD converter and set prescaler to 64 (8M Hz /64 = 125k Hz)
ADCSRA = (unsigned char)0x80 | 6;
//Use Connext VAVCC to ref no left adjust, and select channel
ADMUX = (unsigned char)0x40 | (unsigned char)ch;
//Start AD conversion
ADCSRA_Bit6 =(unsigned char)1;
//Wait for conversation to end
//while(ADCSRA_Bit6){;};
while((temp=ADCSRA_Bit6)!= (unsigned char)0){;};
// for(temp=ADCSRA; (temp&(1<<6))!= (unsigned char)0; temp=ADCSRA){;};
return ADC;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -