Exemplo n.º 1
0
/**
  * @brief  Manages MSC Menu Process.
  * @param  None
  * @retval None
  */
void MSC_MenuProcess(void)
{
  switch(msc_demo.state)
  {
  case MSC_DEMO_IDLE:
    BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
    BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"                                                 ");
    BSP_LCD_DisplayStringAtLine(17, (uint8_t *)"Use [Buttons Left/Right] to scroll up/down       ");
    BSP_LCD_DisplayStringAtLine(18, (uint8_t *)"Use [Joystick Up/Down] to scroll MSC menu        ");
    BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
    MSC_SelectItem(MSC_main_menu, 0); 
    msc_demo.state = MSC_DEMO_WAIT;
    msc_demo.select = 0;
    break;    
    
  case MSC_DEMO_WAIT:
    if(msc_demo.select != prev_select)
    {
      prev_select = msc_demo.select;
      MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F);
      
      /* Handle select item */
      if(msc_demo.select & 0x80)
      {
        switch(msc_demo.select & 0x7F)
        {
        case 0:
          msc_demo.state = MSC_DEMO_FILE_OPERATIONS;  
          break;
          
        case 1:
          msc_demo.state = MSC_DEMO_EXPLORER;  
          break;
          
        case 2:
          msc_demo.state = MSC_REENUMERATE;  
          break;
          
        default:
          break;
        }
      }
    }
    break;
    
  case MSC_DEMO_FILE_OPERATIONS:  
    /* Read and Write File Here */
    if(Appli_state == APPLICATION_MSC)
    {
      MSC_File_Operations();
    }
    msc_demo.state = MSC_DEMO_WAIT;
    break; 
    
  case MSC_DEMO_EXPLORER:
    /* Display disk content */
    if(Appli_state == APPLICATION_MSC)
    {
      /* Register the file system object to the FatFs module */
      if(f_mount(&USBH_fatfs, "", 0 ) != FR_OK )
      {
        LCD_ErrLog("Cannot Initialize FatFs! \n");
      }
      else
      {
        Explore_Disk("0:/", 1);
      }
    }
    msc_demo.state = MSC_DEMO_WAIT;
    break; 
    
  case MSC_REENUMERATE:
    /* Force MSC Device to re-enumerate */
    USBH_ReEnumerate(&hUSBHost); 
    msc_demo.state = MSC_DEMO_WAIT;
    
    break;

  default:
    break;
  }
  msc_demo.select &= 0x7F;
} 
Exemplo n.º 2
0
Arquivo: menu.c Projeto: z80/stm32f429
/**
  * @brief  User task
  * @param  pvParameters not used
  * @retval None
  */
static void MSC_MenuThread(void const *argument)
{
  uint32_t ITstatus = 0;

  for(;;)
  {
    if(osSemaphoreWait(MenuEvent, 100) == osOK)
    {
      switch(msc_demo.state)
      {
      case MSC_DEMO_IDLE:
        MSC_SelectItem(MSC_main_menu, 0); 
        msc_demo.state = MSC_DEMO_WAIT;
        msc_demo.select = 0;
        osSemaphoreRelease(MenuEvent);
        break;    
        
      case MSC_DEMO_WAIT:
        MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F);
        
        /* Handle select item */
        if(msc_demo.select & 0x80)
        {
          switch(msc_demo.select & 0x7F)
          {
          case 0:
            msc_demo.state = MSC_DEMO_FILE_OPERATIONS; 
            osSemaphoreRelease(MenuEvent);
            break;
            
          case 1:
            msc_demo.state = MSC_DEMO_EXPLORER;  
            osSemaphoreRelease(MenuEvent);
            break;
            
          case 2:
            msc_demo.state = MSC_REENUMERATE; 
            osSemaphoreRelease(MenuEvent);
            break;
            
          default:
            break;
          }
        }
        break;
        
      case MSC_DEMO_FILE_OPERATIONS:  
        /* Read and Write File Here */
        if(Appli_state == APPLICATION_READY)
        {
          MSC_File_Operations();
        }
        msc_demo.state = MSC_DEMO_WAIT;
        break; 
        
      case MSC_DEMO_EXPLORER:
        /* Display disk content */
        if(Appli_state == APPLICATION_READY)
        {        
          Explore_Disk("0:/", 1);
        }
        msc_demo.state = MSC_DEMO_WAIT;
        break; 
        
      case MSC_REENUMERATE:
        /* Force MSC Device to re-enumerate */
        USBH_ReEnumerate(&hUSBHost); 
        msc_demo.state = MSC_DEMO_WAIT;
        break;
        
      default:
        break;
      } 
      msc_demo.select &= 0x7F;
    }

    if (osJoySemaphore != NULL)
    {      
      if(osSemaphoreWait(osJoySemaphore , 0) == osOK)
      {
        ITstatus = BSP_IO_ITGetStatus(JOY_ALL_PINS);
        if (ITstatus)
        {
          Joystick_MscMenu();
          /* Clear joystick interrupt pending bits */
          BSP_IO_ITClear();
        }
      }
    }
  }
}
Exemplo n.º 3
0
/**
  * @brief  Manages HID Menu Process.
  * @param  None
  * @retval None
  */
