📄 ds1302.h
字号:
/***********************************
* Company : HSLCN
*
* Filename: DS1302.h
* Summary : A declaration File
*
* Version : 1.0
* Author : lxyppc
* CreateDate:2007-1-26
*
* Copyright (C) 2007 : lxyppc
* All rights reserved.
************************************/
#ifndef DS1302_H
#define DS1302_H
/*Define DS1302 command byte
*bit0 is Write and read control, 1 is read, 0 is write
*bit1 - bit5 is address bits, so we must use a shift left command
*to rise the normal address in command byte
*for the Time RAM, only 0-8 is available
*if the address bits set to 11111, start the brust mode
*bit6 is time and RAM control
*1 is for the RAM operation,0 is for the Time operation
*/
#define WriteTimeCMD(addr) 0B10000000|(addr<<1)
#define WriteRAMCMD(addr) 0B11000000|(addr<<1)
#define WriteTimeAllCMD 0B10111110
#define WriteRAMAllCMD 0B11111110
#define ReadTimeCMD(addr) 0B10000001|(addr<<1)
#define ReadRAMCMD(addr) 0B11000001|(addr<<1)
#define ReadTimeAllCMD 0B10111111
#define ReadRAMAllCMD 0B11111111
//define the special address in DS1302
#define DS_Second 0
#define DS_Minute 1
#define DS_Hour 2
#define DS_Date 3
#define DS_Month 4
#define DS_Day 5
#define DS_Year 6
#define DS_Control 7
#define DS_Charger 8
// command of setting the charger
// use and (&) to join them
#define Charge_ON 0B10101111
// use 2 Diodde
#define Charge_2D 0B11111011
// use 1 Diode
#define Charge_1D 0B11110111
// use 2K resistor
#define Charge_R2K 0B11111101
// use 4K resistor
#define Charge_R4K 0B11111110
// use 8K resistor
#define Charge_R8K 0B11111111
//disable charger
#define Charge_OFF 0B00000000
//When read time in brust mode, we must read all the 8 time bytes
//at one time, the bytes are second, minute, hour, date, month, day, year
//and include control byte
//so when read time in brust mode, we needn't define the number
//of data bytes to read, just set to 8
#define TimeBrust 8
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -