打印

这些函数有何区别

[复制链接]
2380|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
dxf17043206|  楼主 | 2011-5-2 22:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问这两个函数有哪些区别,
  void GPIO_SetBits(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)和
  void GPIO_WriteBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin, BitAction BitVal)
我感觉不出来有说明不一样的。
沙发
dxf17043206|  楼主 | 2011-5-2 22:32 | 只看该作者
并且这两个函数都是对同一个寄存器操作,为什么要用到两个函数,一个不就可以了吗

使用特权

评论回复
板凳
again_gyf| | 2011-5-2 22:33 | 只看该作者
Set=1
Write=0 or 1

使用特权

评论回复
地板
趴趴熊| | 2011-5-3 08:03 | 只看该作者
明显参数不一样 - -

使用特权

评论回复
5
hgjinwei| | 2011-5-3 10:25 | 只看该作者
自己看源码嘛,这不一清二楚了吗?

/**
  * @brief  Sets the selected data port bits.
  * @param  GPIOx: where x can be (A..G) to select the GPIO peripheral.
  * @param  GPIO_Pin: specifies the port bits to be written.
  *   This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
  * @retval None
  */
void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
  /* Check the parameters */
  assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
  assert_param(IS_GPIO_PIN(GPIO_Pin));
  
  GPIOx->BSRR = GPIO_Pin;
}

/**
  * @brief  Sets or clears the selected data port bit.
  * @param  GPIOx: where x can be (A..G) to select the GPIO peripheral.
  * @param  GPIO_Pin: specifies the port bit to be written.
  *   This parameter can be one of GPIO_Pin_x where x can be (0..15).
  * @param  BitVal: specifies the value to be written to the selected bit.
  *   This parameter can be one of the BitAction enum values:
  *     @arg Bit_RESET: to clear the port pin
  *     @arg Bit_SET: to set the port pin
  * @retval None
  */
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
{
  /* Check the parameters */
  assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
  assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
  assert_param(IS_GPIO_BIT_ACTION(BitVal));
  
  if (BitVal != Bit_RESET)
  {
    GPIOx->BSRR = GPIO_Pin;
  }
  else
  {
    GPIOx->BRR = GPIO_Pin;
  }
}

使用特权

评论回复
6
banhushui| | 2011-5-3 12:37 | 只看该作者
确实有时看看源码一切都明白了:P

使用特权

评论回复
7
dxf17043206|  楼主 | 2011-5-3 21:23 | 只看该作者
呵呵,谢谢诸位。

使用特权

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

本版积分规则

9

主题

16

帖子

1

粉丝