void HID_MenuProcess(void)
{
    switch(hid_demo.state)
    {
    case HID_DEMO_IDLE:
        BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
        BSP_LCD_DisplayStringAtLine(17, (uint8_t *)"Use [Buttons Left/Right] to scroll up/down       ");
        BSP_LCD_DisplayStringAtLine(18, (uint8_t *)"Use [Joystick Up/Down] to scroll HID menu        ");
        BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"                                                                                                          ");
        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
        HID_SelectItem(DEMO_HID_menu, 0);
        hid_demo.state = HID_DEMO_WAIT;
        hid_demo.select = 0;
        break;

    case HID_DEMO_WAIT:
        if(hid_demo.select != prev_select)
        {
            prev_select = hid_demo.select;

            HID_SelectItem(DEMO_HID_menu, hid_demo.select & 0x7F);
            /* Handle select item */
            if(hid_demo.select & 0x80)
            {
                hid_demo.select &= 0x7F;
                switch(hid_demo.select)
                {
                case 0:
                    hid_demo.state = HID_DEMO_START;
                    break;

                case 1:
                    hid_demo.state = HID_DEMO_REENUMERATE;
                    break;

                default:
                    break;
                }
            }
        }
        break;

    case HID_DEMO_START:
        if(Appli_state == APPLICATION_HID)
        {
            if(USBH_HID_GetDeviceType(&hUSBHost) == HID_KEYBOARD)
            {
                hid_demo.keyboard_state = HID_KEYBOARD_IDLE;
                hid_demo.state = HID_DEMO_KEYBOARD;
            }
            else if(USBH_HID_GetDeviceType(&hUSBHost) == HID_MOUSE)
            {
                hid_demo.mouse_state = HID_MOUSE_IDLE;
                hid_demo.state = HID_DEMO_MOUSE;
            }
        }
        else
        {
            LCD_ErrLog("No supported HID device!\n");
            hid_demo.state = HID_DEMO_WAIT;
        }

        break;

    case HID_DEMO_REENUMERATE:
        /* Force HID Device to re-enumerate */
        USBH_ReEnumerate(&hUSBHost);
        hid_demo.state = HID_DEMO_WAIT;
        break;

    case HID_DEMO_MOUSE:
        if( Appli_state == APPLICATION_HID)
        {
            HID_MouseMenuProcess();
            USBH_MouseDemo(&hUSBHost);
        }
        break;

    case HID_DEMO_KEYBOARD:
        if( Appli_state == APPLICATION_HID)
        {
            HID_KeyboardMenuProcess();
            USBH_KeybdDemo(&hUSBHost);
        }
        break;

    default:
        break;
    }
}
Exemplo n.º 4
0
/**
  * @brief  Manages Audio Menu Process.
  * @param  None
  * @retval None
  */
