// I2C接口驱动
// 杭州秒寻科技有限公司
// 周涛
// 2023-09-17

#ifndef DRIVERI2C_H
#define DRIVERI2C_H

#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "sysdef.h"

#define DRIVER_I2C1_ADDRESS 0x01;
#define DRIVER_I2C2_ADDRESS 0x02;
#define DRIVER_I2C3_ADDRESS 0x03;

#define DRIVER_DAC_GPIO_CLK RCC_AHB1Periph_GPIOB

#define DRIVER_DAC_SCLK_GPIO_PORT GPIOB
#define DRIVER_DAC_SCLK_GPIO_PIN GPIO_Pin_6

#define DRIVER_DAC_SDA_GPIO_PORT GPIOB
#define DRIVER_DAC_SDA_GPIO_PIN GPIO_Pin_7

// 外部接口
void driver_i2c_init();
uint8 driver_i2c_write_byte(I2C_TypeDef *I2Cx, uint8 bySlaveAddress, uint8 byRegAddress, uint8 bydata);
uint8 driver_i2c_read_byte(I2C_TypeDef *I2Cx, uint8 bySlaveAddress, uint8 byRegAddress, uint8 *pbydata);

// 内部接口
void driver_i2c_init_i2c1();
uint8 driver_i2c_wait_event(I2C_TypeDef *I2Cx, uint32_t I2C_EVENT);

#endif
