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.
 
 
 
 
 
 

168 lines
3.9 KiB

  1. /**
  2. ******************************************************************************
  3. * @file usbd_customhid.h
  4. * @author MCD Application Team
  5. * @brief header file for the usbd_customhid.c file.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __USB_CUSTOMHID_H
  21. #define __USB_CUSTOMHID_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "usbd_ioreq.h"
  27. /** @addtogroup STM32_USB_DEVICE_LIBRARY
  28. * @{
  29. */
  30. /** @defgroup USBD_CUSTOM_HID
  31. * @brief This file is the Header file for USBD_customhid.c
  32. * @{
  33. */
  34. /** @defgroup USBD_CUSTOM_HID_Exported_Defines
  35. * @{
  36. */
  37. #define CUSTOM_HID_EPIN_ADDR 0x81U
  38. #define CUSTOM_HID_EPIN_SIZE 0x02U
  39. #define CUSTOM_HID_EPOUT_ADDR 0x01U
  40. #define CUSTOM_HID_EPOUT_SIZE 0x02U
  41. #define USB_CUSTOM_HID_CONFIG_DESC_SIZ 41U
  42. #define USB_CUSTOM_HID_DESC_SIZ 9U
  43. #ifndef CUSTOM_HID_HS_BINTERVAL
  44. #define CUSTOM_HID_HS_BINTERVAL 0x05U
  45. #endif /* CUSTOM_HID_HS_BINTERVAL */
  46. #ifndef CUSTOM_HID_FS_BINTERVAL
  47. #define CUSTOM_HID_FS_BINTERVAL 0x05U
  48. #endif /* CUSTOM_HID_FS_BINTERVAL */
  49. #ifndef USBD_CUSTOMHID_OUTREPORT_BUF_SIZE
  50. #define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
  51. #endif /* USBD_CUSTOMHID_OUTREPORT_BUF_SIZE */
  52. #ifndef USBD_CUSTOM_HID_REPORT_DESC_SIZE
  53. #define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
  54. #endif /* USBD_CUSTOM_HID_REPORT_DESC_SIZE */
  55. #define CUSTOM_HID_DESCRIPTOR_TYPE 0x21U
  56. #define CUSTOM_HID_REPORT_DESC 0x22U
  57. #define CUSTOM_HID_REQ_SET_PROTOCOL 0x0BU
  58. #define CUSTOM_HID_REQ_GET_PROTOCOL 0x03U
  59. #define CUSTOM_HID_REQ_SET_IDLE 0x0AU
  60. #define CUSTOM_HID_REQ_GET_IDLE 0x02U
  61. #define CUSTOM_HID_REQ_SET_REPORT 0x09U
  62. #define CUSTOM_HID_REQ_GET_REPORT 0x01U
  63. /**
  64. * @}
  65. */
  66. /** @defgroup USBD_CORE_Exported_TypesDefinitions
  67. * @{
  68. */
  69. typedef enum
  70. {
  71. CUSTOM_HID_IDLE = 0U,
  72. CUSTOM_HID_BUSY,
  73. }
  74. CUSTOM_HID_StateTypeDef;
  75. typedef struct _USBD_CUSTOM_HID_Itf
  76. {
  77. uint8_t *pReport;
  78. uint16_t pReportLen;
  79. int8_t (* Init)(void);
  80. int8_t (* DeInit)(void);
  81. int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
  82. } USBD_CUSTOM_HID_ItfTypeDef;
  83. typedef struct
  84. {
  85. uint8_t Report_buf[USBD_CUSTOMHID_OUTREPORT_BUF_SIZE];
  86. uint32_t Protocol;
  87. uint32_t IdleState;
  88. uint32_t AltSetting;
  89. uint32_t IsReportAvailable;
  90. CUSTOM_HID_StateTypeDef state;
  91. }
  92. USBD_CUSTOM_HID_HandleTypeDef;
  93. /**
  94. * @}
  95. */
  96. /** @defgroup USBD_CORE_Exported_Macros
  97. * @{
  98. */
  99. /**
  100. * @}
  101. */
  102. /** @defgroup USBD_CORE_Exported_Variables
  103. * @{
  104. */
  105. extern USBD_ClassTypeDef USBD_CUSTOM_HID;
  106. #define USBD_CUSTOM_HID_CLASS &USBD_CUSTOM_HID
  107. /**
  108. * @}
  109. */
  110. /** @defgroup USB_CORE_Exported_Functions
  111. * @{
  112. */
  113. uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
  114. uint8_t *report,
  115. uint16_t len);
  116. uint8_t USBD_CUSTOM_HID_RegisterInterface(USBD_HandleTypeDef *pdev,
  117. USBD_CUSTOM_HID_ItfTypeDef *fops);
  118. /**
  119. * @}
  120. */
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif /* __USB_CUSTOMHID_H */
  125. /**
  126. * @}
  127. */
  128. /**
  129. * @}
  130. */
  131. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/