User code in the drivers

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LuBe_4654241
Level 4
Level 4
50 sign-ins 25 replies posted 25 sign-ins

Hi,

How can insert user in a driver function ?

I have understood that there was this method:

/* `#START UART_1_SPI_UART_ISR` */

/* `#END` */

But no work, what's the problem ?

Best regards

LuBe

0 Likes
1 Solution

LuBe,

Thank you for sharing your project.

I downloaded your project.

I see the confusion.  Cypress did not provide a "#START ... #END" means of inserting user code into the UART_1_SPI_UART_INT.c component code.  (They did in the file UART_1_SCB_IRQ.c).

However they did provide a method of inserting custom user code in the UART_1_SPI_UART_ISR function.  They have a means of inserting an ENTRY and/or EXIT callback.

Here is the entry callback method:

#ifdef UART_1_SPI_UART_ISR_ENTRY_CALLBACK
    UART_1_SPI_UART_ISR_EntryCallback();
#endif /* UART_1_SPI_UART_ISR_ENTRY_CALLBACK */

and the exit callback:

#ifdef UART_1_SPI_UART_ISR_EXIT_CALLBACK
    UART_1_SPI_UART_ISR_EXITCallback();
#endif /* UART_1_SPI_UART_ISR_EXIT_CALLBACK */

As I described in an earlier post, this is a significantly preferred method of inserting custom user code.

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
8 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

LuBe,

What component were you using?

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi,

I'm using the standard UART.

Best regards

0 Likes

LuBe,

I am unable to generate component code with 

/* `#START UART_1_SPI_UART_ISR` */

/* `#END` */

What configuration did you use to get this code?

Are you willing to share your project with the forum?

Generally speaking I avoid changing component generated code for three main reasons.

Reason #1

Every time I perform a Application Build phase, the components in TopDesign get regenerated.

If you keep your modified code between the #START and #END sections, your changes SHOULD BE preserved.  However this is possibly not always guaranteed.  If the component author eliminates this custom code section in a new version of the component, your changes are not guaranteed to be preserved.

Reason #2

If you change the instance name of the component that previously contained your custom code, this code will NOT be preserved.

Reason #3

If you perform a project or workspace "Clean" operation, your custom code is not guaranteed.

Methods to provide custom ISR code without touching the component-generated code

Method #1 - CALLBACKS

Virtually ALL component ISR code has a method to place custom code in your root directory .c file using CALLBACKS.

Consult the "Macro Callbacks" section of the datasheet to find out how to allow for ISRs to be used without altering the component code.  This is preserved against all the Reasons I list above.

Method #2 - External ISRs

You can select Interrupt = "External".  It will place an output connection from the UART to allow you to place a ISR component.   Consult the ISR datasheet and example projects how to create ISR code without changing the component generated code.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi,

it is clear that there are others solutions, but I want understand why the comments (#START #END) not work. 

The module that I want change is UART_1_SPI_UART_INT.c

Best regards

LuBe

 

0 Likes

LuBe,

Thank you for sharing your project.

I downloaded your project.

I see the confusion.  Cypress did not provide a "#START ... #END" means of inserting user code into the UART_1_SPI_UART_INT.c component code.  (They did in the file UART_1_SCB_IRQ.c).

However they did provide a method of inserting custom user code in the UART_1_SPI_UART_ISR function.  They have a means of inserting an ENTRY and/or EXIT callback.

Here is the entry callback method:

#ifdef UART_1_SPI_UART_ISR_ENTRY_CALLBACK
    UART_1_SPI_UART_ISR_EntryCallback();
#endif /* UART_1_SPI_UART_ISR_ENTRY_CALLBACK */

and the exit callback:

#ifdef UART_1_SPI_UART_ISR_EXIT_CALLBACK
    UART_1_SPI_UART_ISR_EXITCallback();
#endif /* UART_1_SPI_UART_ISR_EXIT_CALLBACK */

As I described in an earlier post, this is a significantly preferred method of inserting custom user code.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi,

Can you delete my project from community (PSoC_EmEEPROM_PSoC401_LB) ?

Best regards

0 Likes

Hi, can someone answer to me ?

Best regards

LuBe

0 Likes

LuBe,

Try this:

  • Select "Edit Reply" on the top right corner of the post with the code attached.
    Len_CONSULTRON_0-1623673618749.png
  • Go to the "Drag and drop" section at the bottom of the post and select the "X" box on the file to delete.
    Screenshot 2021-06-14 082428.jpg

Len
"Engineering is an Art. The Art of Compromise."
0 Likes