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.

Argument to interrupt handler

Other Parts Discussed in Thread: SYSBIOS

Hi,

I have registered my ADC SS0 interrupt as below:

ADC0_SS0_interrupt = Hwi_create(ADC0_Sequence_0_interrupt, ADC0_Seq0_Int_Handler, &ADC0_SS0_Params, NULL);

 if(ADC0_SS0_interrupt == NULL) {

              retValue = FAILURE;

}

 

and interrupt handler is as below:

 

void ADC0_Seq1_Int_Handler(UArg arg) {

       ADC_MAIL_BOX_t msgA;

 

       uint32_t tempBuf[SS1_FIFO_depth];

 

       ADCIntClear(ADC0_BASE, SAMPLE_SEQUENCER_1);

 

       ADCSequenceDataGet(ADC0_BASE, SAMPLE_SEQUENCER_1, tempBuf);

 

       msgA.data = tempBuf[0];

 

}

 

I am receiving interrupt and everything is working fine. 

I want to do an improvement on this by passing an argument to interrupt handler. 

UArg is defined as

typedef xdc_UArg        UArg;  // line 228

in “c:\ti\xdctools_3_25_04_88\packages\xdc\std.h”

which in turn defined as typedef unsigned int xdc_UArg;

 

My requirement is to pass pointer to a struct ( or void *) to interrupt handler?

But from above definition of UArg, I think it is not possible to do this.  Is my understanding correct?

Regards

Srinivasa

  • Hi Srinivasa,
    The UArg type resolves to xdc_UArg which in turn resolves to an unsigned int. If you're on a 32 bit architecture then your pointer is 32 bit wide which is most likely the size of an unsigned integer. In that case you can pass in your void * as the Hwi argument and cast it to void * in your Hwi function (that's what I'd most likely do). Note that this may not be portable to say a 64-bit device where UArg could be 32 bit and pointers are 64 bit wide.

    Let me know if this helps,
    Moses
  • Hi Moses,

    Thanks for your input.

    I am working on 32-bit system and hence I want to pass my address of struct as the Hwi argument.

    I am using Hwi_create to register the interrupt as below:

    ADC0_SS0_interrupt = Hwi_create(ADC0_Sequence_0_interrupt, ADC0_Seq0_Int_Handler, &ADC0_SS0_Params, NULL);

    In Hwi_create

    Param 1: Interrupt number/id.
    Param 2: Name of the ISR.
    Param 4: The "eb" is an error block that you can use to handle errors that may occur during Hwi object creation.

    The only option is to use Param 3:

    Param 3: Hwi_params (Instance config-params structure) which is defined as

    /* Params */
    struct ti_sysbios_hal_Hwi_Params {
    size_t __size;
    const void* __self;
    void* __fxns;
    xdc_runtime_IInstance_Params* instance;
    ti_sysbios_interfaces_IHwi_MaskingOption maskSetting;
    xdc_UArg arg; // Can I use this parameter?
    xdc_Bool enableInt;
    xdc_Int eventId;
    xdc_Int priority;
    xdc_runtime_IInstance_Params __iprms;
    };

    Which member of this structure has to be used to pass my address?

    Regards
    Srinivasa
  • Hi Moses,

    I found an example usage of it under

    "c:\ti\tirtos_1_21_00_09\products\bios_6_37_00_20\packages\ti\sysbios\timers\dmtimer\Timer.c".

    Implemented the same in my code and got it working.

    Regards
    Srinivasa
  • Srinivasa,
    Glad that you got it working!

    Regards,
    Moses