py32f0xx.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx.h
  4. * @brief CMSIS PY32F0xx Device Peripheral Access Layer Header File.
  5. * @version v1.0.0
  6. *
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by Puya under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. * @attention
  20. *
  21. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  22. * All rights reserved.</center></h2>
  23. *
  24. * This software component is licensed by ST under BSD 3-Clause license,
  25. * the "License"; You may not use this file except in compliance with the
  26. * License. You may obtain a copy of the License at:
  27. * opensource.org/licenses/BSD-3-Clause
  28. *
  29. ******************************************************************************
  30. */
  31. /** @addtogroup CMSIS
  32. * @{
  33. */
  34. /** @addtogroup py32f0xx
  35. * @{
  36. */
  37. #ifndef __PY32F0xx_H
  38. #define __PY32F0xx_H
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif /* __cplusplus */
  42. /** @addtogroup Library_configuration_section
  43. * @{
  44. */
  45. /**
  46. * @brief PY32 Family
  47. */
  48. #if !defined (PY32F0)
  49. #define PY32F0
  50. #endif /* PY32F0 */
  51. #if (defined(PY32F030x3) || defined(PY32F030x4) || defined(PY32F030x6) || defined(PY32F030x7) || defined(PY32F030x8))
  52. #define PY32F030PRE
  53. #elif (defined(PY32F003x4) || defined(PY32F003x6) || defined(PY32F003x8))
  54. #define PY32F003PRE
  55. #elif (defined(PY32F072xB))
  56. #define PY32F072PRE
  57. #elif (defined(PY32F002Ax5))
  58. #define PY32F002APRE
  59. #endif
  60. /* Uncomment the line below according to the target PY32 device used in your
  61. application
  62. */
  63. #if !defined (PY32F030x3) && !defined (PY32F030x4) && !defined (PY32F030x6) && !defined (PY32F030x7) && !defined (PY32F030x8) && !defined (PY32F030xx) && \
  64. !defined (PY32F003x4) && !defined (PY32F003x6) && !defined (PY32F003x8) && \
  65. !defined (PY32F072xB) && \
  66. !defined (PY32F002Ax5)
  67. /* #define PY32F030x3 */ /*!< PY32F030x3 Devices (PY32F030xx microcontrollers where the Flash memory is 8 Kbytes) */
  68. /* #define PY32F030x4 */ /*!< PY32F030x4 Devices (PY32F030xx microcontrollers where the Flash memory is 16 Kbytes) */
  69. /* #define PY32F030x6 */ /*!< PY32F030x6 Devices (PY32F030xx microcontrollers where the Flash memory is 32 Kbytes) */
  70. /* #define PY32F030x7 */ /*!< PY32F030x7 Devices (PY32F030xx microcontrollers where the Flash memory is 48 Kbytes) */
  71. /* #define PY32F030x8 */ /*!< PY32F030x8 Devices (PY32F030xx microcontrollers where the Flash memory is 64 Kbytes) */
  72. /* #define PY32F003x4 */ /*!< PY32F003x4 Devices (PY32F003xx microcontrollers where the Flash memory is 16 Kbytes) */
  73. /* #define PY32F003x6 */ /*!< PY32F003x6 Devices (PY32F003xx microcontrollers where the Flash memory is 32 Kbytes) */
  74. /* #define PY32F003x8 */ /*!< PY32F003x8 Devices (PY32F003xx microcontrollers where the Flash memory is 64 Kbytes) */
  75. /* #define PY32F072xB */ /*!< PY32F072xB Devices (PY32F072xx microcontrollers where the Flash memory is 128 Kbytes) */
  76. /* #define PY32F002Ax5 */ /*!< PY32F002Ax5 Devices (PY32F002Ax5 microcontrollers where the Flash memory is 20 Kbytes) */
  77. #endif
  78. /* Tip: To avoid modifying this file each time you need to switch between these
  79. devices, you can define the device in your toolchain compiler preprocessor.
  80. */
  81. #if !defined (USE_HAL_DRIVER)
  82. /**
  83. * @brief Comment the line below if you will not use the peripherals drivers.
  84. In this case, these drivers will not be included and the application code will
  85. be based on direct access to peripherals registers
  86. */
  87. /*#define USE_HAL_DRIVER */
  88. #endif /* USE_HAL_DRIVER */
  89. /**
  90. * @brief CMSIS Device version number V1.0.0
  91. */
  92. #define __PY32F0_DEVICE_VERSION_MAIN (0x01) /*!< [31:24] main version */
  93. #define __PY32F0_DEVICE_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
  94. #define __PY32F0_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
  95. #define __PY32F0_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */
  96. #define __PY32F0_DEVICE_VERSION ((__PY32F0_DEVICE_VERSION_MAIN << 24)\
  97. |(__PY32F0_DEVICE_VERSION_SUB1 << 16)\
  98. |(__PY32F0_DEVICE_VERSION_SUB2 << 8 )\
  99. |(__PY32F0_DEVICE_VERSION_RC))
  100. /**
  101. * @}
  102. */
  103. /** @addtogroup Device_Included
  104. * @{
  105. */
  106. #if defined(PY32F030x3)
  107. #include "py32f030x3.h"
  108. #elif defined(PY32F030x4)
  109. #include "py32f030x4.h"
  110. #elif defined(PY32F030x6)
  111. #include "py32f030x6.h"
  112. #elif defined(PY32F030x7)
  113. #include "py32f030x7.h"
  114. #elif defined(PY32F030x8)
  115. #include "py32f030x8.h"
  116. #elif defined(PY32F003x4)
  117. #include "py32f003x4.h"
  118. #elif defined(PY32F003x6)
  119. #include "py32f003x6.h"
  120. #elif defined(PY32F003x8)
  121. #include "py32f003x8.h"
  122. #elif defined(PY32F072xB)
  123. #include "py32f072xB.h"
  124. #elif defined(PY32F002Ax5)
  125. #include "py32f002ax5.h"
  126. #else
  127. #error "Please select first the target PY32F0xx device used in your application (in py32f0xx.h file)"
  128. #endif
  129. /**
  130. * @}
  131. */
  132. /** @addtogroup Exported_types
  133. * @{
  134. */
  135. typedef enum
  136. {
  137. RESET = 0,
  138. SET = !RESET
  139. } FlagStatus, ITStatus;
  140. typedef enum
  141. {
  142. DISABLE = 0,
  143. ENABLE = !DISABLE
  144. } FunctionalState;
  145. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  146. typedef enum
  147. {
  148. ERROR = 0,
  149. SUCCESS = !ERROR
  150. } ErrorStatus;
  151. /**
  152. * @}
  153. */
  154. /** @addtogroup Exported_macros
  155. * @{
  156. */
  157. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  158. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  159. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  160. #define CLEAR_REG(REG) ((REG) = (0x0))
  161. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  162. #define READ_REG(REG) ((REG))
  163. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  164. #define HW32_REG(ADDRESS) ( * ((volatile unsigned int * )(ADDRESS)))
  165. #define HW16_REG(ADDRESS) ( * ((volatile unsigned short int * )(ADDRESS)))
  166. #define HW8_REG(ADDRESS) ( * ((volatile unsigned char * )(ADDRESS)))
  167. /**
  168. * @}
  169. */
  170. #if defined (USE_HAL_DRIVER)
  171. #include "py32f0xx_hal.h"
  172. #endif /* USE_HAL_DRIVER */
  173. #ifdef __cplusplus
  174. }
  175. #endif /* __cplusplus */
  176. #endif /* __PY32F0xx_H */
  177. /**
  178. * @}
  179. */
  180. /**
  181. * @}
  182. */
  183. /************************ (C) COPYRIGHT Puya *****END OF FILE******************/