Haberler:

Foruma Resim Yükleme ve Boyut Sınırlaması ( ! )  https://bit.ly/2GMFb8H

Ana Menü

class yapısı..

Başlatan brlesc, 06 Temmuz 2013, 22:32:59

brlesc

kolay gelsin arkadaşlar
sorum basit olabilir cahilliğime verin..
c++ da class yapısı ile keil ve stm32f4 kullarak bişeyler yapmaya, öğrenmeye çalışıyorum. fonksiyonları falan halletim ama söyle bir şeyi nasıl yaparım bilemedim;

falanfilan.xx=1 dediğimde belirlediğim pini set ,
falanfilan.xx=0 dediğimde ise reset
yapacak sekilde nasıl yapabilirim
edeb ya hu...

Icarus

Google: Operator Overloading

brlesc

Cevabınız için çok teşekkür ederim..
edeb ya hu...

Gökhan BEKEN

O işlem için class yapısına gerek yok. Struct yapısı ile değişkenlerinizi gruplayabilirsiniz.

ana programa başlamadan önce
struct AdresDefteri { 
	int ID;
	char Ad[100];
	char Soyad[100];
};


bu şekilde yazın
int main() {
      struct AdresDefteri kontak;
          
      kontak.ID = 1;
      strcpy(kontak.Ad, "Pic proje");
      strcpy(kontak.Soyad, "forumu");

      }

şeklinde kullanın
Özel mesaj okumuyorum, lütfen göndermeyin.

yamak

#4
Aşağıdaki kodları incelemeni öneririm.
#include <lpc17xx.h>
#define P0 ((GPIO_TypeDef*) LPC_GPIO0_BASE)
#define P1 ((GPIO_TypeDef*) LPC_GPIO1_BASE)
#define P2 ((GPIO_TypeDef*) LPC_GPIO2_BASE)
#define P3 ((GPIO_TypeDef*) LPC_GPIO3_BASE)
#define P4 ((GPIO_TypeDef*) LPC_GPIO4_BASE)

typedef union
{
	__IO uint32_t all_pin;
	__IO uint8_t byte0;
	__IO uint8_t byte1;
	__IO uint8_t byte2;
	__IO uint8_t byte3;
	struct
	{
		__IO uint32_t pin0:1;
		__IO uint32_t pin1:1;
		__IO uint32_t pin2:1;
		__IO uint32_t pin3:1;
		__IO uint32_t pin4:1;
		__IO uint32_t pin5:1;
		__IO uint32_t pin6:1;
		__IO uint32_t pin7:1;
		__IO uint32_t pin8:1;
		__IO uint32_t pin9:1;
		__IO uint32_t pin10:1;
		__IO uint32_t pin11:1;
		__IO uint32_t pin12:1;
		__IO uint32_t pin13:1;
		__IO uint32_t pin14:1;
		__IO uint32_t pin15:1;
		__IO uint32_t pin16:1;
		__IO uint32_t pin17:1;
		__IO uint32_t pin18:1;
		__IO uint32_t pin19:1;
		__IO uint32_t pin20:1;
		__IO uint32_t pin21:1;
		__IO uint32_t pin22:1;
		__IO uint32_t pin23:1;
		__IO uint32_t pin24:1;
		__IO uint32_t pin25:1;
		__IO uint32_t pin26:1;
		__IO uint32_t pin27:1;
		__IO uint32_t pin28:1;
		__IO uint32_t pin29:1;
		__IO uint32_t pin30:1;
		__IO uint32_t pin31:1;
	}pin;
		
}_32bit;

typedef struct
{
	__IO _32bit FIODIR;
	uint32_t RESERVED0[3];
	__IO _32bit FIOMASK;
	__IO _32bit FIOPIN;
	__IO _32bit FIOSET;
	__IO _32bit FIOCLR;
}GPIO_TypeDef;

Yukarıdaki headerı file ı kullanarak gpio lara P0->FIOPIN.pin0=1 gibi erişebilirsin

brlesc

 yorumlarınızdan boyle bi şey cıkardım hocam. stm32f4 için ne kadarı dogrudur  yardımcı olurmusunuz;

typedef union 
{
 unsigned long FULL;

struct 
{
   unsigned BIT0:1;
   unsigned BIT1:1;
   unsigned BIT2:1;
   unsigned BIT3:1;
   unsigned BIT4:1;
   unsigned BIT5:1;
   unsigned BIT6:1;
   unsigned BIT7:1;
   unsigned BIT8:1;
   unsigned BIT9:1;
   unsigned BIT10:1;
   unsigned BIT11:1;
   unsigned BIT12:1;
   unsigned BIT13:1;
   unsigned BIT14:1;
   unsigned BIT15:1;
   
  }pin;
  
}data;

typedef struct
{
   data BSRRL; // yada  BSRRH; ?

}GPIO_TypeDef;



GPIOE->BSRRL.BIT0=1; gibi mi olacak ?
sacmaladı isem kusura bakmayın hocam
edeb ya hu...

fatih6761

Hocam bitbanding olayına da bakabilrisiniz...