STM32+CH452驱动8位数码管


STM32+CH452驱动8位数码管_第1张图片


bsp_CH452.h

// 硬件相关定义, 请根据实际硬件修改本文件

#include "stm32f10x.h"
#include "bsp.h"
/*
CH452_SCL  PB5
CH452_SDA  PB6
CH452_CS1  PB7
*/

#define RCC_ALL_CH452  RCC_APB2Periph_GPIOB

#define CH452_SCL_Pin    GPIO_Pin_5
#define CH452_SCL_Port   GPIOB       

#define CH452_SDA_Pin	   GPIO_Pin_6
#define CH452_SDA_Port   GPIOB

#define CH452_CS1_Pin    GPIO_Pin_7
#define CH452_CS1_Port   GPIOB       



/* 2线接口的位操作,与单片机有关 */
#define		CH452_SCL_SET		{GPIO_WriteBit(CH452_SCL_Port, CH452_SCL_Pin, (BitAction)1);}
#define		CH452_SCL_CLR		{GPIO_WriteBit(CH452_SCL_Port, CH452_SCL_Pin, (BitAction)0);}

	
	
#define		CH452_SDA_SET		{GPIO_WriteBit(CH452_SDA_Port, CH452_SDA_Pin, (BitAction)1);}
#define		CH452_SDA_CLR		{GPIO_WriteBit(CH452_SDA_Port, CH452_SDA_Pin, (BitAction)0);}

#define   CH452_SDA_IN    CH452_SDA_READ()

#define		CH452_SDA_D_IN		{CH452_SDA_Dir_IN();}
#define		CH452_SDA_D_OUT		{CH452_SDA_Dir_OUT();}

#define   CH452_CH1_EN       {GPIO_WriteBit(CH452_CS1_Port, CH452_CS1_Pin, (BitAction)1);}
	                     
#define   CH452_CHX_DISEN       {GPIO_WriteBit(CH452_CS1_Port, CH452_CS1_Pin, (BitAction)0);}


bsp_CH452.c

// 硬件相关定义, 请根据实际硬件修改本文件

#include "stm32f10x.h"
#include "bsp.h"
/*
CH452_SCL  PB5
CH452_SDA  PB6
CH452_CS1  PB7
*/

#define RCC_ALL_CH452  RCC_APB2Periph_GPIOB

#define CH452_SCL_Pin    GPIO_Pin_5
#define CH452_SCL_Port   GPIOB       

#define CH452_SDA_Pin	   GPIO_Pin_6
#define CH452_SDA_Port   GPIOB

#define CH452_CS1_Pin    GPIO_Pin_7
#define CH452_CS1_Port   GPIOB       



/* 2线接口的位操作,与单片机有关 */
#define		CH452_SCL_SET		{GPIO_WriteBit(CH452_SCL_Port, CH452_SCL_Pin, (BitAction)1);}
#define		CH452_SCL_CLR		{GPIO_WriteBit(CH452_SCL_Port, CH452_SCL_Pin, (BitAction)0);}

	
	
#define		CH452_SDA_SET		{GPIO_WriteBit(CH452_SDA_Port, CH452_SDA_Pin, (BitAction)1);}
#define		CH452_SDA_CLR		{GPIO_WriteBit(CH452_SDA_Port, CH452_SDA_Pin, (BitAction)0);}

#define   CH452_SDA_IN    CH452_SDA_READ()

#define		CH452_SDA_D_IN		{CH452_SDA_Dir_IN();}
#define		CH452_SDA_D_OUT		{CH452_SDA_Dir_OUT();}

#define   CH452_CH1_EN       {GPIO_WriteBit(CH452_CS1_Port, CH452_CS1_Pin, (BitAction)1);}
	                     
#define   CH452_CHX_DISEN       {GPIO_WriteBit(CH452_CS1_Port, CH452_CS1_Pin, (BitAction)0);}

资料:链接:https://pan.baidu.com/s/1c2cwTpu 密码:6g06



你可能感兴趣的:(STM32+CH452驱动8位数码管)