againstsun 发表于 2020-4-1 14:54:34

QCC3020如何设置PIO7输出高电平?

QCC3020如何设置PIO7输出高电平?给下具体例子,谢谢。

951623847 发表于 2020-4-1 22:10:03



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

/**
*\brief Set PIOs as inputs or outputs.
*   
*   Note that all PIOs must be mapped in before they can be used.
*   See the PioSetMapPins32() documentation for information on valid PIO
*directions
*   and PIO mapping.
*\param mask Each bit in the mask corresponds to a PIO line. Bits set to 1 in this mask will
*be modified. Bits set to 0 in this mask will not be modified.
*\param dir Each bit in the "dir" value corresponds to a PIO line. Bits set to 1 in this
*value will result in that PIO line being configured as an output. Bits set to
*0 in this value will result in that PIO line being configured as an input.
*\return A 32 bit mask. If any bit in this mask is high then that PIO could not be set
*to the direction specified; note that no action will have been taken on any
*PIOs.
*
* \note This trap may NOT be called from a high-priority task handler
*
* \ingroup trapset_core
*/
uint32 PioSetDir32(uint32 mask, uint32 dir);

赵阳 发表于 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);

againstsun 发表于 2020-4-2 16:25:09

赵阳 发表于 2020-4-2 08:03
int pio_mask = (1

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

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

#include "trap_api/trap_api.h"

/**
* Init USB device descriptors
*
* Called before the rest of the firmware to configure
* USB device descriptors. */
extern void _init(void);

#define PioDebounce32(mask, count, period) PioDebounce32Bank(0, mask, count, period)
#define PioGet32() PioGet32Bank(0)
#define PioSet32(mask, bits) PioSet32Bank(0, mask, bits)
#define PioGetDir32() PioGetDir32Bank(0)
#define PioSetDir32(mask, dir) PioSetDir32Bank(0, mask, dir)
#define PioGetStrongBias32() PioGetStrongBias32Bank(0)
#define PioSetStrongBias32(mask, bits) PioSetStrongBias32Bank(0, mask, bits)
#define PioGetMapPins32() PioGetMapPins32Bank(0)
#define PioSetMapPins32(mask, bits) PioSetMapPins32Bank(0, mask, bits)
#define PioGetUnusedPins32() PioGetUnusedPins32Bank(0)

/*@}*/

#endif /* PORTABILITY_H_ */

againstsun 发表于 2020-4-2 17:15:36

赵阳 发表于 2020-4-2 08:03
int pio_mask = (1

adk是6.3 好多跟4.几不一样了, 反而不会用了

againstsun 发表于 2020-4-2 17:16:29

bluetooth123 发表于 2020-4-1 22:10


你好,我也找到了这里,但是都是注释掉的,你的adk是多少?

951623847 发表于 2020-4-2 20:45:00

againstsun 发表于 2020-4-2 17:16
你好,我也找到了这里,但是都是注释掉的,你的adk是多少?

ADK6.4~~         

赵阳 发表于 2020-4-3 08:05:51

againstsun 发表于 2020-4-2 17:15
adk是6.3 好多跟4.几不一样了, 反而不会用了

我的6.4,你6.3的也应该可以直接用这几个接口的,在pio.h里包含的有。

againstsun 发表于 2020-4-14 13:59:39

bluetooth123 发表于 2020-4-1 22:10


你好,你的这一段代码是在pio.h里面的,但是是灰色注释掉了的,前面有一个#if TRAPSET_CORE,应该如何使用?谢谢

951623847 发表于 2020-4-14 14:33:26

againstsun 发表于 2020-4-14 13:59
你好,你的这一段代码是在pio.h里面的,但是是灰色注释掉了的,前面有一个#if TRAPSET_CORE,应该如何使 ...

sink项目里面默认是有定义TRAPSET_CORE的
页: [1] 2
查看完整版本: QCC3020如何设置PIO7输出高电平?