找回密码
 立即注册

使用微信账号登录

只需一步,快速开始

查看: 22014|回复: 17

[QCC3系列] QCC3020如何设置PIO7输出高电平?

[复制链接]
连续签到天数:1天
签到总天数:1天
签到总奖励:4金币
发表于 2020-4-1 14:54:34 | 显示全部楼层 |阅读模式

马上注册,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册  

×
QCC3020如何设置PIO7输出高电平?给下具体例子,谢谢。
楼主热帖
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
连续签到天数:1天
签到总天数:29天
签到总奖励:154金币
发表于 2020-4-1 22:10:03 | 显示全部楼层


  1. /**
  2. *  \brief Modifies the contents of the PIO data output register. PIO pins must be set to
  3. *  outputs via PioSetDir32() before they can be driven high or low through this
  4. *  trap. This trap also sets pull direction for PIOs used as inputs.
  5. *   
  6. *   Note that all PIOs must be mapped in before they can be used.
  7. *   See the PioSetMapPins32() documentation for information on valid PIO
  8. *  directions
  9. *   and PIO mapping.  
  10. *   BlueCore has internal resistors which can be configured to either pull-up or
  11. *   pull-down the pins used for input. This is controlled by the value
  12. *   written to the output register using PioSet32().
  13. *   The resistors pull-down if the value is zero, and pull-up otherwise, so the
  14. *   following fragment sets pins 1 and 2 to inputs with pin 1 configured to
  15. *   pull-up and pin 2 configured to pull-down.
  16. *   \code
  17. *   PioSet32(2|4, 2);
  18. *   PioSetDir32(2|4, 0);
  19. *   \endcode
  20. *  \param mask Each bit in the mask corresponds to a PIO line. Bits set to 1 in this mask will
  21. *  be modified. Bits set to 0 in this mask will not be modified.
  22. *  \param bits Each bit in the "bits" value corresponds to a PIO line. Bits set to 1 in this
  23. *  value will result in that PIO line being driven high. Bits set to 0 in this
  24. *  value will result in that PIO line being driven low.
  25. *  \return A 32 bit mask. If any bit in this mask is high then that PIO could not be
  26. *  driven to the level specified; note that no action will have been taken on any
  27. *  PIOs.
  28. *
  29. * \note This trap may NOT be called from a high-priority task handler
  30. *
  31. * \ingroup trapset_core
  32. */
  33. uint32 PioSet32(uint32 mask, uint32 bits);
复制代码

  1. /**
  2. *  \brief Set PIOs as inputs or outputs.
  3. *   
  4. *   Note that all PIOs must be mapped in before they can be used.
  5. *   See the PioSetMapPins32() documentation for information on valid PIO
  6. *  directions
  7. *   and PIO mapping.
  8. *  \param mask Each bit in the mask corresponds to a PIO line. Bits set to 1 in this mask will
  9. *  be modified. Bits set to 0 in this mask will not be modified.
  10. *  \param dir Each bit in the "dir" value corresponds to a PIO line. Bits set to 1 in this
  11. *  value will result in that PIO line being configured as an output. Bits set to
  12. *  0 in this value will result in that PIO line being configured as an input.
  13. *  \return A 32 bit mask. If any bit in this mask is high then that PIO could not be set
  14. *  to the direction specified; note that no action will have been taken on any
  15. *  PIOs.
  16. *
  17. * \note This trap may NOT be called from a high-priority task handler
  18. *
  19. * \ingroup trapset_core
  20. */
  21. uint32 PioSetDir32(uint32 mask, uint32 dir);
复制代码


积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:326天
签到总奖励:3575金币
发表于 2020-4-2 08:03:41 | 显示全部楼层
本帖最后由 赵阳 于 2020-4-2 08:05 编辑

        int pio_mask = (1 << (7 % 32));
        int pio_bank = 7 / 32;

        PioSetMapPins32Bank(pio_bank, pio_mask, pio_mask);
        PioSetDir32Bank(pio_bank, pio_mask, pio_mask);
        PioSet32Bank(pio_bank, pio_mask, pio_mask);
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:1天
签到总奖励:4金币
 楼主| 发表于 2020-4-2 16:25:09 | 显示全部楼层