void AUDIO_MenuProcess(void)
{
  switch(audio_demo.state)
  {
  case AUDIO_DEMO_IDLE:
    BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
    BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"                                                 ");
    BSP_LCD_DisplayStringAtLine(17, (uint8_t *)"Use [Buttons Left/Right] to scroll up/down       ");
    BSP_LCD_DisplayStringAtLine(18, (uint8_t *)"Use [Joystick Up/Down] to scroll audio menu      ");
    BSP_LCD_SetTextColor(LCD_COLOR_WHITE); 
    AUDIO_MenuSelectItem(AUDIO_main_menu, 0); 
    audio_demo.state = AUDIO_DEMO_WAIT;
    audio_demo.select = 0;
    break;    
    
  case AUDIO_DEMO_WAIT:
    if(audio_demo.select != prev_select)
    {
      prev_select = audio_demo.select;
      AUDIO_MenuSelectItem(AUDIO_main_menu, audio_demo.select & 0x7F);
      
      /* Handle select item */
      if(audio_demo.select & 0x80)
      {
        audio_demo.select &= 0x7F;
        
        switch(audio_demo.select)
        {
        case 0:
          audio_demo.state = AUDIO_DEMO_EXPLORE;  
          break;
          
        case 1:
          /* Display HMI messages */
          BSP_LCD_SetTextColor(LCD_COLOR_GREEN);          
          BSP_LCD_DisplayStringAtLine(14, (uint8_t *)"                                             ");
          BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"                                             ");
          BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"Use [User Key] To Stop and return from player");
          BSP_LCD_SetTextColor(LCD_COLOR_WHITE); 

          /* Set PLAYBACK state and start playing 1st file */ 
          audio_state = AUDIO_STATE_IDLE;
          audio_demo.state = AUDIO_DEMO_PLAYBACK;
          Audio_ChangeSelectMode(AUDIO_PLAYBACK_CONTROL);
          break;
          
        case 2:
          audio_demo.state = AUDIO_REENUMERATE;  
          break;
          
        default:
          break;
        }
      }
    }
    break;
    
  case AUDIO_DEMO_EXPLORE: 
    if(Appli_state == APPLICATION_AUDIO)
    {
      if(Audio_ShowWavFiles() > 0)
      {
        LCD_ErrLog("There is no WAV file on the microSD.\n");         
        Audio_ChangeSelectMode(AUDIO_SELECT_MENU);  
      }
      else
      {
        audio_demo.state = AUDIO_DEMO_WAIT;
      }
    }
    break; 
    
  case AUDIO_DEMO_PLAYBACK:
    if(Appli_state == APPLICATION_AUDIO)
    {
      if(audio_state == AUDIO_STATE_IDLE)
      {
        /* Start Playing...*/
        audio_state = AUDIO_STATE_INIT;
        if(AUDIO_Start(0) == AUDIO_ERROR_IO)
        {
          Audio_ChangeSelectMode(AUDIO_SELECT_MENU);  
        }
        else
        {
          BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); 
          BSP_LCD_DisplayStringAtLine(10, (uint8_t *)"[  UP   ] : Volume +");
          BSP_LCD_DisplayStringAtLine(11, (uint8_t *)"[ DOWN  ] : Volume -");
          BSP_LCD_DisplayStringAtLine(12, (uint8_t *)"[ LEFT  ] : Previous");
          BSP_LCD_DisplayStringAtLine(13, (uint8_t *)"[ RIGHT ] : Next");
          BSP_LCD_DisplayStringAtLine(14, (uint8_t *)"[  SEL  ] : Pause/Resume");
          BSP_LCD_SetTextColor(LCD_COLOR_WHITE);           
        }
      }
      else /* Not idle */
      {
        if(AUDIO_Process() == AUDIO_ERROR_IO)
        {
          Audio_ChangeSelectMode(AUDIO_SELECT_MENU);  
        }
      }
    }
    break;    
    
  case AUDIO_REENUMERATE:
    /* Force Audio Device to re-enumerate */   
    USBH_ReEnumerate(&hUSBHost);
    audio_demo.state = AUDIO_DEMO_WAIT;
    break;
    
  default:
    break;
  }  
}
/**
  * @brief  User task
  * @param  pvParameters not used
  * @retval None
  */
