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.
 
 
 
 
 
 

190 lines
5.6 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_pcd_ex.c
  4. * @author MCD Application Team
  5. * @brief PCD Extended HAL module driver.
  6. * This file provides firmware functions to manage the following
  7. * functionalities of the USB Peripheral Controller:
  8. * + Extended features functions
  9. *
  10. ******************************************************************************
  11. * @attention
  12. *
  13. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  14. * All rights reserved.</center></h2>
  15. *
  16. * This software component is licensed by ST under BSD 3-Clause license,
  17. * the "License"; You may not use this file except in compliance with the
  18. * License. You may obtain a copy of the License at:
  19. * opensource.org/licenses/BSD-3-Clause
  20. *
  21. ******************************************************************************
  22. */
  23. /* Includes ------------------------------------------------------------------*/
  24. #include "stm32l1xx_hal.h"
  25. /** @addtogroup STM32L1xx_HAL_Driver
  26. * @{
  27. */
  28. /** @defgroup PCDEx PCDEx
  29. * @brief PCD Extended HAL module driver
  30. * @{
  31. */
  32. #ifdef HAL_PCD_MODULE_ENABLED
  33. #if defined (USB)
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /* Private macros ------------------------------------------------------------*/
  38. /* Private functions ---------------------------------------------------------*/
  39. /* Exported functions --------------------------------------------------------*/
  40. /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions
  41. * @{
  42. */
  43. /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
  44. * @brief PCDEx control functions
  45. *
  46. @verbatim
  47. ===============================================================================
  48. ##### Extended features functions #####
  49. ===============================================================================
  50. [..] This section provides functions allowing to:
  51. (+) Update FIFO configuration
  52. @endverbatim
  53. * @{
  54. */
  55. /**
  56. * @brief Configure PMA for EP
  57. * @param hpcd Device instance
  58. * @param ep_addr endpoint address
  59. * @param ep_kind endpoint Kind
  60. * USB_SNG_BUF: Single Buffer used
  61. * USB_DBL_BUF: Double Buffer used
  62. * @param pmaadress: EP address in The PMA: In case of single buffer endpoint
  63. * this parameter is 16-bit value providing the address
  64. * in PMA allocated to endpoint.
  65. * In case of double buffer endpoint this parameter
  66. * is a 32-bit value providing the endpoint buffer 0 address
  67. * in the LSB part of 32-bit value and endpoint buffer 1 address
  68. * in the MSB part of 32-bit value.
  69. * @retval HAL status
  70. */
  71. HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd,
  72. uint16_t ep_addr,
  73. uint16_t ep_kind,
  74. uint32_t pmaadress)
  75. {
  76. PCD_EPTypeDef *ep;
  77. /* initialize ep structure*/
  78. if ((0x80U & ep_addr) == 0x80U)
  79. {
  80. ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
  81. }
  82. else
  83. {
  84. ep = &hpcd->OUT_ep[ep_addr];
  85. }
  86. /* Here we check if the endpoint is single or double Buffer*/
  87. if (ep_kind == PCD_SNG_BUF)
  88. {
  89. /* Single Buffer */
  90. ep->doublebuffer = 0U;
  91. /* Configure the PMA */
  92. ep->pmaadress = (uint16_t)pmaadress;
  93. }
  94. else /* USB_DBL_BUF */
  95. {
  96. /* Double Buffer Endpoint */
  97. ep->doublebuffer = 1U;
  98. /* Configure the PMA */
  99. ep->pmaaddr0 = (uint16_t)(pmaadress & 0xFFFFU);
  100. ep->pmaaddr1 = (uint16_t)((pmaadress & 0xFFFF0000U) >> 16);
  101. }
  102. return HAL_OK;
  103. }
  104. /**
  105. * @brief Software Device Connection,
  106. * this function is not required by USB OTG FS peripheral, it is used
  107. * only by USB Device FS peripheral.
  108. * @param hpcd: PCD handle
  109. * @param state: connection state (0 : disconnected / 1: connected)
  110. * @retval None
  111. */
  112. __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state)
  113. {
  114. /* Prevent unused argument(s) compilation warning */
  115. UNUSED(hpcd);
  116. UNUSED(state);
  117. /* NOTE : This function Should not be modified, when the callback is needed,
  118. the HAL_PCDEx_SetConnectionState could be implemented in the user file
  119. */
  120. }
  121. /**
  122. * @brief Send LPM message to user layer callback.
  123. * @param hpcd PCD handle
  124. * @param msg LPM message
  125. * @retval HAL status
  126. */
  127. __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
  128. {
  129. /* Prevent unused argument(s) compilation warning */
  130. UNUSED(hpcd);
  131. UNUSED(msg);
  132. /* NOTE : This function should not be modified, when the callback is needed,
  133. the HAL_PCDEx_LPM_Callback could be implemented in the user file
  134. */
  135. }
  136. /**
  137. * @brief Send BatteryCharging message to user layer callback.
  138. * @param hpcd PCD handle
  139. * @param msg LPM message
  140. * @retval HAL status
  141. */
  142. __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg)
  143. {
  144. /* Prevent unused argument(s) compilation warning */
  145. UNUSED(hpcd);
  146. UNUSED(msg);
  147. /* NOTE : This function should not be modified, when the callback is needed,
  148. the HAL_PCDEx_BCD_Callback could be implemented in the user file
  149. */
  150. }
  151. /**
  152. * @}
  153. */
  154. /**
  155. * @}
  156. */
  157. #endif /* defined (USB) */
  158. #endif /* HAL_PCD_MODULE_ENABLED */
  159. /**
  160. * @}
  161. */
  162. /**
  163. * @}
  164. */
  165. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/