?? example_28xgpio.c
字號:
#include "DSP28_Device.h"
#include "DSP28_Globalprototypes.h"
//#include "DSP28_data.h"
//#include "DSP28_lcddata.h"
#define time_line 16
#define time_row 1
#define start_row 200
#define start_line 10
/*#define X_ADDR_CS() {GpioDataRegs.GPBDAT.bit.GPIOB3 = 0;GpioDataRegs.GPBDAT.bit.GPIOB4 = 0;}
#define Y_ADDR_CS() {GpioDataRegs.GPBDAT.bit.GPIOB3 = 1;GpioDataRegs.GPBDAT.bit.GPIOB4 = 0;}
#define CMD_CS() {GpioDataRegs.GPBDAT.bit.GPIOB3 = 0;GpioDataRegs.GPBDAT.bit.GPIOB4 = 1;}
#define DAT_CS() {GpioDataRegs.GPBDAT.bit.GPIOB3 = 1;GpioDataRegs.GPBDAT.bit.GPIOB4 = 1;}
unsigned int *X_ADDR = (unsigned int*)0x2000;
unsigned int *Y_ADDR = (unsigned int*)0x2001;
unsigned int *CMD = (unsigned int*)0x2002;
unsigned int *DAT = (unsigned int*)0x2003;*/
unsigned int page_focus = 0x0000;
unsigned char time_data = 8; // 時間顯示個數,時,分,秒
// key keyva.all = 0x00;
unsigned char time_count = 0xFF;
unsigned char data_min = 45;
unsigned char data_sec = 58;
unsigned char data_our = 23;
unsigned char figure[5] = {1,2,11,5,6};
unsigned char time_buf[7] = {0,0,0,0,0,0,10};
//************************************************************************//
baseData time_all[8] = {
{blue,white,start_row,start_line,time_row,time_line,0,&time_buf[0]},
{blue,white,200+8,start_line,time_row,time_line,0,&time_buf[1]},
{red,white,(200+8*2),start_line,time_row,time_line,0,&time_buf[6]},
{blue,white,(200+8*3),start_line,time_row,time_line,0,&time_buf[2]},
{blue,white,(200+8*4),start_line,time_row,time_line,0,&time_buf[3]},
{red,white,(200+8*5),start_line,time_row,time_line,0,&time_buf[6]},
{blue,white,(200+8*6),start_line,time_row,time_line,0,&time_buf[4]},
{blue,white,(200+8*7),start_line,time_row,time_line,0,&time_buf[5]}
};
//************************************************************************//
baseData figure_one[5] = {
{blue,white,10,start_line,time_row,time_line,0,&figure[0]},
{blue,white,10+8,start_line,time_row,time_line,0,&figure[1]},
{red,white,(10+8*2),start_line,time_row,time_line,0,&figure[2]},
{blue,white,(10+8*3),start_line,time_row,time_line,0,&figure[3]},
{blue,white,(10+8*4),start_line,time_row,time_line,0,&figure[4]},
};
//*****************************************************
// Prototype statements for functions found within this file.
// interrupt void ISRTimer2(void);
void Gpio_select(void);
void Delay(void);
void figure_display(const baseData *point);
//void data_display(const lineData *point);
//void page_display(void);
void data_clear(const baseData *point_clear);
interrupt void cpu_timer0_isr(void);
void main(void)
{
unsigned int x;
unsigned int y;
InitSysCtrl();
Gpio_select();
DINT;
IER = 0x0000;
IFR = 0x0000;
InitPieCtrl();
InitPieVectTable();
EALLOW;
PieVectTable.TINT0 = &cpu_timer0_isr;
EDIS;
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0,100,1500000);
StartCpuTimer0();
IER |= M_INT1;
PieCtrl.PIEIER1.bit.INTx7 = 1;
EINT;
ERTM;
GpioDataRegs.GPBDAT.bit.GPIOB2 = 0;
CMD_CS();
*CMD = 0X04;
DAT_CS();
*DAT = 0XE0; //寫背景色
CMD_CS();
*CMD = 0X08; //清屏
Delay();
CMD_CS();
*CMD = 0X00; //退出清屏
for(y=0;y<240;y++)
{
X_ADDR_CS();
*X_ADDR = 0;
*X_ADDR = 0;
Y_ADDR_CS();
*Y_ADDR = y;
DAT_CS();
for(x=0;x<320;x++)
{
*DAT = 0xFF;
}
}
page_display();
time_data = 5;
figure_display(figure_one);
while(1)
{
}
/* while(1)
{
if(time_count == 0)
{
time_count = 0xFF;
time_display(&time_all[8 - time_data]);
}
}*/
}
//****************************************************
void figure_display(const baseData *point)
{
unsigned char i = 0;
unsigned char x_clum = 0;
unsigned char y_line = 0;
unsigned char *p = ×[*(point->pt_data)][0];
for(i = 0;i < time_data;++i,++point)
{
p = ×[*(point->pt_data)][0];
if (point->menu_sign == 0)
{
CMD_CS();
*CMD = 0X04;
DAT_CS();
*DAT = point->background_color;
CMD_CS();
*CMD = 0X02;
DAT_CS();
*DAT = point->foreground_color;
}
else
{
CMD_CS();
*CMD = 0X04;
DAT_CS();
*DAT = point->foreground_color;
CMD_CS();
*CMD = 0X02;
DAT_CS();
*DAT = point->background_color;
}
CMD_CS();
*CMD = 0x01;
for(y_line = 0;y_line < point->lengh;++y_line)
{
X_ADDR_CS();
*X_ADDR = (point->x_cdinate%256);
*X_ADDR = (point->x_cdinate/256);
Y_ADDR_CS();
*Y_ADDR = point->y_cdinate + y_line;
for(x_clum = 0;x_clum < point->wide;++x_clum,++p)
{
DAT_CS();
*DAT = *p;
}
}
}
}
//**********************************************
void data_clear(const baseData *point_clear)
{
unsigned char x_clum = 0;
unsigned char y_line = 0;
CMD_CS();
*CMD = 0X04;
DAT_CS();
*DAT = point_clear->background_color;
CMD_CS();
*CMD = 0x00;
for(y_line = 0;y_line < time_line;++y_line)
{
X_ADDR_CS();
*X_ADDR = (point_clear->x_cdinate%256);
*X_ADDR = (point_clear->x_cdinate/256);
Y_ADDR_CS();
*Y_ADDR = point_clear->y_cdinate + y_line;
DAT_CS();
for(x_clum = 0;x_clum < time_row;++x_clum)
{
*DAT = white;
}
}
}
//**************************************************
void Delay(void)
{
unsigned int y;
for(y=0;y<250*10;y++);
}
//****************************************************
/* void data_display(const lineData *pt)
{
unsigned char i = 0;
unsigned char x_clum = 0;
unsigned char y_line = 0;
const baseData *pt_a = pt->pt_base;
const unsigned char *p = pt->pt_base->pt_data;
for(i = 0,p = pt_a->pt_data;i < pt->unit_num;++i,++pt_a)
{
if (pt_a->menu_sign == 0)
{
CMD_CS();
*CMD = 0X04;
DAT_CS();
*DAT = pt_a->background_color;
CMD_CS();
*CMD = 0X02;
DAT_CS();
*DAT = pt_a->foreground_color;
}
else
{
CMD_CS();
*CMD = 0X04;
DAT_CS();
*DAT = pt_a->foreground_color;
CMD_CS();
*CMD = 0X02;
DAT_CS();
*DAT = pt_a->background_color;
}
CMD_CS();
*CMD = 0x01;
for(y_line = 0;y_line < pt_a->lengh;++y_line)
{
X_ADDR_CS();
*X_ADDR = (pt_a->x_cdinate%256);
*X_ADDR = (pt_a->x_cdinate/256);
Y_ADDR_CS();
*Y_ADDR = pt_a->y_cdinate + y_line;
for(x_clum = 0;x_clum < pt_a->wide;++x_clum,++p)
{
DAT_CS();
*DAT = *p;
}
}
}
}*/
//************************************************************//
/*void page_display()
{
uchar i = 0;
uchar j = 0;
const lineData *point = page[0].pt_line;
const lineData *pi = page[0].pt_menu;
for(i = 0;i < page[0].line_num;++i,++point)
{
data_display(point);
}
for(j = 0;j < page[0].menu_num;++j,++pi)
{
data_display(pi);
}
}*/
//****************************************************//
/*void get_key(void)
{
}*/
//***************************************************//
void Gpio_select(void)
{
EALLOW;
GpioMuxRegs.GPAMUX.all = 0X0000;
GpioMuxRegs.GPADIR.all = 0x0000;
GpioMuxRegs.GPBMUX.all = 0x0000;
GpioMuxRegs.GPBDIR.all = 0xFFFF; // GPIO PORTs as output
EDIS;
}
//**************************************************//
//************************************************//
interrupt void cpu_timer0_isr(void)
{
PieCtrl.PIEACK.all = PIEACK_GROUP1;
CpuTimer0.InterruptCount++;
time_count = 0;
++data_min;
if(data_min < 60)
{
time_buf[5] = (data_min%10);
time_buf[4] = (data_min/10);
time_data = 2;
}
else
{
data_min = 0;
time_buf[4] = 0;
time_buf[5] = 0;
++data_sec;
}
if(data_sec < 60)
{
time_buf[3] = (data_sec%10);
time_buf[2] = (data_sec/10);
time_data = 5;
}
else
{
data_sec = 0;
time_buf[3] = 0;
time_buf[2] = 0;
++data_our;
}
if(data_our < 24)
{
time_buf[1] = (data_our%10);
time_buf[0] = (data_our/10);
time_data = 8;
}
else
{
data_our = 0;
time_buf[1] = 0;
time_buf[0] = 0;
}
figure_display(&time_all[8 - time_data]);
}
//===========================================================================
// No more.
//===========================================================================
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -