lpc1768 ile dijital-analog saat uygulaması

Başlatan yamak, 16 Eylül 2011, 16:16:30

yamak

LPC1768 in rtc si ile ilgili uygulama olması ve glcd ile analog saat uygulamasının içimde kalmasından dolayı böyle bir uygulama yaptım.Kullandığım kit mcb1700 dür.Saat ayarlamaları için kit üzerindeki joystick i kullandım,ayarlama kısmına geçmek için key1 e yaklaşık 2 sn basılı tutmak ayarlama kısmından çıkmak için de INT0 butonuna basmak yeterli. Umarım bu konu ile ilgilenen arkadaşlara yardımcı olmuşumdur.



main:
#include <lpc17xx.h>
#include <yusuf_rtc.h>
#include <yusuf_lpc17xx_delay.h>
#include <stdio.h>
#include <lpc_glcd.h>
#include <math.h>
#define pi 3.1415926535897932384626433832795
RTC_TIME local_time,current_time,alarm_time;
uint32_t sec,min,hour,mon,mday,wday,year,i=1,j=0,z=0,start_count,select=0,pwm;
volatile uint32_t start=0,stop=0,setting=0,alarm_on=1,yanson=0;
char f[10]=" ";
char g[10]=" ";
void pwm_init(void);
void clock_write(void);
void pwm_start(void);
void pwm_stop(void);
void SysTickStop(void);
void analog_saat(void)
{
	char v[8]=" ";
	int analog_hour,analog_min,analog_sec,akrep_aci,yelkovan_aci,akrep_x,akrep_y,yelkovan_x,yelkovan_y,saniye_aci,saniye_x,saniye_y,i;
	//glcd_circle(30,30,28,0,1);
	glcd_circle(95,30,28,0,1);
	glcd_circle(95,30,2,1,1);
	glcd_text57(91,5,"12",1,1);
	glcd_text57(117,27,"3",1,1);
	glcd_text57(93,50,"6",1,1);
	glcd_text57(70,27,"9",1,1);
	glcd_line(106,10,108,8,1);
	glcd_line(114,19,116,17,1);
	glcd_line(114,41,116,43,1);
	glcd_line(106,49,108,51,1);
	glcd_line(83,49,81,51,1);
	glcd_line(75,41,73,43,1);
	glcd_line(75,19,73,17,1);
	glcd_line(84,10,82,8,1);
	current_time=RTCGetTime();
	analog_min=current_time.RTC_Min;
	analog_hour=current_time.RTC_Hour;
	analog_sec=current_time.RTC_Sec;
	if(analog_hour>11)
	analog_hour=analog_hour-12;
	if(analog_hour>3)	
		analog_hour=15-analog_hour;
	else
		analog_hour=3-analog_hour;
	if(analog_min>15)
		analog_min=75-analog_min;
	else
		analog_min=15-analog_min;
	if(analog_sec>15)
		analog_sec=75-analog_sec;
	else
		analog_sec=15-analog_sec;
	akrep_aci=analog_hour*30-(int)((current_time.RTC_Min/12)*6);
	yelkovan_aci=analog_min*6;
	saniye_aci=analog_sec*6;
	akrep_x=(cos((pi*akrep_aci)/180))*15+95;
	akrep_y=30-(sin((pi*akrep_aci)/180))*15;
	yelkovan_x=(cos((pi*yelkovan_aci)/180))*18+95;
	yelkovan_y=30-(sin((pi*yelkovan_aci)/180))*18;
	saniye_x=(cos((pi*saniye_aci)/180))*20+95;
	saniye_y=30-(sin((pi*saniye_aci)/180))*20;
	glcd_line(95,30,akrep_x,akrep_y,1);
	glcd_line(95,30,yelkovan_x,yelkovan_y,1);
	glcd_line(95,30,saniye_x,saniye_y,1);	
}
void SysTick_Handler(void)
{
	j++;
	if(j==4&&stop==1)	//Ayarlama modunda yanip sönme hizi
	{
		yanson++;
		clock_write();
		j=0;
	}
}
void SysTickStart(void)
{
	SysTick->LOAD=100000000;//45ms preriyot
	SysTick->VAL =(0x00);
	SysTick->CTRL=0x07;
}
void SysTickStop(void)
{
	SysTick->CTRL=0x00;
}
void clock_write(void)
{
	 	if(select%2==0)
		{
			current_time=RTCGetTime();
			sec= current_time.RTC_Sec;
			min=current_time.RTC_Min;
			hour=current_time.RTC_Hour;
			mon=current_time.RTC_Mon;
			mday=current_time.RTC_Mday;
			year=current_time.RTC_Year;
			wday=current_time.RTC_Wday;
		}
		if(select%2!=0)
		{
			alarm_time=RTCGetAlarmTime();
			sec= alarm_time.RTC_Sec;
			min= alarm_time.RTC_Min;
			hour=alarm_time.RTC_Hour;
			mon= alarm_time.RTC_Mon;
			mday=alarm_time.RTC_Mday;
			year=alarm_time.RTC_Year;
			wday=alarm_time.RTC_Wday;	
		}
		if((setting==1&&stop==1)&&yanson%2==0)
		{
			f[0]=' ';
			f[1]=' ';
			f[2]=':';
		}
		else if((stop==0&&hour<10)||(hour<10&&yanson%2!=0&&setting==1)||(hour<10&&setting!=1))
		sprintf(f,"0%d:",hour);
		else if((stop==0&&hour>=10)||(hour>=10&&yanson%2!=0&&setting==1)||(hour>=10&&setting!=1))
		sprintf(f,"%d:",hour);
		if((setting==2&&stop==1)&&yanson%2==0)
		{
			f[3]=' ';
			f[4]=' ';
			f[5]=':';
		}
		else if((stop==0&&min<10)||(min<10&&yanson%2!=0&&setting==2)||(min<10&&setting!=2))
		sprintf(f+3,"0%d:",min);
		else if(stop==0&&min>=10||(min>=10&&yanson%2!=0&&setting==2)||(min>=10&&setting!=2))
		sprintf(f+3,"%d:",min);
		if((setting==3&&stop==1)&&yanson%2==0)
		{
			f[6]=' ';
			f[7]=' ';
		}
		else if((stop==0&&sec<10)||(sec<10&&yanson%2!=0&&setting==3)||(sec<10&&setting!=3))
		sprintf(f+6,"0%d",sec);
		else if((stop==0&&sec>=10)||(sec>=10&&yanson%2!=0&&setting==3)||(sec>=10&&setting!=3))
		sprintf(f+6,"%d",sec);
		glcd_fillScreen(0);
		glcd_rect(1,0,63,20,0,1);
		glcd_rect(1,22,63,53,0,1);
		glcd_text57(3,55,"Yusuf Yamak",1,1);
		analog_saat();
		if(select%2==0)
		{
	    glcd_text57(3,1,"Saat",1,1);
		glcd_text57(3,24,"Tarih",1,1);
		} 
		else
		{ 
		glcd_text57(3,1,"Alrm Saati",1,1);
		glcd_text57(3,24,"Alrm Tarhi",1,1);
		}
		glcd_text57(3,11,f,1,1);
		if((setting==4&&stop==1)&&yanson%2==0)
		{
			g[0]=' ';
			g[1]=' ';
			g[2]='/';
		}
		else if((stop==0&&mday<10)||(mday<10&&yanson%2!=0&&setting==4)||(mday<10&&setting!=4))
		sprintf(g,"0%d/",mday);
		else if(stop==0&&mday>=10||(mday>=10&&yanson%2!=0&&setting==4)||(mday>=10&&setting!=4))
		sprintf(g,"%d/",mday);
		if((setting==5&&stop==1)&&yanson%2==0)
		{
			g[3]=' ';
			g[4]=' ';
			g[5]='/';
		}
		else if((stop==0&&mon<10)||(mon<10&&yanson%2!=0&&setting==5)||(mon<10&&setting!=5))
		sprintf(g+3,"0%d/",mon);
		else if((stop==0&&mon>=10||mon>=10&&yanson%2!=0&&setting==5)||(mon>=10&&setting!=5))
		sprintf(g+3,"%d/",mon);
		if((setting==6&&stop==1)&&yanson%2==0)
		{
			g[6]=' ';
			g[7]=' ';
			g[8]=' ';
			g[9]=' ';
			g[10]='\0';
		}
		else if(stop==0||(yanson%2!=0&&setting==6)||setting!=6)
		sprintf(g+6,"%d",year);
		glcd_text57(3,34,g,1,1);
		if(setting==7&&stop==1&&yanson%2==0)
		glcd_text57(37,55,"     ",1,1);
		else if(stop==0||(yanson%2!=0&&setting==7)||setting!=7)
		{
			switch(wday)
			{				   
				case 0:glcd_text57(4,44,"Pazar",1,1);
				break;
				case 1:glcd_text57(4,44,"Pazartesi",1,1);
				break;
				case 2:glcd_text57(4,44,"Sali",1,1);
				break;
				case 3:glcd_text57(4,44,"Carsamba",1,1);
				break;
				case 4:glcd_text57(4,44,"Persembe",1,1);
				break;
				case 5:glcd_text57(4,44,"Cuma",1,1);
				break;
				case 6:glcd_text57(4,44,"Cumartesi",1,1);
				break;
				default:
				break;
			}
		}
}