void HID_MenuThread(void const *argument)
{
  for(;;)
  {
    if(osSemaphoreWait(MenuEvent , osWaitForever) == osOK)
    {
      switch(hid_demo.state)
      {
      case HID_DEMO_IDLE:
        HID_SelectItem(DEMO_HID_menu, 0); 
        hid_demo.state = HID_DEMO_WAIT;
        hid_demo.select = 0;
        osSemaphoreRelease(MenuEvent);
        break;        
        
      case HID_DEMO_WAIT:
        if(hid_demo.select != prev_select)
        {
          prev_select = hid_demo.select;        
          
          HID_SelectItem(DEMO_HID_menu, hid_demo.select & 0x7F); 
          /* Handle select item */
          if(hid_demo.select & 0x80)
          {
            switch(hid_demo.select & 0x7F)
            {
            case 0:
              hid_demo.state = HID_DEMO_START; 
              osSemaphoreRelease(MenuEvent);
              break;
              
            case 1:
              hid_demo.state = HID_DEMO_REENUMERATE;
              osSemaphoreRelease(MenuEvent);
              break;
              
            default:
              break;
            }
          }
        }
        break; 
        
      case HID_DEMO_START:
        if(Appli_state == APPLICATION_READY)
        {
          if(USBH_HID_GetDeviceType(&hUSBHost) == HID_KEYBOARD)
          {
            hid_demo.keyboard_state = HID_KEYBOARD_IDLE; 
            hid_demo.state = HID_DEMO_KEYBOARD;
          }
          else if(USBH_HID_GetDeviceType(&hUSBHost) == HID_MOUSE)
          {
            hid_demo.mouse_state = HID_MOUSE_IDLE;  
            hid_demo.state = HID_DEMO_MOUSE;        
          }
        }
        else
        {
          LCD_ErrLog("No supported HID device!\n");
          hid_demo.state = HID_DEMO_WAIT;
        }
        osSemaphoreRelease(MenuEvent);
        break;
        
      case HID_DEMO_REENUMERATE:
        /* Force MSC Device to re-enumerate */
        USBH_ReEnumerate(&hUSBHost); 
        hid_demo.state = HID_DEMO_WAIT;
        osSemaphoreRelease(MenuEvent);
        break;
        
      case HID_DEMO_MOUSE:
        if(Appli_state == APPLICATION_READY)
        {
          HID_MouseMenuProcess();
          USBH_MouseDemo(&hUSBHost);
        }
        break; 
        
      case HID_DEMO_KEYBOARD:
        if(Appli_state == APPLICATION_READY)  
        {    
          HID_KeyboardMenuProcess();
          USBH_KeybdDemo(&hUSBHost);
        }   
        break;
        
      default:
        break;
      }
      
      if(Appli_state == APPLICATION_DISCONNECT)
      {
        Appli_state = APPLICATION_IDLE; 
        LCD_LOG_ClearTextZone();
        LCD_ErrLog("HID device disconnected!\n");
        hid_demo.state = HID_DEMO_IDLE;
        hid_demo.select = 0;    
      }
      hid_demo.select &= 0x7F;
    }
  }
}
Exemplo n.º 6
0
/**
  * @brief  Manages MSC Menu Process.
  * @param  None
  * @retval None
  */
void MSC_MenuProcess(void)
{
  switch(msc_demo.state)
  {
  case MSC_DEMO_IDLE:
    MSC_SelectItem(MSC_main_menu, 0); 
    msc_demo.state = MSC_DEMO_WAIT;
    msc_demo.select = 0;
    break;    
    
  case MSC_DEMO_WAIT:
    if(msc_demo.select != prev_select)
    {
      prev_select = msc_demo.select;
      MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F);
      
      /* Handle select item */
      if(msc_demo.select & 0x80)
      {
        switch(msc_demo.select & 0x7F)
        {
        case 0:
          msc_demo.state = MSC_DEMO_FILE_OPERATIONS;  
          break;
          
        case 1:
          msc_demo.state = MSC_DEMO_EXPLORER;  
          break;
          
        case 2:
          msc_demo.state = MSC_REENUMERATE;  
          break;
          
        default:
          break;
        }
      }
    }
    break;
    
  case MSC_DEMO_FILE_OPERATIONS:
    /* Read and Write File Here */
    if(Appli_state == APPLICATION_READY)
    {
      MSC_File_Operations();
    }
    msc_demo.state = MSC_DEMO_WAIT;
    break; 
    
  case MSC_DEMO_EXPLORER:
    /* Display disk content */
    if(Appli_state == APPLICATION_READY)
    {        
      Explore_Disk("0:/", 1);
    }
    msc_demo.state = MSC_DEMO_WAIT;
    break; 
    
  case MSC_REENUMERATE:
    /* Force MSC Device to re-enumerate */
    USBH_ReEnumerate(&hUSBHost); 
    msc_demo.state = MSC_DEMO_WAIT;
    break;
    
  default:
    break;
  }
  msc_demo.select &= 0x7F;
} 
Exemplo n.º 7
0
/**
  * @brief  Manages DUAL Menu Process.
  * @param  None
  * @retval None
  */
