📄 define.h
字号:
/* ======================================= */
#ifndef _DEFINE_H_
#define _DEFINE_H_
//COMMON DEFINE
#define DATA data
#define IDATA idata
#define BDATA bdata
#define RDATA code
//TYPE DEFINE
typedef unsigned char Byte;
typedef unsigned int Word;
typedef bit Bool;
#define FALSE (Bool)0
#define TRUE (Bool)1
#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80
#define HIGHBYTE(word) ((Byte)((word)/0x100))
#define LOWBYTE(word) ((Byte)(word))
/* ======================================= */
//PIN DEFINE
#define PIN_IR_OUT P1_6 //PIN 3
#define PIN_LED1 KB7 //PIN 13
#define PIN_LED2 P1_7 //PIN 2
#define PIN_LED3 KB6 //PIN 14
#define PIN_LED4 KB0 //PIN 1
#define PIN_KEY1 KB3 //PIN 18
#define PIN_KEY2 KB2 //PIN 19
#define PIN_KEY3 KB1 //PIN 20
/* ======================================= */
//LED display define
#define LED1On() {PIN_LED1 = 1;}
#define LED2On() {PIN_LED2 = 1;}
#define LED3On() {PIN_LED3 = 1;}
#define LED4On() {PIN_LED4 = 1;}
#define LED1Off() {PIN_LED1 = 0;}
#define LED2Off() {PIN_LED2 = 0;}
#define LED3Off() {PIN_LED3 = 0;}
#define LED4Off() {PIN_LED4 = 0;}
#define LED1Blink() {PIN_LED1 ^= 1;}
#define LED2Blink() {PIN_LED2 ^= 1;}
#define LED3Blink() {PIN_LED3 ^= 1;}
#define LED4Blink() {PIN_LED4 ^= 1;}
#define LED1_On_Only() {PIN_LED1 = 1;PIN_LED2 = 0;PIN_LED3 = 0;PIN_LED4 = 0;}
#define LED2_On_Only() {PIN_LED1 = 0;PIN_LED2 = 1;PIN_LED3 = 0;PIN_LED4 = 0;}
#define LED3_On_Only() {PIN_LED1 = 0;PIN_LED2 = 0;PIN_LED3 = 1;PIN_LED4 = 0;}
#define LED2_Blink_Only() {PIN_LED1 = 0;PIN_LED2 ^= 1;PIN_LED3 = 0;PIN_LED4 = 0;}
#define LED3_Blink_Only() {PIN_LED1 = 0;PIN_LED2 = 0;PIN_LED3 ^= 1;PIN_LED4 = 0;}
#define LED4_Blink_Only() {PIN_LED1 = 0;PIN_LED2 = 0;PIN_LED3 = 0;PIN_LED4 ^= 1;}
#define All_LED_On() {PIN_LED1 = 1;PIN_LED2 = 1;PIN_LED3 = 1;PIN_LED4 = 1;}
#define All_LED_Blink() {PIN_LED1 ^= 1;PIN_LED2 ^= 1;PIN_LED3 ^= 1;PIN_LED4 ^= 1;}
/* ======================================= */
//CLOCK DEFINE
#define RC_CLOCK_MHZ 7.373//internal oscillator
#define CPU_CLOCK_MHZ RC_CLOCK_MHZ//DIVM = 0
#define CPU_CLOCK_KHZ (CPU_CLOCK_MHZ*1000)
#define PERIPHERAL_CLOCK_KHZ (CPU_CLOCK_KHZ/2) //3686
// 1 counter about 1000/3686 (us)
// 1 us about 3686/1000 (counter) = 3.686
#define ISR_TIME0_38K_COUNTER (33 - 13)//9us = 9 * 3.686 = 33.174 //other for instruction time
#define ISR_TIME0_38K_RELOAD_VALUE (65536 - ISR_TIME0_38K_COUNTER)
#define ISR_TIME_125US_COUNTER (PERIPHERAL_CLOCK_KHZ/8)
#define ISR_TIME_125US_RELOAD_VALUE (65536 - ISR_TIME_125US_COUNTER)
#define ISR_TIME_500US_COUNTER (PERIPHERAL_CLOCK_KHZ/2)
#define ISR_TIME_500US_RELOAD_VALUE (65536 - ISR_TIME_500US_COUNTER)
#define ISR_TIME_250US_COUNTER (PERIPHERAL_CLOCK_KHZ/4)
#define ISR_TIME_250US_RELOAD_VALUE (65536 - ISR_TIME_250US_COUNTER)
#define ISR_TIME_1MS_COUNTER PERIPHERAL_CLOCK_KHZ // 1ms
#define ISR_TIME_1MS_RELOAD_VALUE (65536 - ISR_TIME_1MS_COUNTER)
#define ISR_TIME_9MS_COUNTER (PERIPHERAL_CLOCK_KHZ*9 + 460) //9 ms
#define ISR_TIME_9MS_RELOAD_VALUE (65536 - ISR_TIME_9MS_COUNTER)
#define ISR_TIME_4D5MS_COUNTER (PERIPHERAL_CLOCK_KHZ*4 + PERIPHERAL_CLOCK_KHZ/2 + 96) // 4.5ms
#define ISR_TIME_4D5MS_RELOAD_VALUE (65536 - ISR_TIME_4D5MS_COUNTER)
#define ISR_TIME_1685US_COUNTER 6221// 1685us = 1685*3.686 = 6221.9
#define ISR_TIME_1685US_RELOAD_VALUE (65536 - ISR_TIME_1685US_COUNTER)
#define ISR_TIME_565US_COUNTER 1998// 565us = 565 * 3.686 = 2082.5
#define ISR_TIME_565US_RELOAD_VALUE (65536 - ISR_TIME_565US_COUNTER)
#define ISR_TIME_560US_COUNTER 2045//2035// 560us = 560 * 3.686 = 2064.1
#define ISR_TIME_560US_RELOAD_VALUE (65536 - ISR_TIME_560US_COUNTER)
/* ======================================= */
//HOTEL TV NV ADDR DEFINE
#define CLONE_TV_NV_ADDR_START 0xa2
#define CLONE_TV_NV_ADDR_END 0x3cb//0x3bf//0x3a1
/* ======================================= */
//SWITCH MACRO DEFINE
//#define DEBUG
/* ======================================= */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -