mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-31 00:32:52 +00:00
139 lines
3.1 KiB
C
139 lines
3.1 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file : usb_host.c
|
|
* @version : v1.0_Cube
|
|
* @brief : This file implements the USB Host
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
|
* All rights reserved.</center></h2>
|
|
*
|
|
* This software component is licensed by ST under Ultimate Liberty license
|
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at:
|
|
* www.st.com/SLA0044
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
#include "usb_host.h"
|
|
#include "usbh_core.h"
|
|
#include "usbh_hid.h"
|
|
|
|
/* USER CODE BEGIN Includes */
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
/* USER CODE BEGIN PV */
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
/* USER CODE END PV */
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
/* USB Host core handle declaration */
|
|
USBH_HandleTypeDef hUsbHostFS;
|
|
ApplicationTypeDef Appli_state = APPLICATION_IDLE;
|
|
|
|
/*
|
|
* -- Insert your variables declaration here --
|
|
*/
|
|
/* USER CODE BEGIN 0 */
|
|
|
|
/* USER CODE END 0 */
|
|
|
|
/*
|
|
* user callback declaration
|
|
*/
|
|
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id);
|
|
|
|
/*
|
|
* -- Insert your external function declaration here --
|
|
*/
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|
|
|
|
/**
|
|
* Init USB host library, add supported class and start the library
|
|
* @retval None
|
|
*/
|
|
void MX_USB_HOST_Init(void)
|
|
{
|
|
/* USER CODE BEGIN USB_HOST_Init_PreTreatment */
|
|
|
|
/* USER CODE END USB_HOST_Init_PreTreatment */
|
|
|
|
/* Init host Library, add supported class and start the library. */
|
|
if (USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS) != USBH_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
if (USBH_RegisterClass(&hUsbHostFS, USBH_HID_CLASS) != USBH_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
if (USBH_Start(&hUsbHostFS) != USBH_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
/* USER CODE BEGIN USB_HOST_Init_PostTreatment */
|
|
|
|
/* USER CODE END USB_HOST_Init_PostTreatment */
|
|
}
|
|
|
|
/*
|
|
* Background task
|
|
*/
|
|
void MX_USB_HOST_Process(void)
|
|
{
|
|
/* USB Host Background task */
|
|
USBH_Process(&hUsbHostFS);
|
|
}
|
|
/*
|
|
* user callback definition
|
|
*/
|
|
static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id)
|
|
{
|
|
/* USER CODE BEGIN CALL_BACK_1 */
|
|
switch(id)
|
|
{
|
|
case HOST_USER_SELECT_CONFIGURATION:
|
|
break;
|
|
|
|
case HOST_USER_DISCONNECTION:
|
|
Appli_state = APPLICATION_DISCONNECT;
|
|
break;
|
|
|
|
case HOST_USER_CLASS_ACTIVE:
|
|
Appli_state = APPLICATION_READY;
|
|
break;
|
|
|
|
case HOST_USER_CONNECTION:
|
|
Appli_state = APPLICATION_START;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
/* USER CODE END CALL_BACK_1 */
|
|
}
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|