📄 config.h
字号:
/*
*************************************************************************************************************
* Kingst-51
* Development board samples
*
* (c) Copyright 2009-2012, Kingst Studio
* All Rights Reserved
*
* http://www.kingst.org
* 文件名:config.h
* 描 述:Kingst-51开发板配置文件
* 版本号:1.0.1
* 备 注:本文件用于定义开发板硬件连接情况,以及一些固定的全局参数
*************************************************************************************************************
*/
#ifndef _CONFIG_H
#define _CONFIG_H
#include <reg52.h>
#include <intrins.h>
#include "ktype.h"
/*
* 统一通用的位定义
*/
#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 BIT8 (0x0100)
#define BIT9 (0x0200)
#define BIT10 (0x0400)
#define BIT11 (0x0800)
#define BIT12 (0x1000)
#define BIT13 (0x2000)
#define BIT14 (0x4000)
#define BIT15 (0x8000)
#define BIT16 (0x00010000)
#define BIT17 (0x00020000)
#define BIT18 (0x00040000)
#define BIT19 (0x00080000)
#define BIT20 (0x00100000)
#define BIT21 (0x00200000)
#define BIT22 (0x00400000)
#define BIT23 (0x00800000)
#define BIT24 (0x01000000)
#define BIT25 (0x02000000)
#define BIT26 (0x04000000)
#define BIT27 (0x08000000)
#define BIT28 (0x10000000)
#define BIT29 (0x20000000)
#define BIT30 (0x40000000)
#define BIT31 (0x80000000)
/*
* MCS-51的IO位名称定义
*/
sbit P0_0 = P0^0;
sbit P0_1 = P0^1;
sbit P0_2 = P0^2;
sbit P0_3 = P0^3;
sbit P0_4 = P0^4;
sbit P0_5 = P0^5;
sbit P0_6 = P0^6;
sbit P0_7 = P0^7;
sbit P1_0 = P1^0;
sbit P1_1 = P1^1;
sbit P1_2 = P1^2;
sbit P1_3 = P1^3;
sbit P1_4 = P1^4;
sbit P1_5 = P1^5;
sbit P1_6 = P1^6;
sbit P1_7 = P1^7;
sbit P2_0 = P2^0;
sbit P2_1 = P2^1;
sbit P2_2 = P2^2;
sbit P2_3 = P2^3;
sbit P2_4 = P2^4;
sbit P2_5 = P2^5;
sbit P2_6 = P2^6;
sbit P2_7 = P2^7;
sbit P3_0 = P3^0;
sbit P3_1 = P3^1;
sbit P3_2 = P3^2;
sbit P3_3 = P3^3;
sbit P3_4 = P3^4;
sbit P3_5 = P3^5;
sbit P3_6 = P3^6;
sbit P3_7 = P3^7;
/*
* 时钟部分的配置参数
*/
#define XTAL_FREQ (11059200UL) //外部振荡器频率
#define SYS_MCLK (XTAL_FREQ/12) //系统主时钟频率,即(1/CPU机器周期)
/*
* 显示部分的配置参数
*/
#define DBUS P0 //显示部分的数据总线端口
#define ADDR0 P1_0 //显示部分的地址译码位0
#define ADDR1 P1_1 //显示部分的地址译码位1
#define ADDR2 P1_2 //显示部分的地址译码位2
#define ADDR3 P1_3 //显示部分的地址译码位3
#define ENLED P1_4 //LED显示部分的选通信号
#define ENLCD P1_5 //LCD显示部分的选通信号
#define LED_SEG_a BIT0
#define LED_SEG_b BIT1
#define LED_SEG_c BIT2
#define LED_SEG_d BIT3
#define LED_SEG_e BIT4
#define LED_SEG_f BIT5
#define LED_SEG_g BIT6
#define LED_SEG_dp BIT7
#define LED_SPACE 0xFF
#define LED_CHAR_0 (~(u8)(LED_SEG_a | LED_SEG_b | LED_SEG_c | LED_SEG_d | LED_SEG_e | LED_SEG_f))
#define LED_CHAR_1 (~(u8)(LED_SEG_b | LED_SEG_c))
#define LED_CHAR_2 (~(u8)(LED_SEG_a | LED_SEG_b | LED_SEG_d | LED_SEG_e | LED_SEG_g))
#define LED_CHAR_3 (~(u8)(LED_SEG_a | LED_SEG_b | LED_SEG_c | LED_SEG_d | LED_SEG_g))
#define LED_CHAR_4 (~(u8)(LED_SEG_b | LED_SEG_c | LED_SEG_f | LED_SEG_g))
#define LED_CHAR_5 (~(u8)(LED_SEG_a | LED_SEG_c | LED_SEG_d | LED_SEG_f | LED_SEG_g))
#define LED_CHAR_6 (~(u8)(LED_SEG_a | LED_SEG_c | LED_SEG_d | LED_SEG_e | LED_SEG_f | LED_SEG_g))
#define LED_CHAR_7 (~(u8)(LED_SEG_a | LED_SEG_b | LED_SEG_c))
#define LED_CHAR_8 (~(u8)(LED_SEG_a | LED_SEG_b | LED_SEG_c | LED_SEG_d | LED_SEG_e | LED_SEG_f | LED_SEG_g))
#define LED_CHAR_9 (~(u8)(LED_SEG_a | LED_SEG_b | LED_SEG_c | LED_SEG_d | LED_SEG_f | LED_SEG_g))
#define LED_CHAR_A (~(u8)(LED_SEG_a | LED_SEG_b | LED_SEG_c | LED_SEG_e | LED_SEG_f | LED_SEG_g))
#define LED_CHAR_b (~(u8)(LED_SEG_c | LED_SEG_d | LED_SEG_e | LED_SEG_f | LED_SEG_g))
#define LED_CHAR_C (~(u8)(LED_SEG_a | LED_SEG_d | LED_SEG_e | LED_SEG_f))
#define LED_CHAR_d (~(u8)(LED_SEG_b | LED_SEG_c | LED_SEG_d | LED_SEG_e | LED_SEG_g))
#define LED_CHAR_E (~(u8)(LED_SEG_a | LED_SEG_d | LED_SEG_e | LED_SEG_f | LED_SEG_g))
#define LED_CHAR_F (~(u8)(LED_SEG_a | LED_SEG_e | LED_SEG_f | LED_SEG_g))
/*
* 按键部分的配置参数
*/
#define DEBOUNCE_MASK 0x1F //按键扫描的消抖掩码
#define KEY_OUT_1 P2_3 //矩阵按键的扫描输出引脚1
#define KEY_OUT_2 P2_2 //矩阵按键的扫描输出引脚2
#define KEY_OUT_3 P2_1 //矩阵按键的扫描输出引脚3
#define KEY_OUT_4 P2_0 //矩阵按键的扫描输出引脚4
#define KEY_IN_1 P2_4 //矩阵按键的扫描输入引脚1
#define KEY_IN_2 P2_5 //矩阵按键的扫描输入引脚2
#define KEY_IN_3 P2_6 //矩阵按键的扫描输入引脚3
#define KEY_IN_4 P2_7 //矩阵按键的扫描输入引脚4
typedef enum { //按键状态定义
KEY_UP, KEY_DOWN
} eKeySta;
/*
* 步进电机引脚配置
*/
#define MC0 P1_0
#define MC1 P1_1
#define MC2 P1_2
#define MC3 P1_3
/*
* DS1302引脚配置
*/
#define S1302 P1_7
#define SCK P3_5
#define SIO P3_4
/*
* I2C总线引脚配置
*/
#define SDA P3_6
#define SCL P3_7
/*
* 蜂鸣器引脚配置
*/
#define BUZZ_CTRL P1_6
/*
* 红外接收引脚配置
*/
#define IR_INPUT P3_3
/*
* DS18B20引脚配置
*/
#define IO_18B20 P3_2
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -