fm33lc0xx_fl_divas.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /**
  2. *******************************************************************************************************
  3. * @file fm33lc0xx_fl_divas.h
  4. * @author FMSH Application Team
  5. * @brief Head file of DIVAS FL Module
  6. *******************************************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) [2021] [Fudan Microelectronics]
  10. * THIS SOFTWARE is licensed under Mulan PSL v2.
  11. * You can use this software according to the terms and conditions of the Mulan PSL v2.
  12. * You may obtain a copy of Mulan PSL v2 at:
  13. * http://license.coscl.org.cn/MulanPSL2
  14. * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  15. * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  16. * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  17. * See the Mulan PSL v2 for more details.
  18. *
  19. *******************************************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion---------------------------------------------------------------*/
  22. #ifndef __FM33LC0XX_FL_DIVAS_H
  23. #define __FM33LC0XX_FL_DIVAS_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes -------------------------------------------------------------------------------------------*/
  28. #include "fm33lc0xx_fl_def.h"
  29. /** @addtogroup FM33LC0XX_FL_Driver
  30. * @{
  31. */
  32. /** @defgroup DIVAS DIVAS
  33. * @brief DIVAS FL driver
  34. * @{
  35. */
  36. /* Exported types -------------------------------------------------------------------------------------*/
  37. /** @defgroup DIVAS_FL_ES_INIT DIVAS Exported Init structures
  38. * @{
  39. */
  40. /**
  41. * @}
  42. */
  43. /* Exported constants ---------------------------------------------------------------------------------*/
  44. /** @defgroup DIVAS_FL_Exported_Constants DIVAS Exported Constants
  45. * @{
  46. */
  47. #define DIV_SR_DIVBYZERO_Pos (1U)
  48. #define DIV_SR_DIVBYZERO_Msk (0x1U << DIV_SR_DIVBYZERO_Pos)
  49. #define DIV_SR_DIVBYZERO DIV_SR_DIVBYZERO_Msk
  50. #define DIV_SR_BUSY_Pos (0U)
  51. #define DIV_SR_BUSY_Msk (0x1U << DIV_SR_BUSY_Pos)
  52. #define DIV_SR_BUSY DIV_SR_BUSY_Msk
  53. #define FL_DIVAS_SR_BUSY_TIMEOUT 0xFFFU
  54. /**
  55. * @}
  56. */
  57. /* Exported functions ---------------------------------------------------------------------------------*/
  58. /** @defgroup DIVAS_FL_Exported_Functions DIVAS Exported Functions
  59. * @{
  60. */
  61. /**
  62. * @brief Write Dividend Register
  63. * @rmtoll OPRD FL_DIV_WriteDividend_S32
  64. * @param DIVx DIV instance
  65. * @param number
  66. * @retval None
  67. */
  68. __STATIC_INLINE void FL_DIV_WriteDividend_S32(DIV_Type *DIVx, int32_t number)
  69. {
  70. MODIFY_REG(DIVx->END, (0xffffffffU << 0U), (number << 0U));
  71. }
  72. /**
  73. * @brief Read Dividend Register
  74. * @rmtoll OPRD FL_DIV_ReadDividend_S32
  75. * @param DIVx DIV instance
  76. * @retval
  77. */
  78. __STATIC_INLINE int32_t FL_DIV_ReadDividend_S32(DIV_Type *DIVx)
  79. {
  80. return (uint32_t)(READ_BIT(DIVx->END, (0xffffffffU << 0U)) >> 0U);
  81. }
  82. /**
  83. * @brief Write 16bit Signed Divisor
  84. * @rmtoll DIVSOR FL_DIV_WriteDivisor_S16
  85. * @param DIVx DIV instance
  86. * @param number
  87. * @retval None
  88. */
  89. __STATIC_INLINE void FL_DIV_WriteDivisor_S16(DIV_Type *DIVx, int16_t number)
  90. {
  91. MODIFY_REG(DIVx->SOR, (0xffffU << 0U), (number << 0U));
  92. }
  93. /**
  94. * @brief Read 16bit Signed Divisor
  95. * @rmtoll DIVSOR FL_DIV_ReadDivisor_S16
  96. * @param DIVx DIV instance
  97. * @retval
  98. */
  99. __STATIC_INLINE int32_t FL_DIV_ReadDivisor_S16(DIV_Type *DIVx)
  100. {
  101. return (uint32_t)(READ_BIT(DIVx->SOR, (0xffffU << 0U)) >> 0U);
  102. }
  103. /**
  104. * @brief Read 32bit Signed QUTO
  105. * @rmtoll QUOT FL_DIV_ReadQuotient_S32
  106. * @param DIVx DIV instance
  107. * @retval
  108. */
  109. __STATIC_INLINE int32_t FL_DIV_ReadQuotient_S32(DIV_Type *DIVx)
  110. {
  111. return (uint32_t)(READ_BIT(DIVx->QUOT, (0xffffffffU << 0U)) >> 0U);
  112. }
  113. /**
  114. * @brief Read 16bit Signed Reminder
  115. * @rmtoll REMD FL_DIV_ReadResidue_S16
  116. * @param DIVx DIV instance
  117. * @retval
  118. */
  119. __STATIC_INLINE int32_t FL_DIV_ReadResidue_S16(DIV_Type *DIVx)
  120. {
  121. return (uint32_t)(READ_BIT(DIVx->REMD, (0xffffU << 0U)) >> 0U);
  122. }
  123. /**
  124. * @brief Get divided by 0 flag
  125. * @rmtoll SR DIVBYZERO FL_DIV_IsActiveFlag_DividedZero
  126. * @param DIVx DIV instance
  127. * @retval State of bit (1 or 0).
  128. */
  129. __STATIC_INLINE uint32_t FL_DIV_IsActiveFlag_DividedZero(DIV_Type *DIVx)
  130. {
  131. return (uint32_t)(READ_BIT(DIVx->SR, DIV_SR_DIVBYZERO_Msk) == (DIV_SR_DIVBYZERO_Msk));
  132. }
  133. /**
  134. * @brief Get Busy flag
  135. * @rmtoll SR BUSY FL_DIV_IsActiveFlag_Busy
  136. * @param DIVx DIV instance
  137. * @retval State of bit (1 or 0).
  138. */
  139. __STATIC_INLINE uint32_t FL_DIV_IsActiveFlag_Busy(DIV_Type *DIVx)
  140. {
  141. return (uint32_t)(READ_BIT(DIVx->SR, DIV_SR_BUSY_Msk) == (DIV_SR_BUSY_Msk));
  142. }
  143. /**
  144. * @}
  145. */
  146. /** @defgroup DIVAS_FL_EF_Init Initialization and de-initialization functions
  147. * @{
  148. */
  149. FL_ErrorStatus FL_DIVAS_DeInit(DIV_Type *DIVx);
  150. FL_ErrorStatus FL_DIVAS_Init(DIV_Type *DIVx);
  151. /**
  152. * @}
  153. */
  154. /** @defgroup DIVAS_FL_EF_Operation Opeartion functions
  155. * @{
  156. */
  157. uint32_t FL_DIVAS_Hdiv_Calculation(DIV_Type *DIVx, int32_t DivisorEnd, int16_t Divisor, int32_t *Quotient, int16_t *Residue);
  158. /**
  159. * @}
  160. */
  161. /**
  162. * @}
  163. */
  164. /**
  165. * @}
  166. */
  167. #ifdef __cplusplus
  168. }
  169. #endif
  170. #endif /* __FM33LC0XX_FL_DIVAS_H*/
  171. /*************************Py_Code_Generator Version: 0.1-0.11-0.2 @ 2020-09-23*************************/
  172. /********************** (C) COPYRIGHT Fudan Microelectronics **** END OF FILE ***********************/