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.

45 lines
904 B

#ifndef __MYMYIIC1_H
#define __MYMYIIC1_H
#include "sys.h"
//IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define SDA1_IN() {GPIOA->CRH&=0XFFFFFFF0;GPIOA->CRH|=(u32)8<<0;}
#define SDA1_OUT() {GPIOA->CRH&=0XFFFFFFF0;GPIOA->CRH|=(u32)3<<0;}
//IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define MYIIC1_SCL PBout(12) //SCL
#define MYIIC1_SDA PAout(8) //SDA
#define READ1_SDA PAin(8) //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>SDA
//MYIIC1<EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void MYIIC1_Init(void); //<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>IIC<EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD>
void MYIIC1_Start(void); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IIC<EFBFBD><EFBFBD>ʼ<EFBFBD>ź<EFBFBD>
void MYIIC1_Stop(void); //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IICֹͣ<EFBFBD>ź<EFBFBD>
void MYIIC1_Send_Byte(u8 txd); //IIC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
u8 MYIIC1_Read_Byte(unsigned char ack);//IIC<EFBFBD><EFBFBD>ȡһ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
u8 MYIIC1_Wait_Ack(void); //IIC<EFBFBD>ȴ<EFBFBD>ACK<EFBFBD>ź<EFBFBD>
void MYIIC1_Ack(void); //MYIIC1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ACK<EFBFBD>ź<EFBFBD>
void MYIIC1_NAck(void); //MYIIC1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ACK<EFBFBD>ź<EFBFBD>
void MYIIC1_Write_One_Byte(u8 daddr,u8 addr,u8 data);
u8 MYIIC1_Read_One_Byte(u8 daddr,u8 addr);
#endif