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.

CC2541: Info on HIDEmuKbd project

Part Number: CC2541

Hello,

I am working on the HIDEmuKbd project example, and I am trying to find information about two situations:

1) what sequence of events happens when one of the keys is activated and the peripheral starts advertising? I tried finding it just following the code, but to no avail. Specifically, what function is called that starts advertising and how is either Key1 or Key2 involved?

2) what variable, if any, can tell me when the peripheral is connected to a central?

I am adapting the project to my application, but I need to know these two states of the peripheral, so that I can interact with sensors on my board. Everything is working fine, except that I am not being able to synchronize the sensors with the connection intervals. Ideally, I would like to interact with them at the end of the connection interval, to save power, besides doing calibration and initialization only when I know it is connected to a central device.

Thanks for any pointers,

Julio

  • Hi Julio,
    I'm assigning an expert to help you out.
  • Hello Julio,

    1) After a key is pressed the code execution will eventually end up in HidDev_Report() in hiddev.c.

    Please read through chapter "3  Operating System Abstraction Layer (OSAL)" in the Software Developers Guide to understand the flow of execution works. WHen a key is pressed for example when the device is in sleep this is the flow with regards to the key event:

    • HAL_ISR_FUNCTION( halKeyPort0Isr, P0INT_VECTOR ) -> halProcessKeyInterrupt() -> osal_start_timerEx (Hal_TaskID, HAL_KEY_EVENT, HAL_KEY_DEBOUNCE_VALUE); ->|
    • Hal_ProcessEvent() -> HalKeyPoll() -> (callback) pHalKeyProcessFunction == OnBoard_KeyCallback() -> OnBoard_SendKeys() -> (Send "Key Pressed (KEY_CHANGE)" message to application.) osal_msg_send ->|
    • hidEmuKbd_ProcessOSALMsg() -> case KEY_CHANGE: -> hidEmuKbd_HandleKeys() -> hidEmuKbdSendReport() -> HidDev_Report().

    2) Refer to HidDev_Report():

    if ( hidDevGapState == GAPROLE_CONNECTED )

    Please refer to the TI_BLE_Vendor_Specific_HCI_Guide.pdf and the HCI_EXT_ConnEventNoticeCmd. This can trigger an event at the end of each connection interval. Perhaps you can use this to synchronize your sensor acquisition? 

  • Hi, Eirik,

    Thanks for the reply. Your suggestions and explanation seems to solve the issue, but I will test them before marking it so. I am familiar with the functions you mentioned in the chain, but I missed the connection within the pHalKeyProcessFunction callback. I don't have the HCI_Guide you mention, I'll get it soon.

    Best regards,

    Julio

  • Hi, again,

    Just found the guide under the Documents folder of the BLE stack. I'll go over it.

    Julio
  • OK,
    I'm going to close this post for now then. If you have feedback within a few days you can follow up question to reopen this thread.
    If it takes longer than please post a new thread by pressing the orange button + Ask a related questions.