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.

GPIO / External Interrupts in zstack HA 1.2 for cc2538

Other Parts Discussed in Thread: CC2538, Z-STACK, CC2591, CC2592, CC2530

Hello all,

i am using zstack HA 1.20 and cc2538 board for my project.

I want to implement GPIO interrup or say external interrupt in my project for zstack HA 1.20.

anyone plz tell me how can i recognize GPIO interrupt and how i can jump to ISR associated with it....

for Ex- > key press is a interrupt in a zigbee and handlekey() is a ISR associated for it same way i hav something attached on my GPIO pin of CC2538 and it is giving me some inerrupt and i wrote a ISR for it..so now i want to implement that when ever i get a interrupt on this GPIO pin my prog execution flow should jump to its ISR which i hav register for it......

 in short i want to know 4 things--> 1) how to monitor/read /receive interrupt from GPIO in zstack HA 1.20.

                                                        2) how to attach/register ISR for this interrupt.

                                                        3) how can i generate or implement Events for this interrupt.

                                                        4) How can i recognize Rising Edge and Falling Edge interrupt.

i am using zstack HA 1.20 and cc2538 board..... 

Anyone plz tell me how can i do this ?  if possible give me some example also how and where i hav to do changes in my code or which function i need to add in my code....

Thanks & Regards,

Maneesh singh

  • There is SampleLight example in C:\Texas Instruments\Z-Stack Home 1.2.0\Projects\zstack\HomeAutomation\SampleSwitch\CC2538 and you can refer to hal_key.c that show you how to add GPI as interrupt source and send key event.

  • hello YiKai Chen sir,

    Thanks for replying....thanks a lot...

    sorry for writing such a big post and troubling u by asking so many question but whatever little i know about zigbee is becoz of your support only sir....i am very much thankful to you for help me supporting me and  answering all my silly question..... thanks a lot sir for your help and effort......  :)  :)

     

    Now as u suggested i referred the hal_hey.c file and tries to understand how they are handling key pressed...

    what i understand is that -

    1) During main() fn call in zmain file they are calling init_board(OB_READY) from onboard.c file

    2) now this init_board () fn is calling Hal_Key_config() fn from hal_key.c file

    3) in Hal_Key_config() fn they are enabling interrupts for key, registering its callback fn i.e interrupt_keybd , calling bspkey_init() for key handler, and setting interrupt priority for keys...

    4) so whenever any key is getting pressed interrupts is generating and its registered ISR fn interrupt_keybd() is getting called from hal_hey.c file

    5) and under this ISR fn hal_key_int_key() fn gets called which checks/scans which key was pressed by calling bspkeypushed() fn from the bspkey.c file..

    6) once we get which key was pressed it is calling OnBoard_KeyCallback() fn from the onboard.c file and this fn will generate a Event for Application by using osal_msg_send() function......

    plz tell me whatever i understand is right or i am missing some steps ? plz correct me or guide me if i am wrong or if i misunderstood something ....plz...

    Now and as per your suggestion if i am not wrong then for registering any GPIO interrupt i hav to follow same steps as they did for key ? means ->

    1) i hav to implement a GPIO_config() fn and in that fn i'll enabling interrupts for GPIO, registering its callback fn, calling bspkey_init() for GPIO handler, and setting interrupt priority for GPIO.

    2) then i hav to scan for or wait for any GPIO interrupt and if any interrupt comes then jump to its ISR..... and then generate the Event for Application layer for that particular GPIO like they did for key..... am i right sir ?

    plz correct me if i am wrong.....

    but i hav few doubt - >

    1) how to identify rising edge and falling edge interrupt  on GPIO ?

    2) in BSP we hav io_pin_int.c file which is-

    //!  I/O pin interrupt handler for CC2538. This is an extension to
    //! the driverlib GPIO module, allowing GPIO pins on the same GPIO
    //! port to have different interrupt handlers.

    can i use this file ? if yes then how ?

    3) in Hal_key.h they did ==> typedef void (*halKeyCBack_t) (uint8 keys, uint8 state);

       and in hal_key.c they did ==> static halKeyCBack_t pHal_KeyProcessFunction;

    now in ISR of key i.e in void interrupt_keybd(void) fn they are doing==> 

    if (halIntKeys && (pHal_KeyProcessFunction))
    {
    (pHal_KeyProcessFunction) (halIntKeys, HAL_KEY_STATE_NORMAL);
    }

    they are using it to call the OnBoard_KeyCallback ( uint8 keys, uint8 state ) fn from onboard.c

    i know that a fn name can be used as a address of a fn like array but i didnt understand how they are mappings OnBoard_KeyCallback fn with pHal_KeyProcessFunction ? and where they are doing it? and what is the use or say working of this line typedef void (*halKeyCBack_t) (uint8 keys, uint8 state);

    plz sir help me to understand these problem....

    plz reply sir...

    Thanks a lot

    Maneesh singh

  • hello YiKai Chen sir,

    plz sir help me to understand these problem....

    plz reply sir...

    Thanks & Regards,

    Maneesh singh

     

  • hello YiKai Chen sir,

    plz reply sir...

    Thanks & Regards,

    Maneesh singh

  • hello YiKai Chen sir,

    plz reply sir...

    Thanks & Regards,

    Maneesh singh

  • hello YiKai Chen sir,

    plz reply sir...

    Thanks & Regards,

    Maneesh singh

  • Hello YiKai Chen sir,

    i am using cc2538 and zstack1.2.0 HA but now in my custom board we interfaced cc2538 with cc2592..

    1) so will you plz tell me how i can use it means where i hav to define HAL_PA_LNA it is in the IAR->option->c/c++compiler option-> defined symbol  or in my <sampleapp.c> fle and how to define it means its prototype,     is this ok ->#define HAL_PA_LNA or how?

    2) any other setting i hav to do or by defining only this single macro i am able to use my cc2592 ? if yes then what and where ?

    3) i checked in Z-Stack Home 1.2.0 -> mac_radio_defs.c file there is nothing for cc2592 they are using cc2591 or cc2590only....

    4) and in HAL_API.c pdf it is written there that i need to define these 2 macro -> HAL_PA_LNA_RX_LGM()   and HAL_PA_LNA_RX_HGM()...... will you plz tell me where and in which file i hav to define this macro ? and is any other code also i hav to write ?

     

    plz reply sir...

    Thanks & Regards,

    Maneesh singh

  • Did you already figure out the question regarding Interrupts? Can this be closed?

    The questions raised later in this thread are not related to the original thread post or the subject. Please in future open a new thread when raising a new question, you are more likely to get a response from some that knows the answer if you have the correct subject. 

    maneesh singh said:
    1) so will you plz tell me how i can use it means where i hav to define HAL_PA_LNA it is in the IAR->option->c/c++compiler option-> defined symbol  or in my <sampleapp.c> fle and how to define it means its prototype,     is this ok ->#define HAL_PA_LNA or how?

    In IAR project workspace->HAL->Target->Include you will see a file hal_board_cfg.h, in there you will see:

    /* ------------------------------------------------------------------------------------------------
     *                                       CC2590/CC2591 support
     *
     *                        Define HAL_PA_LNA_CC2590 if CC2538+CC2590EM is used
     *                        Define HAL_PA_LNA if CC2538+CC2591EM is used
     *                        Note that only one of them can be defined
     * ------------------------------------------------------------------------------------------------
     */
    
    #define xHAL_PA_LNA
    #define xHAL_PA_LNA_CC2590
    #define xHAL_PA_LNA_CC2592

    remove the x to define HAL_PA_LNA.

    maneesh singh said:
    2) any other setting i hav to do or by defining only this single macro i am able to use my cc2592 ? if yes then what and where ?

    remove the x to define HAL_PA_LNA_CC2592.

    maneesh singh said:
    3) i checked in Z-Stack Home 1.2.0 -> mac_radio_defs.c file there is nothing for cc2592 they are using cc2591 or cc2590only....

    CC2591 and CC2592 use the same radio defs.

    maneesh singh said:
    4) and in HAL_API.c pdf it is written there that i need to define these 2 macro -> HAL_PA_LNA_RX_LGM()   and HAL_PA_LNA_RX_HGM()...... will you plz tell me where and in which file i hav to define this macro ? and is any other code also i hav to write ?

    Where do you see HAL_API.c? HAL_PA_LNA_RX_LGM and HAL_PA_LNA_RX_HGM macros are already defined in mac_radio_defs.c.

    Regards, TC.

  • Hello Mr. TopCat,

    Thanks for reply sir....

    still i didnt got answer for my interrupt question....

    as i told in my previous post i understood the key event interrupt working but i had few doubts which i posted in my previous post only but till now i didnt got any explanation of it neither any reply from chen sir also........so if you can answer my those question then it will be very helpful for me...  

    and it was HAL_API pdf not a HAL_API.c... its my writing mistake...i am sorry for that..

    i more thing i want to ask till now i am worked on only ZC-----ZED configuration but now i want to do something more..now i want to implement ZC------ZR-------ZED type of configuration.... i hav  2 cc2538 smartRFboard and 2 cc2530 smart rf board...and till now i worked on sample sw-------sample light and sample temp --------sample thermostat projects.... so it's my request to you will you plz tell me how can i implement ZC-----ZR------ZED configuration for sample sw-------sample light and sample temp --------sample thermostat project..... i know how to make it ZC and ZED but i dont know how to make ZR or what are the changes i hav to do to make ZC----ZR----ZED configuration for above mention project........ if you can help me how to do this  then i will be very thankful to you...

    (Note :- i know that in IAR workspace from scroll down menu we should select ZR configuration instead of ZC and ZED but what else i hav to do in project or any other changes required in code to make ZC---ZR-----ZED configuration)

    plz relpy sir..

    Thanks & regards,

    Maneesh singh 

  • Hi Maneesh,

    You can use SampleLight and SampleSwitch to do ZC----ZR---ZED configuration in the following steps:

    1. Build one SampleLight as ZC, one SampleLight as ZR, and one SampleSwitch as ZED.

    2. Turn on SampleLight ZC to form a Zigbee network first.

    3. Turn on SampleLight ZR to join ZC.

    4. Turn on SampleSwitch ZED to join ZC or ZR.

    5. Turn off SampleLight ZC to make SampleSwitch ZED to make sure it joins SampleLight ZR.

    6. Turn on SampeLight ZC again to have a ZC---ZR----ZED zigbee network.