/** * @brief Configures COMPASS / ACCELEROMETER I2C interface. * @param None * @retval None */ void COMPASSACCELERO_IO_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable DRDY clock */ ACCELERO_DRDY_GPIO_CLK_ENABLE(); /* Enable INT1 & INT2 GPIO clock */ ACCELERO_INT_GPIO_CLK_ENABLE(); /* Mems DRDY pin configuration */ GPIO_InitStructure.Pin = ACCELERO_DRDY_PIN; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(ACCELERO_DRDY_GPIO_PORT, &GPIO_InitStructure); /* Enable and set Button EXTI Interrupt to the lowest priority */ HAL_NVIC_SetPriority(ACCELERO_DRDY_EXTI_IRQn, 0x00, 0x00); HAL_NVIC_EnableIRQ(ACCELERO_DRDY_EXTI_IRQn); /* Configure GPIO PINs to detect Interrupts */ GPIO_InitStructure.Pin = ACCELERO_INT1_PIN | ACCELERO_INT2_PIN; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Speed = GPIO_SPEED_HIGH; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(ACCELERO_INT_GPIO_PORT, &GPIO_InitStructure); I2Cx_Init(); }
/** * @brief Configures the Accelerometer INT2. * EXTI0 is already used by user button so INT1 is not configured here. * @param None * @retval None */ void ACCELERO_IO_ITConfig(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable INT2 GPIO clock and configure GPIO PINs to detect Interrupts */ ACCELERO_INT_GPIO_CLK_ENABLE(); /* Configure GPIO PINs to detect Interrupts */ GPIO_InitStructure.Pin = ACCELERO_INT2_PIN; GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING; GPIO_InitStructure.Speed = GPIO_SPEED_FAST; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(ACCELERO_INT_GPIO_PORT, &GPIO_InitStructure); /* Enable and set Accelerometer INT2 to the lowest priority */ HAL_NVIC_SetPriority((IRQn_Type)ACCELERO_INT2_EXTI_IRQn, 0x0F, 0); HAL_NVIC_EnableIRQ((IRQn_Type)ACCELERO_INT2_EXTI_IRQn); }
/** * @brief Configures COMPASS / ACCELERO click IT. * @param None * @retval None */ void COMPASSACCELERO_IO_ITConfig(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable INT1 and INT2 GPIO clock */ ACCELERO_INT_GPIO_CLK_ENABLE(); /* Configure GPIO PINs to detect Interrupts */ GPIO_InitStructure.Pin = ACCELERO_INT1_PIN | ACCELERO_INT2_PIN; GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING; GPIO_InitStructure.Speed = GPIO_SPEED_FAST; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(ACCELERO_INT_GPIO_PORT, &GPIO_InitStructure); /* Enable and set COMPASS / ACCELERO Interrupt to the highest priority */ HAL_NVIC_SetPriority(ACCELERO_INT1_EXTI_IRQn, 0x00, 0x00); HAL_NVIC_EnableIRQ(ACCELERO_INT1_EXTI_IRQn); }