//ds1302_config.h:

/********** DS1302程序配置 **********
* 版本.........: 1.0
* 作者.........: 陈利栋
* 文件名.......: ds1302_config.h
* 创建时间.....: 2010.11.11
* 最后修改.....: 2010.11.11
************************************/
#ifndef __DS1302_CONFIG_H__
#define __DS1302_CONFIG_H__

//#include <ioavr.h>
#include "main.h"
#include <stdbool.h>
#include "stm32f10x_gpio.h"
#include "delay.h"
#include "Key.h"

extern bool DS1302ReadIO ( void );

// 1：自动转换成10进制  0：BCD格式
#define DS1302_AUTO_TO_DEC       1

//对应IO口配置

#define DS1302_IO_OUT           //__nop() //asm("NOP")//         
#define DS1302_IO_IN            //__nop()//asm("NOP")//          
#define DS1302_IO_0 			(GPIO_ResetBits(DS1302_PORT,DS1302_IO_PIN))
#define DS1302_IO_1 			(GPIO_SetBits(DS1302_PORT,DS1302_IO_PIN))
#define DS1302_IO_VALUE    		(DS1302ReadIO())

#define DS1302_SCLK_OUT         //__nop()//asm("NOP")//   
#define DS1302_SCLK_0 			(GPIO_ResetBits(DS1302_PORT,DS1302_SCK_PIN))
#define DS1302_SCLK_1 			(GPIO_SetBits(DS1302_PORT,DS1302_SCK_PIN))

#define DS1302_CE_OUT           //__nop() //asm("NOP")//
#define DS1302_CE_0 			(GPIO_ResetBits(DS1302_PORT,DS1302_CE_PIN))
#define DS1302_CE_1 			(GPIO_SetBits(DS1302_PORT,DS1302_CE_PIN))


// 延时时间定义(参照datasheet)
#define _delay_us delay_us

#define DS1302_DELAY_T_DC        _delay_us(1)
#define DS1302_DELAY_T_CDH       _delay_us(1)
#define DS1302_DELAY_T_CDD       _delay_us(1)
#define DS1302_DELAY_T_CL        _delay_us(1)
#define DS1302_DELAY_T_CH        _delay_us(1)
#define DS1302_DELAY_T_CC        _delay_us(4)
#define DS1302_DELAY_T_CCH       _delay_us(1)
#define DS1302_DELAY_T_CWH       _delay_us(4)


//按键配置
#if 0
#define DS1302_K13      (ScanKey()==13?1:0)
#define DS1302_K14      (ScanKey()==14?1:0)
#define DS1302_K15      (ScanKey()==15?1:0)
#define DS1302_K16      (ScanKey()==16?1:0)
#endif

#endif /* __DS1302_CONFIG_H__ */




