📄 adc0832.c
字号:
// *********************************************************************************** //
//
// Filename : adc0832.c
// Title : ADC0832 Source File
// Author : Fung Tin Ching
// Created Date : 2006.7.24
// Revisited Date : 2008.01.16
// Description : Provide Function to get the value from the ADC0832 at any three pins
// Version : 1.2
//
// Copyright (c) 2008, All rights reserved.
// *********************************************************************************** //
#include "adc0832.h"
volatile u08 CH0=0;
volatile u08 CH1=0;
unsigned char get_ADC_onewire(unsigned char ch)
{
unsigned char temp=0,i;
if (!((ch==0)||(ch==1)))
return 0;
ADC_CLK=0;
ADC_CS=0;
ADC_DIDO=1;
ADC_clk_pulse();
ADC_DIDO=SGL_DIF;
ADC_clk_pulse();
ADC_DIDO=ch;
ADC_clk_pulse();
ADC_DIDO=1;
temp=ADC_DIDO;
temp=0;
for (i=0;i<7;i++){
ADC_clk_pulse();
temp|=(unsigned char)ADC_DIDO;
temp= temp << 1;
}
for (i=0;i<13;i++){
ADC_clk_pulse();
}
ADC_CS=1;
ADC_DIDO=1;
ADC_CLK=0;
return temp;
}
void ADC_clk_pulse(void)
{
ADC_CLK=0;
ADC_CLK=1;
ADC_CLK=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -