combining XC and C++

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
TjBordelon
Active Member
Posts: 39
Joined: Mon Jul 29, 2013 4:41 pm

Re: combining XC and C++

Postby TjBordelon » Sun Aug 04, 2013 9:02 pm

This one is happening to me! I'm going to start a new thread, but in my case I'm calling into assembly from C. It only happens when you have >1 thread. Not sure what to do about it. The #pragma fix doesn't seem to work.
User avatar
myndideal
Active Member
Posts: 58
Joined: Thu May 05, 2011 10:00 pm
Location: Budapest
Contact:

Postby myndideal » Fri Jul 10, 2015 1:12 pm

Hi TjBordelon,
in asm you have to define functionname.nstackwords and maxthreads
linker directive. Better to see in document. Page 5, paragraph 5.3 Resource usage
http://www.xmos.com/download/public/Assembler-Programming-for-the-XMOS-ABI(1.0).pdf
User avatar
myndideal
Active Member
Posts: 58
Joined: Thu May 05, 2011 10:00 pm
Location: Budapest
Contact:

Postby myndideal » Fri Jul 10, 2015 3:30 pm

Hi ,
Iam just wondering, if is it any runtime check for the calling stack size?
I mean, ok we could specify / override the size with the #pragma stackwords n.
But this number may less than the real requirements.
User avatar
aclassifier
Respected Member
Posts: 319
Joined: Wed Apr 25, 2012 8:52 pm
Contact:

Postby aclassifier » Sat Jan 20, 2018 9:01 pm

I have followed yzoer's example and made a global.h

I have a cpp file with code, and a .h file something(?) like this. I am only making some empty code, to try to get som grasp of it, so most is removed from the RadioHead code:

Code: Select all

class RHGenericSPI;
class RHSPIDriver : public RHGenericDriver
{
public:
    RHSPIDriver(uint8_t slaveSelectPin, RHGenericSPI& spi);
    bool init();
    void spiUsingInterrupt(uint8_t interruptNumber);
};
class RH_RF69 : public RHSPIDriver
{
public:
    RH_RF69(uint8_t slaveSelectPin, uint8_t interruptPin, RHGenericSPI& spi);
    // ...
};

This .h file is not included in my .xc file (it contains C++ syntax, so I guess it shouldn't). Now I am referring this in the .xc file tile this:

Code: Select all

EXTERNAL void RHGenericSPI();
EXTERNAL void RH_RF69 (uint8_t slaveSelectPin, uint8_t interruptPin, RHGenericSPI& spi); // Maybe REFERENCE_PARAM(type,value) in last param here?

But I constantly get errors, no matter how much I tweak it:

Code: Select all

../src/__arduino_on_xmos_test.xc:34:70: error: parse error before "RHGenericSPI"
EXTERNAL void RH_RF69 (uint8_t slaveSelectPin, uint8_t interruptPin, RHGenericSPI& spi); // Maybe REFERENCE_PARAM(type,value) in last param here?
                                                                     ^

Have I supplied enough code (and is the .h file correct)?

I guess the question is as simple as how do I specify a pointer to a class from xc? And later, to an instantiated object? Or are there other ways? I haven't found this documented(!?)

PS. I am trying to port some code for a radio board, see Porting to XMOS / XC - disclaimer: no money, no gifts, no ads, just fun and expenses

Who is online

Users browsing this forum: bear118 and 136 guests