Files
stm32-iot-sensor-node/mylib/gpio_iic.h
T
2026-10-19 15:47:18 +08:00

27 lines
758 B
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef __GPIO_IIC_H
#define __GPIO_IIC_H
#include <stm32f10x_conf.h>
typedef unsigned char u8;
// 初始化 IIC 的IO 端口:SDA:PB7,SCL:PB6
void iic_init(void);
// 主机发送起始信号
void iic_start(void);
//主机发送停止信号
void iic_stop(void);
// 主机发送一个字节
void iic_send_byte(u8 txd);
// 主机接收一个字节并回复ack,参数ack:1表示应答,0表示非应答。
u8 iic_recv_byte(u8 ack);
// 主机等待从机,如果从机未响应(收到NACK),则发送停止
// 信号结束本次通信,非应答返回1(NACK),应答返回0,ACK);
u8 iic_wait_ack(void);
// 主机发送 ACK
void iic_send_ack(void);
// 主机发送 NACK
void iic_send_nack(void);
#endif // __GPIO_IIC_H