init.c

来自「上学时做的一个51单片机按键显示程序」· C语言 代码 · 共 75 行

C
75
字号
/*
* Copyright(c)2005 - 2009 danise .China
* All rights reserved.
* Redistribution and use in source and bianry forms
* with or without modification ,are permitted provided
* that following conditions are met:
* 
* 1.Redistrubution of source code must retain the 
* above copyright notice,this list of conditions and
* following disclaimer.
* 
* 2.Redistributions in binary form must reproduce the 
* above copyright notice,this list of conditions and 
* following disclaimer in the documentation and /or other
* materials provided with the distribution.
* 
* Alternately, this acknowledgment may appear in the software
* itself,if and wherever such third-party acknowledgements
* normally appear.
*
* This software is designed for key board and led display.
* 
	
*/
#include "./include/init.h"
#include "./include/global.h"
#include "./include/datatypes.h"
#include "./include/i2c.h"
void CP932Timer0Init(void)
{
	CPL932_TMOD |= 0x01; /*timer1 method 1,timer 0 methed 1*/
	CPL932_TL0 = 0x6b;
	CPL932_TH0 = 0x71; /*osc 7.3M  ,10 ms  */
	CPL932_ET0 = 1; /* set timer0 interrupt */
	CPL932_TR0 = 1;	/* start timer 0*/	
}
void CP932Timer1Init(void)
{
	CPL932_TMOD |= 0x10; /*timer1 method 1,timer 0 methed 1*/
	CPL932_TL1 = 0x1;
	CPL932_TH1 = 0x0; /*osc 7.3M  ,10 ms  */
	CPL932_ET1 = 1; /* set timer0 interrupt */
	CPL932_TR1 = 1;	/* start timer 0 */	
}	
void CP932ISRInit(void)
{
	CPL932_EA = 1;/* open all*/
}
void CP932PortInit(void)
{
	CPL932_PORTMOD_P0M1 = 0x0; /* Quasi-Bidirectional*/
	CPL932_PORTMOD_P0M2 = 0x0;
	CPL932_PORTMOD_P1M1 = 0x0C;
	CPL932_PORTMOD_P1M2 = 0x0C;
	CPL932_PORTMOD_P2M1 = 0x0;
	CPL932_PORTMOD_P2M2 = 0x0;
	
}
void InitSysData(void)
{
	LedsShowStr.length  = 0;
    LedsShowStr.isdot	=0;
    LedsShowStr.dotposition =LED_MAX_NUM-1;
    memset(&LedsShowStr.ledbuf[0],0,8);	
}

void InitIIC(void)
{
	EI2C=1;
	SetBus(SLAVEADD);
	I2CON = 0x44;
	INT1 = 1;	 
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?