You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.3 KiB

#ifndef __MYIIC_H
#define __MYIIC_H
#include "sys.h"
//////////////////////////////////////////////////////////////////////////////////
//<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>;
//ALIENTEKս<EFBFBD><EFBFBD>STM32<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//IIC<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD>@ALIENTEK
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳:www.openedv.com
//<EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:2012/9/9
//<EFBFBD><EFBFBD><EFBFBD>V1.0
//<EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><EFBFBD><EFBFBD>
//Copyright(C) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>޹<EFBFBD>˾ 2009-2019
//All rights reserved
//////////////////////////////////////////////////////////////////////////////////
//IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SDA_IN() {GPIOC->CRH&=0X0FFFFFFF;GPIOC->CRH |= (u32)8<<28;}
#define SDA_OUT() {GPIOC->CRH&=0X0FFFFFFF;GPIOC->CRH |= (u32)3<<28;}
//IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define IIC_SCL PCout(13) //SCL
#define IIC_SDA PCout(14) //SDA
#define READ_SDA PCin(14) //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>SDA B
//IIC<EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void MYIIC_Init(void); //<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>IIC<EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD>
void MYIIC_Start(void); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IIC<EFBFBD><EFBFBD>ʼ<EFBFBD>ź<EFBFBD>
void MYIIC_Stop(void); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IICֹͣ<EFBFBD>ź<EFBFBD>
void IIC_Send_Byte(u8 txd); //IIC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
u8 IIC_Read_Byte(unsigned char ack);//IIC<EFBFBD><EFBFBD>ȡһ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
u8 MYIIC_Wait_Ack(void); //IIC<EFBFBD>ȴ<EFBFBD>ACK<EFBFBD>ź<EFBFBD>
void IIC_Ack(void); //IIC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ACK<EFBFBD>ź<EFBFBD>
void IIC_NAck(void); //IIC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ACK<EFBFBD>ź<EFBFBD>
void IIC_Write_One_Byte(u8 daddr,u8 addr,u8 data);
u8 IIC_Read_One_Byte(u8 daddr,u8 addr);
#endif