/**
  ******************************************************************************
  * @file    VK16D32A.h 
  * @author  kevin_guo
  * @version V1.1
  * @date    07-05-2024
  * @brief   Header files for VK16D32A
  ******************************************************************************
  * @attention
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __VK16D32A_H
#define __VK16D32A_H

/* Includes ------------------------------------------------------------------*/
//此包含文件根据客户单片机做相应的修改
#include "M451Series.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
//基本设置
//I2C地址
#define VK16D32A_ADDR   					0x42 
//I2C地址写
#define VK16D32A_ADDRWR   				0x84 
//I2C地址读
#define VK16D32A_ADDRRD   				0x85 
//显示RAM起始地址
#define VK16D32A_DISPSTARTADDR   	0x00 //0x00-0x0F 16byte

//状态控制命令(bit7~bit2=000000) 
#define VK16D32A_REG_SYSCTRL			0x12 
#define VK16D32A_NORMAL  					0x01  //或bit1=1 NORMAL(正常模式)		 
#define VK16D32A_SHUTDOWN  				0xFE	//与bit1=0 SHUTDPWN(待机模式) 上电默认
#define VK16D32A_LED_ON       		0x02  //或bit1=1 显示开
#define VK16D32A_LED_OFF  				0xFD  //与bit1=0 显示关 上电默认
//显示控制命令(bit7~bit4=0000) 
#define VK16D32A_REG_DISPCTRL			0x10		 
#define VK16D32A_SEGI_LEVEL8  		0x07	//SEG持续输出电流35mA 上电默认
#define VK16D32A_SEGI_LEVEL7  		0x06	//SEG持续输出电流30.6mA
#define VK16D32A_SEGI_LEVEL6  		0x05	//SEG持续输出电流26.25mA
#define VK16D32A_SEGI_LEVEL5  		0x04	//SEG持续输出电流LEVEL5 
#define VK16D32A_SEGI_LEVEL4  		0x03	//SEG持续输出电流LEVEL4
#define VK16D32A_SEGI_LEVEL3  		0x02	//SEG持续输出电流LEVEL3
#define VK16D32A_SEGI_LEVEL2  		0x01	//SEG持续输出电流8.75mA 
#define VK16D32A_SEGI_LEVEL1  		0x00	//SEG持续输出电流4.37mA 
//设置扫描位数(GRID)命令(bit7~bit4=0000) 
#define VK16D32A_REG_GRIDNUM			0x11		 
#define VK16D32A_GRID_NUM12  			0x0B	//扫描12位GRID 上电默认
#define VK16D32A_GRID_NUM11  			0x0A	//扫描11位GRID
#define VK16D32A_GRID_NUM10  			0x09	//扫描10位GRID
#define VK16D32A_GRID_NUM9  			0x08	//扫描9位GRID
#define VK16D32A_GRID_NUM8  			0x07	//扫描8位GRID
#define VK16D32A_GRID_NUM7  			0x06	//扫描7位GRID
#define VK16D32A_GRID_NUM6  			0x05	//扫描6位GRID
#define VK16D32A_GRID_NUM5  			0x04	//扫描5位GRID
#define VK16D32A_GRID_NUM4  			0x03	//扫描4位GRID
#define VK16D32A_GRID_NUM3	 			0x02	//扫描3位GRID
#define VK16D32A_GRID_NUM2  			0x01	//扫描2位GRID
#define VK16D32A_GRID_NUM1  			0x00	//扫描1位GRID

//以下管脚配置根据客户单片机做相应的修改 
#define VK16D32A_SCL_PIN    BIT15
#define VK16D32A_SCL_PORT   PB
#define VK16D32A_SCL_IO     PB15

#define VK16D32A_SDA_PIN    BIT5
#define VK16D32A_SDA_PORT   PB
#define VK16D32A_SDA_IO     PB5

//以下管脚输出定义根据客户单片机做相应的修改
#define VK16D32A_SCL_H() 				VK16D32A_SCL_IO = 1 
#define VK16D32A_SCL_L() 				VK16D32A_SCL_IO = 0 

#define VK16D32A_SDA_H() 				VK16D32A_SDA_IO = 1 
#define VK16D32A_SDA_L() 				VK16D32A_SDA_IO = 0 

#define VK16D32A_GET_SDA() 			VK16D32A_SDA_IO
//SDA脚设为输入脚，用于读ACK和读RAM数据
#define VK16D32A_SET_SDA_IN() 	{\
	GPIO_SetMode(VK16D32A_SDA_PORT, VK16D32A_SDA_PIN, GPIO_MODE_INPUT);\
}
//SDA脚设为输出脚，用于发送命令和写显示RAM数据
#define VK16D32A_SET_SDA_OUT() 	{\
	GPIO_SetMode(VK16D32A_SDA_PORT, VK16D32A_SDA_PIN, GPIO_MODE_OUTPUT);\
}

/* Exported functions ------------------------------------------------------- */
void VK16D32A_Init(void);
void VK16D32A_DisAll(unsigned char dat);
void VK16D32A_DisDotOn(unsigned char seg,unsigned char com);
void VK16D32A_DisDotOff(unsigned char seg,unsigned char com);
unsigned char VK16D32A_Enter_PowerOff(void);
void VK16D32A_Exit_PowerOff(void);

void VK16D32A_Main(void);
#endif  /*__VK16D32A_H*/

/************************END OF FILE****/
