闹钟裸奔核心代码Word文档格式.docx
- 文档编号:18894089
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:54
- 大小:26.40KB
闹钟裸奔核心代码Word文档格式.docx
《闹钟裸奔核心代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《闹钟裸奔核心代码Word文档格式.docx(54页珍藏版)》请在冰豆网上搜索。
externcharImage$$ZI$$Limit[];
externcharImage$$ZI$$Base[];
externunsignedchar__CHS[];
//我添加的字库实验
externunsignedchar__VGA[];
voidLcd_PutASCII(unsignedintx,unsignedinty,unsignedcharch,unsigned
intc,unsignedintbk_c,unsignedintst);
//英文
voidLcd_PutHZ(unsignedintx,unsignedinty,unsignedshortintQW,unsigned
//中文
voidLcd_printf(unsignedintx,unsignedinty,unsignedintc,unsignedint
bk_c,unsignedintst,char*fmt,...);
//输出
voidIsr_Init(void);
voidHaltUndef(void);
voidHaltSwi(void);
voidHaltPabort(void);
voidHaltDabort(void);
voidClearMemory(void);
voidClk0_Enable(intclock_sel);
voidClk1_Enable(intclock_sel);
voidClk0_Disable(void);
voidClk1_Disable(void);
externvoidLcd_TFT_Init(void);
externvoidKeyScan_Test(void);
externvoidLcd_ClearScr(U32c);
externvoidLcd_ClearScr1(intx0,inty0,inth,intl,U32c);
externvoidGlib_Rectangle(intx1,inty1,intx2,inty2,intcolor);
externvoidGlib_Line(intx1,inty1,intx2,inty2,intcolor);
volatileU32downloadAddress;
void(*restart)(void)=(void(*)(void))0x0;
volatileunsignedchar*downPt;
volatileU32downloadFileSize;
volatileU16checkSum;
volatileunsignedinterr=0;
volatileU32totalDmaCount;
volatileintisUsbdSetConfiguration;
intdownload_run=0;
U32tempDownloadAddress;
intmenuUsed=0;
U32*pMagicNum=(U32*)Image$$RW$$Limit;
intconsoleNum;
inta,b,c,d,e;
staticU32cpu_freq;
staticU32UPLL;
staticvoidcal_cpu_bus_clk(void)
{
U32val;
U8m,p,s;
intstart=0;
val=rMPLLCON;
m=(val>
>
12)&
0xff;
p=(val>
4)&
0x3f;
s=val&
3;
//(m+8)*FIN*2不要超出32位数!
FCLK=((m+8)*(FIN/100)*2)/((p+2)*(1<
<
s))*100;
val=rCLKDIVN;
1)&
p=val&
1;
val=rCAMDIVN;
s=val>
8;
switch(m)
{
case0:
HCLK=FCLK;
break;
case1:
HCLK=FCLK>
1;
case2:
if(s&
2)
3;
else
2;
case3:
1)
HCLK=FCLK/6;
HCLK=FCLK/3;
}
if(p)
PCLK=HCLK>
PCLK=HCLK;
0x10)
cpu_freq=HCLK;
cpu_freq=FCLK;
val=rUPLLCON;
UPLL=((m+8)*FIN)/((p+2)*(1<
s));
UCLK=(rCLKDIVN&
8)?
(UPLL>
1):
UPLL;
}
//****************************我添加的一段程序**************************************
voidRTC_Time_Set(void)
rRTCCON=1;
//RTCreadandwriteenable
rBCDYEAR=0x10;
//年
rBCDMON=0x01;
//月
rBCDDATE=0x28;
//日
rBCDDAY=0x05;
//星期
rBCDHOUR=0x12;
//小时
rBCDMIN=0x00;
//分
rBCDSEC=0x00;
//秒
rRTCCON&
=~1;
//RTCreadandwritedisable
//RTC_flag=false;
//这是我添加的,用于标记时钟设置时间。
doublesin(doublex)
intn;
doublei=0.0000001;
doublej=0;
doublek;
k=x;
n=1;
do
j=j+k;
n++;
k=-k*x*x/(2*n-1)/(2*n-2);
while(k>
i||-k>
i);
return(j);
doublecos(doublex)
k=1;
k=-k*x*x/(2*n)/(2*n-1);
voidMain(void)
doubleaas,aam,aah;
intssbit,sgbit,msbit,mgbit,hsbit,hgbit;
doublexxs,yys,xxm,yym,xxh,yyh;
doublexxs1,yys1,xxm1,yym1,xxh1,yyh1;
//这句调适很重要
intsecondp,minutep,hourp;
intAlarm_flag;
intAlm_count;
intx0,y0;
intx1,y1;
//-------addbgn-------------------
U32pix_x,pix_y,offset_x,offset_y;
//-------addend-------------------
U16year,rBCDYEAR1;
U8month,day;
//week
U8hour,minute,second,sec_cfg,hour_cfg,min_cfg;
U8rBCDYEARS,rBCDYEARG;
U8rBCDMON1,rBCDDATE1,rBCDHOUR1,rBCDMIN1,rBCDSEC1;
//闹钟临时变量
char*mode;
inti,ii;
U8key;
U32mpll_val=0;
//U32divn_upll=0;
//#ifADS10
//__rt_lib_init();
//forADS1.0
//#endif
Port_Init();
Isr_Init();
i=2;
//don'
tuse100M!
switch(i)
//200
key=12;
mpll_val=(92<
12)|(4<
4)|
(1);
//300
key=13;
mpll_val=(67<
12)|(1<
//400
key=14;
//440!
!
mpll_val=(102<
default:
//initFCLK=400M,sochangeMPLLfirst
ChangeMPllValue((mpll_val>
0xff,(mpll_val>
0x3f,mpll_val&
3);
ChangeClockDivider(key,12);
cal_cpu_bus_clk();
consoleNum=0;
//Uart1selectfordebug.
Uart_Init(0,115200);
Uart_Select(consoleNum);
Beep(2000,100);
Uart_SendByte('
\n'
);
Uart_Printf("
***************************************>
\n"
TQ2440TestProgram\n"
\n"
Buildtimeis:
%s%s\n"
__DATE__,__TIME__);
//wangwang如果不删掉,pc串口依然可以工作
rMISCCR=rMISCCR&
~(1<
3);
//USBDisselectedinsteadofUSBH1
13);
//USBport1isenabled.
rDSC0=0x2aa;
rDSC1=0x2aaaaaaa;
//EnableNAND,USBD,PWMTImer,UART0,1andGPIOclock,
//theothersmustbeenabledinOS!
rCLKCON=0xfffff0;
MMU_Init();
//
pISR_SWI=(_ISR_STARTADDRESS+0xf0);
//forpSOS
Led_Display(0x66);
mode="
DMA"
;
Clk0_Disable();
Clk1_Disable();
mpll_val=rMPLLCON;
#ifdefCSTM_LCD
cstmLcd_init();
#else
Lcd_TFT_Init();
//LCDinitial
#endif
download_run=1;
//ThedefaultmenuistheDownload&
Runmode.
rADCDLY=50000;
//Normalconversionmodedelayabout(1/3.6864M)*50000=13.56ms
rADCCON=(1<
14)+(ADCPRS<
6);
//ADCPRSEn,ADCPRSValue
//Uart_Printf("
\nTouchScreentest\n"
rADCTSC=0xd3;
//Wfait,XP_PU,XP_Dis,XM_Dis,YP_Dis,YM_En
pISR_ADC=(int)AdcTsAuto;
rINTMSK=~BIT_ADC;
//ADCTouchScreenMaskbitclear
rINTSUBMSK=~(BIT_SUB_TC);
Lcd_ClearScr(0xffff);
RTC_Time_Set();
//-------addbgn---------------
#ifdefCSTM_LCD
g_type=get_pix(&
pix_x,&
pix_y);
offset_x=(pix_x-320)/2;
offset_y=(pix_y-240)/2;
offset_x=(LCD_XSIZE_TFT-320)/2;
offset_y=(LCD_YSIZE_TFT-240)/2;
if(LCD_Type==LCDW35)
g_type=LCD_35;
elseif(LCD_Type==LCDW43)
g_type=LCD_43;
elseif(LCD_Type==LCDA70)
g_type=LCD_70;
#endif
//-------addend---------------
while
(1)
Paint_Bmp(0+offset_x,0+offset_y,320,240,windesk_320240);
x0=100;
y0=158;
x1=224;
y1=158;
Alarm_flag=0;
Alm_count=0;
xxs=xxm=xxh=x0;
yys=yym=yyh=y0;
//和共同sec_cfg进行去痕迹;
xxs1=xxm1=xxh1=x1;
yys1=yym1=yyh1=y1;
if(rBCDSEC!
=second)
Alm_count++;
if(0x2000+rBCDYEAR==rBCDYEAR1&
&
rBCDMON==rBCDMON1&
rBCDDATE==rBCDDATE1&
rBCDHOUR==rBCDHOUR1&
rBCDMIN==
rBCDMIN1&
rBCDSEC==rBCDSEC1)
U16freq=800;
Buzzer_Freq_Set(freq);
}//闹钟检查
//闹钟只响60s
if(Alm_count==60)
Buzzer_Stop();
if(xdata>
(270+offset_x)&
xdata<
(320+offset_x)&
ydata<
(240+offset_y)&
ydata>
(210+offset_y))
//返回键
//电子时钟////////////////////////////////////////////////////////////////////////////////////////////
if(xdata<
(45+offset_x)&
xdata>
(0+offset_x)&
(100+offset_y)&
(70+offset_y))
Lcd_ClearScr(0x0000);
Paint_Bmp(0+offset_x,0+offset_y,320,240,electro_320240);
xdata=X_NULL;
rBCDMON==rBCDMON1
&
rBCDMIN==rBCDMIN1&
(60+offset_y)&
(30+offset_y))
//切换键
(310+offset_x)&
(260+offset_x)&
(235+offset_y)&
/************************************************************
时间调整bgn
************************************************************/
//小时调整
(130+offset_x)&
(70+offset_x)&
(40+offset_y)&
//如果没有这句使能的语句的话,这个调整是不被系统接收的。
rBCDHOUR=0x01+rBCDHOUR;
if(rBCDHOUR==0x0A)
rBCDHOUR=rBCDHOUR+0x06;
elseif(rBCDHOUR==0x13)
rBCDHOUR=0x01;
//防止无限的加下去。
//分调整
(180+offset_x)&
rBCDMIN=0x01+rBCDMIN;
if(rBCDMIN==0x0A||rBCDMIN==0x1A||rBCDMIN==
0x2A||rBCDMIN==0x3A||rBCDMIN==0x4A||
rBCDMIN==0x5A)
rBCDMIN=rBCDMIN+0x06;
//wang我添加的代码,
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 闹钟 裸奔 核心 代码
![提示](https://static.bdocx.com/images/bang_tan.gif)