[牛人杂谈] 新唐单片机的头文件注释真详细啊

[复制链接]
1009|10
 楼主| 捉虫天师 发表于 2020-3-6 20:13 | 显示全部楼层 |阅读模式
  1. typedef struct
  2. {


  3. /**
  4. * [url=home.php?mod=space&uid=176933]@VAR[/url] GPIO_T::PMD
  5. * Offset: 0x00/0x40/0x80/0xC0/0x100  Port 0-4  I/O Mode Control
  6. * ---------------------------------------------------------------------------------------------------
  7. * |Bits    |Field     |Descriptions
  8. * | :----: | :----:   | :---- |
  9. * |[2n+1:2n]|PMDn     |Determine each I/O mode of Px.n pins.
  10. * |        |          |00 = Px.n is in Input mode.
  11. * |        |          |01 = Px.n is in Push-pull Output mode.
  12. * |        |          |10 = Px.n is in Open-drain Output mode.
  13. * |        |          |11 = Px.n is in Quasi-bidirectional mode.
  14. * |        |          |Note1: x = 0~4, n = 0~7.
  15. * |        |          |Note2: The default value is 0x0000_FFFF and all pins will be quasi-bidirectional mode after chip is powered on (only for M05xxBN).
  16. * |        |          |Note3: The initial value of this field is defined by CIOINI (CONFIG[10]) (only for M05xxDN/DE).
  17. * |        |          |If CIOINI is set to 1, the default value is 0x0000_FFFF and all pins will be quasi-bidirectional mode after chip powered on.
  18. * |        |          |If CIOINI is set to 0, the default value is 0x0000_0000 and all pins will be input tri-state mode after chip powered on.        
  19. * @var GPIO_T::OFFD
  20. * Offset: 0x04/0x44/0x84/0xC4/0x104 Port 0-4 Digital Input Path Disable Control
  21. * ---------------------------------------------------------------------------------------------------
  22. * |Bits    |Field     |Descriptions
  23. * | :----: | :----:   | :---- |
  24. * |[23:16] |OFFD      |Port 0-4 Pin [n] Digital Input Path Disable Control
  25. * |        |          |Each of these bits is used to control if the digital input path of corresponding Px.n pin is disabled.
  26. * |        |          |If input is analog signal, users can disable Px.n digital input path to avoid input current leakage.
  27. * |        |          |0 = Px.n digital input path Enabled.
  28. * |        |          |1 = Px.n digital input path Disabled (digital input tied to low).
  29. * |        |          |Note: x = 0~4, n = 0~7.
  30. * @var GPIO_T::DOUT
  31. * Offset: 0x8/0x48/0x88/0xC8/0x108 Port 0-4 Data Output Value
  32. * ---------------------------------------------------------------------------------------------------
  33. * |Bits    |Field     |Descriptions
  34. * | :----: | :----:   | :---- |
  35. * |[7:0]   |DOUT[n]   |Port 0-4 Pin [n] Output Value
  36. * |        |          |Each of these bits controls the status of a Px.n pin when the Px.n is configured as Push-pull output, Open-drain output or Quasi-bidirectional mode.
  37. * |        |          |0 = Px.n will drive Low if the Px.n pin is configured as Push-pull output, Open-drain output or Quasi-bidirectional mode.
  38. * |        |          |1 = Px.n will drive High if the Px.n pin is configured as Push-pull output or Quasi-bidirectional mode.
  39. * |        |          |Note: x = 0~4, n = 0~7.
  40. * @var GPIO_T::DMASK
  41. * Offset: 0x0C/0x4C/0x8C/0xCC/0x10C Port 0-4 Data Output Write Mask
  42. * ---------------------------------------------------------------------------------------------------
  43. * |Bits    |Field     |Descriptions
  44. * | :----: | :----:   | :---- |
  45. * |[7:0]   |DMASK[n]  |Port 0-4 Pin [n] Data Output Write Mask
  46. * |        |          |These bits are used to protect the corresponding Px_DOUT[n] bit. When the DMASK[n] bit is set to 1, the corresponding Px_DOUT[n] bit is protected.
  47. * |        |          |If the write signal is masked, writing data to the protect bit is ignored.
  48. * |        |          |0 = Corresponding Px_DOUT[n] bit can be updated.
  49. * |        |          |1 = Corresponding Px_DOUT[n] bit protected.
  50. * |        |          |Note1: x = 0~4, n = 0~7.
  51. * |        |          |Note2: This function only protects the corresponding Px_DOUT[n] bit, and will not protect the corresponding Pxn_PDIO bit.
  52. * @var GPIO_T::PIN
  53. * Offset: 0x10/0x50/0x90/0xD0/0x110 Port 0-4 Pin Value
  54. * ---------------------------------------------------------------------------------------------------
  55. * |Bits    |Field     |Descriptions
  56. * | :----: | :----:   | :---- |
  57. * |[15:0]  |PIN[n]    |Port 0-4 Pin [n] Pin Value
  58. * |        |          |Each bit of the register reflects the actual status of the respective Px.n pin. If the bit is 1, it indicates the corresponding pin status is high; else the pin status is low.
  59. * |        |          |Note: x = 0~4, n = 0~7.
  60. * @var GPIO_T::DBEN
  61. * Offset: 0x14/0x54/0x94/0xD4/0x114 Port 0-4 De-bounce Enable
  62. * ---------------------------------------------------------------------------------------------------
  63. * |Bits    |Field     |Descriptions
  64. * | :----: | :----:   | :---- |
  65. * |[15:0]  |DBEN[n]   |Port 0-4 Pin [n] Input Signal De-bounce Enable Control
  66. * |        |          |DBEN[n] bit is used to enable the de-bounce function for each corresponding bit.
  67. * |        |          |If the input signal pulse width cannot be sampled by continuous two de-bounce sample cycle, the input signal transition is seen as the signal bounce and will not trigger the interrupt.
  68. * |        |          |The de-bounce clock source is controlled by DBNCECON[4], one de-bounce sample cycle period is controlled by DBNCECON[3:0].
  69. * |        |          |0 = Px.n de-bounce function Disabled.
  70. * |        |          |1 = Px.n de-bounce function Enabled.
  71. * |        |          |The de-bounce function is valid only for edge triggered interrupt. If the interrupt mode is level triggered, the de-bounce enable bit is ignored.
  72. * |        |          |Note1: x = 0~4, n = 0~7.
  73. * |        |          |Note2: If Px.n pin is chosen as Power-down wake-up source, user should be disable the de-bounce function before entering Power-down mode to avoid the second interrupt event occurred after system waken up which caused by Px.n de-bounce function.
  74. * @var GPIO_T::IMD
  75. * Offset: 0x18/0x58/0x98/0xD8/0x118 Port 0-4 Interrupt Mode Control
  76. * ---------------------------------------------------------------------------------------------------
  77. * |Bits    |Field     |Descriptions
  78. * | :----: | :----:   | :---- |
  79. * |[15:0]  |IMD[n]    |Port 0-4 Pin [n] Edge or Level Detection Interrupt Mode Control
  80. * |        |          |IMD[n] bit is used to control the triggered interrupt is by level trigger or by edge trigger.
  81. * |        |          |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce.
  82. * |        |          |If the interrupt is by level trigger, the input source is sampled by one HCLK clock and generates the interrupt.
  83. * |        |          |0 = Edge trigger interrupt.
  84. * |        |          |1 = Level trigger interrupt.
  85. * |        |          |If the pin is set as the level trigger interrupt, only one level can be set on the registers Px_IEN. If both levels to trigger interrupt are set, the setting is ignored and no interrupt will occur.
  86. * |        |          |The de-bounce function is valid only for edge triggered interrupt. If the interrupt mode is level triggered, the de-bounce enable bit is ignored.
  87. * |        |          |Note: x = 0~4, n = 0~7.
  88. * @var GPIO_T::IEN
  89. * Offset: 0x1C/0x5C/0x9C/0xDC/0x11C Port 0-4 Interrupt Enable Control
  90. * ---------------------------------------------------------------------------------------------------
  91. * |Bits    |Field     |Descriptions
  92. * | :----: | :----:   | :---- |
  93. * |[23:16] |IR_EN[n]  |Port 0-4 Pin [n] Interrupt Enable by Input Rising Edge or Input Level High
  94. * |        |          |IR_EN[n] bit is used to enable the interrupt for each of the corresponding input Px.n pin.
  95. * |        |          |Set bit to 1 also enable the pin wake-up function.
  96. * |        |          |When setting the IR_EN[n] bit to 1 :
  97. * |        |          |If the interrupt is level trigger (IMD[n] is 1), the input Px.n pin will generate the interrupt while this pin state is at high level.
  98. * |        |          |If the interrupt is edge trigger (IMD[n] is 0), the input Px.n pin will generate the interrupt while this pin state changed from low to high.
  99. * |        |          |0 = Px.n level high or low to high interrupt Disabled.
  100. * |        |          |1 = Px.n level high or low to high interrupt Enabled.
  101. * |        |          |Note: x = 0~4, n = 0~7.
  102. * |[7:0]   |IF_EN[n]  |Port 0-4 Pin [n] Interrupt Enable by Input Falling Edge or Input Level Low
  103. * |        |          |IF_EN[n] bit is used to enable the interrupt for each of the corresponding input Px.n pin.
  104. * |        |          |Set bit to 1 also enable the pin wake-up function.
  105. * |        |          |When setting the IF_EN[n] bit to 1 :
  106. * |        |          |If the interrupt is level trigger (IMD[n] is 1), the input Px.n pin will generate the interrupt while this pin state is at low level.
  107. * |        |          |If the interrupt is edge trigger (IMD[n] is 0), the input Px.n pin will generate the interrupt while this pin state changed from high to low.
  108. * |        |          |0 = Px.n level low or high to low interrupt Disabled.
  109. * |        |          |1 = Px.n level low or high to low interrupt Enabled.
  110. * |        |          |Note: x = 0~4, n = 0~7.
  111. * @var GPIO_T::ISRC
  112. * Offset: 0x20/0x60/0xA0/0xE0/0x120 Port 0-4 Interrupt Trigger Source
  113. * ---------------------------------------------------------------------------------------------------
  114. * |Bits    |Field     |Descriptions
  115. * | :----: | :----:   | :---- |
  116. * |[7:0]   |ISRC[n]   |Port 0-4 Pin [n] Interrupt Source Flag
  117. * |        |          |Write :
  118. * |        |          |0 = No action.
  119. * |        |          |1 = Clear the corresponding pending interrupt.
  120. * |        |          |Read :
  121. * |        |          |0 = No interrupt at Px.n.
  122. * |        |          |1 = Px.n generates an interrupt.
  123. * |        |          |Note: x = 0~4, n = 0~7.
  124. */

  125.     __IO uint32_t PMD;           /* Offset: 0x00/0x40/0x80/0xC0/0x100 Port 0-4  I/O Mode Control                     */
  126.     __IO uint32_t OFFD;          /* Offset: 0x04/0x44/0x84/0xC4/0x104 Port 0-4 Digital Input Path Disable Control    */
  127.     __IO uint32_t DOUT;          /* Offset: 0x08/0x48/0x88/0xC8/0x108 Port 0-4 Data Output Value                     */
  128.     __IO uint32_t DMASK;         /* Offset: 0x0C/0x4C/0x8C/0xCC/0x10C Port 0-4 Data Output Write Mask                */
  129.     __IO uint32_t PIN;           /* Offset: 0x10/0x50/0x90/0xD0/0x110 Port 0-4 Pin Value                             */
  130.     __IO uint32_t DBEN;          /* Offset: 0x14/0x54/0x94/0xD4/0x114 Port 0-4 De-bounce Enable                      */
  131.     __IO uint32_t IMD;           /* Offset: 0x18/0x58/0x98/0xD8/0x118 Port 0-4 Interrupt Mode Control                */
  132.     __IO uint32_t IEN;           /* Offset: 0x1C/0x5C/0x9C/0xDC/0x11C Port 0-4 Interrupt Enable Control              */
  133.     __IO uint32_t ISRC;          /* Offset: 0x20/0x60/0xA0/0xE0/0x120 Port 0-4 Interrupt Trigger Source              */

  134. } GPIO_T;


 楼主| 捉虫天师 发表于 2020-3-6 20:29 | 显示全部楼层
