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.
 
 
 
 
 
 

230 lines
8.3 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_ll_usb.h
  4. * @author MCD Application Team
  5. * @brief Header file of USB Low Layer HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32L1xx_LL_USB_H
  21. #define STM32L1xx_LL_USB_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32l1xx_hal_def.h"
  27. #if defined (USB)
  28. /** @addtogroup STM32L1xx_HAL_Driver
  29. * @{
  30. */
  31. /** @addtogroup USB_LL
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /**
  36. * @brief USB Mode definition
  37. */
  38. typedef enum
  39. {
  40. USB_DEVICE_MODE = 0
  41. } USB_ModeTypeDef;
  42. /**
  43. * @brief USB Initialization Structure definition
  44. */
  45. typedef struct
  46. {
  47. uint32_t dev_endpoints; /*!< Device Endpoints number.
  48. This parameter depends on the used USB core.
  49. This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
  50. uint32_t speed; /*!< USB Core speed.
  51. This parameter can be any value of @ref USB_Core_Speed */
  52. uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */
  53. uint32_t phy_itface; /*!< Select the used PHY interface.
  54. This parameter can be any value of @ref USB_Core_PHY */
  55. uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */
  56. uint32_t low_power_enable; /*!< Enable or disable Low Power mode */
  57. uint32_t lpm_enable; /*!< Enable or disable Battery charging. */
  58. uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */
  59. } USB_CfgTypeDef;
  60. typedef struct
  61. {
  62. uint8_t num; /*!< Endpoint number
  63. This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
  64. uint8_t is_in; /*!< Endpoint direction
  65. This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
  66. uint8_t is_stall; /*!< Endpoint stall condition
  67. This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
  68. uint8_t type; /*!< Endpoint type
  69. This parameter can be any value of @ref USB_EP_Type */
  70. uint8_t data_pid_start; /*!< Initial data PID
  71. This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
  72. uint16_t pmaadress; /*!< PMA Address
  73. This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
  74. uint16_t pmaaddr0; /*!< PMA Address0
  75. This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
  76. uint16_t pmaaddr1; /*!< PMA Address1
  77. This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
  78. uint8_t doublebuffer; /*!< Double buffer enable
  79. This parameter can be 0 or 1 */
  80. uint16_t tx_fifo_num; /*!< This parameter is not required by USB Device FS peripheral, it is used
  81. only by USB OTG FS peripheral
  82. This parameter is added to ensure compatibility across USB peripherals */
  83. uint32_t maxpacket; /*!< Endpoint Max packet size
  84. This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
  85. uint8_t *xfer_buff; /*!< Pointer to transfer buffer */
  86. uint32_t xfer_len; /*!< Current transfer length */
  87. uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */
  88. } USB_EPTypeDef;
  89. /* Exported constants --------------------------------------------------------*/
  90. /** @defgroup PCD_Exported_Constants PCD Exported Constants
  91. * @{
  92. */
  93. /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
  94. * @{
  95. */
  96. #define DEP0CTL_MPS_64 0U
  97. #define DEP0CTL_MPS_32 1U
  98. #define DEP0CTL_MPS_16 2U
  99. #define DEP0CTL_MPS_8 3U
  100. /**
  101. * @}
  102. */
  103. /** @defgroup USB_LL_EP_Type USB Low Layer EP Type
  104. * @{
  105. */
  106. #define EP_TYPE_CTRL 0U
  107. #define EP_TYPE_ISOC 1U
  108. #define EP_TYPE_BULK 2U
  109. #define EP_TYPE_INTR 3U
  110. #define EP_TYPE_MSK 3U
  111. /**
  112. * @}
  113. */
  114. #define BTABLE_ADDRESS 0x000U
  115. #define PMA_ACCESS 2U
  116. #define EP_ADDR_MSK 0x7U
  117. /**
  118. * @}
  119. */
  120. /* Exported macro ------------------------------------------------------------*/
  121. /**
  122. * @}
  123. */
  124. /* Exported functions --------------------------------------------------------*/
  125. /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions
  126. * @{
  127. */
  128. HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
  129. HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
  130. HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx);
  131. HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx);
  132. HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode);
  133. HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed);
  134. HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef *USBx);
  135. HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef *USBx, uint32_t num);
  136. HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
  137. HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
  138. HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep);
  139. HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len);
  140. void *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len);
  141. HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
  142. HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
  143. HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address);
  144. HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx);
  145. HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx);
  146. HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx);
  147. HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup);
  148. uint32_t USB_ReadInterrupts(USB_TypeDef *USBx);
  149. uint32_t USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx);
  150. uint32_t USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum);
  151. uint32_t USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx);
  152. uint32_t USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum);
  153. void USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt);
  154. HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx);
  155. HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx);
  156. void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
  157. void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
  158. /**
  159. * @}
  160. */
  161. /**
  162. * @}
  163. */
  164. /**
  165. * @}
  166. */
  167. /**
  168. * @}
  169. */
  170. #endif /* defined (USB) */
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174. #endif /* STM32L1xx_LL_USB_H */
  175. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/