Using user defined Interrupts in own Driver

Hello!

 

I'm currently trying to develop an own driver. So far so good, I've got the whole pack , xml files structure, and managed to include those into the project. They will also be visible in the configuration and thread view in e2studio.

My question is: how can I write the driver code that a user defined interrupt in the configuration of the driver will be used?

Example of the timer driver configuration is what I mean:

 

The user is configuring the Callback function that should be used when the Interrupt is triggered. Also defines the priority of the Interrupt and the channel to be used.

 

I want to write a SMBus driver, were I can force a Interrupt if some timing issues are occurred or the incoming data have to be decoded.

 

My question is how to do this in the code?

 

I'm not sure if this can be done with this function: "NVIC_SetPendingIRQ(IRQn_Type IRQn)"

 

The connection between the callback function and the interrupt will be generated automatically? (Have to de defined in the xml file as property and in the head section).

 

Thank you for any help!

 

Regards,

Gregor

  • Gregor,

    I have uploaded an pack file that I created to support phase counting on GPT.
    It took my a while to work out how the ISRs work.
    Please have a look as it may help you understand how interrupts and callbacks can be implemented.

    For the GPT phase counting mode I wanted to the option of using 4 possible interrupts: Compare Match A, Compare Match B, Overflow, Underflow.

    If you look in Renesas##HAL Drivers##all##r_gpt_phase_counting####1.3.0.xml, as part of the declarations at the end of the xml coding, you will see how the ISR's are registered.

    NOTE: The interrupt are registered using the MACRO:

    SSP_VECTOR_DEFINE_CHAN(gpt_phase_counting_compare_a_isr, GPT, CAPTURE_COMPARE_A, ${module.driver.gpt_phase_counting.channel});

    This is registering the GPT Input Capture / Output compare interrupt for a specified GPT channel number.
    The ISR definition to be passed into this MACRO can be determined from the file ssp_features.h
    If you look in this file, you will see an enum of SSP signals.
    Therefore, to register the interrupt
    SSP_SIGNAL_GPT_CAPTURE_COMPARE_A,
    will use the MACRO as:
    SSP_VECTOR_DEFINE_CHAN(gpt_phase_counting_compare_a_isr, GPT, CAPTURE_COMPARE_A, ${module.driver.gpt_phase_counting.channel});

    To register the Serial Port interrupt SSP_SIGNAL_SCI_ERI
    use the MACRO as:
    SSP_VECTOR_DEFINE_CHAN(gpt_phase_counting_compare_a_isr, SCI, ERI, ${module.driver.sci.channel});

    I hope this makes sense!


    The interrupt service routines for these 4 ISR's are hard coded into the driver (r_gpt_phase_counting.c) and they are enabled / disabled as part of .open (which calls the function - gpt_phase_counting_hardware_initialize)
    The ISRs call the common callback which is specified in the configuration.

    I hope this will allow you to piece together how it all works

    Regards,
    Richard
  • Hello Richard!

    Thank you for your fast reply! I will take a look into it and try it out. Today I had some crazy day at work ;)

    Regards,
    Gregor
  • In reply to Richard:

    Hi,

    I'm still analyzing the code from you, but so far I had create a simple graphic overview of how the .xml file is built:

    If I'm right, then only the green part defines the interface from ISR and code... but I'm still learning it :)

    Regards,

    Gregor

  • In reply to Richard:

    Hello Richard!

    I'm currently struggling with my SMbus driver. Could you please install this driver (it is under construction) and try to build a new project with it?

    If I use an empty project and try to build with the SMBus driver added, then I get this message:

     

    I have no idea where thouse names of interrupts are coming from... I have expected something like "smb_counter_overflow_isr" and so on.

     

    Synergy.r_smb.1.4.2.zip

     

    I will be very gratefull for any hint.

     

    Regards,

    Gregor