关于GPIO的结构体里面都详细讲了哪些是干啥的,用的时候特别方便,比手册还容易懂。
yiyigirl2014 发表于 2020-3-6 21:14 | 显示全部楼层
是的,非常棒。
Harvard 发表于 2020-3-6 21:39 | 显示全部楼层
哈哈 用惯了新唐的人 会发现新唐bsp库的精髓 .比stm32的 简洁实用 .当然stm32是中国最伟大的单片机.
yiyigirl2014 发表于 2020-3-6 22:18 | 显示全部楼层
Harvard 发表于 2020-3-6 21:39
哈哈 用惯了新唐的人 会发现新唐bsp库的精髓 .比stm32的 简洁实用 .当然stm32是中国最伟大的单片机. ...

STM32是国外的吧,新唐才是中国的。
yiyigirl2014 发表于 2020-3-6 22:19 | 显示全部楼层
Harvard 发表于 2020-3-6 21:39
哈哈 用惯了新唐的人 会发现新唐bsp库的精髓 .比stm32的 简洁实用 .当然stm32是中国最伟大的单片机. ...

新唐的BSP简洁,而STM32的分层比较细,一个功能的实现要在多层函数里完成,如果不是很熟练,很难上手。
wanduzi 发表于 2020-3-7 10:55 | 显示全部楼层
确实给力,没想到还有这么详细的学习资料。之前没打开看过
xixi2017 发表于 2020-3-7 20:54 | 显示全部楼层
__IO这个 是关键字?
zhuomuniao110 发表于 2020-3-7 22:39 | 显示全部楼层
新唐这一点做的非常好。
zhuomuniao110 发表于 2020-3-9 21:36 | 显示全部楼层
好多厂家的头文件都是这样
玛尼玛尼哄 发表于 2020-3-10 18:09 | 显示全部楼层
如果提供中文版注释的就爽了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

216

主题

3284

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部