void DUAL_MenuProcess(void)
{
  switch(demo.state)
  {
  case DEMO_IDLE:
    Demo_SelectItem(DEMO_main_menu, 0); 
    LCD_UsrLog("Select an operation to continue.\n");
    demo.state = DEMO_WAIT;
    demo.select = 0;
    break;    
  case DEMO_WAIT:
    
    if(demo.select != prev_select)
    {
      prev_select = demo.select;
      Demo_SelectItem(DEMO_main_menu, demo.select & 0x7F);
      
      /* Handle select item */
      if(demo.select & 0x80)
      {
        demo.select &= 0x7F;
        
        switch(demo.select)
        {
        case 0:
          demo.state = DEMO_MSC_START;  
          break;
          
        case 1:
          demo.state = DEMO_HID_START;  
          break;
          
        case 2:
          demo.state = DEMO_MSC_REENUMERATE;
          break;
          
        case 3:
          demo.state = DEMO_HID_REENUMERATE;
          break;
          
        default:
          break;
        }
      }
    }
    break;
    
  case DEMO_MSC_START:
    if(Appli_HS_state == APPLICATION_HS_READY) 
    {
      /* If HS device connected*/
      demo.state = DEMO_MSC; 
      demo.msc_state = APPLI_MSC_IDLE;
    }
    else
    {
      LCD_ErrLog("No Mass storage device connected.\n");
      demo.state = DEMO_WAIT; 
    }
    break;
    
  case DEMO_HID_START:
    if(Appli_FS_state == APPLICATION_FS_READY)
    {
      /*if FS device connected*/
      demo.state = DEMO_HID; 
      demo.hid_state = APPLI_HID_IDLE;
    }
    else
    {
      LCD_ErrLog("No HID device connected.\n");
      demo.state = DEMO_WAIT; 
    }
    break;
    
  case DEMO_MSC: 
    MSC_MenuProcess();
    break;
    
  case DEMO_HID:
    HID_MenuProcess();
    break;
    
  case DEMO_MSC_REENUMERATE: /* Re-Enumeration MSC */
    LCD_DbgLog("Starting Enumeration MSC...."); 
    LCD_DbgLog("\n");
    USBH_ReEnumerate(&hUSBHost_HS); 
    demo.state = DEMO_WAIT;
    break;
    
  case DEMO_HID_REENUMERATE: /* Re-Enumeration HID */
    LCD_DbgLog("Starting Enumeration HID...."); 
    LCD_DbgLog("\n");
    USBH_ReEnumerate(&hUSBHost_FS);
    demo.state = DEMO_WAIT;
    break;
    
  default:
    break;
  }
  
  if(Appli_FS_state == APPLICATION_FS_DISCONNECT)
  {
    Appli_FS_state = APPLICATION_IDLE; 
    LCD_LOG_ClearTextZone();
    LCD_ErrLog("device FS disconnected!\n");
    demo.state = DEMO_IDLE;
    demo.select = 0; 
  }
  
  if(Appli_HS_state == APPLICATION_HS_DISCONNECT)
  {
    Appli_HS_state = APPLICATION_IDLE; 
    LCD_LOG_ClearTextZone();
    LCD_ErrLog("device HS disconnected!\n");
    demo.state = DEMO_IDLE;
    demo.select = 0; 
  }
}
Exemplo n.º 8
0
/**
  * @brief  Manages CDC Menu Process.
  * @param  None
  * @retval None
  */
