STM32F407 Discovery Kitle 3310 Lcd ve DS18B20 uygulaması

Başlatan M_B, 16 Ocak 2013, 12:12:16

M_B

STM32F407 kitle 3310 ve DS18B20 uygulaması


main.c

#include "stm32f4xx.h"
#include "3310.h"
#include "delay.h"
#include "ds18b20.h" 
#include "stdio.h"




GPIO_InitTypeDef GPIO_InitStructure;
void TimingDelay_Decrement(void);
void Delay(__IO uint32_t nTime);
static __IO uint32_t TimingDelay;


float sicaklik;
char buffer1[16];

#define MESSAGE2   "STM32F4 kitle " 
#define MESSAGE3   "   DS18B20     "
#define MESSAGE4   " Uygulamasi  "

int main(void)
{
  
 	SysTick_Config(SystemCoreClock/ 1000);
 

 

   		Lcd_init();             							
   		LCD_clean_ddram();    								
			LCD_gotoxy(0,0);   
			LCD_printstr("* Mehmet 2013 ",2);  	
			Delay(500);	Delay(500);	Delay(500);
	
			LCD_clean_ddram();									
   		LCD_rect(10,10,74,38,1);			// Kare 
	
	
	
 	  	Delay(500);	Delay(500);	Delay(500);
   		LCD_gotoxy(0,0);   
			LCD_printstr("DS18B20 Uygula",1);  	
	  	LCD_circle(42,24,12,1);	 // Daire ciziyor
			LCD_gotoxy(0,5);   
			LCD_printstr("** M_B 2013 ** ",2);  
	  	Delay(500);	Delay(500);	Delay(500);
   
			LCD_clean_ddram(); 
			LCD_gotoxy(0,0); 
		  LCD_printstr( MESSAGE2,1);     
			LCD_printstr( MESSAGE3,1);     
			LCD_printstr( MESSAGE4,1);     
    
  		while (1)
  					{
					sicaklik=ds18b20_read();
					if(sicaklik>4095)
								{
									LCD_gotoxy(0,4); 
									sprintf(buffer1,"Sensor Yok");
									LCD_printstr(buffer1 ,2);     
								}
					else
							{
							LCD_gotoxy(0,4); 
							sprintf(buffer1,"Sicaklik:%3.1f",sicaklik);
							LCD_printstr(buffer1,3);     
							}


        
  					}	// While sonu.
} // main sonu.



void Delay(__IO uint32_t nTime)
{ 
  TimingDelay = nTime;

  while(TimingDelay != 0);
}


void TimingDelay_Decrement(void)
{
  if (TimingDelay != 0x00)
  { 
    TimingDelay--;
  }
}

#ifdef  USE_FULL_ASSERT


void assert_failed(uint8_t* file, uint32_t line)
{ 

  while (1)
  {
  }
}
#endif


DS18B20.c
#ifndef	__DS18B20_C_
#define	__DS18B20_C_

#include "stm32f4xx.h"
#include "ds18b20.h"
#include "stdio.h"
#include <string.h>
#include "delay.h"





#define	in  1
#define out 0

// GPIO_InitTypeDef GPIO_InitStructure;



void DelayUss(u32 t)	
{
	t*=6;			 // 32 Mhz DelayUs
	while(t--);
}



/******************************************************************************
*******************************************************************************/

/*
void init_port (void)
{	

 
  GPIO_InitStructure.GPIO_Pin = RES_PIN | SCE_PIN | DC_PIN |SDIN_PIN |SCLK_PIN ; Ok
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
}
*/

/***********************************************************************************
***********************************************************************************/

void TRIS_PIN(char x)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
	
    GPIO_InitStructure.GPIO_Pin = DQ_PIN;
		GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;	
  	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	
	
if(!x)
  	{
		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
		GPIO_Init(DQ_GPIO_PORT, &GPIO_InitStructure);
	}
else 
  	{GPIO_InitStructure.GPIO_Mode =  GPIO_Mode_IN ;}
  	GPIO_Init(DQ_GPIO_PORT, &GPIO_InitStructure);
}



void onewire_reset(void)
{
    TRIS_PIN(out);
    DQ_PIN_WRITE(0)
	delay_us(480);
    TRIS_PIN(in);
	delay_us(400);
    TRIS_PIN(out);
}

