#define UBIK2_DECLARE_CONST 1 #include "led_platform.h" /* include for gpio APIs */ /*--- #include ---*/ /*--- #include "ubik2_gpio.h" ---*/ /**************************************************************************** * FUNCTION: avalanche_gpio_ctrl ***************************************************************************/ int avalanche_gpio_ctrl(unsigned int gpio_pin, AVALANCHE_GPIO_PIN_MODE_T enable, AVALANCHE_GPIO_PIN_DIRECTION_T pin_direction) { int index = 0; if (gpio_pin > 40 ) return(-1); /* Check whether gpio refers to the first GPIO reg or second. */ if(gpio_pin > 31) { index = 1; gpio_pin -= 32; } if(enable) ubik2_ioarea_systemservices->GPIO.GPDIS[index] &= ~(1 << gpio_pin); /* Enable as GPIO */ else ubik2_ioarea_systemservices->GPIO.GPDIS[index] |= (1 << gpio_pin); /* Disable GPIO */ if(pin_direction) ubik2_ioarea_systemservices->GPIO.GPDIR[index] &= ~(1 << gpio_pin); /* Input */ else ubik2_ioarea_systemservices->GPIO.GPDIR[index] |= (1 << gpio_pin); /* Output */ return(0); } /* end of function gpio_ctrl */