// DAC驱动(GPIO模拟I2C)
// 杭州秒寻科技有限公司
// 周涛
// 2023-09-29

#ifndef DRIVERDACGPIO_H
#define DRIVERDACGPIO_H

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

// 复位管脚定义
#define DRIVER_DACGPIO_RESET_CLK RCC_AHB1Periph_GPIOB
#define DRIVER_DACGPIO_RESET_PORT GPIOB
#define DRIVER_DACGPIO_RESET_PIN GPIO_Pin_13

// 模拟静音管脚
#define DRIVER_DACGPIO_AMUTE_CLK RCC_AHB1Periph_GPIOE
#define DRIVER_DACGPIO_AMUTE_PORT GPIOE
#define DRIVER_DACGPIO_AMUTE_PIN GPIO_Pin_11

// SCL管脚定义
#define DRIVER_DACGPIO_SCL_CLK RCC_AHB1Periph_GPIOE
#define DRIVER_DACGPIO_SCL_PORT GPIOE
#define DRIVER_DACGPIO_SCL_PIN GPIO_Pin_14

// SDA管脚定义
#define DRIVER_DACGPIO_SDA_CLK RCC_AHB1Periph_GPIOE
#define DRIVER_DACGPIO_SDA_PORT GPIOE
#define DRIVER_DACGPIO_SDA_PIN GPIO_Pin_13

// 供外部使用的接口
void driver_dacgpio_init();
uint8 driver_dacgpio_write_data(uint8 bySlaveAddress, uint8 byRegAddress, uint8 *pbyData, uint16 wLen);
uint8 driver_dacgpio_read_data(uint8 bySlaveAddress, uint8 byRegAddress, uint8 *pbyData, uint16 wLen);
void driver_dacgpio_reset();
void driver_dacgpio_amute(uint8 byMute);

// 内部使用接口
void driver_dacgpio_delay();
void driver_dacgpio_w_scl(uint8 byBitValue);
void driver_dacgpio_w_sda(uint8 byBitValue);
uint8 driver_dacgpio_r_sda();
void driver_dacgpio_start();
void driver_dacgpio_stop();
void driver_dacgpio_send_byte(uint8 byData);
uint8 driver_dacgpio_receive_byte();
void driver_dacgpio_send_ack(uint8 byAck);
uint8 driver_dacgpio_receive_ack();

#endif
