/** * @brief Initializes and Configures the IO_Expander Touch Panel Functionality * and configures all STM32F429I_DISCO necessary * hardware (GPIOs, APB clocks ..). * @param None * @retval IOE_OK if all initializations done correctly. Other value if error. */ uint8_t IOE_Config(void) { /* Configure the needed pins */ IOE_GPIO_Config(); /* I2C initialization */ IOE_I2C_Config(); /* Read IO Expander ID */ if(IOE_IsOperational()) { return IOE_NOT_OPERATIONAL; } /* Generate IO Expander Software reset */ IOE_Reset(); /* IO Expander configuration */ /* Touch Panel controller and ADC configuration */ IOE_FnctCmd(IOE_ADC_FCT, ENABLE); IOE_TP_Config(); /* Configuration is OK */ return IOE_OK; }
/** * @brief IOE_TIMEOUT_UserCallback * @param None * @retval 0 */ uint8_t IOE_TimeoutUserCallback(void) { I2C_InitTypeDef I2C_InitStructure; I2C_GenerateSTOP(IOE_I2C, ENABLE); I2C_SoftwareResetCmd(IOE_I2C, ENABLE); I2C_SoftwareResetCmd(IOE_I2C, DISABLE); IOE_GPIO_Config(); /* CODEC_I2C peripheral configuration */ I2C_DeInit(IOE_I2C); I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2; I2C_InitStructure.I2C_OwnAddress1 = 0x00; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED; /* Enable the I2C peripheral */ I2C_Cmd(IOE_I2C, ENABLE); I2C_Init(IOE_I2C, &I2C_InitStructure); return 0; }
/** * @brief Initializes and Configures the IO_Expanders Functionalities * (Touch Screen ..) and configures all STM32100E-EVAL necessary * hardware (GPIOs, APB clocks ..). * @param None * @retval IOE_OK if all initializations done correctly. Other value if error. */ uint8_t IOE_Config(void) { /* Configure the needed pins */ IOE_GPIO_Config(); /* Configure I2C peripheral */ IOE_I2C_Config(); /* Read IO Expander 1 ID */ if(IOE_IsOperational(IOE_1_ADDR)) { return IOE1_NOT_OPERATIONAL; } /* Generate IOExpander Software reset */ IOE_Reset(IOE_1_ADDR); /* ---------------------- IO Expander configuration --------------------- */ /* Enable the GPIO, Touch Screen and ADC functionalities */ IOE_FnctCmd(IOE_1_ADDR, IOE_TS_FCT | IOE_ADC_FCT | IOE_IO_FCT | IOE_TEMPSENS_FCT , ENABLE); /* Touch Screen controller configuration */ IOE_TS_Config(); /* Temperature Sensor configuration */ IOE_TempSens_Config(); /* ------------------------------------------------------------------------ */ /* Configuration is OK */ return IOE_OK; }
/** * @brief Initializes and Configures the two IO_Expanders Functionalities * (IOs, Touch Screen ..) and configures all STM3210C-EVAL necessary * hardware (GPIOs, APB clocks ..). * @param None * @retval IOE_OK if all initializations done correctly. Other value if error. */ uint8_t IOE_Config(void) { /* Configure the needed pins */ IOE_GPIO_Config(); /* Configure the I2C peripheral */ IOE_I2C_Config(); /* Read IO Expander 1 ID */ if(IOE_IsOperational(IOE_1_ADDR)) { return IOE1_NOT_OPERATIONAL; } if(IOE_IsOperational(IOE_2_ADDR)) { return IOE2_NOT_OPERATIONAL; } /* Generate IOExpander Software reset */ IOE_Reset(IOE_1_ADDR); IOE_Reset(IOE_2_ADDR); /* ---------------------- IO Expander 1 configuration --------------------- */ /* Enable the GPIO, Touch Screen and ADC functionalities */ IOE_FnctCmd(IOE_1_ADDR, IOE_IO_FCT | IOE_TS_FCT | IOE_ADC_FCT, ENABLE); /* Configure the VBAT pin in output mode pin*/ IOE_IOPinConfig(IOE_1_ADDR, VBAT_DIV_PIN , Direction_OUT); /* ENABLE the alternate function for IN1 pin */ IOE_IOAFConfig(IOE_1_ADDR, VBAT_DIV_PIN, ENABLE); /* Apply the default state for the out pins */ IOE_WriteIOPin(VBAT_DIV_PIN, BitReset); /* Configure the MEMS interrupt pins in Input mode */ IOE_IOPinConfig(IOE_2_ADDR, (uint32_t)(MEMS_INT1_PIN | MEMS_INT2_PIN), Direction_IN); /* ENABLE the alternate function for the Joystick pins */ IOE_IOAFConfig(IOE_2_ADDR, (uint32_t)(MEMS_INT1_PIN | MEMS_INT2_PIN), ENABLE); /* Configure the IOs to detect Falling and Rising Edges */ IOE_IOEdgeConfig(IOE_2_ADDR, (uint32_t)(MEMS_INT1_PIN | MEMS_INT2_PIN), (uint32_t)(EDGE_FALLING | EDGE_RISING)); /* Touch Screen controller configuration */ IOE_TS_Config(); /* ------------------------------------------------------------------------ */ /* ---------------------- IO Expander 2 configuration --------------------- */ /* Enable the GPIO, Temperature Sensor and ADC functionalities */ IOE_FnctCmd(IOE_2_ADDR, IOE_IO_FCT | IOE_TEMPSENS_FCT | IOE_ADC_FCT, ENABLE); /* Configure the Audio Codec Reset pin in output mode pin*/ IOE_IOPinConfig(IOE_2_ADDR, (uint32_t)(AUDIO_RESET_PIN), Direction_OUT); IOE_IOPinConfig(IOE_2_ADDR, (uint32_t)(MII_INT_PIN), Direction_IN); /* ENABLE the alternate function for IN1 pin */ IOE_IOAFConfig(IOE_2_ADDR, (uint32_t)(AUDIO_RESET_PIN | MII_INT_PIN), ENABLE); /* Apply the default state for the out pins */ IOE_WriteIOPin(AUDIO_RESET_PIN, BitReset); IOE_WriteIOPin(MII_INT_PIN, BitReset); /* Configure the Joystick pins in Input mode */ IOE_IOPinConfig(IOE_2_ADDR, JOY_IO_PINS , Direction_IN); /* ENABLE the alternate function for the Joystick pins */ IOE_IOAFConfig(IOE_2_ADDR, JOY_IO_PINS, ENABLE); /* Configure the IOs to detect Falling and Rising Edges */ IOE_IOEdgeConfig(IOE_2_ADDR, JOY_IO_PINS, (uint8_t)(EDGE_FALLING | EDGE_RISING)); /* Temperature Sensor module configuration */ IOE_TempSens_Config(); /* ------------------------------------------------------------------------ */ /* Configuration is OK */ return IOE_OK; }