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.

how to implementUser defined events in zstack

Other Parts Discussed in Thread: CC2538, CC2530

Hello all,

i am using zstack HA 1.2 and cc2538 and in my project i am using few sensors......

and i know that using OSAL_TIMER_START API i can generate some time-out event and when that timer expire i'll get event callback and the task jump to ISR and execute it.....but it is a kind of polling based mechanism....

but i want a interrupt based mechanism i mean to say i want a mechanism which monitor for a current sensor data and as soon as the sensor data changes it should generate some event callback and start executing particular ISR...sensor may me anything...say motion sensor so if any motion detected it should generate some event callback and start executing ISR......or temp sensor so if temp data crossing some particular level i need a interrupt....

one ex.is  KEY_CHANGE event in zstack....here until anyone presses any key nothing will happens but as anyone pressed any key it jumps to handle key ISR fn....   same way i also want to implement a  interrupt based mechanism which monitor for a particular level and if that level reached it should generate some  event callback for me....

hope i explained my requirement.....

anyone plz  help me solve this problem..

Thanks & Regards,

Maneesh singh

  • On CC2530, ADC can't trigger interrupt but GPI can. If you can accept using GPI interrupt, you can refer to how SW_6 implement in hal_key.c. It shows you how to register GPI as interrupt source and send out key event when triggered.

  • Hello YiKai Chen sir,

    as u suggested i am going through hal_key.c file....if i'll get any doubt i'll ask you......

    but what i notice is that hal_key.c is different for cc2538 and cc2530...i mean to say there is no SW_6 implementation kind of things in cc2538 hal_key.c... so if i want to implement same thing for cc2538 and zstack HA 1.20 then how can i do that ?

     

    Plz help me and plz reply...

    Thanks and Regards,

    Maneesh 

  • hal_key.c for CC2530 used joystick up/right/down/left for SW1/2/3/4 but hal_key.c for CC2538 uses up/right/down/left button for SW1/2/3/4. The GPI of these buttons in CC2538 are defined in bsp.h

    // Board key defines
    #define BSP_KEY_DIR_BASE        GPIO_C_BASE     //!< Base for left/right/up/down
    #define BSP_KEY_SEL_BASE        GPIO_A_BASE     //!< Base for Select
    #define BSP_KEY_1               GPIO_PIN_4      //!< PC4
    #define BSP_KEY_2               GPIO_PIN_5      //!< PC5
    #define BSP_KEY_3               GPIO_PIN_6      //!< PC6
    #define BSP_KEY_4               GPIO_PIN_7      //!< PC7
    #define BSP_KEY_5               GPIO_PIN_3      //!< PA3
    #define BSP_KEY_ALL             (BSP_KEY_1| \
                                     BSP_KEY_2| \
                                     BSP_KEY_3| \
                                     BSP_KEY_4| \
                                     BSP_KEY_5)     //!< Bitmask of all keys
    #define BSP_KEY_LEFT            BSP_KEY_1
    #define BSP_KEY_RIGHT           BSP_KEY_2
    #define BSP_KEY_UP              BSP_KEY_3
    #define BSP_KEY_DOWN            BSP_KEY_4
    #define BSP_KEY_SELECT          BSP_KEY_5
    #define BSP_KEY_DIR_ALL         (BSP_KEY_LEFT|  \
                                     BSP_KEY_RIGHT| \
                                     BSP_KEY_UP|    \
                                     BSP_KEY_DOWN)  //!< Bitmask of all dir. keys