예제 #1
0
int main()
{
    init_platform();

    int pin1 = 0;
    int pin2 = 0;
    int pin3 = 0;
    int pin4 = 0;
    int all_pins = 0;

    print("GPIO Demo\n\r");

    GPIO_begin(&myDevice, XPAR_PMODGPIO_0_AXI_LITE_GPIO_BASEADDR, 0xFF);

    while(1){
		//read individually
    	pin1 = GPIO_getPin(&myDevice, 1);
    	pin2 = GPIO_getPin(&myDevice, 2);
    	pin3 = GPIO_getPin(&myDevice, 3);
    	pin4 = GPIO_getPin(&myDevice, 4);
		//read all together
    	all_pins = GPIO_getPins(&myDevice);
		//print individual reads and the total read masked to the first four bits
    	xil_printf("switch 1: %d   switch 2: %d   switch 3: %d   switch 4: %d   all pins: %d\n\r", pin1, pin2, pin3, pin4, all_pins & 0x0f);
    }

    cleanup_platform();
    return 0;
}
예제 #2
0
/**
 * \brief Liest den Status eines Ausganges ein.
 * \param	PIN		Pinnummer des Ausganges der eingelesen werden soll.
 */
char GPIO_out_state( char pin )
{
	char returnval=0;
	
	if ( pin >= sizeof( GPIO_OUT_DATA ) )
		return(0);
	
	if ( GPIO_getPin( pgm_read_byte( &GPIO_OUT_DATA[ (int)pin ] ) ) != 0 )
		returnval = 1;
	
	return( returnval );
}
예제 #3
0
void LED_invert(USER_LED_t led)
{
   if(LED_checkValidLed(led))
   {
      level_t actual = GPIO_getPin(GPIO1,led);
      if(actual == HIGH)
      {
         GPIO_clrPin(GPIO1,led);
      }
      else
      {
         GPIO_setPin(GPIO1,led);
      }
   }
}