/**
******************************************************************************
* @file V_MC74HC595.h
* @author LuJ
* @version V3.5.0
* @date 2015-03-31
* @brief 移位寄存器头文件管理
******************************************************************************
* (C) Copyright Vango Technoglogy, Inc. 2015
******************************************************************************
*/
#ifndef __V_MC74HC595_H
#define __V_MC74HC595_H
#include "stm32f10x.h"
//位带操作,实现51类似的GPIO控制功能
//具体实现思想,参考<<CM3权威指南>>第五章(87页~92页).
#define V_74TCLK_OUT *((volatile unsigned long *)((((GPIOF_BASE+12) & 0xF0000000)+0x2000000+(((GPIOF_BASE+12) &0xFFFFF)<<5)+(4<<2))))
#define V_74HCLK_OUT *((volatile unsigned long *)((((GPIOF_BASE+12) & 0xF0000000)+0x2000000+(((GPIOF_BASE+12) &0xFFFFF)<<5)+(5<<2))))
#define V_74OE_OUT *((volatile unsigned long *)((((GPIOF_BASE+12) & 0xF0000000)+0x2000000+(((GPIOF_BASE+12) &0xFFFFF)<<5)+(6<<2))))
#define V_74SDI_OUT *((volatile unsigned long *)((((GPIOF_BASE+12) & 0xF0000000)+0x2000000+(((GPIOF_BASE+12) &0xFFFFF)<<5)+(7<<2))))
#define MC74HC595_OUT_V_SELA ((uint32_t)0x00000001)//MC74HC595移位寄存器
#define MC74HC595_OUT_V_SELB ((uint32_t)0x00000002)
#define MC74HC595_OUT_V_SELC ((uint32_t)0x00000004)
#define MC74HC595_OUT_V_SEL_EN ((uint32_t)0x00000008)
#define MC74HC595_OUT_V_SEL_PWM1 ((uint32_t)0x00000010)
#define MC74HC595_OUT_V_SEL_PWM2 ((uint32_t)0x00000020)
#define MC74HC595_OUT_V_SEL_UART ((uint32_t)0x00000040)
#define MC74HC595_OUT_V_RSTn ((uint32_t)0x00000080)
#define MC74HC595_OUT_V_VDCIN ((uint32_t)0x00000100)
#define MC74HC595_OUT_V_V3V ((uint32_t)0x00000200)
#define MC74HC595_OUT_VT_MODE0 ((uint32_t)0x00000400)
#define MC74HC595_OUT_VT_MODE1 ((uint32_t)0x00000800)
#define MC74HC595_OUT_V_DVCC_ctr2 ((uint32_t)0x00001000)
#define MC74HC595_OUT_V_DVCC_ctr1 ((uint32_t)0x00002000)
#define MC74HC595_OUT_V_LDO33_ctr2 ((uint32_t)0x00004000)
#define MC74HC595_OUT_V_LDO33_ctr1 ((uint32_t)0x00008000)
#define MC74HC595_OUT_V_vPower_ctr1 ((uint32_t)0x00010000)
#define MC74HC595_OUT_V_vPower_ctr2 ((uint32_t)0x00020000)
#define MC74HC595_OUT_V_vPower_ctr3 ((uint32_t)0x00040000)
#define MC74HC595_OUT_V_SPI1_CS1 ((uint32_t)0x00080000)
#define MC74HC595_OUT_V_SPI1_CS2 ((uint32_t)0x00100000)
#define MC74HC595_OUT_V_W25Q_CS ((uint32_t)0x00200000)
#define MC74HC595_OUT_V_DS3231_ctr1 ((uint32_t)0x00400000)
#define MC74HC595_OUT_V_DS3231_ctr2 ((uint32_t)0x00800000)
#define MC74HC595_OUT_V_LED1 ((uint32_t)0x01000000)
#define MC74HC595_OUT_V_LED2 ((uint32_t)0x02000000)
#define MC74HC595_OUT_V_LED3 ((uint32_t)0x04000000)
#define Target_SET_DVCC_ctr1 ((uint8_t)0x01)//DVCC控制,ctr1和ctr2不同时打开
#define Target_SET_DVCC_ctr2 ((uint8_t)0x02)
#define Target_RESET_DVCC_ctr ((uint8_t)0x80)
#define Target_SET_LDO33_ctr1 ((uint8_t)0x01)//LDO33控制
#define Target_SET_LDO33_ctr2 ((uint8_t)0x02)
#define Target_RESET_LDO33_ctr ((uint8_t)0x80)
#define Target_SET_vPower_ctr1 ((uint8_t)0x01)//Target的电源供给控制
#define Target_SET_vPower_ctr2 ((uint8_t)0x02)
#define Target_SET_vPower_ctr3 ((uint8_t)0x04)
#define Target_RESET_vPower_ctr ((uint8_t)0x80)
#define Target_SET_DS3231_ctr1 ((uint8_t)0x01)//DS3231秒脉冲和32KHz输出控制
#define Target_SET_DS3231_ctr2 ((uint8_t)0x02)
#define Target_RESET_DS3231_ctr ((uint8_t)0x80)
#define STM32_SET_LED_1 ((uint8_t)0x01)//STM32外围LED灯控制
#define STM32_SET_LED_2 ((uint8_t)0x02)
#define STM32_SET_LED_3 ((uint8_t)0x04)
#define STM32_RESET_LED_x ((uint8_t)0x80)
#define ADG1408_Type_SEGx ((uint8_t)0x01)//模拟开关类型选择,可选择SEG/UART/PWM1/PWM2
#define ADG1408_Type_UARTx ((uint8_t)0x02)
#define ADG1408_Type_PWM1 ((uint8_t)0x04)
#define ADG1408_Type_PWM2 ((uint8_t)0x08)
#define ADG1408_Type_AllClose ((uint8_t)0x80)
#define ADG1408_Channel_1 ((uint8_t)0x00)//模拟开关通道1-8选择
#define ADG1408_Channel_2 ((uint8_t)0x01)
#define ADG1408_Channel_3 ((uint8_t)0x02)
#define ADG1408_Channel_4 ((uint8_t)0x03)
#define ADG1408_Channel_5 ((uint8_t)0x04)
#define ADG1408_Channel_6 ((uint8_t)0x05)
#define ADG1408_Channel_7 ((uint8_t)0x06)
#define ADG1408_Channel_8 ((uint8_t)0x07)
extern uint32_t mc74hc595_val;
void V_74HC595_Init(void);//初始化
void V_74HC595_ShiftOuput(u32 shift_val);
void T_ADG1408_Select(uint8_t ADG1408_Type_x,uint8_t ADG1408_Channel_x);
void T_Target_RSTn(void);
void T_Target_VDCIN(BitAction BitVal);
void T_Target_V3V(BitAction BitVal);
void T_Target_MODEx(BitAction BitMode0,BitAction BitMode1);
void T_Target_DVCC_ctr(uint8_t DVCC_ctr_x);
void T_Target_LDO33_ctr(uint8_t LDO33_ctr_x);
void T_Target_vPower_ctr(uint8_t vPower_ctr_x);
void T_ADS8332_SPI1_CS1(BitAction BitVal);
void T_TLV5618_SPI1_CS2(BitAction BitVal);
void W25Q80_W25Q_CS(BitAction BitVal);
void V_DS3231_ctr(uint8_t DS3231_ctr_x);
void STM32_V_LEDx(uint8_t STM32_SET_LED_x);
void V_74HC595_Test(void);
#endif
/**
******************************************************************************
* @file V_MC74HC595.c
* @author LuJ
* @version V3.5.0
* @date 2015-03-31
* @brief MC74HC595移位寄存器 驱动
******************************************************************************
* (C) Copyright Vango Technoglogy, Inc. 2015
******************************************************************************
*/
#include "st_lib.h"
#include "V_MC74HC595.h"
uint32_t mc74hc595_val=0x07380980;//全局变量,控制移位寄存器输出状态
/**
* 函数功能:移位寄存器IO配置.初始化PF4/PF5/PF6/PF7为输出口,并使能这两个口的时钟
* 输入参数:无
* 输出参数:无
* 全局变量:无
* 作者:LuJ
* 修改日期:2015/03/31
* 备注:无
*/
void V_74HC595_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_TypeDef* GPIOx;
uint16_t GPIO_Pin_x;
GPIOx = GPIOF;
GPIO_Pin_x = GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;//移位寄存器硬件对应IO
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF, ENABLE);//使能PF端口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_x;//74HC595端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//IO口速度为50MHz
GPIO_Init(GPIOx, &GPIO_InitStructure);//根据设定参数初始化GPIOx
GPIO_ResetBits(GPIOx,GPIO_Pin_x);//输出低
}
/**
* 函数功能:移位寄存器移位输出
* 输入参数:shift_val:待输入的移位值,输入后移位寄存器输出设定的状态
* 输出参数:无
* 全局变量:无
* 作者:LuJ
* 修改日期:2015/03/31
* 备注:高位先移入,低位后移入
*/
void V_74HC595_ShiftOuput(u32 shift_val)
{
uint8_t i,j;
j=26;
V_74TCLK_OUT=0;//输出低
V_74HCLK_OUT=0;
V_74OE_OUT=0;
V_74SDI_OUT=0;
for(i=0;i<27;i++,j--)
{
if(((shift_val>>j)&0x01)==0x01)
{
V_74SDI_OUT=1;
}
else
{
V_74SDI_OUT=0;
}
V_74TCLK_OUT=0;
V_74TCLK_OUT=1;//产生一个上升沿,移数据
}
V_74HCLK_OUT=0;
V_74HCLK_OUT=1;
}
/**
* 函数功能:模拟开关通道选择
* 输入参数:ADG1408_Type_x:模拟开关选择,可选择SEG/UART/PWM1/PWM2四种
* ADG1408_Channel_x:选择通道,1-8通道可选
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/03/31
* 备注:可以同时选择SEG/UART/PWM1/PWM2组合,PWM1/PWM2不会同时选择
*/
void T_ADG1408_Select(uint8_t ADG1408_Type_x,uint8_t ADG1408_Channel_x)
{
uint32_t temp=0x00000000;
if((ADG1408_Channel_x<ADG1408_Channel_1) || (ADG1408_Channel_x>ADG1408_Channel_8))
return;
if(((ADG1408_Type_x&ADG1408_Type_PWM1)==ADG1408_Type_PWM1) && ((ADG1408_Type_x&ADG1408_Type_PWM2)==ADG1408_Type_PWM2))//不能同时打开
return;
temp &=(~(MC74HC595_OUT_V_SEL_EN|MC74HC595_OUT_V_SEL_UART|MC74HC595_OUT_V_SEL_PWM1|MC74HC595_OUT_V_SEL_PWM2));
if((ADG1408_Type_x&ADG1408_Type_SEGx)==ADG1408_Type_SEGx)
temp|=MC74HC595_OUT_V_SEL_EN;//SEG
if((ADG1408_Type_x&ADG1408_Type_UARTx)==ADG1408_Type_UARTx)
temp|=MC74HC595_OUT_V_SEL_UART;//UART
if((ADG1408_Type_x&ADG1408_Type_PWM1)==ADG1408_Type_PWM1)
temp|=MC74HC595_OUT_V_SEL_PWM1;//PWM1
if((ADG1408_Type_x&ADG1408_Type_PWM2)==ADG1408_Type_PWM2)
temp|=MC74HC595_OUT_V_SEL_PWM2;//PWM2
switch(ADG1408_Channel_x)
{
case ADG1408_Channel_1:
temp|=ADG1408_Channel_1;
break;
case ADG1408_Channel_2:
temp|=ADG1408_Channel_2;
break;
case ADG1408_Channel_3:
temp|=ADG1408_Channel_3;
break;
case ADG1408_Channel_4:
temp|=ADG1408_Channel_4;
break;
case ADG1408_Channel_5:
temp|=ADG1408_Channel_5;
break;
case ADG1408_Channel_6:
temp|=ADG1408_Channel_6;
break;
case ADG1408_Channel_7:
temp|=ADG1408_Channel_7;
break;
case ADG1408_Channel_8:
temp|=ADG1408_Channel_8;
break;
default:
break;
}
mc74hc595_val &=(~(MC74HC595_OUT_V_SELA|MC74HC595_OUT_V_SELB|MC74HC595_OUT_V_SELC|MC74HC595_OUT_V_SEL_EN\
|MC74HC595_OUT_V_SEL_UART|MC74HC595_OUT_V_SEL_PWM1|MC74HC595_OUT_V_SEL_PWM2));
mc74hc595_val|=temp;
V_74HC595_ShiftOuput(mc74hc595_val);//更新模拟开关控制
}
/**
* 函数功能:产生一个Target复位信号,复位Target
* 输入参数:无
* 输出参数:无
* 全局变量:修改mc74hc595_val,然后复原
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:拉低Target的RSTn一定时间来复位Target
*/
void T_Target_RSTn(void)
{
mc74hc595_val &=(~MC74HC595_OUT_V_RSTn);
V_74HC595_ShiftOuput(mc74hc595_val);//拉低RSTn
//mininum = 5 ms
Delay_ms(8);
mc74hc595_val |=MC74HC595_OUT_V_RSTn;
V_74HC595_ShiftOuput(mc74hc595_val);//拉高RSTn
}
/**
* 函数功能:控制VDCIN的高低电平
* 输入参数:BitVal:设置VDCIN的电平,可设置为Bit_RESET和Bit_SET两种状态
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:Target的掉电检测
*/
void T_Target_VDCIN(BitAction BitVal)
{
assert_param(IS_GPIO_BIT_ACTION(BitVal));
if (BitVal != Bit_RESET)
{
mc74hc595_val |=MC74HC595_OUT_V_VDCIN;
}
else
{
mc74hc595_val &=(~MC74HC595_OUT_V_VDCIN);
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新VDCIN设置数据
}
/**
* 函数功能:控制V3V的高低电平
* 输入参数:BitVal:设置V3V的电平,可设置为Bit_RESET和Bit_SET两种状态
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:Target的电源电压设置
*/
void T_Target_V3V(BitAction BitVal)
{
assert_param(IS_GPIO_BIT_ACTION(BitVal));
if (BitVal != Bit_RESET)
{
mc74hc595_val |=MC74HC595_OUT_V_V3V;
}
else
{
mc74hc595_val &=(~MC74HC595_OUT_V_V3V);
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新V3V设置数据
}
/**
* 函数功能:控制Target的MODE0/MODE1的高低电平
* 输入参数:BitMode0:设置MODE0的电平,可设置为Bit_RESET和Bit_SET两种状态
* BitMode1:设置MODE1的电平
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:Target启动模式设置,一般时候MODE0=0,MODE1=1;
*/
void T_Target_MODEx(BitAction BitMode0,BitAction BitMode1)
{
assert_param(IS_GPIO_BIT_ACTION(BitMode0));
assert_param(IS_GPIO_BIT_ACTION(BitMode1));
if (BitMode0 != Bit_RESET)
{
mc74hc595_val |=MC74HC595_OUT_VT_MODE0;
}
else
{
mc74hc595_val &=(~MC74HC595_OUT_VT_MODE0);
}
if (BitMode1 != Bit_RESET)
{
mc74hc595_val |=MC74HC595_OUT_VT_MODE1;
}
else
{
mc74hc595_val &=(~MC74HC595_OUT_VT_MODE1);
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新MODE0/MODE1设置数据
}
/**
* 函数功能:控制Target的DVCC
* 输入参数:DVCC_ctr_x:设置Target的DVCC,给它灌电压还是拉电压
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:DVCC管脚处理
*/
void T_Target_DVCC_ctr(uint8_t DVCC_ctr_x)
{
mc74hc595_val &=(~(MC74HC595_OUT_V_DVCC_ctr1|MC74HC595_OUT_V_DVCC_ctr2));
if (DVCC_ctr_x == Target_SET_DVCC_ctr1)
{
mc74hc595_val |=MC74HC595_OUT_V_DVCC_ctr1;
}
else if (DVCC_ctr_x == Target_SET_DVCC_ctr2)
{
mc74hc595_val |=MC74HC595_OUT_V_DVCC_ctr2;
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新DVCC控制信号
}
/**
* 函数功能:控制Target的LDO33
* 输入参数:LDO33_ctr_x:设置Target的LDO33,给它灌电压还是拉电压
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:LDO33管脚处理
*/
void T_Target_LDO33_ctr(uint8_t LDO33_ctr_x)
{
mc74hc595_val &=(~(MC74HC595_OUT_V_LDO33_ctr1|MC74HC595_OUT_V_LDO33_ctr2));
if (LDO33_ctr_x == Target_SET_LDO33_ctr1)
{
mc74hc595_val |=MC74HC595_OUT_V_LDO33_ctr1;
}
else if (LDO33_ctr_x == Target_SET_LDO33_ctr2)
{
mc74hc595_val |=MC74HC595_OUT_V_LDO33_ctr2;
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新DVCC控制信号
}
/**
* 函数功能:控制Target的电源供给
* 输入参数:vPower_ctr_x:设置Target的总电源
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:在正常测试时候,打开ctr1,在低功耗测试时,打开ctr2,这两个电源不要同时打开
*/
void T_Target_vPower_ctr(uint8_t vPower_ctr_x)
{
if(((vPower_ctr_x&Target_SET_vPower_ctr1) == Target_SET_vPower_ctr1) \
&& ((vPower_ctr_x&Target_SET_vPower_ctr2) == Target_SET_vPower_ctr2))
return;
mc74hc595_val &=(~(MC74HC595_OUT_V_vPower_ctr1|MC74HC595_OUT_V_vPower_ctr2));
if ((vPower_ctr_x&Target_SET_vPower_ctr1) == Target_SET_vPower_ctr1)//主电源
{
mc74hc595_val |=MC74HC595_OUT_V_vPower_ctr1;
}
else if ((vPower_ctr_x&Target_SET_vPower_ctr2) == Target_SET_vPower_ctr2)
{
mc74hc595_val |=MC74HC595_OUT_V_vPower_ctr2;
}
if ((vPower_ctr_x&Target_SET_vPower_ctr3) == Target_SET_vPower_ctr3)//后备电源
{
mc74hc595_val |=MC74HC595_OUT_V_vPower_ctr3;
}
else
{
mc74hc595_val &=(~MC74HC595_OUT_V_vPower_ctr3);
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新Target电源控制信号
}
/**
* 函数功能:控制ADS8332的片选信号,低电平有效
* 输入参数:BitVal:设置ADS8332的CS信号,可设置为Bit_RESET和Bit_SET两种状态
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:无
*/
void T_ADS8332_SPI1_CS1(BitAction BitVal)
{
assert_param(IS_GPIO_BIT_ACTION(BitVal));
if (BitVal != Bit_RESET)
{
mc74hc595_val |=MC74HC595_OUT_V_SPI1_CS1;
}
else
{
mc74hc595_val &=(~MC74HC595_OUT_V_SPI1_CS1);
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新ADS8332的片选设置数据
}
/**
* 函数功能:控制TLV5618的片选信号,低电平有效
* 输入参数:BitVal:设置ADS8332的CS信号,可设置为Bit_RESET和Bit_SET两种状态
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:无
*/
void T_TLV5618_SPI1_CS2(BitAction BitVal)
{
assert_param(IS_GPIO_BIT_ACTION(BitVal));
if (BitVal != Bit_RESET)
{
mc74hc595_val |=MC74HC595_OUT_V_SPI1_CS2;
}
else
{
mc74hc595_val &=(~MC74HC595_OUT_V_SPI1_CS2);
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新TLV5618的片选设置数据
}
/**
* 函数功能:控制W25Q80BV的片选信号,低电平有效
* 输入参数:BitVal:设置W25Q80BV的CS信号,可设置为Bit_RESET和Bit_SET两种状态
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:无
*/
void W25Q80_W25Q_CS(BitAction BitVal)
{
assert_param(IS_GPIO_BIT_ACTION(BitVal));
if (BitVal != Bit_RESET)
{
mc74hc595_val |=MC74HC595_OUT_V_W25Q_CS;
}
else
{
mc74hc595_val &=(~MC74HC595_OUT_V_W25Q_CS);
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新W25Q80BV的片选设置数据
}
/**
* 函数功能:控制DS3231的秒脉冲和32KHz输出
* 输入参数:DS3231_ctr_x:选择输出秒脉冲还是32kHz
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/03
* 备注:Target_SET_DS3231_ctr1选择秒脉冲输出,Target_SET_DS3231_ctr2选择32kHZ输出,
* Target_RESET_DS3231_ctr同时关闭两者
*/
void V_DS3231_ctr(uint8_t DS3231_ctr_x)
{
mc74hc595_val &=(~(MC74HC595_OUT_V_DS3231_ctr1|MC74HC595_OUT_V_DS3231_ctr2));
if (DS3231_ctr_x == Target_SET_DS3231_ctr1)
{
mc74hc595_val |=MC74HC595_OUT_V_DS3231_ctr1;
}
else if (DS3231_ctr_x == Target_SET_DS3231_ctr2)
{
mc74hc595_val |=MC74HC595_OUT_V_DS3231_ctr2;
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新DS3231的秒脉冲和32KHz输出情况
}
/**
* 函数功能:STM32外围LED灯控制
* 输入参数:STM32_SET_LED_x:选择需要点亮的LED灯,可以以(STM32_SET_LED_1|STM32_SET_LED_2)同时点亮LED1和LED2
* 输出参数:无
* 全局变量:修改mc74hc595_val
* 作者:LuJ
* 修改日期:2015/04/07
* 备注:STM32_RESET_LED_x关闭所有LED灯
*/
void STM32_V_LEDx(uint8_t STM32_SET_LED_x)
{
mc74hc595_val |=(MC74HC595_OUT_V_LED1|MC74HC595_OUT_V_LED2|MC74HC595_OUT_V_LED3);//灭掉所有LED
if ((STM32_SET_LED_x&STM32_SET_LED_1) == STM32_SET_LED_1)
{
mc74hc595_val &=~MC74HC595_OUT_V_LED1;
}
if ((STM32_SET_LED_x&STM32_SET_LED_2) == STM32_SET_LED_2)
{
mc74hc595_val &=~MC74HC595_OUT_V_LED2;
}
if ((STM32_SET_LED_x&STM32_SET_LED_3) == STM32_SET_LED_3)
{
mc74hc595_val &=~MC74HC595_OUT_V_LED3;
}
V_74HC595_ShiftOuput(mc74hc595_val);//更新STM32的LED灯
}
/**
* 函数功能:移位寄存器移位输出测试
* 输入参数:无
* 输出参数:无
* 全局变量:无
* 作者:LuJ
* 修改日期:2015/03/31
* 备注:在主函数中调用即可看到STM32的3个LED实现跑马灯
*/
void V_74HC595_Test(void)
{
u32 i;
V_74HC595_Init();//初始化与MC74HC595连接的硬件接口
while (1)
{
STM32_V_LEDx(STM32_SET_LED_1|STM32_SET_LED_2);
for(i=0;i<8000000;i++);
STM32_V_LEDx(STM32_SET_LED_2|STM32_SET_LED_3);
for(i=0;i<8000000;i++);
STM32_V_LEDx(STM32_SET_LED_3|STM32_SET_LED_1);
for(i=0;i<8000000;i++);
}
}