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.

CCS/CC2640R2F: Using pin for wake-up

Part Number: CC2640R2F

Tool/software: Code Composer Studio

Hello,

I'm trying to wake up the CC2640r2 from standby via a button push like this:

static void SimplePeripheral_handleKeys(uint8_t keys)
{
    bStatus_t status = SUCCESS;
    //uint8_t buttonClosed = 1;
    //uint8_t buttonOpen =0;

  if (keys & KEY_LEFT)
  {
    // Check if the key is still pressed. Workaround for possible bouncing.
    if (PIN_getInputValue(Board_PIN_BUTTON0) == 1);
    {
      status = PIN_getInputValue(Board_PIN_BUTTON0);
      status = GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
      SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
      //SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t), &buttonOpen);
      //tbm_buttonLeft();
    }
    if (PIN_getInputValue(Board_PIN_BUTTON0) == 0)
    {
      //SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t), &buttonClosed);
      //tbm_buttonLeft();

    }else {
      tbm_buttonLeft();
    }
  }

Sorry for the messy cpde, I'm still dittling around with it. This lets me begin advertising when the button is pushed. In this application the button stays pushed. With the button pushed for 10+ seconds the device stops advertising and can no longer be woke up with a button push. I need to rebuild the app and redownload it to have the device begin to advertise after a button push. Is there a way to release this pin at the end of this function so that it will not disrupt the operation of the device?

Thanks,

Patrick

  • If you mean to know how to implement button pressed and hold for 10 seconds, you can refer to sunmaysky.blogspot.com/.../how-to-detect-buttont-hold-in-cc26x2.html
  • Hello Patrick,
    Maybe the code is hitting SIMPLEPERIPHERAL_ASSERT due to a returned bleAlreadyInRequestedMode?
    You can confirm this in debug mode and simply accept this return code in addition to SUCCESS.
    SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);

    The key is active low so you should check for (Board_PIN_BUTTON0) == 0.
  • Hi Eirik,

    The held button is causing the code to enter:

      // If there is an ongoing update, queue this for when the udpate completes
      if (status == bleAlreadyInRequestedMode)
      {
        spConnHandleEntry_t *connHandleEntry = ICall_malloc(sizeof(spConnHandleEntry_t));
        if (connHandleEntry)
        {
          connHandleEntry->connHandle = connHandle;
    
          List_put(&paramUpdateList, (List_Elem *)&connHandleEntry);
        }
      }

    Since the if statement evaluates to "false" the statement is never executed. You mentioned in your reply that I should "simply accept this return code in addition to SUCCESS". What exactly do you mean by this? Perhaps you could provide a code snippet.

    Thanks,

    Patrick

  • The code segment above is not related to what we discussed.
    To test just comment out the assert:
    //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);