void onewire_write(char data)
{
    unsigned char i, bitshifter;
    bitshifter = 1;
    for (i=0; i<8; i++)
    {
        if (data & bitshifter)
        {
            TRIS_PIN(out);
            DQ_PIN_WRITE(0)
          delay_us(3);
            TRIS_PIN(in);
          delay_us(60);
        }
        else
        {
            TRIS_PIN(out);
            DQ_PIN_WRITE(0)
           delay_us(60);
            TRIS_PIN(in);
        }
	bitshifter = bitshifter<<1;
    }
}

unsigned char onewire_read( void )
{
    unsigned char i;
    unsigned char data, bitshifter;
    data = 0; bitshifter = 1;
    for (i=0; i<8; i++)
    {
        TRIS_PIN(out);
        DQ_PIN_WRITE(0)
      delay_us(6);
        TRIS_PIN(in);
      delay_us(4);
        if (DQ_PIN_READ)
            data |= bitshifter;
       delay_us(50);
        bitshifter = bitshifter<<1;
    }
    return data;
}

float ds18b20_read(void)
{
    int busy,sayi1,sayi2;
    float result;
    onewire_reset();
    onewire_write(0xCC);
    onewire_write(0x44);

    while(busy==0)
        busy=onewire_read();

    onewire_reset();
    onewire_write(0xCC);
    onewire_write(0xBE);
    sayi1 = onewire_read();
    sayi2 = onewire_read();

    result=sayi2*256+sayi1;
    result=result/16.0;   

    delay_ms(250); // DelayMs(250);
    return result;
}

//----------------------------------------------------------------------------//
#endif


DS18b20.h
#ifndef	__DS18B20_H_
#define	__DS18B20_H_
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

#define DQ_PIN	                       GPIO_Pin_11		  
#define DQ_GPIO_PORT                   GPIOC
#define DQ_GPIO_CLK                    RCC_AHB1Periph_GPIOC  



#define DQ_PIN_WRITE(x) ((x) ? (GPIO_SetBits(DQ_GPIO_PORT,DQ_PIN))  : (GPIO_ResetBits(DQ_GPIO_PORT,DQ_PIN)) );
#define DQ_PIN_READ 		((GPIO_ReadInputDataBit(DQ_GPIO_PORT,DQ_PIN))&0x01)

extern void onewire_reset(void);
extern void onewire_write(char data);
extern unsigned char onewire_read( void );
extern float ds18b20_read(void);

#endif


3310.c
#ifndef	__3310_C_
#define	__3310_C_

#include "stm32f4xx.h"
#include "3310.h"
#include "stdio.h"
#include <string.h>

static vu32 TimingDelay;




/**************************************************************************
			Table de caracteres ASCII
			5 unsigned char par caractere.
**************************************************************************/

