📄 main.c
字号:
#include <string.h>
#include "..\inc\option.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\def.h"
#include "..\inc\uart.h"
#include "..\inc\ds18b20.h"
#include "..\inc\3510i.h"
#include "..\inc\common.h"
extern const unsigned char IMAGE1[];
unsigned char str[]="DS18B20 TEST";
unsigned char number[]="00.00C";
void Isr_Init(void);
void Main(void)
{
unsigned char x;
unsigned char y;
unsigned int z;
unsigned int n;
Isr_Init();
Port_Init();
Uart_Init(0,115200);
Uart_Select(0);
Delay(0); //calibrate Delay()
Delay(5000);
LCD_Initialize();
BGColor = 0;
LCD_ClearScreen(1);
Delay(10000);
BGColor = 0xff;
LCD_ClearScreen(1);
Delay(10000);
BGColor = 0xf0f;
LCD_ClearScreen(1);
Delay(10000);
BGColor = 0xff0;
LCD_ClearScreen(1);
Delay(10000);
BGColor = 0xfff;
LCD_ClearScreen(1);
Delay(10000);
//R
LCD_SendCommand(0x3a); //interface pixel format
LCD_SendData(0x03);
LCD_DataOver();
LCD_SendCommand(0x2a); //column address set
LCD_SendData(0);
LCD_SendData(97);
LCD_DataOver();
LCD_SendCommand(0x2b); //page address set
LCD_SendData(0);
LCD_SendData(66);
LCD_DataOver();
LCD_SendCommand(0x2c); //memory write
for(y = 0; y < 64; y ++)
{
for(x = 0 ;x < 98; x += 2)
{
z = 63 - y;
z = z >> 2;
LCD_SendData(z);
LCD_SendData(z << 4);
LCD_SendData((z << 4) + z);
}
}
LCD_DataOver();
Delay(10000);
//G
LCD_SendCommand(0x3a); //interface pixel format
LCD_SendData(0x03);
LCD_DataOver();
LCD_SendCommand(0x2a); //column address set
LCD_SendData(0);
LCD_SendData(97);
LCD_DataOver();
LCD_SendCommand(0x2b); //page address set
LCD_SendData(0);
LCD_SendData(66);
LCD_DataOver();
LCD_SendCommand(0x2c); //memory write
for(y = 0; y < 64; y ++)
for(x = 0 ;x < 98; x += 2)
{
z = 63 - y;
z = z >> 2;
LCD_SendData(z << 4);
LCD_SendData((z << 4) + z);
LCD_SendData(z);
}
LCD_DataOver();
Delay(10000);
//B
LCD_SendCommand(0x3a); //interface pixel format
LCD_SendData(0x03);
LCD_DataOver();
LCD_SendCommand(0x2a); //column address set
LCD_SendData(0);
LCD_SendData(97);
LCD_DataOver();
LCD_SendCommand(0x2b); //page address set
LCD_SendData(0);
LCD_SendData(66);
LCD_DataOver();
LCD_SendCommand(0x2c); //memory write
for(y = 0; y < 64; y ++)
{
for(x = 0 ;x < 98; x += 2)
{
z = 63 - y;
z = z >> 2;
LCD_SendData((z << 4) + z);
LCD_SendData(z);
LCD_SendData(z << 4);
}
}
LCD_DataOver();
Delay(10000);
//
LCD_SendCommand(0x3a); //interface pixel format
LCD_SendData(0x03);
LCD_DataOver();
LCD_SendCommand(0x2a); //column address set
LCD_SendData(0);
LCD_SendData(97);
LCD_DataOver();
LCD_SendCommand(0x2b); //page address set
LCD_SendData(0);
LCD_SendData(66);
LCD_DataOver();
LCD_SendCommand(0x2c); //memory write
z = 0xfff;
n = z;
for(y = 0; y < 67; y ++)
{
for(x = 0 ;x < 98; x += 2)
{
LCD_SendData(n >> 4);
LCD_SendData(((n & 0x00f) << 4) + (z >> 8));
LCD_SendData(z & 0x0ff);
z--;
n = z;
z--;
}
}
LCD_DataOver();
Delay(10000);
BGColor = 0x0;
LCD_ClearScreen(0);
Delay(10000);
BGColor = 0x1f;
LCD_ClearScreen(0);
Delay(10000);
BGColor = 0xe3;
LCD_ClearScreen(0);
Delay(10000);
BGColor = 0xfc;
LCD_ClearScreen(0);
Delay(10000);
BGColor = 0xff;
LCD_ClearScreen(0);
Delay(10000);
PenColor = 0X1F; //red
LCD_DrawRectangle(color256,10, 30, 30, 50);
PenColor = 0XE3; //green
LCD_DrawLine(color256, 40, 50, 50, 30);
LCD_DrawLine(color256, 50, 30, 60, 50);
LCD_DrawLine(color256, 60, 50, 40, 50);
PenColor = 0XFC; //blue
LCD_DrawLine(color256, 70, 30, 90, 50);
LCD_DrawLine(color256, 70, 50, 90, 30);
Delay(10000);
BGColor = 0;
LCD_ClearScreen(0);
Delay(10000);
while(1)
{
Uart_Printf("\n\n*********************************************************************");
Uart_Printf("\n\n 欢迎使用S3C44B0+DS18B20+3510测试程序(2009)\n ");
Uart_Printf("\n*-------------------Begin to Start DS18B20 test--------------------*");
Uart_Printf("\n\n");
LCD_WriteString(1,10,str,sizeof(str)-1,0,0xfc);
//主循环
for (;;)
{
ReadTemperature();
Uart_Printf("现在温度是:%d.%d`C\n",sdata,xiaoshu);
number[0]=sdata/10+48;
number[1]=sdata%10+48;
number[3]=xiaoshu/10+48;
number[4]=xiaoshu%10+48;
LCD_WriteString(25,40,number,sizeof(number)-1,0,0x1f);
//Delay(1000);
}
}
}
void Isr_Init(void)
{
U32 i;
for(i=_RAM_STARTADDRESS;i<(_RAM_STARTADDRESS+0x20);i+=4)
{
*((volatile unsigned *)i)=0xEA000000+0x1FFE;
}
//rINTCON=0x1; // Vectored Int. IRQ enable,FIQ disable
rINTCON=0x5; // Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; // All=IRQ mode
rINTMSK|=BIT_GLOBAL|BIT_EINT4567; // All interrupt is masked.
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -