voqc/board/Src/hc595.c

47 lines
939 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "hc595.h"
/**********************************/
/** 函数名称void HC595_Write_Data(unsigned char dis_data) **/
/** 输入参数unsigned char dis_data 需要输入的数据 */
/** 函数功能将数据写进74HC595中*/
/** ****************************** **/
void hc595_write_data(unsigned char dis_data)
{
unsigned char i;
unsigned char temp;
temp = dis_data;
for(i=0;i<8;i++) // 循环将一个字节的八位依次写入到寄存器
{
HC595_SRCLK(0);// SRCLK低电平
if(temp & 0X80)
{
HC595_SER(1);
}
else
{
HC595_SER(0);
}
temp = temp<<1;
HC595_SRCLK(0); // SRCLK低电平
delay_us(10);
HC595_SRCLK(1); // SRCLK高电平
delay_us(10);
}
}
/****************************************/
/**函数名称void Disp_out(void)*/
/**函数参数:无参*/
/**函数功能:将写入到寄存器的数据输出到端口显示*/
/****************************************/
void disp_out(void)
{
HC595_RCLK(0);
delay_us(10);
HC595_RCLK(1);
delay_us(10);
}