微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI无线射频设计 > cc1310的uart关闭后dio2和dio3是什么状态?

cc1310的uart关闭后dio2和dio3是什么状态?

时间:12-23 整理:3721RD 点击:

cc1310的uart关闭后dio2和dio3是什么状态?高电平还是低电平,还是高阻态?

可能都是高电平?一个输出,一个输入

可以在仿真环境看看gpio,ioc寄存器

// Find GPIO default value and revert to it
if (pinGpioConfigTable[pinId] == PIN_UNASSIGNED) {
    // Revert pin to default configuration:
    // GPIO, input buffer disable, GPIO output disable, low GPIO output, no pull, no IRQ, no wakeup
    PINCC26XX_setIoCfg(PIN_BM_ALL, PIN_ID(pinId) | PIN_INPUT_DIS);
} else {
    // Revert pin to previous GPIO configuration
    PINCC26XX_setIoCfg(PIN_BM_ALL, defaultPinConfig[pinGpioConfigTable[pinId]]);
}
// Revert to GPIO
PINCC26XX_setIoCfgMux(PIN_ID(pinId), -1);

  • Felix ZF 你好。我刚才测试了一下,我调用了函数UART_close(uart);之后,用示波器观察端口2和3.。发现dio2是低电平,dio3是高电平。并不是像注释说的那样,拉低去。。。。?这个是怎么回事呢?

const PIN_Config BoardGpioInitTable[] = {

    Board_RLED   | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,         /* LED initially off             */

    Board_GLED   | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,         /* LED initially off             */

    Board_BTN1   | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,            /* Button is active low          */

    Board_BTN2   | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,            /* Button is active low          */

    Board_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,  /* External flash chip select    */

    Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */

    Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,                        /* UART TX via debugger back channel */

    Board_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master out - slave in */

    Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master in - slave out */

    Board_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,                                             /* SPI clock */

    PIN_TERMINATE

};

我想关掉串口去之后,想让串口达到// GPIO, input buffer disable, GPIO output disable, low GPIO output, no pull, no IRQ, no wakeup这种状态,也就是和其他模块串口相连的时候,不会通过串口浪费电去。这个调用UART_close(uart);两个端口没有达到这种状态啊?

是不是需要调用PIN_Status PIN_remove(PIN_Handle handle, PIN_Id pinId);这条函数?

您是想彻底关闭串口引脚?

PIN_Status PIN_remove ( PIN_Handle  handle,
PIN_Id  pinId 
)

Removes pin from pin set foropen PIN handle.

If the requested pin is allocated to handle it will be removed from the pin set, else an error code will be returned.

Parameters
handle handle retrieved through an earlier call to PIN_open().
pinId Pin ID for pin to remove.
Returns
Error code if unsuccessful, else PIN_SUCCESS

我现在对于串口想是想两个功能:

1,串口使用完之后,关掉。---------------------------------------------------------------------------这个可以用过UART_close(uart);来实现。我也实现了。

2,串口使用完之后,把串口的两个脚设置成PIN_remove这个函数关掉后的状态。----这个我一直实现不了。

我现在有个思路:

1,把Board_initGeneral();里面的串口初始化注释掉

const PIN_Config BoardGpioInitTable[] = {

    CC1310_LAUNCHXL_PIN_RLED     | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL      | PIN_DRVSTR_MAX,     /* LED initially off          */
    CC1310_LAUNCHXL_PIN_GLED     | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL      | PIN_DRVSTR_MAX,     /* LED initially off          */
    CC1310_LAUNCHXL_PIN_BTN1     | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,     /* Button is active low       */
    CC1310_LAUNCHXL_PIN_BTN2     | PIN_INPUT_EN       | PIN_PULLUP    | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,     /* Button is active low       */
    CC1310_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL      | PIN_DRVSTR_MIN,     /* External flash chip select */
    //CC1310_LAUNCHXL_UART_RX      | PIN_INPUT_EN       | PIN_PULLDOWN,                                           /* UART RX via debugger back channel */
    //CC1310_LAUNCHXL_UART_TX      | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,                           /* UART TX via debugger back channel */
    CC1310_LAUNCHXL_SPI0_MOSI    | PIN_INPUT_EN       | PIN_PULLDOWN,                                           /* SPI master out - slave in */
    CC1310_LAUNCHXL_SPI0_MISO    | PIN_INPUT_EN       | PIN_PULLDOWN,                                           /* SPI master in - slave out */
    CC1310_LAUNCHXL_SPI0_CLK     | PIN_INPUT_EN       | PIN_PULLDOWN,                                           /* SPI clock */

    PIN_TERMINATE
};

2,自己在写一个初始化的串口2,3脚的函数来。

/* Pin driver object and handle */
static PIN_Handle UART_PinHandle;
static PIN_State  UART_PinState;
static PIN_Config UART_pinTable[] =
{
    IOID_2 | PIN_INPUT_EN       | PIN_PULLDOWN,
    IOID_3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,

    PIN_TERMINATE
};

void UART_open(void)
{
    UART_PinHandle = PIN_open(&UART_PinState, UART_pinTable);
}

void UART_add(void)
{
    UART_PinState = PIN_add(UART_PinHandle, UART_pinTable);
}

void UART_remove(void)
{
    UART_PinState = PIN_remove(UART_PinHandle, IOID_2);
    UART_PinState = PIN_remove(UART_PinHandle, IOID_3);
}

3,程序运行之前调用UART_open();然后用UART_add();和UART_remove();来实现串口的io口的开关。

这样可以吗?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top