2019-03-17 12:12 AM
I want to use same pin for SPI MISO and GPIO Interrupt.When I need to take data from SPI BUS then I want touse it as SPI MISO else want to use as GPIO Interrupt. How can I use same pin for both functions?
2019-03-17 01:43 AM
You need to hack as CubeMX and HAL won't intuitively offer EXTI interrupt on an Alternate function pin.
The Reference manual shows that EXTI is an independent block.
Got this working on SPI SCK on STM32L4R
void SPIP_EnableSCK_EXTI(SPIP_t* pSPIP) {
SYSCFG->EXTICR[0] &= ~(0xF<<4);
SYSCFG->EXTICR[0] |= (3<<4);
EXTI->IMR1 |= GPIO_PIN_1; // interrupt enable
EXTI->RTSR1 |= GPIO_PIN_1; // rising sense
EXTI->FTSR1 |= GPIO_PIN_1; // falling sense
// Above is to have EXTI on AF pin.
__HAL_GPIO_EXTI_CLEAR_IT(pSPIP->pSCK->Init.Pin);
__HAL_GPIO_EXTI_CLEAR_FLAG(pSPIP->pSCK->Init.Pin);
//EXTI->IMR1 |= (1<<1);
HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
}