const unsigned char ASCII_TABLE [490]={
                        0x00,0x00,0x00,0x00,0x00,	// 20 space
						0x00,0x00,0x5f,0x00,0x00,	// 21 !
						0x00,0x07,0x00,0x07,0x00,	// 22 "
						0x14,0x7f,0x14,0x7f,0x14,	// 23 #
						0x24,0x2a,0x7f,0x2a,0x12,	// 24 $
						0x23,0x13,0x08,0x64,0x62,	// 25 %
						0x36,0x49,0x55,0x22,0x50,	// 26 &
						0x00,0x05,0x03,0x00,0x00,	// 27 '
						0x00,0x1c,0x22,0x41,0x00,	// 28 (
						0x00,0x41,0x22,0x1c,0x00,	// 29 )
						0x14,0x08,0x3e,0x08,0x14,	// 2a *
						0x08,0x08,0x3e,0x08,0x08,	// 2b +
						0x00,0x50,0x30,0x00,0x00,	// 2c ,
						0x08,0x08,0x08,0x08,0x08,	// 2d -
						0x00,0x60,0x60,0x00,0x00,	// 2e .
						0x20,0x10,0x08,0x04,0x02,	// 2f /
						0x3e,0x51,0x49,0x45,0x3e,	// 30 0
						0x00,0x42,0x7f,0x40,0x00,	// 31 1
						0x42,0x61,0x51,0x49,0x46,	// 32 2
						0x21,0x41,0x45,0x4b,0x31,	// 33 3
						0x18,0x14,0x12,0x7f,0x10,	// 34 4
						0x27,0x45,0x45,0x45,0x39,	// 35 5
						0x3c,0x4a,0x49,0x49,0x30,	// 36 6
						0x01,0x71,0x09,0x05,0x03,	// 37 7
						0x36,0x49,0x49,0x49,0x36,	// 38 8
						0x06,0x49,0x49,0x29,0x1e,	// 39 9
						0x00,0x36,0x36,0x00,0x00,	// 3a :
						0x00,0x56,0x36,0x00,0x00,	// 3b ;
						0x08,0x14,0x22,0x41,0x00,	// 3c <
						0x14,0x14,0x14,0x14,0x14,	// 3d =
						0x00,0x41,0x22,0x14,0x08,	// 3e >
						0x02,0x01,0x51,0x09,0x06,	// 3f ?
						0x32,0x49,0x79,0x41,0x3e,	// 40 @
						0x7e,0x11,0x11,0x11,0x7e,	// 41 A
						0x7f,0x49,0x49,0x49,0x36,	// 42 B
						0x3e,0x41,0x41,0x41,0x22,	// 43 C
						0x7f,0x41,0x41,0x22,0x1c,	// 44 D
						0x7f,0x49,0x49,0x49,0x41,	// 45 E
						0x7f,0x09,0x09,0x09,0x01,	// 46 F
						0x3e,0x41,0x49,0x49,0x7a,	// 47 G
						0x7f,0x08,0x08,0x08,0x7f,	// 48 H
						0x00,0x41,0x7f,0x41,0x00,	// 49 I
						0x20,0x40,0x41,0x3f,0x01,	// 4a J
						0x7f,0x08,0x14,0x22,0x41,	// 4b K
						0x7f,0x40,0x40,0x40,0x40,	// 4c L
						0x7f,0x02,0x0c,0x02,0x7f,	// 4d M
						0x7f,0x04,0x08,0x10,0x7f,	// 4e N
						0x3e,0x41,0x41,0x41,0x3e,	// 4f O
            			0x7f,0x09,0x09,0x09,0x06,	// 50 P
						0x3e,0x41,0x51,0x21,0x5e,	// 51 Q
						0x7f,0x09,0x19,0x29,0x46,	// 52 R
						0x46,0x49,0x49,0x49,0x31,	// 53 S
						0x01,0x01,0x7f,0x01,0x01,	// 54 T
						0x3f,0x40,0x40,0x40,0x3f,	// 55 U
						0x1f,0x20,0x40,0x20,0x1f,	// 56 V
						0x3f,0x40,0x38,0x40,0x3f,	// 57 W
						0x63,0x14,0x08,0x14,0x63,	// 58 X
						0x07,0x08,0x70,0x08,0x07,	// 59 Y
						0x61,0x51,0x49,0x45,0x43,	// 5a Z
						0x00,0x7f,0x41,0x41,0x00,	// 5b [
						0x02,0x04,0x08,0x10,0x20,	// 5c
						0x00,0x41,0x41,0x7f,0x00,	// 5d
						0x04,0x02,0x01,0x02,0x04,	// 5e
						0x40,0x40,0x40,0x40,0x40,	// 5f
						0x00,0x01,0x02,0x04,0x00,	// 60
						0x20,0x54,0x54,0x54,0x78,	// 61 a
						0x7f,0x48,0x44,0x44,0x38,	// 62 b
						0x38,0x44,0x44,0x44,0x20,	// 63 c
						0x38,0x44,0x44,0x48,0x7f,	// 64 d
						0x38,0x54,0x54,0x54,0x18,	// 65 e
						0x08,0x7e,0x09,0x01,0x02,	// 66 f
						0x0c,0x52,0x52,0x52,0x3e,	// 67 g
						0x7f,0x08,0x04,0x04,0x78,	// 68 h
						0x00,0x44,0x7d,0x40,0x00,	// 69 i
						0x20,0x40,0x44,0x3d,0x00,	// 6a j
						0x7f,0x10,0x28,0x44,0x00,	// 6b k
						0x00,0x41,0x7f,0x40,0x00,	// 6c l
						0x7c,0x04,0x18,0x04,0x78,	// 6d m
						0x7c,0x08,0x04,0x04,0x78,	// 6e n
						0x38,0x44,0x44,0x44,0x38,	// 6f o
						0x7c,0x14,0x14,0x14,0x08,	// 70 p
						0x08,0x14,0x14,0x18,0x7c,	// 71 q
						0x7c,0x08,0x04,0x04,0x08,	// 72 r
						0x48,0x54,0x54,0x54,0x20,	// 73 s
						0x04,0x3f,0x44,0x40,0x20,	// 74 t
						0x3c,0x40,0x40,0x20,0x7c,	// 75 u
						0x1c,0x20,0x40,0x20,0x1c,	// 76 v
						0x3c,0x40,0x30,0x40,0x3c,	// 77 w
						0x44,0x28,0x10,0x28,0x44,	// 78 x
						0x0c,0x50,0x50,0x50,0x3c,	// 79 y
						0x44,0x64,0x54,0x4c,0x44,	// 7a z
						0x00,0x08,0x36,0x41,0x00,	// 7b
						0x00,0x00,0x7f,0x00,0x00,	// 7c
						0x00,0x41,0x36,0x08,0x00,	// 7d
						0x10,0x08,0x08,0x10,0x08,	// 7e
						0x78,0x46,0x41,0x46,0x78, // 7F
            0x7C,0x09,0x05,0x05,0x78, // 80 -> ñ
            0x7E,0x05,0x09,0x11,0x7E  // 81 -> Ñ
																	};	// 7f