void start_timer(uint32_t wait)
{

	  LPC_TIM1->TCR=0x02;//reset timer
      LPC_TIM1->IR=0xFF;//tüm kesmeleri resetle
      LPC_TIM1->MR1=wait*24000;
      LPC_TIM1->MCR=1<<3;
      LPC_TIM1->TCR=0x01;//start timer
	  LPC_TIM1->PR=0x00;
	  NVIC_EnableIRQ(TIMER1_IRQn);
                    
}
void stop_timer(void)
{
	LPC_TIM1->TCR=2;
	NVIC_DisableIRQ(TIMER1_IRQn);
}
void TIMER1_IRQHandler(void)
{
	if(start_count==0)//ayarlama modunda degilken timer acilmissa
	{
		stop=1;
		setting=1;
		alarm_on=0;
		j=0;
		SysTickStart();
	}
	stop_timer();
	start=0;
}
void RTC_IRQHandler (void) 
{		
		if(LPC_RTC->ILR&0x01) //artis kesmesi olusmussa
		{	
		LPC_RTC->ILR|=1; //kesme bayragi temizle 
		
		if(pwm==1)//alarm 10 saniye boyunca çalacak
		{
			z++;
			if(z==10)
			{
				pwm_stop();
				z=0;
			}
		}
		clock_write();
	
		}	
		if((LPC_RTC->ILR)&0x02&&alarm_on==1)	// Alarm kesmesi olusmussa
		{
			LPC_RTC->ILR|=2;//kesme bayragi temizle
			pwm_start();
		    glcd_fillScreen(0);
			glcd_text57(30,20,"ALARM",2,1);
			
			SysTickStart();	
		}
		
}
void pll_hazirla(void)
{
	LPC_SC->SCS=0x20;
	LPC_SC->CLKSRCSEL=0x01;	//select main oscilator
	LPC_SC->CCLKCFG=0x03;	//pllclk/4
	LPC_SC->PLL0CON=0x01;	//pll activeted
	LPC_SC->PLL0CFG=0x20031; //msel=49,nsel=2;
	LPC_SC->PLL0FEED=0xAA;
    LPC_SC->PLL0FEED=0x55;
	while(!(LPC_SC->PLL0STAT&(1<<26)));
	LPC_SC->PLL0CON=0x07;
	LPC_SC->PLL0FEED=0xAA;
    LPC_SC->PLL0FEED=0x55;
	LPC_SC->PCLKSEL0=0;
}
void pwm_start(void)
{
	LPC_PINCON->PINSEL4|=1<<10;
	LPC_PWM1->MR0=25000000;//FREKANS=PCLK/25000000
	LPC_PWM1->MR6=10000000;//DUTY CYCLE=10/25
	LPC_PWM1->MCR=2;
	LPC_PWM1->PCR=1<<14;//PWM6 OUTPUT ENABLED
	LPC_PWM1->TCR=0x02;
	LPC_PWM1->LER=0x40;//MCR YAZILAN DEGER AKTIFLESTI
	LPC_PWM1->TCR=0x09;
	pwm=1;
}
void pwm_stop(void)
{
	LPC_PWM1->PCR=0;
	LPC_PWM1->TCR=0x00;
	pwm=0;
}
int main(void)
{
	int m1=0,m2=0,s=0;
	pll_hazirla();
	LPC_GPIO2->FIODIR=0xFF;
	LPC_GPIO2->FIOCLR=0xFF;
	LPC_GPIO0->FIODIR=0xFFFFFFFF;
	LPC_GPIO0->FIOCLR=0xFFFFFFFF;
	LPC_GPIO1->FIODIR=0xFFFFFFFF;
	LPC_GPIO1->FIOCLR=0xFFFFFFFF;
	LPC_GPIO1->FIODIR&=~((1<<25)|(1<<26)|(1<<27)|(1<<28)|(1<<29));//joystick icin 
	glcd_init();
	rtc_init();
	rtc_start();
	NVIC_EnableIRQ(RTC_IRQn);
	RTCAlarmMask(AMRDOM|AMRDOW|AMRDOY|AMRMON|AMRYEAR);//alarm'i sadece saat dakika ve saniye etkileyecek
	while(1)
	{				
	  	
	   if(!(LPC_GPIO1->FIOPIN&(1<<25))) //alarm time ya da local time secme
				{
					if(stop==1)
					setting=1;
					if(s==0)
					{
					   	select++;
						s=1;	
					}
				}
				else if((LPC_GPIO1->FIOPIN&(1<<25)))
				{
					s=0;
				}
	   if(stop==0)	//ayarlama modunda degilse
	   {
	   if(start==0)
	   {
		    if(!(LPC_GPIO2->FIOPIN&(1<<11)))//butonu basilmissa
			{
		    start_timer(1000);
		    start=1;
			start_count=0;
			}
	   }
	   else
	   {
		   	if((LPC_GPIO2->FIOPIN&(1<<11)))	//butona basilmamissa
			{
			stop_timer();
			start=0;
			}
		}
		}
		else if(stop==1)	//ayarlama modunda ise
		{
			if(!(LPC_GPIO1->FIOPIN&(1<<28)))//joystick saga hareket ettirilmisse
				{
					if(m2==0)
					{
						setting++;
						if(setting==8)
						{
						setting=1;
						}
						m2=1;	
					}
				}
			else if((LPC_GPIO1->FIOPIN&(1<<28)))
					{
						m2=0;
					}
			if(!(LPC_GPIO1->FIOPIN&(1<<27)))//joystick sola hareket ettirilmisse
				{
					if(m1==0)
					{
						setting--;
						if(setting==0)
						{
						setting=7;
						}
						m1=1;	
					}
				}
			else if((LPC_GPIO1->FIOPIN&(1<<27)))
					{
						m1=0;
					}		
			if(setting==1)//Saat ayari
			{
					
				if(!(LPC_GPIO1->FIOPIN&(1<<29)))
				{
						if(stop==0||(select%2==0&&stop==1))	//local time saat ayari artis
						{
							local_time.RTC_Hour=LPC_RTC->HOUR;
							local_time.RTC_Hour++;
							if(local_time.RTC_Hour==24)
							local_time.RTC_Hour=0;
							LPC_RTC->HOUR=local_time.RTC_Hour;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1)) //alarm time saat ayari artis
						{
							alarm_time.RTC_Hour=LPC_RTC->ALHOUR;
							alarm_time.RTC_Hour++;
							if(alarm_time.RTC_Hour==24)
							alarm_time.RTC_Hour=0;
							LPC_RTC->ALHOUR=alarm_time.RTC_Hour;
							DelayMs(0,400);
						}	
				}
					
					if(!(LPC_GPIO1->FIOPIN&(1<<26)))
					{
						if(stop==0||(select%2==0&&stop==1))
						{
							local_time.RTC_Hour=LPC_RTC->HOUR; //local time saat ayari azalis
							local_time.RTC_Hour--;
							if(local_time.RTC_Hour<0)
							local_time.RTC_Hour=23;
							LPC_RTC->HOUR=local_time.RTC_Hour;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1))
						{
							alarm_time.RTC_Hour=LPC_RTC->ALHOUR;//alarm time saat ayari azalis
							alarm_time.RTC_Hour--;
							if(local_time.RTC_Hour<0)
							alarm_time.RTC_Hour=23;
							LPC_RTC->ALHOUR=alarm_time.RTC_Hour;
							DelayMs(0,400);
						}
					}		
			}
			else if(setting==2)	//Dakika ayari
			{
				 
				if(!(LPC_GPIO1->FIOPIN&(1<<29)))
				{
						
						if(stop==0||(select%2==0&&stop==1)) //local time dakika ayari artis
						{
							local_time.RTC_Min=LPC_RTC->MIN;
							local_time.RTC_Min++;
							if(local_time.RTC_Min==60)
							local_time.RTC_Min=0;
							LPC_RTC->MIN=local_time.RTC_Min;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1))
						{
							alarm_time.RTC_Min=LPC_RTC->ALMIN; //alarm time dakika ayari artis
							alarm_time.RTC_Min++;
							if(alarm_time.RTC_Min==60)
							alarm_time.RTC_Min=0;
							LPC_RTC->ALMIN=alarm_time.RTC_Min;
							DelayMs(0,400);
						}
				}
				if(!(LPC_GPIO1->FIOPIN&(1<<26)))
				{
						if(stop==0||(select%2==0&&stop==1))	//local time dakika ayari azalis
						{
							local_time.RTC_Min=LPC_RTC->MIN;
							local_time.RTC_Min--;
							if(local_time.RTC_Min<0)
							local_time.RTC_Min=59;
							LPC_RTC->MIN=local_time.RTC_Min;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1))	//alarm time dakika ayari azalis
						{
							alarm_time.RTC_Min=LPC_RTC->ALMIN;
							alarm_time.RTC_Min--;
							if(local_time.RTC_Min<0)
							alarm_time.RTC_Min=59;
							LPC_RTC->ALMIN=alarm_time.RTC_Min;
							DelayMs(0,400);
						}
				}	
			}
			else if(setting==3)	//saniye ayari
			{
				if(!(LPC_GPIO1->FIOPIN&(1<<29)))
				{
						if(stop==0||(select%2==0&&stop==1))//local time saniye ayari artis
						{
							LPC_RTC->SEC=0;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1)) // alarm time saniye ayari artis
						{
							alarm_time.RTC_Sec=LPC_RTC->ALSEC;
							alarm_time.RTC_Sec++;
							if(alarm_time.RTC_Sec==60)
							alarm_time.RTC_Sec=0;
							LPC_RTC->ALSEC=alarm_time.RTC_Sec;
							DelayMs(0,400);
						}
				}
				if(!(LPC_GPIO1->FIOPIN&(1<<26)))
				{
						if(stop==0||(select%2==0&&stop==1))	//local time saniye ayari azalis
						{
							LPC_RTC->SEC=0;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1)) //alarm time saniye ayari azalis
						{
							alarm_time.RTC_Sec=LPC_RTC->ALSEC;
							alarm_time.RTC_Sec--;
							if(local_time.RTC_Sec<0)
							alarm_time.RTC_Sec=23;
							LPC_RTC->ALSEC=alarm_time.RTC_Sec;
							DelayMs(0,400);
						}
				}			
			}
			else if(setting==4)	 //ayin günü ayari
			{
				if(!(LPC_GPIO1->FIOPIN&(1<<29)))
				{
						if(stop==0||(select%2==0&&stop==1))
						{
							local_time.RTC_Mday=LPC_RTC->DOM; //local time ay gunu ayari artis
							local_time.RTC_Mday++;
							if(local_time.RTC_Mday==32)
							local_time.RTC_Mday=1;
							LPC_RTC->DOM=local_time.RTC_Mday;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1)) //alarm time ay gunu ayari artis
						{
							alarm_time.RTC_Mday=LPC_RTC->ALDOM;
							alarm_time.RTC_Mday++;
							if(alarm_time.RTC_Mday==32)
							alarm_time.RTC_Mday=1;
							LPC_RTC->ALDOM=alarm_time.RTC_Mday;
							DelayMs(0,400);
						}
				}
				if(!(LPC_GPIO1->FIOPIN&(1<<26)))
				{
						if(stop==0||(select%2==0&&stop==1))	//local time ay gunu ayari azalis
						{
							local_time.RTC_Mday=LPC_RTC->DOM;
							local_time.RTC_Mday--;
							if(local_time.RTC_Mday<0)
							local_time.RTC_Mday=31;
							LPC_RTC->DOM=local_time.RTC_Mday;
							clock_write();
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1))	// alarm time ay gunu ayari azalis
						{
							alarm_time.RTC_Mday=LPC_RTC->ALDOM;
							alarm_time.RTC_Mday--;
							if(local_time.RTC_Mday<0)
							alarm_time.RTC_Mday=31;
							LPC_RTC->ALDOM=alarm_time.RTC_Mday;
							DelayMs(0,400);
						}
				}			
			}
			else if(setting==5) //ay ayari
			{
				if(!(LPC_GPIO1->FIOPIN&(1<<29))) //local time ay ayari artis
				{
						if(stop==0||(select%2==0&&stop==1))
						{
							local_time.RTC_Mon=LPC_RTC->MONTH;
							local_time.RTC_Mon++;
							if(local_time.RTC_Mon==13)
							local_time.RTC_Mon=1;
							LPC_RTC->MONTH=local_time.RTC_Mon;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1))	//alarm time ay ayari artis
						{
							alarm_time.RTC_Mon=LPC_RTC->ALMON;
							alarm_time.RTC_Mon++;
							if(alarm_time.RTC_Mday==13)
							alarm_time.RTC_Mon=1;
							LPC_RTC->ALMON=alarm_time.RTC_Mon;
							clock_write();
							DelayMs(0,400);
						}
				}
				if(!(LPC_GPIO1->FIOPIN&(1<<26)))
				{
						if(stop==0||(select%2==0&&stop==1))	//local time ay ayari azalis
						{
							local_time.RTC_Mon=LPC_RTC->MONTH;
							local_time.RTC_Mon--;
							if(local_time.RTC_Mon==0)
							local_time.RTC_Mon=12;
							LPC_RTC->MONTH=local_time.RTC_Mon;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1))	//alarm time ay ayari azalis
						{
							alarm_time.RTC_Mon=LPC_RTC->ALMON;
							alarm_time.RTC_Mon--;
							if(local_time.RTC_Mon==0)
							alarm_time.RTC_Mon=12;
							LPC_RTC->ALMON=alarm_time.RTC_Mon;
							DelayMs(0,400);
						}
				}		
			}
			else if(setting==6)	//yil ayari
			{
				if(!(LPC_GPIO1->FIOPIN&(1<<29))) //local time yil ayari artis
				{
						if(stop==0||(select%2==0&&stop==1))
						{
							local_time.RTC_Year=LPC_RTC->YEAR;
							local_time.RTC_Year++;
							if(local_time.RTC_Year==2100)
							local_time.RTC_Year=2000;
							LPC_RTC->YEAR=local_time.RTC_Year;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1)) //alarm time yil ayari artis
						{
							alarm_time.RTC_Year=LPC_RTC->ALYEAR;
							alarm_time.RTC_Year++;
							if(alarm_time.RTC_Year==2100)
							alarm_time.RTC_Year=2000;
							LPC_RTC->ALYEAR=alarm_time.RTC_Year;
							DelayMs(0,400);
						}
				}
				if(!(LPC_GPIO1->FIOPIN&(1<<26)))//local time yil ayari azalis
				{
						if(stop==0||(select%2==0&&stop==1))
						{
							local_time.RTC_Year=LPC_RTC->YEAR;
							local_time.RTC_Year--;
							if(local_time.RTC_Year==1999)
							local_time.RTC_Year=2099;
							LPC_RTC->YEAR=local_time.RTC_Year;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1)) //alarm time yil ayari azalis
						{
							alarm_time.RTC_Year=LPC_RTC->ALYEAR;
							alarm_time.RTC_Year--;
							if(local_time.RTC_Year==1999)
							alarm_time.RTC_Year=2099;
							LPC_RTC->ALYEAR=alarm_time.RTC_Year;
							DelayMs(0,400);
						}
				}		
			}
				else if(setting==7)	  //haftanin gunu ayari
				{
				if(!(LPC_GPIO1->FIOPIN&(1<<29)))
				{
						if(stop==0||(select%2==0&&stop==1)) //local time haftanin gunu ayari artis
						{
							local_time.RTC_Wday=LPC_RTC->DOW;
							local_time.RTC_Wday++;
							if(local_time.RTC_Wday==7)
							local_time.RTC_Wday=0;
							LPC_RTC->DOW=local_time.RTC_Wday;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1))	//alarm time haftanin günü ayari artis
						{
							alarm_time.RTC_Wday=LPC_RTC->ALDOW;
							alarm_time.RTC_Wday++;
							if(alarm_time.RTC_Wday==7)
							alarm_time.RTC_Wday=0;
							LPC_RTC->ALDOW=alarm_time.RTC_Wday;
							DelayMs(0,400);
						}
				}
				if(!(LPC_GPIO1->FIOPIN&(1<<26))) //local time haftanin gunu ayari azalis
				{
						if(stop==0||(select%2==0&&stop==1))
						{
							local_time.RTC_Wday=LPC_RTC->DOW;
							local_time.RTC_Wday--;
							if(local_time.RTC_Wday<0)
							local_time.RTC_Wday=6;
							LPC_RTC->DOW=local_time.RTC_Wday;
							DelayMs(0,400);
						}
						if((select%2==1&&stop==1)) //alarm time haftanin gunu ayari azalis
						{
							alarm_time.RTC_Wday=LPC_RTC->ALDOW;
							alarm_time.RTC_Wday--;
							if(local_time.RTC_Wday<0)
							alarm_time.RTC_Wday=6;
							LPC_RTC->ALDOW=alarm_time.RTC_Wday;
							DelayMs(0,400);
						}
				}			
			}
			 if(!(LPC_GPIO2->FIOPIN&(1<<10))) //Ayarlama tamam
				{
					 	stop=0;
						setting=0;
						yanson=0;
						j=0;
						rtc_stop();
						alarm_on=1;
						SysTickStop();
						glcd_fillScreen(0);
						glcd_text57(17,15,"AYARLAMA",2,1);
						glcd_text57(8,35,"TAMAMLANDI",2,1);
						DelayMs(0,1000);
						rtc_start();
				}
	}
	   
	}
}

