📄 emot.h
字号:
/*****************************************
// For: CC1110 in PS
// emot.h
// 2008年1月30日 wxl
*****************************************/
#ifndef EMOT_H
#define EMOT_H
#include <ioCC1110.h>
/*****************************************
//定义类型
*****************************************/
#define uchar unsigned char
#define uint unsigned int
/*****************************************
//定义常量
*****************************************/
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef HIGH
#define HIGH 1
#endif
#ifndef LOW
#define LOW 0
#endif
/*****************************************
//LED 使能控制
*****************************************/
#define LED_ENABLE(val) \
do{ \
if(val==1) \
{ \
P1SEL &= ~0X03; \
P1DIR |= 0X03; \
RLED = 1; \
GLED = 1; \
} \
else \
{ \
P1DIR &= ~0X03; \
} \
}while(0)
#define RLED P1_0
#define GLED P1_1
/*****************************************
//选择主时钟,关闭不用的时钟
*****************************************/
#define SET_MAIN_CLOCK_SOURCE(source) \
do { \
if(source) { \
CLKCON |= 0x40; /*RC*/ \
while(!(SLEEP&0X20)); /*待稳*/ \
SLEEP |= 0x04; /*关掉不用的*/ \
} \
else { \
SLEEP &= ~0x04; /*全开*/ \
while(!(SLEEP&0X40));/*待稳*/ \
asm("NOP"); \
CLKCON &= ~0x47; /*晶振*/ \
SLEEP |= 0x04; /*关掉不用的*/ \
} \
}while (0)
#define CRYSTAL 0
#define RC 1
/*****************************************
//选择低速时钟
*****************************************/
#define SET_LOW_CLOCK(val) \
do{ \
CLKCON |= (val)?(CLKCON|0X80):(CLKCON & ~0X80); \
}while(0)
//Macro for setting the clock tick for timer3 or 4
#define TIMER3_START(val) \
(T##timer##CTL = (val) ? T##timer##CTL | 0X10 : T##timer##CTL&~0X10)
#define TIMER3_SET_CLOCK_DIVIDE(timer,val) \
do{ \
T##timer##CTL &= ~0XE0; \
(val==2) ? (T##timer##CTL|=0X20): \
(val==4) ? (T##timer##CTL|=0x40): \
(val==8) ? (T##timer##CTL|=0X60): \
(val==16)? (T##timer##CTL|=0x80): \
(val==32)? (T##timer##CTL|=0xa0): \
(val==64) ? (T##timer##CTL|=0xc0): \
(val==128) ? (T##timer##CTL|=0XE0): \
(T##timer##CTL|=0X00); /* 1 */ \
}while(0)
//Macro for setting the mode of timer3 or 4
#define TIMER3_SET_MODE(timer,val) \
do{ \
T##timer##CTL &= ~0X03; \
(val==1)?(T##timer##CTL|=0X01): /*DOWN */ \
(val==2)?(T##timer##CTL|=0X02): /*Modulo */ \
(val==3)?(T##timer##CTL|=0X03): /*UP / DOWN */ \
(T##timer##CTL|=0X00); /*free runing */ \
}while(0)
#define SET_POWER_MODE(mode) \
do { \
if(mode == 0) { SLEEP &= ~0x03; } \
else if (mode == 3) { SLEEP |= 0x03; } \
else { SLEEP &= ~0x03; SLEEP |= mode; } \
PCON |= 0x01; \
asm("NOP"); \
}while (0)
/*****************************************
//开启电池板上的按键
*****************************************/
#define USE_KEY_ON_BT() \
do{ \
P1DIR &= ~0X0C; /*按键在P12 P13*/\
P1INP &= ~0x0c; /*上、下拉*/ \
P2INP |= 0x40; \
}while(0)
#endif //EMOT_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -