Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

103 lines
2.5 KiB

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : usb_device.c
  5. * @version : v2.0_Cube
  6. * @brief : This file implements the USB Device
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under Ultimate Liberty license
  14. * SLA0044, the "License"; You may not use this file except in compliance with
  15. * the License. You may obtain a copy of the License at:
  16. * www.st.com/SLA0044
  17. *
  18. ******************************************************************************
  19. */
  20. /* USER CODE END Header */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "usb_device.h"
  23. #include "usbd_core.h"
  24. #include "usbd_desc.h"
  25. #include "usbd_cdc.h"
  26. #include "usbd_cdc_if.h"
  27. /* USER CODE BEGIN Includes */
  28. /* USER CODE END Includes */
  29. /* USER CODE BEGIN PV */
  30. /* Private variables ---------------------------------------------------------*/
  31. /* USER CODE END PV */
  32. /* USER CODE BEGIN PFP */
  33. /* Private function prototypes -----------------------------------------------*/
  34. /* USER CODE END PFP */
  35. /* USB Device Core handle declaration. */
  36. USBD_HandleTypeDef hUsbDeviceFS;
  37. /*
  38. * -- Insert your variables declaration here --
  39. */
  40. /* USER CODE BEGIN 0 */
  41. /* USER CODE END 0 */
  42. /*
  43. * -- Insert your external function declaration here --
  44. */
  45. /* USER CODE BEGIN 1 */
  46. /* USER CODE END 1 */
  47. /**
  48. * Init USB device Library, add supported class and start the library
  49. * @retval None
  50. */
  51. void MX_USB_DEVICE_Init(void)
  52. {
  53. /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
  54. /* USER CODE END USB_DEVICE_Init_PreTreatment */
  55. /* Init Device Library, add supported class and start the library. */
  56. if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
  57. {
  58. Error_Handler();
  59. }
  60. if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK)
  61. {
  62. Error_Handler();
  63. }
  64. if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK)
  65. {
  66. Error_Handler();
  67. }
  68. if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
  69. {
  70. Error_Handler();
  71. }
  72. /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
  73. vcp_usb = funopen(&vcp_usb, NULL, usb_write, NULL, NULL);
  74. /* USER CODE END USB_DEVICE_Init_PostTreatment */
  75. }
  76. /**
  77. * @}
  78. */
  79. /**
  80. * @}
  81. */
  82. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/