rtc.c:
#include <lpc17xx.h>
#include "yusuf_rtc.h"

void rtc_init(void)
{
	LPC_SC->PCONP |= (1 << 9);
	if(!(LPC_RTC->RTC_AUX)&(0x01<<4))
	{
       LPC_RTC->RTC_AUX|=0x01<<4;
	}
	LPC_RTC->AMR = 0;
  	LPC_RTC->CIIR = 1;
  	LPC_RTC->CCR = 0;
  	return;
}

void rtc_start(void)
{
	
	LPC_RTC->CCR|=0x01;
	LPC_RTC->ILR |= 0x03;

}

void rtc_restart(void)
{

	LPC_RTC->CCR|=0x02;
}

void rtc_stop(void)
{
	LPC_RTC->CCR=0;	

}
void RTCSetTime(RTC_TIME Time)
{
	LPC_RTC->SEC = Time.RTC_Sec;
    LPC_RTC->MIN = Time.RTC_Min;
  	LPC_RTC->HOUR = Time.RTC_Hour;
  	LPC_RTC->DOM = Time.RTC_Mday;
  	LPC_RTC->DOW = Time.RTC_Wday;
  	LPC_RTC->DOY = Time.RTC_Yday;
  	LPC_RTC->MONTH = Time.RTC_Mon;
  	LPC_RTC->YEAR = Time.RTC_Year;
}

RTC_TIME RTCGetTime(void)
{
	RTC_TIME LocalTime;
	
	LocalTime.RTC_Sec = LPC_RTC->SEC;
  	LocalTime.RTC_Min = LPC_RTC->MIN;
  	LocalTime.RTC_Hour = LPC_RTC->HOUR;
  	LocalTime.RTC_Mday = LPC_RTC->DOM;
  	LocalTime.RTC_Wday = LPC_RTC->DOW;
  	LocalTime.RTC_Yday = LPC_RTC->DOY;
  	LocalTime.RTC_Mon = LPC_RTC->MONTH;
  	LocalTime.RTC_Year = LPC_RTC->YEAR;
  	return ( LocalTime );    
}
void RTCSetAlarm(RTC_TIME Time)
{
	LPC_RTC->ALSEC = Time.RTC_Sec;
    LPC_RTC->ALMIN = Time.RTC_Min;
  	LPC_RTC->ALHOUR = Time.RTC_Hour;
  	LPC_RTC->ALDOM = Time.RTC_Mday;
  	LPC_RTC->ALDOW = Time.RTC_Wday;
  	LPC_RTC->ALDOY = Time.RTC_Yday;
  	LPC_RTC->ALMON = Time.RTC_Mon;
  	LPC_RTC->ALYEAR = Time.RTC_Year;
}
RTC_TIME RTCGetAlarmTime(void)
{
	RTC_TIME AlarmTime;
	
	AlarmTime.RTC_Sec = LPC_RTC->ALSEC;
  	AlarmTime.RTC_Min = LPC_RTC->ALMIN;
  	AlarmTime.RTC_Hour = LPC_RTC->ALHOUR;
  	AlarmTime.RTC_Mday = LPC_RTC->ALDOM;
  	AlarmTime.RTC_Wday = LPC_RTC->ALDOW;
  	AlarmTime.RTC_Yday = LPC_RTC->ALDOY;
  	AlarmTime.RTC_Mon = LPC_RTC->ALMON;
  	AlarmTime.RTC_Year = LPC_RTC->ALYEAR;
  	return ( AlarmTime );    
}
void RTCAlarmMask(uint32_t AlarmMask)
{
	LPC_RTC->AMR=AlarmMask;
}

