打印
[牛人杂谈]

新唐单片机的头文件注释真详细啊

[复制链接]
552|10
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
捉虫天师|  楼主 | 2020-3-6 20:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
typedef struct
{


/**
* [url=home.php?mod=space&uid=176933]@VAR[/url] GPIO_T::PMD
* Offset: 0x00/0x40/0x80/0xC0/0x100  Port 0-4  I/O Mode Control
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[2n+1:2n]|PMDn     |Determine each I/O mode of Px.n pins.
* |        |          |00 = Px.n is in Input mode.
* |        |          |01 = Px.n is in Push-pull Output mode.
* |        |          |10 = Px.n is in Open-drain Output mode.
* |        |          |11 = Px.n is in Quasi-bidirectional mode.
* |        |          |Note1: x = 0~4, n = 0~7.
* |        |          |Note2: The default value is 0x0000_FFFF and all pins will be quasi-bidirectional mode after chip is powered on (only for M05xxBN).
* |        |          |Note3: The initial value of this field is defined by CIOINI (CONFIG[10]) (only for M05xxDN/DE).
* |        |          |If CIOINI is set to 1, the default value is 0x0000_FFFF and all pins will be quasi-bidirectional mode after chip powered on.
* |        |          |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.        
* @var GPIO_T::OFFD
* Offset: 0x04/0x44/0x84/0xC4/0x104 Port 0-4 Digital Input Path Disable Control
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[23:16] |OFFD      |Port 0-4 Pin [n] Digital Input Path Disable Control
* |        |          |Each of these bits is used to control if the digital input path of corresponding Px.n pin is disabled.
* |        |          |If input is analog signal, users can disable Px.n digital input path to avoid input current leakage.
* |        |          |0 = Px.n digital input path Enabled.
* |        |          |1 = Px.n digital input path Disabled (digital input tied to low).
* |        |          |Note: x = 0~4, n = 0~7.
* @var GPIO_T::DOUT
* Offset: 0x8/0x48/0x88/0xC8/0x108 Port 0-4 Data Output Value
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[7:0]   |DOUT[n]   |Port 0-4 Pin [n] Output Value
* |        |          |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.
* |        |          |0 = Px.n will drive Low if the Px.n pin is configured as Push-pull output, Open-drain output or Quasi-bidirectional mode.
* |        |          |1 = Px.n will drive High if the Px.n pin is configured as Push-pull output or Quasi-bidirectional mode.
* |        |          |Note: x = 0~4, n = 0~7.
* @var GPIO_T::DMASK
* Offset: 0x0C/0x4C/0x8C/0xCC/0x10C Port 0-4 Data Output Write Mask
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[7:0]   |DMASK[n]  |Port 0-4 Pin [n] Data Output Write Mask
* |        |          |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.
* |        |          |If the write signal is masked, writing data to the protect bit is ignored.
* |        |          |0 = Corresponding Px_DOUT[n] bit can be updated.
* |        |          |1 = Corresponding Px_DOUT[n] bit protected.
* |        |          |Note1: x = 0~4, n = 0~7.
* |        |          |Note2: This function only protects the corresponding Px_DOUT[n] bit, and will not protect the corresponding Pxn_PDIO bit.
* @var GPIO_T::PIN
* Offset: 0x10/0x50/0x90/0xD0/0x110 Port 0-4 Pin Value
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[15:0]  |PIN[n]    |Port 0-4 Pin [n] Pin Value
* |        |          |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.
* |        |          |Note: x = 0~4, n = 0~7.
* @var GPIO_T::DBEN
* Offset: 0x14/0x54/0x94/0xD4/0x114 Port 0-4 De-bounce Enable
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[15:0]  |DBEN[n]   |Port 0-4 Pin [n] Input Signal De-bounce Enable Control
* |        |          |DBEN[n] bit is used to enable the de-bounce function for each corresponding bit.
* |        |          |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.
* |        |          |The de-bounce clock source is controlled by DBNCECON[4], one de-bounce sample cycle period is controlled by DBNCECON[3:0].
* |        |          |0 = Px.n de-bounce function Disabled.
* |        |          |1 = Px.n de-bounce function Enabled.
* |        |          |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.
* |        |          |Note1: x = 0~4, n = 0~7.
* |        |          |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.
* @var GPIO_T::IMD
* Offset: 0x18/0x58/0x98/0xD8/0x118 Port 0-4 Interrupt Mode Control
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[15:0]  |IMD[n]    |Port 0-4 Pin [n] Edge or Level Detection Interrupt Mode Control
* |        |          |IMD[n] bit is used to control the triggered interrupt is by level trigger or by edge trigger.
* |        |          |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce.
* |        |          |If the interrupt is by level trigger, the input source is sampled by one HCLK clock and generates the interrupt.
* |        |          |0 = Edge trigger interrupt.
* |        |          |1 = Level trigger interrupt.
* |        |          |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.
* |        |          |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.
* |        |          |Note: x = 0~4, n = 0~7.
* @var GPIO_T::IEN
* Offset: 0x1C/0x5C/0x9C/0xDC/0x11C Port 0-4 Interrupt Enable Control
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[23:16] |IR_EN[n]  |Port 0-4 Pin [n] Interrupt Enable by Input Rising Edge or Input Level High
* |        |          |IR_EN[n] bit is used to enable the interrupt for each of the corresponding input Px.n pin.
* |        |          |Set bit to 1 also enable the pin wake-up function.
* |        |          |When setting the IR_EN[n] bit to 1 :
* |        |          |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.
* |        |          |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.
* |        |          |0 = Px.n level high or low to high interrupt Disabled.
* |        |          |1 = Px.n level high or low to high interrupt Enabled.
* |        |          |Note: x = 0~4, n = 0~7.
* |[7:0]   |IF_EN[n]  |Port 0-4 Pin [n] Interrupt Enable by Input Falling Edge or Input Level Low
* |        |          |IF_EN[n] bit is used to enable the interrupt for each of the corresponding input Px.n pin.
* |        |          |Set bit to 1 also enable the pin wake-up function.
* |        |          |When setting the IF_EN[n] bit to 1 :
* |        |          |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.
* |        |          |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.
* |        |          |0 = Px.n level low or high to low interrupt Disabled.
* |        |          |1 = Px.n level low or high to low interrupt Enabled.
* |        |          |Note: x = 0~4, n = 0~7.
* @var GPIO_T::ISRC
* Offset: 0x20/0x60/0xA0/0xE0/0x120 Port 0-4 Interrupt Trigger Source
* ---------------------------------------------------------------------------------------------------
* |Bits    |Field     |Descriptions
* | :----: | :----:   | :---- |
* |[7:0]   |ISRC[n]   |Port 0-4 Pin [n] Interrupt Source Flag
* |        |          |Write :
* |        |          |0 = No action.
* |        |          |1 = Clear the corresponding pending interrupt.
* |        |          |Read :
* |        |          |0 = No interrupt at Px.n.
* |        |          |1 = Px.n generates an interrupt.
* |        |          |Note: x = 0~4, n = 0~7.
*/

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

} GPIO_T;


使用特权

评论回复
沙发
捉虫天师|  楼主 | 2020-3-6 20:29 | 只看该作者
关于GPIO的结构体里面都详细讲了哪些是干啥的,用的时候特别方便,比手册还容易懂。

使用特权

评论回复
板凳
yiyigirl2014| | 2020-3-6 21:14 | 只看该作者
是的,非常棒。

使用特权

评论回复
地板
Harvard| | 2020-3-6 21:39 | 只看该作者
哈哈 用惯了新唐的人 会发现新唐bsp库的精髓 .比stm32的 简洁实用 .当然stm32是中国最伟大的单片机.

使用特权

评论回复
5
yiyigirl2014| | 2020-3-6 22:18 | 只看该作者
Harvard 发表于 2020-3-6 21:39
哈哈 用惯了新唐的人 会发现新唐bsp库的精髓 .比stm32的 简洁实用 .当然stm32是中国最伟大的单片机. ...

STM32是国外的吧,新唐才是中国的。

使用特权

评论回复
6
yiyigirl2014| | 2020-3-6 22:19 | 只看该作者
Harvard 发表于 2020-3-6 21:39
哈哈 用惯了新唐的人 会发现新唐bsp库的精髓 .比stm32的 简洁实用 .当然stm32是中国最伟大的单片机. ...

新唐的BSP简洁,而STM32的分层比较细,一个功能的实现要在多层函数里完成,如果不是很熟练,很难上手。

使用特权

评论回复
7
wanduzi| | 2020-3-7 10:55 | 只看该作者
确实给力,没想到还有这么详细的学习资料。之前没打开看过

使用特权

评论回复
8
xixi2017| | 2020-3-7 20:54 | 只看该作者
__IO这个 是关键字?

使用特权

评论回复
9
zhuomuniao110| | 2020-3-7 22:39 | 只看该作者
新唐这一点做的非常好。

使用特权

评论回复
10
zhuomuniao110| | 2020-3-9 21:36 | 只看该作者
好多厂家的头文件都是这样

使用特权

评论回复
11
玛尼玛尼哄| | 2020-3-10 18:09 | 只看该作者
如果提供中文版注释的就爽了。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

178

主题

3007

帖子

7

粉丝