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.

Configuring HAL_KEY_SW_6 - Z-Stack

Other Parts Discussed in Thread: CC2530

Hello,

I'm currently stuck on a certain part of my project and I was wondering if you can help:

I'm using the cc2530, generic app example and building my project code up from there. I've hit a few snags with manipulating the key presses for the system.

As I believe: The HAL_KEY_SW_6 is acting a modifier switch which enables the joystick keys to behave as interupts rather then polling them(?).

I want to use HAL_KEY_SW_6 as it's own interrupting switch, removing the shift modifier and functionality. However I can't seen to get it to a working stage, can you help or point me in the right direction?

Thank you,

Chris

  • I'd value any help on this subject please!

    Thank you,

    Chris

  • Hi,

    How, and where in the code you are trying to catch an event from this button?

    By the way, HAL_KEY_SW_6 is actually button1 (S1) on the smartRF05EB.

  • Hello,
    I'm writing my commands in:
    void Gamma_HandleKeys( byte shift, byte keys ){
    if ( keys & HAL_KEY_SW_6 ) //smartRF05EB button 1
    {
    The problem I have is when I press Button 1, nothing happens.
    I've now realised it is due to the function: 
    OnBoard_KeyCallback () in  OnBoard.c that is modifying my state to shifted. 
    I've got my system now working by:
    OnBoard.c:
    Firstly enabling interrupts:
    void InitBoard( uint8 level )
    {
    HalKeyConfig(HAL_KEY_INTERRUPT_ENABLE, OnBoard_KeyCallback);
    
    
    Then Setting shift to always be zero.
    OnBoard_KeyCallback (..){
    uint8 shift = 0; // set shift to always be off.
    (void)state;

    if ( OnBoard_SendKeys( keys, shift ) != ZSuccess ) {

    And finally setting 

    #define HAL_KEY_SW_6_EDGE     HAL_KEY_RISING_EDGE

    in Hal_Key.c

    This all seems to let my button 1 behave as I wish.

    Have I missed a trick or a better solution to my problem?

    Thank you,

    Chris

  • Hi,

    I think you can avoid setting shift to always be off

    Then you can add the following in Gamma(HandleKeys() :

    if ( shift ){

    if ( keys & HAL_KEY_SW_6 )
    {
    }

    etc...

  • Igor,

    That is a far simpler solution.

    So my actual fix to all of this was to enable interupts in OnBoard.c.

    Setting the detection of the rising edge was only really for stability.

    Thanks,

    Chris