rtc.h:
typedef struct{
	int RTC_Sec;
	int RTC_Min;
	int RTC_Hour;
	int RTC_Mday;
	int RTC_Year;
	int RTC_Mon;
	int RTC_Wday;
	int RTC_Yday;
}RTC_TIME;

#define AMRSEC 	0x01
#define AMRMIN 	0x02
#define AMRHOUR 0x04
#define AMRDOM  0x08
#define AMRDOW  0x10
#define AMRDOY  0x20
#define AMRMON  0x40
#define AMRYEAR 0x80

 
extern void rtc_init(void);
extern void rtc_start(void);
extern void rtc_restart(void);
extern void rtc_stop(void);
extern void RTCSetTime(RTC_TIME time);
extern RTC_TIME RTCGetTime(void);
extern RTC_TIME RTCGetAlarmTime(void);

delay.c:
#include <lpc17xx.h>
#include "yusuf_lpc17xx_delay.h"
void DelayMs(int timer_num,int bekle)
{
     if(timer_num==0)
     {
	 				
                     LPC_TIM0->TCR=0x02;//reset timer
                     LPC_TIM0->IR=0xFF;//tüm kesmeleri restle
                     LPC_TIM0->MR0=bekle*25000;
                     LPC_TIM0->MCR=0x04;
                     LPC_TIM0->TCR=0x01;//start timer
		             LPC_TIM0->PR=0x00;//prescalar deger.Örnegin 2 oldugunda her 3 tick de bir sayar.
                     while(LPC_TIM0->TCR&0x01);//tasana kadar bekle
     }
     if(timer_num==1)
     {
                     LPC_TIM1->TCR=0x02;
                     LPC_TIM1->IR=0xFF;
                     LPC_TIM1->MR0=bekle*25000;
                     LPC_TIM1->MCR=0x04;
                     LPC_TIM1->TCR=0x01;
                     while(LPC_TIM1->TCR&0x01);
     }
     return;
}
void DelayUs(int timer_num,int bekle)
{
     if(timer_num==0)
     {
                     LPC_TIM0->TCR=0x02;
                     LPC_TIM0->IR=0xFF;
                     LPC_TIM0->MR0=bekle*12;
                     LPC_TIM0->MCR=0x04;
                     LPC_TIM0->TCR=0x01;
                     while(LPC_TIM0->TCR&0x01);
     }
     if(timer_num==1)
     {
                     LPC_TIM1->TCR=0x02;
                     LPC_TIM1->IR=0xFF;
                     LPC_TIM1->MR0=bekle*25;
                     LPC_TIM1->MCR=0x04;
                     LPC_TIM1->TCR=0x01;
                     while(LPC_TIM1->TCR&0x01);
     }
     return;
}

Note:GPIO2.5 pinine buzzer bağlandığında alarm vakti gelince çalıyo fakat bu vdeoda buzzer bağlamadığım için sadece ekrana ALARM yazıyo.

Okan AKÇA

hocam cok güzel olmuş ama ilk yorum yapan ben oldum bi arm cılgınlıgı başlamıstı  gercekten arm ile ilgilenenler icin bulunmaz bir kaynak

M_B

@yamak hocam;
paylaşımınız ve projeniz icin tebrik ederim. ARM ye başlayanlar için guzel bir örnek.
Bende de LPC1768 kiti var ama henuz bir adım atamadım. İnşallah kısa zaman da onunla çalışmaya başlayacağım.

Hocam
yusuf_rtc.h
yusuf_lpc17xx_delay.h
lpc_glcd.h

bunlarıda paylaşabilirmisiniz.

Teşekkürler
İmkanın sınırlarını görmek için imkansızı denemek lazım.                                                             Fatih Sultan Mehmet

Kadir Can(16F84)


yamak

evet arkadaslar rtc.h yusuf_rtc.h. su an telefondan giriyorum nete bilgisayardan girdimde geri kalan kutuphane dosyalarini da paylasirim.

yamak

@ M_B
Uygulamanın geri kalan kütüphane dosyaları:

