GPIO_Write和Bit GPIO_SetBit有什么区别呢

[复制链接]
 楼主| jermy_z 发表于 2015-8-27 10:09 | 显示全部楼层 |阅读模式
我觉得两者的功能重复了,前者的这个库函数完全是多余的?
若相依 发表于 2015-8-27 22:15 | 显示全部楼层
我也觉得两者一模一样。
裁定心生 发表于 2015-8-28 07:57 | 显示全部楼层
前者可以写0和1,后者只可以置1
若相依 发表于 2015-8-28 08:39 | 显示全部楼层
你看看两者的底层,看看分别操作了什么寄存器就知道了。
eggbiscuit 发表于 2015-8-29 14:52 | 显示全部楼层
  1. void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
  2. {
  3.   /* Check the parameters */
  4.   assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
  5.   assert_param(IS_GPIO_PIN(GPIO_Pin));
  6.   
  7.   GPIOx->BSRR = GPIO_Pin;
  8. }
eggbiscuit 发表于 2015-8-29 14:52 | 显示全部楼层
  1. void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
  2. {
  3.   /* Check the parameters */
  4.   assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
  5.   assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
  6.   assert_param(IS_GPIO_BIT_ACTION(BitVal));
  7.   
  8.   if (BitVal != Bit_RESET)
  9.   {
  10.     GPIOx->BSRR = GPIO_Pin;
  11.   }
  12.   else
  13.   {
  14.     GPIOx->BRR = GPIO_Pin;
  15.   }
  16. }
eggbiscuit 发表于 2015-8-29 14:53 | 显示全部楼层
  assert_param(IS_GPIO_BIT_ACTION(BitVal));
两者相比,多了一句这个
niuyaliang 发表于 2015-8-29 19:12 | 显示全部楼层
eggbiscuit 发表于 2015-8-29 14:53
assert_param(IS_GPIO_BIT_ACTION(BitVal));
两者相比,多了一句这个

assert_param,能解释下这个断言是什么作用么?起了什么作用呢?
黑夜的风 发表于 2015-8-30 10:24 | 显示全部楼层
niuyaliang 发表于 2015-8-29 19:12
assert_param,能解释下这个断言是什么作用么?起了什么作用呢?

查了查资料,找到这个东西是什么,看我新发表的帖子。
eggbiscuit 发表于 2015-8-31 21:23 | 显示全部楼层
黑夜的风 发表于 2015-8-30 10:24
查了查资料,找到这个东西是什么,看我新发表的帖子。

我看看去。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

17

主题

100

帖子

0

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