This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2642R-Q1: CC2642 GPIO output mode to input mode/input to output

Part Number: CC2642R-Q1


HI,

   GPIO cannot convert directly from output to input?

First configure as:

     PIN_Config BoardGpioInitTable1 [2+1] {

        DIO1| PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS,

         DIO0| PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,

          PIN_TERMINATE

     };

    PIN_init(BoardGpioInitTable1);

 And then configure it as:

   

PIN_Config BoardGpioInitTable2 [2+1] {

        DIO1| PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,

         DIO0| PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS,

          PIN_TERMINATE

     };

PIN_open(&s_UserPins, BoardGpioInitTable2 );

 

  • Part Number: CC2642R-Q1

    hi,PIN_init()  cannot be called more than once?  Board_initGeneral();中有一次PIN_init(), 我又调用了一次PIN_init(),为什么还是可以运行?第二次的调用是否生效?

        

    int main()
    {
      /* Register Application callback to trap asserts raised in the Stack */
      RegisterAssertCback(AssertHandler); 
    
      Board_initGeneral();
    
      #define CONFIG_PIN_COUNT 10-8
    
      const PIN_Config BoardGpioInitTable[CONFIG_PIN_COUNT + 1] = {
        /* LaunchPad Button BTN-1 (Left), Parent Signal: CONFIG_GPIO_BTN1 GPIO Pin, (DIO13) */
                                                                 0x0000000d | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_DIS,
        /* LaunchPad Button BTN-2 (Right), Parent Signal: CONFIG_GPIO_BTN2 GPIO Pin, (DIO14) */
                                                                 0x0000000e | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_DIS,
    //    /* LaunchPad LED Red, Parent Signal: CONFIG_GPIO_RLED GPIO Pin, (DIO6) */
    //                                                             0x00000006 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,
    //    /* LaunchPad LED Green, Parent Signal: CONFIG_GPIO_GLED GPIO Pin, (DIO7) */
    //                                                             0x00000007 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,
    //    /* Parent Signal: CONFIG_GPIO_0 GPIO Pin, (DIO4) */
    //                                                             0x00000004 | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS,
    //    /* Parent Signal: CONFIG_GPIO_1 GPIO Pin, (DIO5) */
    //                                                             0x00000005 | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS,
    //    /* Parent Signal: CONFIG_GPIO_2 GPIO Pin, (DIO12) */
    //                                                             0x0000000c | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS,
    //    /* Parent Signal: CONFIG_SPI_0 SCLK, (DIO11) */
    //                                                             0x0000000b  | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,
    ////    /* Parent Signal: CONFIG_SPI_0 MISO, (DIO1) */
    ////                                                             0x00000001 | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS,
    ////    /* Parent Signal: CONFIG_SPI_0 MOSI, (DIO0) */
    ////                                                             0x00000000 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED,
    //
        PIN_TERMINATE
    };
    if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
            /* Error with PIN_init */
            while (1);
    }
    
    .............
    }

  • sdk:simplelink_cc13xx_cc26xx_sdk_5_40_00_40

  • Hi,

    PIN_init should only be called once and as early as possible in the boot sequence.  Please note that the PIN driver will be removed in the v6.20 SDK in favor of the GPIO++ driver.  You can read more from PIN.h in the TI Drivers API and BLE5-Stack Migration Guide.

    Regards,
    Ryan