void CDC_MenuProcess(void)
{
  switch(CdcDemo.state)
  {
  case CDC_DEMO_IDLE:
    CDC_SelectItem(CDC_main_menu, 0); 
    CdcDemo.state = CDC_DEMO_WAIT;
    CdcDemo.select = 0;
    break;    
    
  case CDC_DEMO_WAIT:
    if(CdcDemo.select != PrevSelect)
    {
      PrevSelect = CdcDemo.select;
      CDC_SelectItem(CDC_main_menu, CdcDemo.select & 0x7F);
      
      /* Handle select item */
      if(CdcDemo.select & 0x80)
      {
        switch(CdcDemo.select & 0x7F)
        {
        case 0:
          CdcDemo.state = CDC_DEMO_SEND;
          CdcDemo.Send_state = CDC_SEND_IDLE;
          break;
          
        case 1:
          CdcDemo.state = CDC_DEMO_RECEIVE; 
          CdcDemo.Receive_state = CDC_RECEIVE_IDLE;   
          break;
          
        case 2:
          CdcDemo.state = CDC_DEMO_CONFIGURATION;  
          CdcDemo.Configuration_state = CDC_CONFIGURATION_IDLE; 
          break;
          
        case 3:
          CdcDemo.state = CDC_DEMO_REENUMERATE;  
          break;
          
        default:
          break;
        }
      }
    }
    break;
    
  case CDC_DEMO_SEND: 
    if(Appli_state == APPLICATION_READY)
    {    
      CDC_Handle_Send_Menu();
    }
    else
    {
      CdcDemo.state = CDC_DEMO_WAIT;
    }  
    break; 
    
  case CDC_DEMO_RECEIVE:
    if(Appli_state == APPLICATION_READY)
    {    
      CDC_Handle_Receive_Menu();
    }    
    else
    {
      CdcDemo.state = CDC_DEMO_WAIT;
    }
    break; 
    
  case CDC_DEMO_CONFIGURATION:
    if(Appli_state == APPLICATION_READY)
    {
      CDC_Handle_Configuration_Menu();
    }
    else
    {
      CdcDemo.state = CDC_DEMO_WAIT;
    }
    break;
    
  case CDC_DEMO_REENUMERATE:
    /* Force MSC Device to re-enumerate */
    USBH_ReEnumerate(&hUSBHost); 
    CdcDemo.state = CDC_DEMO_WAIT;
    break;
    
  default:
    break;
  } 
  
  CdcDemo.select &= 0x7F;
  
  if(Appli_state == APPLICATION_DISCONNECT)
  {
    Appli_state = APPLICATION_IDLE; 
    LCD_LOG_ClearTextZone();
    LCD_ErrLog("CDC device disconnected!\n");
    CDC_ChangeSelectMode(CDC_SELECT_MENU);
    CdcDemo.state = CDC_DEMO_IDLE;
    CdcDemo.select = 0;    
  } 
} 
Exemplo n.º 9
0
/**
  * @brief  User task
  * @param  pvParameters not used
  * @retval None
  */
static void MSC_MenuThread(void const *argument)
{
  for(;;)
  {
    if(osSemaphoreWait(MenuEvent, osWaitForever) == osOK)
    {
      switch(msc_demo.state)
      {
      case MSC_DEMO_IDLE:
        MSC_SelectItem(MSC_main_menu, 0);
        msc_demo.state = MSC_DEMO_WAIT;
        msc_demo.select = 0;
        osSemaphoreRelease(MenuEvent);
        break;

      case MSC_DEMO_WAIT:
        MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F);

        /* Handle select item */
        if(msc_demo.select & 0x80)
        {
          switch(msc_demo.select & 0x7F)
          {
          case 0:
            msc_demo.state = MSC_DEMO_FILE_OPERATIONS;
            osSemaphoreRelease(MenuEvent);
            break;

          case 1:
            msc_demo.state = MSC_DEMO_EXPLORER;
            osSemaphoreRelease(MenuEvent);
            break;

          case 2:
            msc_demo.state = MSC_REENUMERATE;
            osSemaphoreRelease(MenuEvent);
            break;

          default:
            break;
          }
        }
        break;

      case MSC_DEMO_FILE_OPERATIONS:
        /* Read and Write File Here */
        if(Appli_state == APPLICATION_READY)
        {
          MSC_File_Operations();
        }
        msc_demo.state = MSC_DEMO_WAIT;
        break;

      case MSC_DEMO_EXPLORER:
        /* Display disk content */
        if(Appli_state == APPLICATION_READY)
        {
          Explore_Disk("0:/", 1);
        }
        msc_demo.state = MSC_DEMO_WAIT;
        break;

      case MSC_REENUMERATE:
        /* Force MSC Device to re-enumerate */
        USBH_ReEnumerate(&hUSBHost);
        msc_demo.state = MSC_DEMO_WAIT;
        break;

      default:
        break;
      }
      msc_demo.select &= 0x7F;
    }
  }
}
Exemplo n.º 10
0
/**
  * @brief  Manages MTP Menu Process.
  * @param  None
  * @retval None
  */
