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.
44 lines
904 B
44 lines
904 B
#ifndef __MYMYIIC1_H |
|
#define __MYMYIIC1_H |
|
#include "sys.h" |
|
|
|
//IO方向设置 |
|
#define SDA1_IN() {GPIOA->CRH&=0XFFFFFFF0;GPIOA->CRH|=(u32)8<<0;} |
|
#define SDA1_OUT() {GPIOA->CRH&=0XFFFFFFF0;GPIOA->CRH|=(u32)3<<0;} |
|
|
|
//IO操作函数 |
|
#define MYIIC1_SCL PBout(12) //SCL |
|
#define MYIIC1_SDA PAout(8) //SDA |
|
#define READ1_SDA PAin(8) //输入SDA |
|
|
|
|
|
//MYIIC1所有操作函数 |
|
void MYIIC1_Init(void); //初始化IIC的IO口 |
|
void MYIIC1_Start(void); //发送IIC开始信号 |
|
void MYIIC1_Stop(void); //发送IIC停止信号 |
|
void MYIIC1_Send_Byte(u8 txd); //IIC发送一个字节 |
|
u8 MYIIC1_Read_Byte(unsigned char ack);//IIC读取一个字节 |
|
u8 MYIIC1_Wait_Ack(void); //IIC等待ACK信号 |
|
void MYIIC1_Ack(void); //MYIIC1发送ACK信号 |
|
void MYIIC1_NAck(void); //MYIIC1不发送ACK信号 |
|
|
|
void MYIIC1_Write_One_Byte(u8 daddr,u8 addr,u8 data); |
|
u8 MYIIC1_Read_One_Byte(u8 daddr,u8 addr); |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|