Technical questions regarding the XTC tools and programming with XMOS.
Posts: 12
Joined: Wed Aug 03, 2016 11:59 pm


Post by fas »

We are trying to use the i2c code from the USB audio projects. In file i2c-sp.xc is:
#ifdef __XS2A__

What does this definition mean and where would it be defined? Do we want to use it for an XU216? I searched everywhere for the string and could not find it.
XCore Addict
Posts: 158
Joined: Thu Mar 20, 2014 8:04 am

Post by srinie »

If your target platform is using XS2 devices, then this macro check becomes true (expanded in xml file I believe!? during build time).

In specific i2c_master_single_port.xc file, this check "__XS2A__" facilitates the following:
  • Since XS2 devices support dual fetch and execute, I presume its possible to sample the Clock line at the same bit period, where as with XS1 devices, this might not be possible
  • Hence XS2 device implements more feature in I2C lib (clock stretching) in comparison with previous version devices
@XMOS, pls correct me if my understanding is incorrect.

XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Post by robertxmos »

Hi Fas,

This is one of several pre-defined macros created by the tools (XC & C compilers and assembler preprocessor).
xcc1llvm -dM -E test.xc
xcc2clang -dM -E test.c
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Post by robertxmos »

I should have added, the tools decide what predefines to define based on the XN file or the target or architecture (etc) you pass into them directly (as above) or indirectly (via xcc front end) viz:

xcc -march=xs2a -dM -E test.c
Respected Member
Posts: 347
Joined: Wed Jan 27, 2016 5:21 pm

Post by henk »

For background - xCORE200 devices implement the XS2 architecture; similar to XS1 but with dual issue and a few extra instructions. The compiler needs to know; and some libraries depend on the extended instructions.
Active Member
Posts: 36
Joined: Sat May 09, 2020 4:20 pm

Post by fabra »

Is "XS2A" equivalent with "XS2"?
User avatar
XCore Expert
Posts: 1006
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Yes, essentially, there never was an XS2B and the latest architecture is XS3A, so never likely to be one.

(fun fact, there was an XS1A and XS1B)
Technical Director @ XMOS. Opinions expressed are my own.