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.
 
 
 
 
 
 

105 lines
2.6 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. FILE *vcp_usb;
  32. /* USER CODE END PV */
  33. /* USER CODE BEGIN PFP */
  34. /* Private function prototypes -----------------------------------------------*/
  35. /* USER CODE END PFP */
  36. /* USB Device Core handle declaration. */
  37. USBD_HandleTypeDef hUsbDeviceFS;
  38. /*
  39. * -- Insert your variables declaration here --
  40. */
  41. /* USER CODE BEGIN 0 */
  42. /* USER CODE END 0 */
  43. /*
  44. * -- Insert your external function declaration here --
  45. */
  46. /* USER CODE BEGIN 1 */
  47. /* USER CODE END 1 */
  48. /**
  49. * Init USB device Library, add supported class and start the library
  50. * @retval None
  51. */
  52. void MX_USB_DEVICE_Init(void)
  53. {
  54. /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
  55. /* USER CODE END USB_DEVICE_Init_PreTreatment */
  56. /* Init Device Library, add supported class and start the library. */
  57. if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
  58. {
  59. Error_Handler();
  60. }
  61. if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK)
  62. {
  63. Error_Handler();
  64. }
  65. if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK)
  66. {
  67. Error_Handler();
  68. }
  69. if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
  70. {
  71. Error_Handler();
  72. }
  73. /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
  74. vcp_usb = funopen(&vcp_usb, NULL, usb_write, NULL, NULL);
  75. /* USER CODE END USB_DEVICE_Init_PostTreatment */
  76. }
  77. /**
  78. * @}
  79. */
  80. /**
  81. * @}
  82. */
  83. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/