SPI CPP wrapper problems.
Posted: Fri Oct 18, 2019 4:14 pm
Hi first post here so please be gentle
I have been pulling my hair out for a couple of days with this problem.
I have very simple cpp wrapper for the SPI driver which is working well in some cases.
I'm using: -
#define SPI_USE_WAIT TRUE
#define SPI_USE_MUTUAL_EXCLUSION TRUE
As I want to share the SPI between different drivers. I have tested with a couple of threads and it is working ok.
The problem is that now I'm extending the basic class I'm running into problems which I have traced back to local variables.
If I use a local variable as in the testFail method than the code crashes with unhandled exception after entering (void) osalThreadSuspendS(&spip->thread); from spiExchange. Trying to debug this is not working for me.
If I use a static as in testPass then it is ok.
I have attached a stripped down piece of code that exhibits this problem, now maybe I'm doing something wrong with C++ but I'm stumped, hope fully someone can see the obvious mistake.
I'm from a C background, just testing the water out with C++, I'm assuming the local variables would go on the stack i.e. in the THD_WORKING_AREA for the thread.
Sorry compiled and tested on a STM32F446RE-Nucleo64 board
Cheers
Andy
I have been pulling my hair out for a couple of days with this problem.
I have very simple cpp wrapper for the SPI driver which is working well in some cases.
I'm using: -
#define SPI_USE_WAIT TRUE
#define SPI_USE_MUTUAL_EXCLUSION TRUE
As I want to share the SPI between different drivers. I have tested with a couple of threads and it is working ok.
The problem is that now I'm extending the basic class I'm running into problems which I have traced back to local variables.
If I use a local variable as in the testFail method than the code crashes with unhandled exception after entering (void) osalThreadSuspendS(&spip->thread); from spiExchange. Trying to debug this is not working for me.
If I use a static as in testPass then it is ok.
I have attached a stripped down piece of code that exhibits this problem, now maybe I'm doing something wrong with C++ but I'm stumped, hope fully someone can see the obvious mistake.
I'm from a C background, just testing the water out with C++, I'm assuming the local variables would go on the stack i.e. in the THD_WORKING_AREA for the thread.
Sorry compiled and tested on a STM32F446RE-Nucleo64 board
Cheers
Andy