Killing a function from interrupt ISR on baremetal

Hi folks.

I am working with Xilinx boards, and I am using Xilinx spi,iic.. drivers in C to build user application. So basically it goes like this:

in my main program:

result = spi_transfer (arguments..); // here i call Xilinx function which is like black box, I don't know the hierarchy. this function can stuck inside and get to endless loop in some cases.

To cope with those anomalies (endledd loop), I added watchdog timer that set time before the function , and it gets to isr if the spi_transfer function don't execute after desired time.

Is there a way to kill spi_transfer function from inside of the ISR?
I read a little about it, and I understood that it is done easily with os like linux, freertos, but for now , my project is based on baremetal.

My question is - Is there a reasonable way to make what I've described?
Thanks for the support.




Is longjmp() out of an ISR valid?

You could call setjmp() just before your call to spi_transfer.
https://en.cppreference.com/w/c/program/setjmp

Depending on how your architecture handles interrupts, there may be some register hacking (like selecting the right stack) before executing the longjmp.

Also note this won't be a normal ISR exit either, so that might need some non-standard fixing up as well.
Probably my post won't be too helpful, but just to drive you in maybe a useful direction,

Do you know if you have the latest patches for your platform?
https://github.com/Xilinx/embeddedsw/issues/152

Can you link the documentation for the spi_transfer function itself so we can see if there are usage notes? And maybe show more-specific calling code/context.

Just ideas, not saying it will necessarily help. But it seems like we need to treat the actual problem, and not the symptoms.
seems like good source!

XSpi_Transfer is just an example, there are other functions that can get stuck like: XSpi_LookupConfig,XSpi_CfgInitialize, XSpi_SelfTest..

You can see the functions for xspi here:
https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/spi/examples/xspi_polled_example.c


Here is information about the function that are used by spi drivers:
https://xilinx.github.io/embeddedsw.github.io/spi/doc/html/api/group__spi__v4__9.html#ga4c44c082ef2d2b9cf4ba3db8bcebd954
So even their example code you linked has this issue for you?
I can't find any obvious "gotchas" to watch out for, sorry I'm not sure. Maybe someone else can help.
Topic archived. No new replies allowed.