资源简介
ti ads7142驱动程序,调通可用,只需在.h头文件里修改对应引脚即可 资料包括ads7142数据手册
代码片段和文件信息
#include “ads7142.h“
#include “bsp.h“
#include “adsxx.h“
/*
static void DelayNus(uint32_t N)
{
uint8_t i;
do{
for(i=6;i>0;i--) //8MHZ:=7; 12MHZ:=11
;
}while(--N);
}
*/
/**
* @brief IIC Init
* @param None
* @retval None
*/
static void ads7142_gpio_init(void)
{
ADS7142_SDA_SET_OUT();
ADS7142_SCL_SET();
ADS7142_BSY_SET();
ADS7142_CLK_SET();
}
/**
* @brief Set SDA Pin as Output Mode
* @param None
* @retval None
*/
static void SDA_OUT(void)
{
ADS7142_SDA_SET_OUT();
}
/**
* @brief Set SDA Pin as Input Mode
* @param None
* @retval None
*/
static void SDA_IN()
{
ADS7142_SDA_SET_IN();
}
/**
* @brief create start signal
* @param None
* @retval 1 or 0
*/
static uint8_t IIC_Start(void)
{
SDA_OUT(); //sda output
SDA_H;
SCL_H;
DelayNus(6);
if(!SDA_read)
{
return 0;
}
SDA_L;
DelayNus(6);
if(SDA_read)
{
return 0;
}
SDA_L;
DelayNus(6);
return 1;
}
/**
* @brief Simulate IIC conmunication : Create Stop signal
* @param None
* @retval None
*/
static void IIC_Stop(void)
{
SCL_L;
SDA_OUT(); //sda output mode
DelayNus(6);
SDA_L;
DelayNus(6);
SCL_H;
DelayNus(6);
SDA_H;
DelayNus(6);
}
/**
* @brief Simulate IIC conmunication : wait for target device‘s ACK
* @param None
* @retval ACK (1) : receive success
* NACK(0) : receive unsuccess
*/
static uint8_t IIC_WaitAck(void)
{
uint8_t err_time = 0;
SCL_L;
SDA_IN(); //set as input mode
DelayNus(6);
SDA_H;
DelayNus(6);
SCL_H;
DelayNus(6);
while(SDA_read)
{
err_time++;
if (err_time > 250)
{
return 0;
}
}
SCL_L;
return 1;
}
/**
* @brief Simulate IIC conmunication : make an ACK
* @param None
* @retval None
*/
static void IIC_Ack(void)
{
SCL_L;
SDA_OUT();
DelayNus(6);
SDA_L;
DelayNus(6);
SCL_H;
DelayNus(6);
SCL_L;
DelayNus(6);
}
/**
* @brief Simulate IIC conmunication : don‘t make an ACK
* @retval None
*/
static void IIC_NoAck(void)
{
SCL_L;
SDA_OUT();
DelayNus(6);
SDA_H;
DelayNus(6);
SCL_H;
DelayNus(6);
SCL_L;
DelayNus(6);
}
/**
* @brief Simulate IIC conmunication : Transmit one byte Data
* @param SendByte: data to be transmit
* @retval None
*/
static void IIC_SendByte(uint8_t SendByte)
{
uint8_t i=8;
SDA_OUT();
while(i--)
{
SCL_L;
DelayNus(6);
if(SendByte&0x80)
SDA_H;
else
SDA_L;
SendByte <<= 1;
DelayNus(6);
SCL_H;
DelayNus(6);
}
SCL_L;
}
/**
* @brief Simulate IIC conmunication : Receive one byte Data
* @param ack ->Whether transm
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9949 2018-09-06 15:39 ads7142\ads7142.c
文件 21466 2018-09-06 15:47 ads7142\ads7142.h
文件 2008363 2018-09-06 14:16 ads7142\ads7142.pdf
目录 0 2018-11-01 17:42 ads7142\
- 上一篇:h264编码流程概述
- 下一篇:2019年aws的sap专业架构师考试题库英文版
相关资源
- Introduction to Graph Theory West 2e solutions
- Guide to Elliptic Curve Cryptography
- Advanced Compiler Design and Implementation (高
- Topics in Multi-User Information Theory
- Introduction to Probability Models[Ross] 第10版
- 在线考试系统含UML课程设计rational r
- Lambda-Calculus and Combinators,an Introduct
- ANSI-VITA 66.0-2016 Optical Interconnect on VP
- 计算机结构习题答案 Computer+Organizat
- WAVELET METHODS FOR TIME SERIES ANALYSIS
- AMI刷新工具 AMIBIOS8_AMI_Firmware_Update_U
- LaTeX: A Document Preparation System 英文原版
- µC/OS-II: The Real-Time Kernel 2nd Edition英文
- 图论导引习题答案 Introduction to Graph
- scientific workplace中文教程
- A Practical Guide to TPM 2.0
- Computer Organization and Design The Hardware/
- SIMATIC ET 200MP ET 200MP 分布式 IO 系统-系
- Altium Designer教程交互式布线篇__开发者
- 用AS3加载外部SWF文件
- 信号与系统 西蒙 赫金 signals and syst
- Wavelet methods in statistics with R
- MIPI_D-PHY_Specification_v1.00.00
- prime time 教程
- A Mathematical Gift 2
- A Mathematical Gift 1
- Solutions Manual for Computer Networking: A To
- Manfredo Do Carmo - Differential geometry of c
- synopsys primetime px user guide 2017
- truetime2.0
评论
共有 条评论