?? ads8344.h
字號:
//// Driver routines for the ADS8344 chip
#define AD1_CS PIN_D4
#define AD2_CS PIN_D5
#define ADC_BUSY PIN_D3
#define ADC_DIN PIN_D1
#define ADC_DOUT PIN_D2
#define ADC_DCLK PIN_D0
void write_adc_byte(byte data) {
byte i;
for(i=1;i<=8;++i) {
output_low(ADC_DCLK);
output_bit(ADC_DIN, shift_left(&data,1,0));
output_high(ADC_DCLK);
}
output_low(ADC_DCLK);
}
long int read_adc_word() {
byte i;
long data;
while ( input(ADC_BUSY) ) {
output_high(ADC_DCLK);
output_low(ADC_DCLK);
}
for(i=1;i<=16;++i) {
output_low(ADC_DCLK);
delay_cycles(50);
output_high(ADC_DCLK);
shift_left(&data,2,input(ADC_DOUT));
}
return data;
}
long read_adc_value(byte ch) {
long value;
if (ch<8) output_low(AD1_CS); else output_low(AD2_CS);
switch(ch) {
case 0 : write_adc_byte(0x87);
break;
case 1 : write_adc_byte(0xC7);
break;
case 2 : write_adc_byte(0x97);
break;
case 3 : write_adc_byte(0xD7);
break;
case 4 : write_adc_byte(0xA7);
break;
case 5 : write_adc_byte(0xE7);
break;
case 6 : write_adc_byte(0xB7);
break;
case 7 : write_adc_byte(0xF7);
break;
}
value=read_adc_word();
if (ch<8) output_high(AD1_CS); else output_high(AD2_CS);
return value;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -