Esempio n. 1
0
void initLED(void) {
	//SIM (System Integration Module) - rejestr dajacy kontrole nad podawaniem zegara peryferiom
		//SCGC5 (System Clock Gating Control Register 5) - rejestr odpowiedzialny za taktowanie portow
	SIM->SCGC5 |=
		SIM_SCGC5_PORTD_MASK |
		SIM_SCGC5_PORTE_MASK; //wlaczenie takowania portow
	
	//PORT (Port Control and Interrupts) - rejestr decydujacy o tym, ktore piny wkorzystywane sa dla dancyh peryferiow
		//PCR (Pin Control Register) - sluzy do ustawienia na multiplekserze danego pinu GPIO (001)
	PORTD->PCR[LED_PIN_RED]   = PORT_PCR_MUX(1UL);
	PORTE->PCR[LED_PIN_GREEN] = PORT_PCR_MUX(1UL);
	
	//GPIO (General Purpose Input Output)
	//dla danego pinu trzeba okreslic kierunek, a potem konkretne zachowanie
		//PDDR (Direction): 1 - output, 0 - input
		//PDOR (Output)
		//PSOR (Set)
		//PCOR (Clear)
		//PTOR (Toggle)
		//PDIR (Input)
	PTD->PDDR |= LED_MASK_RED;
	PTE->PDDR |= LED_MASK_GREEN;
	
	offLED( LED_MASK_ALL );
}
Esempio n. 2
0
void offAllLEDs()
{
   uchar i;
   for(i=0;i<=7;i++)
   {
      offLED(i);
   }    
}
Esempio n. 3
0
int main() 
{

	int fd = open("/dev/mem", O_RDWR | O_SYNC);

	if (fd < 0) 
	{
		printf("Could not open memory\n");
		return 0;
	}
	setLED(fd);
	sleep(2);
	offLED(fd);
	sleep(2);
}
Esempio n. 4
0
void testLEDs(void)
{
   uchar i;
   while(1)
   {
      for(i=0;i<=7;i++)
      {
         onLED(i);
         wait(1000);
      }
      for(i=0;i<=7;i++)
      {
         offLED(i);
      }    
      wait(2000);
   }

}
Esempio n. 5
0
//level is between 0 and 3
void setLEDLevel(uchar level, uchar side)
{
   uchar i=0; //values for left
   int max=3; //default range 0-3 
   if(side==LEFT)
   {
      i=4; //new range 4-7
      max=7;
      level+=4; //shift level up by 4 because bucket ranges 0-3
   }
   for(;i<=max;i++)
   {
      if(i<=level)  //turn on LEDs below and equal to the level
         onLED(i);
      else
         offLED(i);  //turn off LEDs above level
   }
}
Esempio n. 6
0
//U1-4 are left drum, U3-7,T0 are right drum from bottom to top.
void advanceLEDs(void)
{
   static char currLED=0; //next one in cycle will be U1, which is first LED
   //above must be in range 0 to 7 or trouble will occur.
   
   offLED(currLED);
   if(currLED>3)
      currLED++;
   else
      currLED--;
   
   if(currLED>7) //go above red, go back to top of green
      currLED=3;
   if(currLED<0) //go below green, go to bottom of red
      currLED=4;
   
   onLED(currLED);
}