/* * FUNCTION * GPIO_PullenSetup * * DESCRIPTION * This function is to enable or disable the pull up/down of the related GPIO pin. * You can not decide to pull up or down, it is set inside the chip. * And, the setting is different from pin by pin. * * PARAMETERS * enable: enable the pull up/down * * RETURNS * None * * GLOBALS AFFECTED * */ void GPIO_PullenSetup(kal_uint16 pin, kal_bool enable) { kal_uint16 modeno; kal_uint16 remainder; modeno = pin/16; remainder = pin % 16; if(enable) DRV_WriteReg(GPIO_PULLEN_SET(modeno), 1 << remainder); else DRV_WriteReg(GPIO_PULLEN_CLR(modeno), 1 << remainder); }
void GPIO_InitIO(unsigned int dir, unsigned int pin) { unsigned int no,remainder; no = pin >>4; remainder = pin & 0xf; if (dir == OUTPUT) { DRV_WriteReg16(GPIO_PULLEN_SET(no),(1 << remainder)); DRV_WriteReg16(GPIO_DIR_SET(no),(1 << remainder)); } else { DRV_WriteReg16(GPIO_PULLEN_CLR(no),(1 << remainder)); DRV_WriteReg16(GPIO_DIR_CLR(no),(1 << remainder)); } I2C_DUMMY_DELAY(100); }