static unsigned char  LcdCache [504];
static unsigned int   LcdPos = 0;


//----------------------------------------------------------------------------//
void DelayUs(u32 nTime)
{
    uint32_t n;  
  	
    TimingDelay = nTime;

  	while(TimingDelay-- != 0)
  	{
  		for (n = 0; n < 15;n++);
  	};
}
//----------------------------------------------------------------------------//

void DelayMs(u32 nTime)
{
    uint32_t n;  
  	
    TimingDelay = nTime;

  	while(TimingDelay-- != 0)
  	{
  		for (n = 0; n < 10000;n++);
  	};
}
//----------------------------------------------------------------------------//

void LCD_write_dorc(unsigned char bytefornokia)
{
char caa;
   for (caa=8;caa>0;caa--) 
		{
		nok_sclk(0)
		DelayUs(1);
		if ((bytefornokia&0x80)==0) 
				{
				nok_sda(0)
				}
				else {
					 nok_sda(1)
					 }
		nok_sclk(1)
		bytefornokia=bytefornokia<<1;
		}
}


/***********************************************************************************************
							 Envois des donnée serie a l'Ecran

***********************************************************************************************/
void LCD_write_data(unsigned char byteforLCD_data)
{
   nok_dc(1)
   nok_cs(0)							// chip activé
   LCD_write_dorc(byteforLCD_data);     // routine d'envois des bits en serie
   nok_cs(1)							// chip desactivé
}



/***********************************************************************************************
						 Execute une commande

***********************************************************************************************/
void LCD_write_command(unsigned char byteforLCD_command)
{
   nok_dc(0)							// unsigned char is a command it is read with the eight SCLK pulse
   nok_cs(0)							// chip activé
   LCD_write_dorc(byteforLCD_command);
   nok_cs(1)							// chip desactivé
}


/***********************************************************************************************
					Afficher le caractere passé à l'ecran

***********************************************************************************************/
void LCD_printchar(unsigned char caracter,unsigned int charMode)
{
unsigned char char_row;
unsigned int charpos,chardata;

   if(caracter==0xF1) caracter=0x80;
   else if(caracter==0xD1) caracter=0x81;
   else if (caracter<0x20) return;
   else if (caracter>0x7f) return;

   for (char_row=0;char_row<5;char_row++) 					// 5 unsigned chars par caractere
	  {           								  
      charpos=(((caracter&0xff)-0x20)*5)+char_row;
      chardata=ASCII_TABLE[charpos];
	  if (charMode == 0) LcdCache[LcdPos] &= chardata;		// Mise en memoire graphique
   	  if (charMode == 1) LcdCache[LcdPos] |= chardata;
	  if (charMode == 2) LcdCache[LcdPos] ^= chardata;
	  LcdPos += 1;											// incremente position en memoire graphique
      LCD_write_data(chardata);                 			// affiche une partie du caractere
      }
   LCD_write_data(0x00);                        			// un espace blanc(separation des caracteres)
  // LcdCache[LcdPos]=0x00;									// Mise en memoire graphique
   if (charMode == 0) LcdCache[LcdPos] &= 0x00;     		// Mise en memoire graphique
   if (charMode == 1) LcdCache[LcdPos] |= 0x00;
   if (charMode == 2) LcdCache[LcdPos] ^= 0x00;
   LcdPos += 1;												// incremente position en memoire graphique
}
/***************************************************************************************

***************************************************************************************/

void LCD_printstr(const char *str,unsigned int charMode)
{
	while(*str!=0) {
		LCD_printchar(*str,charMode);
		str++;
	}
//	LCD_redraw();
}


/***********************************************************************************************
				 Positionnement du curseur sur l'Ecran

***********************************************************************************************/
void LCD_gotoxy(unsigned char xnokia, unsigned char ynokia)
{
		LCD_write_command(0x40|(ynokia&0x07));				// Y axe initialisation: 0100 0yyy
		LCD_write_command(0x80|(xnokia&0x7f));				// X axe initialisation: 1xxx xxxx
		LcdPos = (xnokia * 6) + (ynokia * 84);
}


/***********************************************************************************************
			 Effacer la RAM Ecran

***********************************************************************************************/
void LCD_clean_ddram(void)
{
int ddram;  
unsigned int a;

   LCD_gotoxy(0,0);                  		// Retour a l'origine
   for (ddram=504;ddram>0;ddram--) {   		// boucle de remplissage de la memoire en 0x00
      LCD_write_data(0x00);
   }
   for (a=0;a<=503;a++){LcdCache[a]=0x00;} 	// Efface le cache Ecran
}



void init_port (void)
{	
 GPIO_InitTypeDef  GPIO_InitStructure;
  
  /* Enable the GPIO_LED Clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

  /* Configure the GPIO_LED pin */
  GPIO_InitStructure.GPIO_Pin = RES_PIN | SCE_PIN | DC_PIN |SDIN_PIN |SCLK_PIN ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_InitStructure);
}

/***********************************************************************************************
				 Initialisatinn de l'ecran
***********************************************************************************************/
void Lcd_init(void) {
    unsigned int a;

	init_port();


  DelayUs(200);       	    // Petit delais de securité
	nok_dc(1)				    // Destino de unsigned chars -> RAM
	nok_cs(1)				    // Désactive l'ecran pour l'initialisation
  DelayMs(10);
	nok_res(0)				    // Une impulsion de Reset comme sur le datasheet
	DelayMs(250);			    // durant 250 mS
	nok_res(1)
	LCD_write_command(0x21);	// Active les commandes etendues
	LCD_write_command(0xC8);  //0x90);	// Defini le Vop. Etabli la tension interne (Contraste)
	LCD_write_command(0x13);	// bias 13. Min 10 Max 17
	LCD_write_command(0x20);	// Mode Horizontal, s'incremente automatiquement
  LCD_write_command(0x0C);  //0x09);	// all on
	DelayMs(50);
	LCD_clean_ddram();        // Efface la RAM
	DelayMs(10);
	LCD_write_command(0x0C);	// Active les commandes normales
  for (a=0;a<=503;a++){LcdCache[a]=0x00;} 	// Efface le cache Ecran
}

/***********************************************************************************************
					 Trace un Pixel sur l'Ecran	 
/***********************************************************************************************/
void LCD_pixel(unsigned char pixelX,unsigned char pixelY,unsigned char pixelMode)
{
	unsigned int index;
	unsigned char offset;
    if ( pixelX > 83 ) return;
    if ( pixelY > 47 ) return;
	index = ((pixelY / 8) * 84) + pixelX;
	offset= pixelY - ((pixelY / 8) * 8);
	if (pixelMode == 0) LcdCache[index] &= ~(0x01 << offset);
	if (pixelMode == 1) LcdCache[index] |= (0x01 << offset);
	if (pixelMode == 2) LcdCache[index] ^= (0x01 << offset);
}
 
/***********************************************************************************************
							 Trace une ligne sur l'Ecran

***********************************************************************************************/
void LCD_line(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,unsigned char lineMode)
{
    int dx, dy, stepx, stepy, fraction;

    dy = y2 - y1;
    dx = x2 - x1;

    if ( dy < 0 )
    {
        dy    = -dy;
        stepy = -1;
    }
    else
    {
        stepy = 1;
    }

    if ( dx < 0 )
    {
        dx    = -dx;
        stepx = -1;
    }
    else
    {
        stepx = 1;
    }

    dx <<= 1;
    dy <<= 1;

    LCD_pixel( x1, y1, lineMode );

    if ( dx > dy )
    {
        fraction = dy - (dx >> 1);
        while ( x1 != x2 )
        {
            if ( fraction >= 0 )
            {
                y1 += stepy;
                fraction -= dx;
            }
            x1 += stepx;
            fraction += dy;
            LCD_pixel( x1, y1, lineMode );
        }
    }
    else
    {
        fraction = dx - (dy >> 1);
        while ( y1 != y2 )
        {
            if ( fraction >= 0 )
            {
                x1 += stepx;
                fraction -= dy;
            }
            y1 += stepy;
            fraction += dx;
            LCD_pixel( x1, y1, lineMode );
        }
    }
}

/***********************************************************************************************
						 Reaffiche l'Ecran	  
						 Ekraný ayarlanan surelerde yeniler. 
***********************************************************************************************/
void LCD_redraw(void)
{
	unsigned int a;
    LCD_gotoxy(0,0);      							    // Se placer en 0,0
	LcdPos = 0;
    for (a=0;a<=503;a++){LCD_write_data(LcdCache[a]);} 	// Affiche le bitmap
}


/***********************************************************************************************
					 Ecran noir
					 Siyah Ekran 
***********************************************************************************************/
void ecran_noir(void)
{
	unsigned int a;
    for (a=0;a<=503;a++){LcdCache[a] = 0xFF;} 	// Affiche le bitmap	Bitmap goruntuler.
	LCD_redraw();
}


/***********************************************************************************************
								 Trace un Rectangle sur l'Ecran
								 Ekran üzerinde bir dikdortgen cizer 
***********************************************************************************************/
void LCD_rect(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,unsigned char rectMode)
{
	LCD_line(x1,y1,x2,y1,rectMode);
	LCD_line(x2,y1,x2,y2,rectMode);
	LCD_line(x2,y2,x1,y2,rectMode);
	LCD_line(x1,y2,x1,y1,rectMode);
	LCD_redraw();
}


/***********************************************************************************************
 					Trace un Rectangle plein sur l'Ecran	
 					 Ekranda dolgulu dikdortgen cizme
************************************************************************************************/
void LCD_rectfill(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,unsigned char rectMode)
{

	unsigned char a;

	if (x1 <= x2)
		{
			for (a = x1;a <= x2;a++)
		    LCD_line(a,y1,a,y2,rectMode);
		}
	else
		{
			for (a = x2;a <= x1;a++)
		    LCD_line(a,y1,a,y2,rectMode);
		}

	LCD_redraw();
}


/***********************************************************************************************
				 Trace un Cercle sur l'Ecran	
			 	 Ekran uzerinde bir daire cizer

**********************************************************************************************/
void LCD_circle(unsigned char centerX,unsigned char centerY,unsigned char radius,unsigned char circleMode)
{
	signed int tswitch;
	unsigned char y, x = 0;
	unsigned char d;	//uchar??

	d = centerY - centerX;
	y = radius;
	tswitch = 3 - 2 * radius;
	while (x <= y) 
		{
		LCD_pixel(centerX + x,centerY + y, circleMode);
		LCD_pixel(centerX + x,centerY - y, circleMode);
		LCD_pixel(centerX - x,centerY + y, circleMode);     
		LCD_pixel(centerX - x,centerY - y, circleMode);
		LCD_pixel(centerY + y - d, centerY + x, circleMode); 
		LCD_pixel(centerY + y - d, centerY - x, circleMode);
		LCD_pixel(centerY - y - d, centerY + x, circleMode); 
		LCD_pixel(centerY - y - d, centerY - x, circleMode);

		if (tswitch < 0) tswitch += (4 * x + 6);
		else {
			tswitch += (4 * (x - y) + 10);
			y--;
		}
		x++;
	}
	LCD_redraw();


}