yusuf_lpc17xx_delay.h
extern void DelayMs(int timer_num,int bekle);
extern void DelayUs(int timer_num,int bekle) ;


lpc_glcd.c:
#include <lpc17xx.h>
#include <yusuf_lpc17xx_delay.h>
#include <lpc_glcd.h>
#include <string.h>
const unsigned char TEXT[51][5] ={0x00, 0x00, 0x00, 0x00, 0x00, // SPACE
                         0x00, 0x00, 0x5F, 0x00, 0x00, // !
                         0x00, 0x03, 0x00, 0x03, 0x00, // "
                         0x14, 0x3E, 0x14, 0x3E, 0x14, // #
                         0x24, 0x2A, 0x7F, 0x2A, 0x12, // $
                         0x43, 0x33, 0x08, 0x66, 0x61, // %
                         0x36, 0x49, 0x55, 0x22, 0x50, // &
                         0x00, 0x05, 0x03, 0x00, 0x00, // '
                         0x00, 0x1C, 0x22, 0x41, 0x00, // (
                         0x00, 0x41, 0x22, 0x1C, 0x00, // )
                         0x14, 0x08, 0x3E, 0x08, 0x14, // *
                         0x08, 0x08, 0x3E, 0x08, 0x08, // +
                         0x00, 0x50, 0x30, 0x00, 0x00, // ,
                         0x08, 0x08, 0x08, 0x08, 0x08, // -
                         0x00, 0x60, 0x60, 0x00, 0x00, // .
                         0x20, 0x10, 0x08, 0x04, 0x02, // /
                         0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
                         0x04, 0x02, 0x7F, 0x00, 0x00, // 1
                         0x42, 0x61, 0x51, 0x49, 0x46, // 2
                         0x22, 0x41, 0x49, 0x49, 0x36, // 3
                         0x18, 0x14, 0x12, 0x7F, 0x10, // 4
                         0x27, 0x45, 0x45, 0x45, 0x39, // 5
                         0x3E, 0x49, 0x49, 0x49, 0x32, // 6
                         0x01, 0x01, 0x71, 0x09, 0x07, // 7
                         0x36, 0x49, 0x49, 0x49, 0x36, // 8
                         0x26, 0x49, 0x49, 0x49, 0x3E, // 9
                         0x00, 0x36, 0x36, 0x00, 0x00, // :
                         0x00, 0x56, 0x36, 0x00, 0x00, // ;
                         0x08, 0x14, 0x22, 0x41, 0x00, // <
                         0x14, 0x14, 0x14, 0x14, 0x14, // =
                         0x00, 0x41, 0x22, 0x14, 0x08, // >
                         0x02, 0x01, 0x51, 0x09, 0x06, // ?
                         0x3E, 0x41, 0x59, 0x55, 0x5E, // @
                         0x7E, 0x09, 0x09, 0x09, 0x7E, // A
                         0x7F, 0x49, 0x49, 0x49, 0x36, // B
                         0x3E, 0x41, 0x41, 0x41, 0x22, // C
                         0x7F, 0x41, 0x41, 0x41, 0x3E, // D
                         0x7F, 0x49, 0x49, 0x49, 0x41, // E
                         0x7F, 0x09, 0x09, 0x09, 0x01, // F
                         0x3E, 0x41, 0x41, 0x49, 0x3A, // G
                         0x7F, 0x08, 0x08, 0x08, 0x7F, // H
                         0x00, 0x41, 0x7F, 0x41, 0x00, // I
                         0x30, 0x40, 0x40, 0x40, 0x3F, // J
                         0x7F, 0x08, 0x14, 0x22, 0x41, // K
                         0x7F, 0x40, 0x40, 0x40, 0x40, // L
                         0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
                         0x7F, 0x02, 0x04, 0x08, 0x7F, // N
                         0x3E, 0x41, 0x41, 0x41, 0x3E, // O
                         0x7F, 0x09, 0x09, 0x09, 0x06, // P
                         0x1E, 0x21, 0x21, 0x21, 0x5E, // Q
                         0x7F, 0x09, 0x09, 0x09, 0x76};// R

const unsigned char TEXT2[44][5]={0x26, 0x49, 0x49, 0x49, 0x32, // S
                         0x01, 0x01, 0x7F, 0x01, 0x01, // T
                         0x3F, 0x40, 0x40, 0x40, 0x3F, // U
                         0x1F, 0x20, 0x40, 0x20, 0x1F, // V
                         0x7F, 0x20, 0x10, 0x20, 0x7F, // W
                         0x41, 0x22, 0x1C, 0x22, 0x41, // X
                         0x07, 0x08, 0x70, 0x08, 0x07, // Y
                         0x61, 0x51, 0x49, 0x45, 0x43, // Z
                         0x00, 0x7F, 0x41, 0x00, 0x00, // [
                         0x02, 0x04, 0x08, 0x10, 0x20, // 
                         0x00, 0x00, 0x41, 0x7F, 0x00, // ]
                         0x04, 0x02, 0x01, 0x02, 0x04, // ^
                         0x40, 0x40, 0x40, 0x40, 0x40, // _
                         0x00, 0x01, 0x02, 0x04, 0x00, // `
                         0x20, 0x54, 0x54, 0x54, 0x78, // a
                         0x7F, 0x44, 0x44, 0x44, 0x38, // b
                         0x38, 0x44, 0x44, 0x44, 0x44, // c
                         0x38, 0x44, 0x44, 0x44, 0x7F, // d
                         0x38, 0x54, 0x54, 0x54, 0x18, // e
                         0x04, 0x04, 0x7E, 0x05, 0x05, // f
                         0x08, 0x54, 0x54, 0x54, 0x3C, // g
                         0x7F, 0x08, 0x04, 0x04, 0x78, // h
                         0x00, 0x44, 0x7D, 0x40, 0x00, // i
                         0x20, 0x40, 0x44, 0x3D, 0x00, // j
                         0x7F, 0x10, 0x28, 0x44, 0x00, // k
                         0x00, 0x41, 0x7F, 0x40, 0x00, // l
                         0x7C, 0x04, 0x78, 0x04, 0x78, // m
                         0x7C, 0x08, 0x04, 0x04, 0x78, // n
                         0x38, 0x44, 0x44, 0x44, 0x38, // o
                         0x7C, 0x14, 0x14, 0x14, 0x08, // p
                         0x08, 0x14, 0x14, 0x14, 0x7C, // q
                         0x00, 0x7C, 0x08, 0x04, 0x04, // r
                         0x48, 0x54, 0x54, 0x54, 0x20, // s
                         0x04, 0x04, 0x3F, 0x44, 0x44, // t
                         0x3C, 0x40, 0x40, 0x20, 0x7C, // u
                         0x1C, 0x20, 0x40, 0x20, 0x1C, // v
                         0x3C, 0x40, 0x30, 0x40, 0x3C, // w
                         0x44, 0x28, 0x10, 0x28, 0x44, // x
                         0x0C, 0x50, 0x50, 0x50, 0x3C, // y
                         0x44, 0x64, 0x54, 0x4C, 0x44, // z
                         0x00, 0x08, 0x36, 0x41, 0x41, // {
                         0x00, 0x00, 0x7F, 0x00, 0x00, // |
                         0x41, 0x41, 0x36, 0x08, 0x00, // }
                         0x02, 0x01, 0x02, 0x04, 0x02};// ~
