/** * @brief Joystick Msc menu * @param None * @retval None */ void Joystick_MscMenu(void) { static JOYState_TypeDef JoyState = JOY_NONE; /* Get the Joystick State */ JoyState = BSP_JOY_GetState(); MSC_DEMO_ProbeKey(JoyState); switch(JoyState) { case JOY_LEFT: LCD_LOG_ScrollBack(); break; case JOY_RIGHT: LCD_LOG_ScrollForward(); break; default: break; } osSemaphoreRelease(MenuEvent); }
/** * @brief EXTI line detection callbacks. * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { static JOYState_TypeDef JoyState = JOY_NONE; if(GPIO_Pin == GPIO_PIN_2) { /* Get the Joystick State */ JoyState = BSP_JOY_GetState(); MSC_DEMO_ProbeKey(JoyState); switch(JoyState) { case JOY_LEFT: LCD_LOG_ScrollBack(); break; case JOY_RIGHT: LCD_LOG_ScrollForward(); break; default: break; } /* Clear joystick interrupt pending bits */ BSP_IO_ITClear(JOY_ALL_PINS); } }
/** * @brief EXTI line detection callbacks. * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { static JOYState_TypeDef JoyState = JOY_NONE; if(GPIO_Pin == MFX_IRQOUT_PIN) { /* The different functionalities of MFX (TS, Joystick, SD detection, etc. ) can be configured in exti mode to generate an IRQ on given events. The MFX IRQ_OUT pin is unique and common to all functionalities, so if several functionalities are configured in exit mode, the MCU has to enquire MFX about the IRQ source (see BSP_IO_ITGetStatus). Communication with Mfx is done by I2C. Often the sw requires ISRs (irq service routines) to be quick while communication with I2C can be considered relatively long (hundreds of usec depending on I2C clk). Considering that the features for human interaction like TS, Joystick, SD detection don’t need immediate reaction, it is suggested to use POLLING instead of EXTI mode, in order to avoid "blocking I2C communication" on interrupt service routines */ /* Get the Joystick State */ JoyState = BSP_JOY_GetState(); HAL_Delay(200); MSC_DEMO_ProbeKey(JoyState); switch(JoyState) { case JOY_LEFT: LCD_LOG_ScrollBack(); break; case JOY_RIGHT: LCD_LOG_ScrollForward(); break; default: break; } /* Clear joystick interrupt pending bits */ BSP_IO_ITClear(); } }
/** * @brief EXTI line detection callbacks. * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { static JOYState_TypeDef JoyState = JOY_NONE; static uint32_t debounce_time = 0; if(GPIO_Pin == GPIO_PIN_8) { /* Get the Joystick State */ JoyState = BSP_JOY_GetState(); HAL_Delay(200); /* Clear joystick interrupt pending bits */ BSP_IO_ITClear(); if(Appli_state == APPLICATION_MSC) { MSC_DEMO_ProbeKey(JoyState); } else if(Appli_state == APPLICATION_HID) { HID_DEMO_ProbeKey(JoyState); } else if(Appli_state == APPLICATION_AUDIO) { if(audio_select_mode == AUDIO_SELECT_MENU) { AUDIO_MenuProbeKey(JoyState); } else if(audio_select_mode == AUDIO_PLAYBACK_CONTROL) { AUDIO_PlaybackProbeKey(JoyState); } } switch(JoyState) { case JOY_LEFT: LCD_LOG_ScrollBack(); break; case JOY_RIGHT: LCD_LOG_ScrollForward(); break; default: break; } } if(audio_demo.state == AUDIO_DEMO_PLAYBACK) { if(GPIO_Pin == KEY_BUTTON_PIN) { /* Prevent debounce effect for user key */ if((HAL_GetTick() - debounce_time) > 50) { debounce_time = HAL_GetTick(); } else { return; } /* Change the selection type */ if(audio_select_mode == AUDIO_SELECT_MENU) { Audio_ChangeSelectMode(AUDIO_PLAYBACK_CONTROL); } else if(audio_select_mode == AUDIO_PLAYBACK_CONTROL) { Audio_ChangeSelectMode(AUDIO_SELECT_MENU); } } } }