void MTP_MenuProcess(void)
{
  switch(mtp_demo.state)
  {
  case MTP_DEMO_IDLE:
    MTP_SelectItem(MTP_main_menu, 0); 
    mtp_demo.state = MTP_DEMO_WAIT;
    mtp_demo.select = 0;
    BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
    BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"Use [Joystick Left/Right] to scroll up/down");
    BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"Use [Joystick Up/Down] to scroll MTP menu");
    break;    
    
  case MTP_DEMO_WAIT:
    
    if(mtp_demo.select != prev_select)
    {
      prev_select = mtp_demo.select;
      MTP_SelectItem(MTP_main_menu, mtp_demo.select & 0x7F);
      
      /* Handle select item */
      if(mtp_demo.select & 0x80)
      {
        
        switch(mtp_demo.select & 0x7F)
        {
        case 0:
          mtp_demo.state = MTP_DEMO_EXPLORE;  
          break;
        
        case 1:         
          /* Display HMI messages */
          BSP_LCD_SetTextColor(LCD_COLOR_GREEN);          
          BSP_LCD_DisplayStringAtLine(14, (uint8_t *)"                                             ");
          BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"                                             ");          
          BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"Use [User Key] To Stop and return from player");
          BSP_LCD_SetTextColor(LCD_COLOR_WHITE); 
          
          /* Set PLAYBACK state and start playing 1st file */ 
          audio_state = AUDIO_STATE_IDLE;
          mtp_demo.state = MTP_DEMO_PLAYBACK;
          MTP_ChangeSelectMode(MTP_PLAYBACK_CONTROL);           
          break;
        
        case 2:
          mtp_demo.state = MTP_REENUMERATE;  
          break;
        
        default:
          break;
        }
      }
    }
    break;
    
  case MTP_DEMO_EXPLORE:  
    if(Appli_state == APPLICATION_READY)
    {
      if(MTP_Init() == 0)
      {
        if(MTP_ExploreWavFile() > 0)
        {
          LCD_ErrLog("There is no WAV file on the microSD.\n" );         
          MTP_ChangeSelectMode(MTP_SELECT_MENU); 
          mtp_demo.state = MTP_DEMO_IDLE;
        }
        else
        {
          mtp_demo.state = MTP_DEMO_WAIT;
        }
      }
    }
    else
    {
      mtp_demo.state = MTP_DEMO_WAIT;
    }
    break; 
    
  case MTP_DEMO_PLAYBACK:
    if(Appli_state == APPLICATION_READY)
    {
      if(MTP_Init() == 0)
      {
        if(audio_state == AUDIO_STATE_IDLE)
        {
          /* Start Playing */
          audio_state = AUDIO_STATE_INIT;
          if(AUDIO_Start(0) == AUDIO_ERROR_IO)
          {
            MTP_ChangeSelectMode(MTP_SELECT_MENU); 
             mtp_demo.state = MTP_DEMO_IDLE;
          }
          else
          {
            BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); 
            BSP_LCD_DisplayStringAtLine(10, (uint8_t *)"[  UP   ] : Volume +");
            BSP_LCD_DisplayStringAtLine(11, (uint8_t *)"[ DOWN  ] : Volume -");
            BSP_LCD_DisplayStringAtLine(12, (uint8_t *)"[ LEFT  ] : Previous");
            BSP_LCD_DisplayStringAtLine(13, (uint8_t *)"[ RIGHT ] : Next");
            BSP_LCD_DisplayStringAtLine(14, (uint8_t *)"[  SEL  ] : Pause/Resume");          
            BSP_LCD_SetTextColor(LCD_COLOR_WHITE);           
          }
        }
        else /* Not idle */
        {
          if(AUDIO_Process() == AUDIO_ERROR_IO)
          {
            MTP_ChangeSelectMode(MTP_SELECT_MENU);  
            mtp_demo.state = MTP_DEMO_IDLE;
          }
        }
      }
    }
    else
    {
      mtp_demo.state = MTP_DEMO_WAIT;
    }
    break; 
    
  case MTP_REENUMERATE:
    /* Force MTP Device to re-enumerate */
    USBH_ReEnumerate(&hUSBHost); 
    mtp_demo.state = MTP_DEMO_WAIT;
    break;

  default:
    break;
  }

  if(Appli_state == APPLICATION_DISCONNECT)
  {
    Appli_state = APPLICATION_IDLE;     
    BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
    MTP_ChangeSelectMode(MTP_SELECT_MENU);     
  }
   
  mtp_demo.select &= 0x7F;
}