void glcd_init(void)
{

   GLCD_RST(1);
   GLCD_EC(1);
   GLCD_CS1C(1);
   GLCD_CS2C(1);

   GLCD_DIC(1);                     
   glcd_writeByte(1, 0xC0);   
   glcd_writeByte(0, 0xC0);   
   glcd_writeByte(1, 0x40);   
   glcd_writeByte(0, 0x40);
   glcd_writeByte(1, 0xB8); 
   glcd_writeByte(0, 0xB8);
   
   glcd_writeByte(1, 0x3F);
   glcd_writeByte(0, 0x3F);

   glcd_fillScreen(0);         
}

void glcd_pixel(int x, int y, int color)
{
   int data;
   int chip = 0; 

   if(x > 63) 
   {
      x -= 64;
      chip = 1;
   }

   GLCD_DIC(1);                               
   x= x&0x7F;                                          
   x= x|0x40;                                          
   glcd_writeByte(chip, x);                             
   glcd_writeByte(chip, (y/8 & 0xBF) | 0xB8);   
   GLCD_DI(1); 
   glcd_readByte(chip);                                 
   data = glcd_readByte(chip);

   if(color == 1)
     data=data|(1<<(y%8));      
   else                     
      data= data&(~(1<<(y%8)));    
   GLCD_DIC(1);    
   glcd_writeByte(chip, x);     
   GLCD_DI(1);       
   glcd_writeByte(chip, data); 
}

void glcd_line(int x1, int y1, int x2, int y2, int color)
{
   signed int  x, y, addx, addy, dx, dy;
   signed long P;
   int i;
   if(x2>x1)
     dx=x2-x1;
   else
      dx=x1-x2;
   if(y2>y1)
      dy=y2-y1;
   else
      dy=y1-y2;
   x = x1;
   y = y1;

   if(x1 > x2)
      addx = -1;
   else
      addx = 1;
   if(y1 > y2)
      addy = -1;
   else
      addy = 1;

   if(dx >= dy)
   {
      P = 2*dy - dx;
      for(i=0; i<=dx; ++i)
      {
         glcd_pixel(x, y, color);

         if(P < 0)
         {
            P += 2*dy;
            x += addx;
         }
         else
         {
            P += 2*dy - 2*dx;
            x += addx;
            y += addy;
         }
      }
   }
   else
   {
      P = 2*dx - dy;
      for(i=0; i<=dy; ++i)
      {
         glcd_pixel(x, y, color);

         if(P < 0)
         {
            P += 2*dx;
            y += addy;
         }
         else
         {
            P += 2*dx - 2*dy;
            x += addx;
            y += addy;
         }
      }
   }
}
void glcd_rect(int x1, int y1, int x2, int y2, int fill, int color)
{
   if(fill)
   {
      int ymin, ymax;
      int xmin,xmax,i,j;
      if(x1<x2)
      {
	xmin=x1;
        xmax=x2;
      }                         
      else
      {
	xmin=x2;
        xmax=x1;
      }
      if(y1 < y2)
      {
         ymin = y1;
         ymax = y2;
      }
      else
      {
         ymin = y2;
         ymax = y1;
      }
      for(j=xmin;j<=xmax;++j)
      {
      for(i=ymin;i<=ymax;++i) 
         {              
         glcd_pixel(j,i,color);
         }
       }
    }
   else
   {
      glcd_line(x1, y1, x2, y1, color);   
      glcd_line(x1, y2, x2, y2, color);
      glcd_line(x1, y1, x1, y2, color);
      glcd_line(x2, y1, x2, y2, color);
   }
}

void glcd_bar(int x1, int y1, int x2, int y2, int width, int color)
{
   signed int  x, y, addx, addy, j;
   signed long P, dx, dy, c1, c2;
   int i;
   if(x2>x1)
   dx=x2-x1;
   else
   dx=x1-x2;
   if(y2>y1)
   dy=y2-y1;
   else
   dy=y1-y2;
   
   x = x1;
   y = y1;
   c1 = -dx*x1 - dy*y1;
   c2 = -dx*x2 - dy*y2;

   if(x1 > x2)
   {
      addx = -1;
      c1 = -dx*x2 - dy*y2;
      c2 = -dx*x1 - dy*y1;
   }
   else
      addx = 1;
   if(y1 > y2)
   {
      addy = -1;
      c1 = -dx*x2 - dy*y2;
      c2 = -dx*x1 - dy*y1;
   }
   else
      addy = 1;

   if(dx >= dy)
   {
      P = 2*dy - dx;

      for(i=0; i<=dx; ++i)
      {
         for(j=-(width/2); j<width/2+width%2; ++j)
         {
            if(dx*x+dy*(y+j)+c1 >= 0 && dx*x+dy*(y+j)+c2 <=0)
               glcd_pixel(x, y+j, color);
         }
         if(P < 0)
         {
            P += 2*dy;
            x += addx;
         }
         else
         {
            P += 2*dy - 2*dx;
            x += addx;
            y += addy;
         }
      }
   }
   else
   {
      P = 2*dx - dy;

      for(i=0; i<=dy; ++i)
      {
         if(P < 0)
         {
            P += 2*dx;
            y += addy;
         }
         else
         {
            P += 2*dx - 2*dy;
            x += addx;
            y += addy;
         }
         for(j=-(width/2); j<width/2+width%2; ++j)
         {
            if(dx*x+dy*(y+j)+c1 >= 0 && dx*x+dy*(y+j)+c2 <=0)
               glcd_pixel(x+j, y, color);
         }
      }
   }
}

void glcd_circle(int x, int y, int radius, int fill, int color)
{
   signed int a, b, P;
   a = 0;
   b = radius;
   P = 1 - radius;

   do
   {
      if(fill)
      {
         glcd_line(x-a, y+b, x+a, y+b, color);
         glcd_line(x-a, y-b, x+a, y-b, color);
         glcd_line(x-b, y+a, x+b, y+a, color);
         glcd_line(x-b, y-a, x+b, y-a, color);
      }
      else
      {
         glcd_pixel(a+x, b+y, color);
         glcd_pixel(b+x, a+y, color);
         glcd_pixel(x-a, b+y, color);
         glcd_pixel(x-b, a+y, color);
         glcd_pixel(b+x, y-a, color);
         glcd_pixel(a+x, y-b, color);
         glcd_pixel(x-a, y-b, color);
         glcd_pixel(x-b, y-a, color);
      }

      if(P < 0)
         P+= 3 + 2*a++;
      else
         P+= 5 + 2*(a++ - b--);
    } while(a <= b);
}

