ft32f0xx_opa.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /**
  2. ******************************************************************************
  3. * @file ft32f0xx_opa.h
  4. * @author FMD AE
  5. * @brief This file contains all the functions prototypes for the OPA firmware
  6. * library.
  7. * @version V1.0.0
  8. * @data 2021-07-01
  9. ******************************************************************************
  10. */
  11. /* Define to prevent recursive inclusion -------------------------------------*/
  12. #ifndef __FT32F0XX_OPA_H
  13. #define __FT32F0XX_OPA_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* Includes ------------------------------------------------------------------*/
  18. #include "ft32f0xx.h"
  19. /** @addtogroup OPA
  20. * @{
  21. */
  22. /* Exported types ------------------------------------------------------------*/
  23. /**
  24. * @brief OPA Init structure definition
  25. */
  26. typedef struct
  27. {
  28. uint32_t OPA_OP0PSel; /*!< Select the positive input of the OPA.
  29. This parameter can be a value of @ref OPA_OP0PSel */
  30. uint32_t OPA_OP0NSel; /*!< Select the negative input of the OPA.
  31. This parameter can be a value of @ref OPA_OP0NSel */
  32. uint32_t OPA_OP0FR; /*!< Selects The feedback resister of the OPA.
  33. This parameter can be a value of @ref OPA_OP0FR */
  34. uint32_t OPA_OP0FCAPE; /*!< Selects The compensate cap of the OPA.
  35. This parameter can be a value of @ref OPA_OP0FCAPE */
  36. uint32_t OPA_OPTODIG; /*!< Selects The output to REG of the OPA.
  37. This parameter can be a value of @ref OPA_OPTODIG */
  38. uint32_t OPA_OPTOIO; /*!< Selects The output to PA0 of the OPA.
  39. This parameter can be a value of @ref OPA_OPTOIO */
  40. }OPA_InitTypeDef;
  41. /* Exported constants --------------------------------------------------------*/
  42. /**
  43. * @}
  44. */
  45. /** @defgroup OPA_Exported_Constants
  46. * @{
  47. */
  48. #define IS_OPA_ALL_PERIPH(PERIPH) (((PERIPH) == OPA) || ((PERIPH) == OPA2))
  49. /** @defgroup OPA_OP0PSel
  50. * @{
  51. */
  52. #define OPA_VIP_SEL_PA1 ((uint32_t)0x00000000)
  53. #define OPA_VIP_SEL_GND ((uint32_t)0x00008000)
  54. #define OPA1_VIP_SEL_PA1 OPA_VIP_SEL_PA1
  55. #define OPA1_VIP_SEL_GND OPA_VIP_SEL_GND
  56. #define OPA2_VIP_SEL_PA3 ((uint32_t)0x00000000)
  57. #define OPA2_VIP_SEL_PA4 ((uint32_t)0x00020000)
  58. #define OPA2_VIP_SEL_GND ((uint32_t)0x00008000)
  59. #define IS_OPA_VIP_SEL(INPUT) ( ((INPUT) == OPA_VIP_SEL_PA1) || \
  60. ((INPUT) == OPA2_VIP_SEL_PA4) || \
  61. ((INPUT) == OPA_VIP_SEL_GND) )
  62. /**
  63. * @}
  64. */
  65. /** @defgroup OPA_OP0NSel
  66. * @{
  67. */
  68. #define OPA_VIN_SEL_GND ((uint32_t)0x00000000)
  69. #define OPA_VIN_SEL_PA2 ((uint32_t)0x00002000)
  70. #define OPA_VIN_SEL_R4K_PA2 ((uint32_t)0x00004000)
  71. #define OPA_VIN_SEL_R4K_GND ((uint32_t)0x00006000)
  72. #define OPA2_VIN_SEL_GND ((uint32_t)0x00000000)
  73. #define OPA2_VIN_SEL_PF4 ((uint32_t)0x00002000)
  74. #define OPA2_VIN_SEL_R4K_PF4 ((uint32_t)0x00004000)
  75. #define OPA2_VIN_SEL_R4K_GND ((uint32_t)0x00006000)
  76. #define IS_OPA_VIN_SEL(INPUT) ( ((INPUT) == OPA_VIN_SEL_GND) || \
  77. ((INPUT) == OPA_VIN_SEL_PA2) || \
  78. ((INPUT) == OPA_VIN_SEL_R4K_PA2) || \
  79. ((INPUT) == OPA_VIN_SEL_R4K_GND) )
  80. /**
  81. * @}
  82. */
  83. /** @defgroup OPA_OP0FR
  84. * @{
  85. */
  86. #define OPA_FR_SEL_NORES ((uint32_t)0x00000000)
  87. #define OPA_FR_SEL_40K ((uint32_t)0x00001000)
  88. #define OPA_FR_SEL_80K ((uint32_t)0x00001400)
  89. #define OPA_FR_SEL_160K ((uint32_t)0x00001800)
  90. #define OPA_FR_SEL_320K ((uint32_t)0x00001C00)
  91. #define OPA2_FR_SEL_NORES ((uint32_t)0x00000000)
  92. #define OPA2_FR_SEL_40K ((uint32_t)0x00001000)
  93. #define OPA2_FR_SEL_80K ((uint32_t)0x00001400)
  94. #define OPA2_FR_SEL_160K ((uint32_t)0x00001800)
  95. #define OPA2_FR_SEL_320K ((uint32_t)0x00001C00)
  96. #define IS_OPA_FR_SEL(INPUT) ( ((INPUT) == OPA_FR_SEL_NORES) || \
  97. ((INPUT) == OPA_FR_SEL_40K) || \
  98. ((INPUT) == OPA_FR_SEL_80K) || \
  99. ((INPUT) == OPA_FR_SEL_160K) || \
  100. ((INPUT) == OPA_FR_SEL_320K) )
  101. /**
  102. * @}
  103. */
  104. /** @defgroup OPA_OP0FCAPE
  105. * @{
  106. */
  107. #define OPA_FCAP_SEL_EN ((uint32_t)0x00000000)
  108. #define OPA_FCAP_SEL_DIS ((uint32_t)0x00000200)
  109. #define OPA2_FCAP_SEL_EN ((uint32_t)0x00000000)
  110. #define OPA2_FCAP_SEL_DIS ((uint32_t)0x00000200)
  111. #define IS_OPA_FCAP_SEL(INPUT) (((INPUT) == OPA_FCAP_SEL_EN) || \
  112. ((INPUT) == OPA_FCAP_SEL_DIS))
  113. /**
  114. * @}
  115. */
  116. /** @defgroup OPA_OPTODIG
  117. * @{
  118. */
  119. #define OPA_ODIG_SEL_DIS ((uint32_t)0x00000000)
  120. #define OPA_ODIG_SEL_EN ((uint32_t)0x00000080)
  121. #define OPA2_ODIG_SEL_DIS ((uint32_t)0x00000000)
  122. #define OPA2_ODIG_SEL_EN ((uint32_t)0x00000080)
  123. #define IS_OPA_ODIG_SEL(INPUT) (((INPUT) == OPA_ODIG_SEL_DIS) || \
  124. ((INPUT) == OPA_ODIG_SEL_EN))
  125. /**
  126. * @}
  127. */
  128. /** @defgroup OPA_OPTOIO
  129. * @{
  130. */
  131. #define OPA_OIO_SEL_DIS ((uint32_t)0x00000000)
  132. #define OPA_OIO_SEL_EN ((uint32_t)0x00000040)
  133. #define OPA2_OIO_SEL_DIS ((uint32_t)0x00000000)
  134. #define OPA2_OIO_SEL_EN ((uint32_t)0x00000040)
  135. #define IS_OPA_OIO_SEL(INPUT) (((INPUT) == OPA_OIO_SEL_DIS) || \
  136. ((INPUT) == OPA_OIO_SEL_EN))
  137. #define OPA_OutputLevel_High ((uint32_t)0x00010000)
  138. #define OPA_OutputLevel_Low ((uint32_t)0x00000000)
  139. #define IS_OPA_OUTPUT_LEVEL(LEVEL) ( ((LEVEL) == OPA_OutputLevel_High) || \
  140. ((LEVEL) == OPA_OutputLevel_Low))
  141. /**
  142. * @}
  143. */
  144. /**
  145. * @}
  146. */
  147. /* Exported macro ------------------------------------------------------------*/
  148. /* Exported functions ------------------------------------------------------- */
  149. /* Function used to set the OPA configuration to the default reset state ****/
  150. void OPA_DeInit(OPA_TypeDef* OPAx);
  151. /* Initialization and Configuration functions *********************************/
  152. void OPA_Init(OPA_TypeDef* OPAx, OPA_InitTypeDef* OPA_InitStruct);
  153. void OPA_StructInit(OPA_InitTypeDef* OPA_InitStruct);
  154. void OPA_Cmd(OPA_TypeDef* OPAx, FunctionalState NewState);
  155. uint32_t OPA_GetOutputLevel(OPA_TypeDef* OPAx, uint32_t OPA_OutLevel);
  156. uint8_t OPA_Cali(OPA_TypeDef* OPAx);
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif /*__FT32F0XX_OPA_H */
  161. /**
  162. * @}
  163. */
  164. /**
  165. * @}
  166. */
  167. /************************ (C) COPYRIGHT FMD *****END OF FILE****/