RobotHardware-UESTC/Hardware/银星机器人底盘/PiRobot-YH_Firmware v1.0/STM32/BSPLIB/i2c.h

35 lines
861 B
C
Raw Permalink Normal View History

2024-01-24 22:08:32 +08:00
#ifndef __I2C_H__
#define __I2C_H__
2024-01-20 13:19:09 +08:00
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32f10x.h"
#define SCL_H GPIOB->BSRR = GPIO_Pin_8
#define SCL_L GPIOB->BRR = GPIO_Pin_8
#define SDA_H GPIOB->BSRR = GPIO_Pin_9
#define SDA_L GPIOB->BRR = GPIO_Pin_9
#define SCL_read GPIOB->IDR & GPIO_Pin_8
#define SDA_read GPIOB->IDR & GPIO_Pin_9
/*********************************************************************************************************************/
2024-01-24 22:08:32 +08:00
void I2C_InitGPIO(void);
int I2C_WriteByte(uint8_t addr, uint8_t reg, uint8_t data);
int I2C_WriteBuf(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t size);
int I2C_ReadByte(uint8_t addr, uint8_t reg, uint8_t* data);
int I2C_ReadBuf(uint8_t addr,uint8_t reg, uint8_t* data, uint8_t size);
2024-01-20 13:19:09 +08:00
#ifdef __cplusplus
}
#endif
2024-01-24 22:08:32 +08:00
#endif // __I2C_H__
2024-01-20 13:19:09 +08:00