void glcd_fillScreen(unsigned char color)
{
   unsigned char i, j;
   for(i = 0; i < 8; i++)
   {
      GLCD_DIC(1);                   
      glcd_writeByte(1, 0x40);   
      glcd_writeByte(0, 0x40);
      glcd_writeByte(1, i | 0xB8); 
      glcd_writeByte(0, i | 0xB8);
      GLCD_DI(1);                   
      for(j = 0; j < 64; j++)
      {
         glcd_writeByte(1, 0xFF*color);
         glcd_writeByte(0, 0xFF*color);
      }
   }
}
void glcd_text57(int x, int y, char* textptr, int size, int color)
{
   int i, j, k, l, m;                   
   unsigned char pixelData[5];              

   for(i=0; textptr[i] != '\0'; ++i, ++x)
   {
      if(textptr[i] < 'S') 
         memcpy(pixelData, TEXT[textptr[i]-' '], 5);
      else if(textptr[i] <= '~') 
         memcpy(pixelData, TEXT2[textptr[i]-'S'], 5);
      else
         memcpy(pixelData, TEXT[0], 5);  

      if(x+5*size >= GLCD_WIDTH)       
      {
         x = 0;                         
         y += 7*size + 1;                
      }
      for(j=0; j<5; ++j, x+=size)        
      {
         for(k=0; k<7*size; ++k)      
         {
            if((pixelData[j]&(1<<k))>>k==1)
            {
               for(l=0; l<size; ++l)     
               {                       
                  for(m=0; m<size; ++m)
                  {
                     glcd_pixel(x+m, y+k*size+l, color); 
                  }
               }
            }
         }
      }
   }
}

void glcd_writeByte(int chip, unsigned char data)
{
   if(chip == 1)   
     { 
      GLCD_CS1(1);
      GLCD_CS2C(1);
     }
   else
      {
      GLCD_CS2(1);
      GLCD_CS1C(1);
      }
   DelayUs(0,1);//****
   GLCD_RWC(1);
   DelayUs(0,1);//****    
   LPC_GPIO0->FIOCLR=0xFFFFFFFF;
   LPC_GPIO0->FIOSET=data<<15;          
   GLCD_E(1);     
   DelayUs(0,1);
   GLCD_EC(1);
   GLCD_CS1C(1);      
   GLCD_CS2C(1);
}
unsigned char glcd_readByte(int chip)
{
   unsigned char data; 
   LPC_GPIO0->FIODIR=0x0000;
   DelayUs(0,1);
   GLCD_RW(1);
   if(chip == 1)       
     { 
      GLCD_CS1(1);
      GLCD_CS2C(1);
     }
   else
      {
      GLCD_CS2(1);
      GLCD_CS1C(1);
      }
   DelayUs(0,1);
   GLCD_E(1);      
   DelayUs(0,1);
   data = ((LPC_GPIO0->FIOPIN>>15)&(0xFF));
   GLCD_EC(1);
   LPC_GPIO0->FIODIR=0xFFFFFFFF;
   GLCD_CS1C(1);     
   GLCD_CS2C(1);
   return (data);         
}


lpc_glcd.h:
#define GLCD_WIDTH  128  
#define GLCD_HEIGTH 64

#define ON  1
#define OFF 0

#define YES 1
#define NO  0

#define GLCD_CS1(a) (LPC_GPIO1->FIOSET=a<<19)   // Chip Selection 1
#define GLCD_CS1C(a) (LPC_GPIO1->FIOCLR=a<<19)

#define GLCD_CS2(a) (LPC_GPIO1->FIOSET=a<<20)   // Chip Selection 2
#define GLCD_CS2C(a) (LPC_GPIO1->FIOCLR=a<<20)

#define GLCD_DI(a)  (LPC_GPIO1->FIOSET=a<<21)   // Data or Instruction input
#define GLCD_DIC(a)  (LPC_GPIO1->FIOCLR=a<<21)

#define GLCD_RW(a)  (LPC_GPIO1->FIOSET=a<<24)  // Read/Write
#define GLCD_RWC(a)  (LPC_GPIO1->FIOCLR=a<<24)

#define GLCD_E(a)   (LPC_GPIO1->FIOSET=a<<23)   // Enable
#define GLCD_EC(a)   (LPC_GPIO1->FIOCLR=a<<23)

#define GLCD_RST(a) (LPC_GPIO1->FIOSET=a<<25)
#define GLCD_RSTC(a) (LPC_GPIO1->FIOCLR=a<<25)   // Reset*/	

extern void glcd_init(void);
extern void glcd_pixel(int x,int y,int color);
extern void glcd_line(int x1,int y1,int x2,int y2,int color);
extern void glcd_rect(int x1,int y1,int x2,int y2,int fill,int color);
extern void glcd_bar(int x1,int y1,int x2,int y2,int width,int color);
extern void glcd_circle(int x,int y,int radius,int fill,int color);
extern void glcd_text57(int x,int y,char *textptr,int size,int color);
extern void glcd_fillScreen(unsigned char color);
extern void glcd_writeByte(int chip,unsigned char data);
unsigned char glcd_readByte(int chip);


M_B

İmkanın sınırlarını görmek için imkansızı denemek lazım.                                                             Fatih Sultan Mehmet

buzkırıcı

Çok Teşekkürler. Çok güzel bir paylaşım..
İmza Atmayı bilmem Parnak Bassam olur mu?

Mujdat117

hocam tebrik ederim çok güzel bir uygulama olmuş insanın iştahını kabartıyo  :D
Ayinesi iştir kişinin lâfa bakılmaz.Şahsın görünür rütbe-i aklı eserinde

-Hasan-

Hocam süper süper süper olmuş.  :D Tebrikler, ARM için çok güzel bir örnek.

Murat Mert

Hasan Arm sende iyice ısınmaya başladı :D
mert07

-Hasan-

Alıntı yapılan: mert07 - 20 Kasım 2011, 15:54:43
Hasan Arm sende iyice ısınmaya başladı :D

Aynen öyle hocam.  :) Bir ARM öğrenme çılgınlığı aldı başını gidiyor bende.  :D

yamak

Alıntı yapılan: -Hasan- - 20 Kasım 2011, 17:30:00
Aynen öyle hocam.  :) Bir ARM öğrenme çılgınlığı aldı başını gidiyor bende.  :D
Hangi mcu yu kullanıyosunuz?

-Hasan-

Hocam yanlış anladınız galiba. ARM öğrenme hevesi demek istemiştim. ARM ' lar bayağı ilgimi çekiyor da o yüzden öyle söyledim.  :) STM32 kitlerini bekliyorum başlamak için. Ama siz bu işi çözmüşsünüz hocam. Tebrik ederim.

yamak

Yok ya benim de kendimi eksik hissettiğim bayaa yerler var. Öğrenecek daha çok şey var.Hem sen niye dert ediyon yaşın daha küçük benim yaşıma kadar neler öğrenirsin neler :)