ft32f0xx_div.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. ******************************************************************************
  3. * @file FT32f0xx_div.h
  4. * @author FMD AE
  5. * @brief This file contains all the functions prototypes for the dividor firmware
  6. * library.
  7. * @version V1.0.0
  8. * @data 2021-12-01
  9. ******************************************************************************
  10. */
  11. /* Define to prevent recursive inclusion -------------------------------------*/
  12. #ifndef __FT32F0XX_DIV_H
  13. #define __FT32F0XX_DIV_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /* Includes ------------------------------------------------------------------*/
  18. #include "ft32f0xx.h"
  19. #include <stdint.h>
  20. /** @addtogroup DIV
  21. * @{
  22. */
  23. /* Exported types ------------------------------------------------------------*/
  24. /**
  25. * @brief DIV Status
  26. */
  27. typedef enum
  28. {
  29. DIV_COMPLETE = 0,
  30. DIV_ERROR_DIV0ERR,
  31. DIV_ERROR_DIV0V,
  32. }DIV_Status;
  33. /**
  34. * @brief Dividor Data structure definition
  35. */
  36. typedef struct
  37. {
  38. uint32_t DIV_quotient; /*!< Selects The feedback resister of the OPA. */
  39. uint32_t DIV_remainder; /*!< Selects The compensate cap of the OPA.*/
  40. }DIV_ResultTypeDef;
  41. /* Exported constants --------------------------------------------------------*/
  42. /** @defgroup DIV_interrupts_definition
  43. * @{
  44. */
  45. #define DIV_IT_DIV0ERR DIV_SC_DIV0IE
  46. #define DIV_IT_DIVOV DIV_SC_DIVOVIE
  47. #define IS_DIV_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFFFFEB) == (uint32_t)RESET))
  48. #define IS_DIV_GET_IT(IT) (((IT) == DIV_IT_DIV0ERR) || ((IT) == DIV_IT_DIVOV))
  49. #define IS_DIV_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFFFFEB0) == (uint32_t)RESET))
  50. /**
  51. * @}
  52. */
  53. /** @defgroup DIV_flags_definition
  54. * @{
  55. */
  56. #define DIV_FLAG_BUSY DIV_SC_DIVBUSY
  57. #define DIV_FLAG_DIV0ERR DIV_SC_DIV0ERR
  58. #define DIV_FLAG_DIVOV DIV_SC_DIVOV
  59. #define IS_DIV_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFFFFFF5) == (uint32_t)RESET))
  60. #define IS_DIV_GET_FLAG(FLAG) (((FLAG) == DIV_FLAG_BUSY) || ((FLAG) == DIV_FLAG_DIV0ERR) || ((FLAG) == DIV_FLAG_DIV0ERR))
  61. /**
  62. * @}
  63. */
  64. /**
  65. * @}
  66. */
  67. /* Exported macro ------------------------------------------------------------*/
  68. /* Exported functions ------------------------------------------------------- */
  69. /* DIV Calculating functions *****************************************/
  70. DIV_Status DivS32ByS16(DIV_ResultTypeDef* pResult,int32_t divedent,int16_t dividor);
  71. /* Interrupts and flags management functions **********************************/
  72. void DIV_ITConfig(uint32_t DIV_IT, FunctionalState NewState);
  73. FlagStatus DIV_GetFlagStatus(uint32_t DIV_FLAG);
  74. void DIV_ClearFlag(uint32_t DIV_FLAG);
  75. ITStatus DIV_GetITStatus(uint32_t DIV_IT);
  76. void DIV_ClearITPendingBit(uint32_t DIV_IT);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /*__FT32F0XX_DIV_H */
  81. /**
  82. * @}
  83. */
  84. /**
  85. * @}
  86. */
  87. /************************ (C) COPYRIGHT FMD *****END OF FILE****/