Example #1
0
void checkButtonsState()
{
	if (!GPIO_PinRead(0, 0))
	{
		if (buttonsState.button1pressed == false)
		{
			//button pressed
			buttonsState.button1pressed = true;
			button1PressEvent();
		}
	}
	else
		buttonsState.button1pressed = false;

	if (!GPIO_PinRead(0, 1))
	{
		if (buttonsState.button2pressed == false)
		{
			//button pressed
			buttonsState.button2pressed = true;
			button2PressEvent();
		}
	}
	else
		buttonsState.button2pressed = false;
}
char detectEnemyGreen(unsigned long startTime)
{
	if(GPIO_PinRead(forwardRightSensor) == 0 || GPIO_PinRead(forwardLeftSensor) == 0)
	{
		stop(SOFT_STOP);
		_delay_ms(2000);
	}
	return 0;
}
char detectEnemyYellow(unsigned long startTime)
{
	if(GPIO_PinRead(forwardLeftSensor) == 1 || GPIO_PinRead(forwardRightSensor) == 1)
	{
		stop(SOFT_STOP);
		PORTG = 0xFF;
		
		return 1;
	}
	
	PORTG = 0x00;
	return 0;
}
char driveByYellow(unsigned long time)
{
	if(GPIO_PinRead(forwardLeftSensor) == 1 || GPIO_PinRead(forwardRightSensor) == 1)
	{
		stop(SOFT_STOP);
		while(1);
	}
	if(carpetsReleased == 0)
	{
		_delay_ms(3300);//3100
		servo_position(205);
		//servo_position(0);//iskljucen
		carpetsReleased = 1;	
	}
	
	return 0;
}
Example #5
0
/*
_delay_ms(200);
while(greenSideTacticOnePositions[currentPosition].detectionCallback(0) != 0)
_delay_ms(100);
*/
int main(void)
{
	systemInit();
	_delay_ms(100);
	
	while(1)
		{
			if(GPIO_PinRead(changeSides) == 0)
			{	
				greenSide();
			}
			else if(GPIO_PinRead(changeSides) == 1)
			{
				yellowSide();
			}
		}
		
}
Example #6
0
static int mcux_igpio_read(struct device *dev,
			  int access_op, u32_t pin, u32_t *value)
{
	const struct mcux_igpio_config *config = dev->config->config_info;

	if (access_op == GPIO_ACCESS_BY_PIN) {
		*value = GPIO_PinRead(config->base, pin);
	} else { /* GPIO_ACCESS_BY_PORT */
		*value = config->base->DR;
	}

	return 0;
}
/* start the main program */
void main() 
{
    uint8_t value;

    GPIO_PinDirection(SW1,INPUT);        // Configure the switch pin as Input
    GPIO_PinDirection(Buzzer,OUTPUT);       // Configure the Buzzer pin as OUTPUT

  while(1)
    {

       value = GPIO_PinRead(SW1);         // Read the switch status
       GPIO_PinWrite(Buzzer,!value);          // ON/OFF theBuzzer as per switch status  
    }
}
Example #8
0
/*
 * Get all keys
 */
uint32_t Keyboard_GetKeys (void) 
{
   /* Read board keyboard inputs */
   uint32_t val = 0;
   uint32_t n;

   for (n = 0; n < NUM_KEYS; n++) 
   {
      if (GPIO_PinRead(Pin_Key[n].port, Pin_Key[n].num) != 0) 
      {
          val |= 1<<n;
      }
   }
   return (val);
}
Example #9
0
int main() 
{
    uint8_t value;
    SystemInit();                               /* Clock and PLL configuration */

    GPIO_PinFunction(MY_SWITCH,PINSEL_FUNC_0);  /* Configure Pin for Gpio */
    GPIO_PinDirection(MY_SWITCH,INPUT);         /* Configure the switch pin as Input */

    GPIO_PinFunction(MY_LED,PINSEL_FUNC_0);     /* Configure Pin for Gpio */
    GPIO_PinDirection(MY_LED,OUTPUT);           /* Configure the Led pin as OUTPUT */

    while(1)
    {
        value = GPIO_PinRead(MY_SWITCH);         /* Read the switch status */
        GPIO_PinWrite(MY_LED,value);             /*  ON/OFF the led as per switch status */  
    }
}
Example #10
0
static inline uint8_t SDA_IN(void)
{
    return GPIO_PinRead(i2c.instace, i2c.sda);
}
Example #11
0
/*
 * Get status of one key
 */
int Keyboard_GetKey(uint32_t num)
{
	return (GPIO_PinRead(Pin_Key[num].port, Pin_Key[num].num) != 0);
}