📄 tlc1543.c
字号:
/**
* @file
* Driver of ADC chip TLC1543
*
* TLC1543.c
* Copyright(C) 2007 Agate Logic Corporation. All rights reserved.
* This file is licensed under the terms of Agate Logic SDK License Agreement.
*
* @author bxu@agatelogic.com.cn
*/
#define TLC1543_GLOBALS ///< define macro "TLC1543_GLOBALS" as empty
#include "tlc1543.h"
/**
* @brief Initialize the interface of ADC chip.
*
* The Function set the clock division register and initialize the interface of ADC chip.
*
* @param clkdiv The clock division value to set.
*
* @return N/A
*/
void init_tlc1543(uchar clkdiv)
{
TLC1543_CLKDIV = clkdiv;
}
/**
* @brief Read the adc result of ADC chip at the specified channel.
*
* The Function start a adc acquirement at the specified channel and then read back the ad convert result.
*
* @param nextchannel The AD channel to acquire.
*
* @return N/A
*/
uint read_tlc1543(uchar nextchannel)
{
uint ad_result=0;
nextchannel&=0x0f;//set channel
nextchannel|=0x80;//start ad acq
TLC1543_CONTROL=nextchannel;
do
{
nextchannel=TLC1543_CONTROL;
ad_result++;
}
while(((nextchannel&0x40)==0x00)&&ad_result<1000);
ad_result = TLC1543_DATAH & 0x03;
ad_result <<= 8;
ad_result += TLC1543_DATAL;
return ad_result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -