// RTC驱动(GPIO模拟I2C)
// 杭州秒寻科技有限公司
// 周涛
// 2025-02-28

#ifndef __DRIVER_RTCI2C_H__
#define __DRIVER_RTCI2C_H__

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

// SCL管脚定义
#define DRIVER_RTCI2C_SCL_CLK RCC_AHB1Periph_GPIOE
#define DRIVER_RTCI2C_SCL_PORT GPIOE
#define DRIVER_RTCI2C_SCL_PIN GPIO_Pin_1

// SDA管脚定义
#define DRIVER_RTCI2C_SDA_CLK RCC_AHB1Periph_GPIOE
#define DRIVER_RTCI2C_SDA_PORT GPIOE
#define DRIVER_RTCI2C_SDA_PIN GPIO_Pin_0

// 供外部使用的接口
void driver_rtci2c_init();
uint8 driver_rtci2c_write_data(uint8 bySlaveAddress, uint8 byRegAddress, uint8 *pbyData, uint16 wLen);
uint8 driver_rtci2c_read_data(uint8 bySlaveAddress, uint8 byRegAddress, uint8 *pbyData, uint16 wLen);

// 内部使用接口
void driver_rtci2c_delay();
void driver_rtci2c_w_scl(uint8 byBitValue);
void driver_rtci2c_w_sda(uint8 byBitValue);
uint8 driver_rtci2c_r_sda();
void driver_rtci2c_start();
void driver_rtci2c_stop();
void driver_rtci2c_send_byte(uint8 byData);
uint8 driver_rtci2c_receive_byte();
void driver_rtci2c_send_ack(uint8 byAck);
uint8 driver_rtci2c_receive_ack();

#endif
