1.5wuling_zhuanjietou/SYSTEM/bsp_i2c_gpio.c

323 lines
8.6 KiB
C
Raw Normal View History

2024-10-17 01:06:51 +00:00
/*
*********************************************************************************************************
*
* ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : I2C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : bsp_i2c_gpio.c
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> : V1.0
* ˵ <EFBFBD><EFBFBD> : <EFBFBD><EFBFBD>gpioģ<EFBFBD><EFBFBD>i2c<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>STM32F4ϵ<EFBFBD><EFBFBD>CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I2C<EFBFBD><EFBFBD><EFBFBD>߻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* <EFBFBD>޸ļ<EFBFBD>¼ :
* <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ˵<EFBFBD><EFBFBD>
* V1.0 2015-05-21 armfly <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* Copyright (C), 2015-2016, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com
*
*********************************************************************************************************
*/
/*
Ӧ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD>ڷ<EFBFBD><EFBFBD><EFBFBD>I2C<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD> i2c_CheckDevice() <EFBFBD><EFBFBD><EFBFBD><EFBFBD>I2C<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO
*/
#include "stm32f10x.h"
#include "bsp_i2c_gpio.h"
/*
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>STM32-V4<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> i2c<EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO:
PB6/I2C1_SCL
PB7/I2C1_SDA
*/
/* <20><><EFBFBD><EFBFBD>I2C<32><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>GPIO<49>˿<EFBFBD>, <20>û<EFBFBD>ֻ<EFBFBD><D6BB>Ҫ<EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EBBCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>SCL<43><4C>SDA<44><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#define RCC_I2C_PORT RCC_APB2Periph_GPIOB /* GPIO<49>˿<EFBFBD>ʱ<EFBFBD><CAB1> */
#define PORT_I2C_SCL GPIOB /* GPIO<49>˿<EFBFBD> */
#define PIN_I2C_SCL GPIO_Pin_10 /* GPIO<49><4F><EFBFBD><EFBFBD> */
#define PORT_I2C_SDA GPIOB /* GPIO<49>˿<EFBFBD> */
#define PIN_I2C_SDA GPIO_Pin_11 /* GPIO<49><4F><EFBFBD><EFBFBD> */
#define I2C_SCL_PIN GPIO_Pin_10 /* <20><><EFBFBD>ӵ<EFBFBD>SCLʱ<4C><CAB1><EFBFBD>ߵ<EFBFBD>GPIO */
#define I2C_SDA_PIN GPIO_Pin_11 /* <20><><EFBFBD>ӵ<EFBFBD>SDA<44><41><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>GPIO */
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>дSCL<43><4C>SDA<44>ĺ<EFBFBD> */
#define I2C_SCL_1() PORT_I2C_SCL->BSRR = I2C_SCL_PIN /* SCL = 1 */
#define I2C_SCL_0() PORT_I2C_SCL->BRR = I2C_SCL_PIN /* SCL = 0 */
#define I2C_SDA_1() PORT_I2C_SDA->BSRR = I2C_SDA_PIN /* SDA = 1 */
#define I2C_SDA_0() PORT_I2C_SDA->BRR = I2C_SDA_PIN /* SDA = 0 */
#define I2C_SDA_READ() ((PORT_I2C_SDA->IDR & I2C_SDA_PIN) != 0) /* <20><>SDA<44><41><EFBFBD><EFBFBD>״̬ */
#define I2C_SCL_READ() ((PORT_I2C_SCL->IDR & I2C_SCL_PIN) != 0) /* <20><>SCL<43><4C><EFBFBD><EFBFBD>״̬ */
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: bsp_InitI2C
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>I2C<EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>GPIO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>IO<EFBFBD>ķ<EFBFBD>ʽʵ<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
*********************************************************************************************************
*/
void bsp_InitI2C(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_I2C_PORT, ENABLE); /* <20><><EFBFBD><EFBFBD>GPIOʱ<4F><CAB1> */
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; /* <20><>©<EFBFBD><C2A9><EFBFBD><EFBFBD>ģʽ */
GPIO_InitStructure.GPIO_Pin = PIN_I2C_SCL;
GPIO_Init(PORT_I2C_SCL, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = PIN_I2C_SDA;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; /* <20><>©<EFBFBD><C2A9><EFBFBD><EFBFBD>ģʽ */
GPIO_Init(PORT_I2C_SDA, &GPIO_InitStructure);
/* <20><>һ<EFBFBD><D2BB>ֹͣ<CDA3>ź<EFBFBD>, <20><>λI2C<32><43><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
// IIC_Stop();
GPIO_SetBits(PORT_I2C_SCL,PIN_I2C_SCL); //PB6,PB7 ???
GPIO_SetBits(PORT_I2C_SDA,PIN_I2C_SDA);
//???
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;//A SCL SDA
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
// GPIO_Init(GPIOB, &GPIO_InitStructure);
// GPIO_SetBits(GPIOB,GPIO_Pin_6|GPIO_Pin_7); //PB6,PB7 ???
}
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: i2c_Delay
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: I2C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ӳ٣<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>400KHz
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
*********************************************************************************************************
*/
static void i2c_Delay(void)
{
uint16_t i;
/*<2A><>
CPU<EFBFBD><EFBFBD>Ƶ168MHzʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>Flash<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, MDK<EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨ʽʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۲<EFBFBD>Ρ<EFBFBD>
ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ5ʱ<EFBFBD><EFBFBD>SCLƵ<EFBFBD><EFBFBD> = 1.78MHz (<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ: 92ms, <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̽ͷ<EFBFBD><EFBFBD><EFBFBD>ϾͶ<EFBFBD>дʧ<EFBFBD>ܡ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD>ٽ<EFBFBD>)
ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ10ʱ<EFBFBD><EFBFBD>SCLƵ<EFBFBD><EFBFBD> = 1.1MHz (<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ: 138ms, <EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>: 118724B/s)
ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ30ʱ<EFBFBD><EFBFBD>SCLƵ<EFBFBD><EFBFBD> = 440KHz<EFBFBD><EFBFBD> SCL<EFBFBD>ߵ<EFBFBD>ƽʱ<EFBFBD><EFBFBD>1.0us<EFBFBD><EFBFBD>SCL<EFBFBD>͵<EFBFBD>ƽʱ<EFBFBD><EFBFBD>1.2us
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>2.2Kŷʱ<EFBFBD><EFBFBD>SCL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Լ0.5us<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ4.7<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ1us
ʵ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>400KHz<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>
*/
for (i = 0; i < 60; i++);
}
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: i2c_Start
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>I2C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
*********************************************************************************************************
*/
void IIC_Start(void)
{
/* <20><>SCL<43>ߵ<EFBFBD>ƽʱ<C6BD><CAB1>SDA<44><41><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ʾI2C<32><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> */
I2C_SDA_1();
I2C_SCL_1();
i2c_Delay();
I2C_SDA_0();
i2c_Delay();
I2C_SCL_0();
i2c_Delay();
}
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: i2c_Start
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>I2C<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD>ź<EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
*********************************************************************************************************
*/
void IIC_Stop(void)
{
/* <20><>SCL<43>ߵ<EFBFBD>ƽʱ<C6BD><CAB1>SDA<44><41><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ʾI2C<32><43><EFBFBD><EFBFBD>ֹͣ<CDA3>ź<EFBFBD> */
I2C_SDA_0();
I2C_SCL_1();
i2c_Delay();
I2C_SDA_1();
i2c_Delay();
}
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: i2c_SendByte
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CPU<EFBFBD><EFBFBD>I2C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8bit<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: _ucByte <EFBFBD><EFBFBD> <EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD>ֽ<EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
*********************************************************************************************************
*/
void IIC_Send_Byte(uint8_t _ucByte)
{
uint8_t i;
/* <20>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ֽڵĸ<DAB5>λbit7 */
for (i = 0; i < 8; i++)
{
if (_ucByte & 0x80)
{
I2C_SDA_1();
}
else
{
I2C_SDA_0();
}
i2c_Delay();
I2C_SCL_1();
i2c_Delay();
I2C_SCL_0();
if (i == 7)
{
I2C_SDA_1(); // <20>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
}
_ucByte <<= 1; /* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>bit */
i2c_Delay();
}
}
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: i2c_ReadByte
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CPU<EFBFBD><EFBFBD>I2C<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ8bit<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*********************************************************************************************************
*/
u8 IIC_Read_Byte(unsigned char ack)
{
uint8_t i;
uint8_t value;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>bitΪ<74><CEAA><EFBFBD>ݵ<EFBFBD>bit7 */
value = 0;
for (i = 0; i < 8; i++)
{
value <<= 1;
I2C_SCL_1();
i2c_Delay();
if (I2C_SDA_READ())
{
value++;
}
I2C_SCL_0();
i2c_Delay();
}
if (!ack)
IIC_NAck();//??nACK
else
IIC_Ack(); //??ACK
return value;
}
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: i2c_WaitAck
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ʱ<EFBFBD>ӣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ACKӦ<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ȷӦ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
*********************************************************************************************************
*/
uint8_t IIC_Wait_Ack(void)
{
uint8_t re;
I2C_SDA_1(); /* CPU<50>ͷ<EFBFBD>SDA<44><41><EFBFBD><EFBFBD> */
i2c_Delay();
I2C_SCL_1(); /* CPU<50><55><EFBFBD><EFBFBD>SCL = 1, <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B7B5>ACKӦ<4B><D3A6> */
i2c_Delay();
if (I2C_SDA_READ()) /* CPU<50><55>ȡSDA<44><41><EFBFBD><EFBFBD>״̬ */
{
re = 1;
}
else
{
re = 0;
}
I2C_SCL_0();
i2c_Delay();
return re;
}
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: i2c_Ack
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ACK<EFBFBD>ź<EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
*********************************************************************************************************
*/
void IIC_Ack(void)
{
I2C_SDA_0(); /* CPU<50><55><EFBFBD><EFBFBD>SDA = 0 */
i2c_Delay();
I2C_SCL_1(); /* CPU<50><55><EFBFBD><EFBFBD>1<EFBFBD><31>ʱ<EFBFBD><CAB1> */
i2c_Delay();
I2C_SCL_0();
i2c_Delay();
I2C_SDA_1(); /* CPU<50>ͷ<EFBFBD>SDA<44><41><EFBFBD><EFBFBD> */
}
/*
*********************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: i2c_NAck
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>NACK<EFBFBD>ź<EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
*********************************************************************************************************
*/
void IIC_NAck(void)
{
I2C_SDA_1(); /* CPU<50><55><EFBFBD><EFBFBD>SDA = 1 */
i2c_Delay();
I2C_SCL_1(); /* CPU<50><55><EFBFBD><EFBFBD>1<EFBFBD><31>ʱ<EFBFBD><CAB1> */
i2c_Delay();
I2C_SCL_0();
i2c_Delay();
}
///*
//*********************************************************************************************************
//* <09><> <20><> <20><>: i2c_CheckDevice
//* <09><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <20><><EFBFBD><EFBFBD>I2C<32><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8>CPU<50><55><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8>ַ<EFBFBD><D6B7>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>ȡ<EFBFBD>豸Ӧ<E8B1B8><D3A6><EFBFBD><EFBFBD><EFBFBD>жϸ<D0B6><CFB8><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
//* <09><> <20><>: _Address<73><73><EFBFBD><EFBFBD><E8B1B8>I2C<32><43><EFBFBD>ߵ<EFBFBD>ַ
//* <09><> <20><> ֵ: <20><><EFBFBD><EFBFBD>ֵ 0 <20><>ʾ<EFBFBD><CABE>ȷ<EFBFBD><C8B7> <20><><EFBFBD><EFBFBD>1<EFBFBD><31>ʾδ̽<CEB4>
//*********************************************************************************************************
//*/
//#define ADS1015_ADDRESS 0x48
// u8 AD1015_Check(u8 i2cAddress)
//{
// uint8_t ucAck;
// if (I2C_SDA_READ() && I2C_SCL_READ())
// {
// IIC_Start(); /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> */
// /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8>ַ+<2B><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>bit<69><74>0 = w<><77> 1 = r) bit7 <20>ȴ<EFBFBD> */
// IIC_Send_Byte(i2cAddress | I2C_WR);
// ucAck = IIC_Wait_Ack(); /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B1B8>ACKӦ<4B><D3A6> */
// IIC_Stop(); /* <20><><EFBFBD><EFBFBD>ֹͣ<CDA3>ź<EFBFBD> */
// return ucAck;
// }
// return 1; /* I2C<32><43><EFBFBD><EFBFBD><EFBFBD>쳣 */
//}
/***************************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> www.armfly.com (END OF FILE) *********************************/