//----------------------------------------------------------------------------//
#endif


3310.h

#ifndef	__3310_H_
#define	__3310_H_
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/


#define RES_PIN                         GPIO_Pin_11		  // lcd 8 pin	 acýk mavi
#define RES_GPIO_PORT                   GPIOD
#define RES_GPIO_CLK                    RCC_AHB1Periph_GPIOD  
  
#define SCE_PIN                         GPIO_Pin_12		 // lcd 5 pin  siyah
#define SCE_GPIO_PORT                   GPIOD
#define SCE_GPIO_CLK                    RCC_AHB1Periph_GPIOD  
  
#define DC_PIN                          GPIO_Pin_13		// lcd 4 pin Beyaz
#define DC_GPIO_PORT                    GPIOD
#define DC_GPIO_CLK                     RCC_AHB1Periph_GPIOD  
  
#define SDIN_PIN                         GPIO_Pin_14		// lcd 3 pin kahverengi
#define SDIN_GPIO_PORT                   GPIOD
#define SDIN_GPIO_CLK                    RCC_AHB1Periph_GPIOD

#define SCLK_PIN                         GPIO_Pin_15   // lcd 2 pin	   sari
#define SCLK_GPIO_PORT                   GPIOD
#define SCLK_GPIO_CLK                    RCC_AHB1Periph_GPIOD

#define CTRL_PORT  						 				  GPIOD


#define nok_res(x)      ((x) ? (GPIO_SetBits(CTRL_PORT,RES_PIN))    : (GPIO_ResetBits(CTRL_PORT,RES_PIN)));
#define nok_cs(x)				((x) ? (GPIO_SetBits(CTRL_PORT,SCE_PIN))    : (GPIO_ResetBits(CTRL_PORT,SCE_PIN)));
#define nok_dc(x)				((x) ? (GPIO_SetBits(CTRL_PORT,DC_PIN))     : (GPIO_ResetBits(CTRL_PORT,DC_PIN)));
#define nok_sda(x)			((x) ? (GPIO_SetBits(CTRL_PORT,SDIN_PIN))   : (GPIO_ResetBits(CTRL_PORT,SDIN_PIN)));
#define nok_sclk(x)			((x) ? (GPIO_SetBits(CTRL_PORT,SCLK_PIN))   : (GPIO_ResetBits(CTRL_PORT,SCLK_PIN)));



void LCD_write_dorc(unsigned char bytefornokia);
void LCD_write_data(unsigned char byteforLCD_data);
void LCD_write_command(unsigned char byteforLCD_command);
void LCD_printchar(unsigned char caracter,unsigned int charmode);
void LCD_gotoxy(unsigned char xnokia, unsigned char ynokia);
void LCD_clean_ddram(void);
void init_port (void);
void Lcd_init(void);
void DelayUs(u32 nTime);
void DelayMs(u32 nTime);
void LCD_printstr(const char *str,unsigned int charMode);
void LCD_pixel(unsigned char pixelX,unsigned char pixelY,unsigned char pixelMode);
void LCD_line(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,unsigned char lineMode);
void LCD_rect(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,unsigned char rectMode);
void LCD_rectfill(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,unsigned char rectMode);
void LCD_circle(unsigned char centerX,unsigned char centerY,unsigned char radius,unsigned char circleMode);
void LCD_redraw(void);
void ecran_noir(void);

#endif





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

serhat1990

Emeklerinize sağlık Hocam . Bu güzel paylaşım için teşekkürler .

İyi çalışmalar dilerim .

M_B

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

gilamada

Selamlar,
Güzel paylaşım olmuş elinize sağlık delay.h kodlarınıda koyabilir misiniz?

M_B

Alıntı yapılan: gilamada - 20 Ocak 2013, 09:34:14
Selamlar,
Güzel paylaşım olmuş elinize sağlık delay.h kodlarınıda koyabilir misiniz?
delay.c ve *.h dosyaları
https://www.picproje.org/index.php?topic=44619.0;topicseen
mevcut.
İmkanın sınırlarını görmek için imkansızı denemek lazım.                                                             Fatih Sultan Mehmet