summaryrefslogtreecommitdiffstatshomepage
path: root/stm/stmusbh/usbh_usr.c
diff options
context:
space:
mode:
Diffstat (limited to 'stm/stmusbh/usbh_usr.c')
-rw-r--r--stm/stmusbh/usbh_usr.c386
1 files changed, 386 insertions, 0 deletions
diff --git a/stm/stmusbh/usbh_usr.c b/stm/stmusbh/usbh_usr.c
new file mode 100644
index 0000000000..19312c2e40
--- /dev/null
+++ b/stm/stmusbh/usbh_usr.c
@@ -0,0 +1,386 @@
+/**
+ ******************************************************************************
+ * @file usbh_usr.c
+ * @author MCD Application Team
+ * @version V2.1.0
+ * @date 19-March-2012
+ * @brief This file includes the user application layer
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include <stdio.h>
+
+#include "usbh_usr.h"
+#include "usbh_hid_mouse.h"
+#include "usbh_hid_keybd.h"
+
+extern void led_state(int, int);
+
+/** @addtogroup USBH_USER
+* @{
+*/
+
+/** @addtogroup USBH_HID_DEMO_USER_CALLBACKS
+* @{
+*/
+
+/** @defgroup USBH_USR
+* @brief This file is the Header file for usbh_usr.c
+* @{
+*/
+
+
+/**
+* @}
+*/
+
+/** @addtogroup USER
+* @{
+*/
+
+/** @defgroup USBH_USR
+* @brief This file includes the user application layer
+* @{
+*/
+
+/** @defgroup USBH_CORE_Exported_Types
+* @{
+*/
+
+
+
+/** @defgroup USBH_USR_Private_Defines
+* @{
+*/
+/**
+* @}
+*/
+
+
+/** @defgroup USBH_USR_Private_Macros
+* @{
+*/
+/**
+* @}
+*/
+
+/** @defgroup USBH_USR_Private_Variables
+* @{
+*/
+/* Points to the DEVICE_PROP structure of current device */
+/* The purpose of this register is to speed up the execution */
+
+USBH_Usr_cb_TypeDef USR_Callbacks =
+{
+ USBH_USR_Init,
+ USBH_USR_DeInit,
+ USBH_USR_DeviceAttached,
+ USBH_USR_ResetDevice,
+ USBH_USR_DeviceDisconnected,
+ USBH_USR_OverCurrentDetected,
+ USBH_USR_DeviceSpeedDetected,
+ USBH_USR_Device_DescAvailable,
+ USBH_USR_DeviceAddressAssigned,
+ USBH_USR_Configuration_DescAvailable,
+ USBH_USR_Manufacturer_String,
+ USBH_USR_Product_String,
+ USBH_USR_SerialNum_String,
+ USBH_USR_EnumerationDone,
+ USBH_USR_UserInput,
+ NULL,
+ USBH_USR_DeviceNotSupported,
+ USBH_USR_UnrecoveredError
+};
+
+/**
+* @}
+*/
+
+/** @defgroup USBH_USR_Private_Constants
+* @{
+*/
+
+/**
+* @}
+*/
+
+
+
+/** @defgroup USBH_USR_Private_FunctionPrototypes
+* @{
+*/
+/**
+* @}
+*/
+
+
+/** @defgroup USBH_USR_Private_Functions
+* @{
+*/
+
+
+
+
+
+/**
+* @brief USBH_USR_Init
+* Displays the message on LCD for host lib initialization
+* @param None
+* @retval None
+*/
+void USBH_USR_Init(void)
+{
+ static uint8_t startup = 0;
+
+ if (startup == 0) {
+ startup = 1;
+
+ printf("USB Host library started.\n");
+ }
+}
+
+/**
+* @brief USBH_USR_DeviceAttached
+* Displays the message on LCD on device attached
+* @param None
+* @retval None
+*/
+void USBH_USR_DeviceAttached(void) {
+ led_state(1, 1);
+ USB_OTG_BSP_mDelay(900);
+}
+
+/**
+* @brief USBH_USR_UnrecoveredError
+* @param None
+* @retval None
+*/
+void USBH_USR_UnrecoveredError(void) {
+}
+
+/**
+* @brief USBH_DisconnectEvent
+* Device disconnect event
+* @param None
+* @retval None
+*/
+void USBH_USR_DeviceDisconnected (void)
+{
+ led_state(1, 0);
+ led_state(2, 0);
+ led_state(3, 0);
+ led_state(4, 0);
+ USB_OTG_BSP_mDelay(100);
+}
+
+/**
+* @brief USBH_USR_ResetUSBDevice
+* Reset USB Device
+* @param None
+* @retval None
+*/
+void USBH_USR_ResetDevice(void)
+{
+ /* Users can do their application actions here for the USB-Reset */
+ led_state(3, 1);
+ USB_OTG_BSP_mDelay(100);
+ led_state(3, 0);
+}
+
+
+/**
+* @brief USBH_USR_DeviceSpeedDetected
+* Displays the message on LCD for device speed
+* @param Devicespeed : Device Speed
+* @retval None
+*/
+void USBH_USR_DeviceSpeedDetected(uint8_t DeviceSpeed)
+{
+ /*
+ if(DeviceSpeed == HPRT0_PRTSPD_HIGH_SPEED)
+ {
+ printf(MSG_DEV_HIGHSPEED);
+ }
+ else if(DeviceSpeed == HPRT0_PRTSPD_FULL_SPEED)
+ {
+ printf(MSG_DEV_FULLSPEED);
+ }
+ else if(DeviceSpeed == HPRT0_PRTSPD_LOW_SPEED)
+ {
+ printf(MSG_DEV_LOWSPEED);
+ }
+ else
+ {
+ printf(MSG_DEV_ERROR);
+ }
+ */
+}
+
+/**
+* @brief USBH_USR_Device_DescAvailable
+* Displays the message on LCD for device descriptor
+* @param DeviceDesc : device descriptor
+* @retval None
+*/
+void USBH_USR_Device_DescAvailable(void *DeviceDesc)
+{
+ /*
+ USBH_DevDesc_TypeDef *hs;
+ hs = DeviceDesc;
+
+ printf("VID : %04Xh\n" , (unsigned int)(*hs).idVendor);
+ printf("PID : %04Xh\n" , (unsigned int)(*hs).idProduct);
+ */
+}
+
+/**
+* @brief USBH_USR_DeviceAddressAssigned
+* USB device is successfully assigned the Address
+* @param None
+* @retval None
+*/
+void USBH_USR_DeviceAddressAssigned(void)
+{
+
+}
+
+
+/**
+* @brief USBH_USR_Conf_Desc
+* Displays the message on LCD for configuration descriptor
+* @param ConfDesc : Configuration descriptor
+* @retval None
+*/
+void USBH_USR_Configuration_DescAvailable(USBH_CfgDesc_TypeDef * cfgDesc,
+ USBH_InterfaceDesc_TypeDef *itfDesc,
+ USBH_EpDesc_TypeDef *epDesc)
+{
+ /*
+ USBH_InterfaceDesc_TypeDef *id;
+
+ id = itfDesc;
+
+ if((*id).bInterfaceClass == 0x08)
+ {
+ printf(MSG_MSC_CLASS);
+ }
+ else if((*id).bInterfaceClass == 0x03)
+ {
+ printf(MSG_HID_CLASS);
+ }
+ */
+}
+
+/**
+* @brief USBH_USR_Manufacturer_String
+* Displays the message on LCD for Manufacturer String
+* @param ManufacturerString : Manufacturer String of Device
+* @retval None
+*/
+void USBH_USR_Manufacturer_String(void *ManufacturerString) {
+}
+
+/**
+* @brief USBH_USR_Product_String
+* Displays the message on LCD for Product String
+* @param ProductString : Product String of Device
+* @retval None
+*/
+void USBH_USR_Product_String(void *ProductString) {
+}
+
+/**
+* @brief USBH_USR_SerialNum_String
+* Displays the message on LCD for SerialNum_String
+* @param SerialNumString : SerialNum_String of device
+* @retval None
+*/
+void USBH_USR_SerialNum_String(void *SerialNumString) {
+}
+
+/**
+* @brief EnumerationDone
+* User response request is displayed to ask for
+* application jump to class
+* @param None
+* @retval None
+*/
+void USBH_USR_EnumerationDone(void) {
+ /* Enumeration complete */
+ led_state(2, 1);
+ USB_OTG_BSP_mDelay(500);
+}
+
+/**
+* @brief USBH_USR_DeviceNotSupported
+* Device is not supported
+* @param None
+* @retval None
+*/
+void USBH_USR_DeviceNotSupported(void){
+}
+
+
+/**
+* @brief USBH_USR_UserInput
+* User Action for application state entry
+* @param None
+* @retval USBH_USR_Status : User response for key button
+*/
+USBH_USR_Status USBH_USR_UserInput(void) {
+ return USBH_USR_RESP_OK;
+}
+
+/**
+* @brief USBH_USR_OverCurrentDetected
+* Device Overcurrent detection event
+* @param None
+* @retval None
+*/
+void USBH_USR_OverCurrentDetected(void) {
+}
+
+/**
+* @brief USBH_USR_DeInit
+* Deint User state and associated variables
+* @param None
+* @retval None
+*/
+void USBH_USR_DeInit(void)
+{
+}
+
+/**
+* @}
+*/
+
+/**
+* @}
+*/
+
+/**
+* @}
+*/
+
+/**
+* @}
+*/
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/