/************************** Copyright (c) **********************************
|
** FUZHOU FUGUANG ELECTRONICS Co.,LTD.
|
** ¸£Öݸ£¹âµç×ÓÓÐÏÞ¹«Ë¾
|
** http://www.fuguang.com
|
**
|
**-------------- File Info -------------------------------------------------
|
** File name: 74HC595_Driver.c
|
** Last modified Date: 2008-11-16
|
** Last Version: 1.0
|
** Descriptions: 74HC595 Drivers lib
|
**
|
**--------------------------------------------------------------------------
|
** Created by: mxpopstar
|
** Created date: 2008-11-16
|
** Version: 1.0
|
** Descriptions: The original version
|
**
|
**--------------------------------------------------------------------------
|
** Modified by: mxpopstar
|
** Modified date: 2008-11-20
|
** Version:
|
** Descriptions: 74HC595 Drivers lib
|
**
|
***************************************************************************/
|
//
|
#include <avr/io.h>
|
#include "74HC595_Driver.h"
|
#include "WorkingPage.h"
|
|
//------------ ÅäÖÃHC595¶Ë¿Ú -----------------------------------------------
|
void InitIo_HC595(void)
|
{
|
HC595_OE_DDR |= (1<<HC595_OE_PIN);
|
HC595_STcp_DDR |= (1<<HC595_STcp_PIN);
|
HC595_DS_DDR |= (1<<HC595_DS_PIN);
|
HC595_SHcp_DDR |= (1<<HC595_SHcp_PIN);
|
|
HC595_OE_1;
|
HC595_SHcp_0;
|
_delay_us(5);
|
//SendDataToHC595(DischargeControlInit & (~WIND));
|
_delay_us(5);
|
}
|
//
|
|
//------------ function SpiWrite(); ----------------------------------------
|
void SpiWrite_HC595(const unsigned char byte)
|
{
|
unsigned char i;
|
for (i=0; i<8; i++) // Setup byte circulation bits
|
{
|
if (0x80 & (byte<<i)) // Put DATA_BUF.7 on data line
|
HC595_DS_1;
|
else
|
HC595_DS_0;
|
|
HC595_SHcp_1; // Set clock line high
|
_delay_us(10);
|
HC595_SHcp_0; // Set clock line low
|
_delay_us(10);
|
}
|
}
|
//
|
|
//--------------- ÏòHC595·¢ËÍ16λµÄÊý¾Ý ------------------------------------
|
void SendDataToHC595(const unsigned int data)
|
{
|
SpiWrite_HC595((unsigned char)(data>>8));
|
SpiWrite_HC595((unsigned char)data);
|
HC595_STcp_1;
|
HC595_STcp_0;
|
HC595_OE_0;
|
}
|
//
|