谢谢,可以是可以了,但是我发现我用在main.c时候,要先把下面那个portability.h的define那一堆,再main里面又定义一次。才能用你给的函数。想要include这个h文件,又会出错。请教是不是哪里用错了?

  1. /* Copyright (c) 2016 Qualcomm Technologies International, Ltd. */
  2. /*   Part of 6.3.2 */
  3. #ifndef PORTABILITY_H_
  4. #define PORTABILITY_H_

  5. #include "trap_api/trap_api.h"

  6. /**
  7. * Init USB device descriptors
  8. *
  9. * Called before the rest of the firmware to configure
  10. * USB device descriptors. */
  11. extern void _init(void);

  12. #define PioDebounce32(mask, count, period) PioDebounce32Bank(0, mask, count, period)
  13. #define PioGet32() PioGet32Bank(0)
  14. #define PioSet32(mask, bits) PioSet32Bank(0, mask, bits)
  15. #define PioGetDir32() PioGetDir32Bank(0)
  16. #define PioSetDir32(mask, dir) PioSetDir32Bank(0, mask, dir)
  17. #define PioGetStrongBias32() PioGetStrongBias32Bank(0)
  18. #define PioSetStrongBias32(mask, bits) PioSetStrongBias32Bank(0, mask, bits)
  19. #define PioGetMapPins32() PioGetMapPins32Bank(0)
  20. #define PioSetMapPins32(mask, bits) PioSetMapPins32Bank(0, mask, bits)
  21. #define PioGetUnusedPins32() PioGetUnusedPins32Bank(0)

  22. /*@}*/

  23. #endif /* PORTABILITY_H_ */
复制代码
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:1天
签到总奖励:4金币
 楼主| 发表于 2020-4-2 17:15:36 | 显示全部楼层

adk是6.3 好多跟4.几不一样了, 反而不会用了
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:1天
签到总奖励:4金币
 楼主| 发表于 2020-4-2 17:16:29 | 显示全部楼层

你好,我也找到了这里,但是都是注释掉的,你的adk是多少?
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:29天
签到总奖励:154金币
发表于 2020-4-2 20:45:00 | 显示全部楼层
againstsun 发表于 2020-4-2 17:16
你好,我也找到了这里,但是都是注释掉的,你的adk是多少?

ADK6.4~~         
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:326天
签到总奖励:3575金币
发表于 2020-4-3 08:05:51 | 显示全部楼层
againstsun 发表于 2020-4-2 17:15
adk是6.3 好多跟4.几不一样了, 反而不会用了

我的6.4,你6.3的也应该可以直接用这几个接口的,在pio.h里包含的有。
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:1天
签到总奖励:4金币
 楼主| 发表于 2020-4-14 13:59:39 | 显示全部楼层

你好,你的这一段代码是在pio.h里面的,但是是灰色注释掉了的,前面有一个#if TRAPSET_CORE,应该如何使用?谢谢
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

连续签到天数:1天
签到总天数:29天
签到总奖励:154金币
发表于 2020-4-14 14:33:26 | 显示全部楼层
againstsun 发表于 2020-4-14 13:59
你好,你的这一段代码是在pio.h里面的,但是是灰色注释掉了的,前面有一个#if TRAPSET_CORE,应该如何使 ...

sink项目里面默认是有定义TRAPSET_CORE的
积分商城 - 让您的金币更有价值!||官方Q群 - 让您的沟通更加及时!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册  

本版积分规则

小黑屋|手机版|我爱蓝牙网 - 52Bluetooth

GMT+8, 2024-4-24 02:41 , Processed in 0.221105 second(s), 21 queries , Gzip On, MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表