[hr]
Description:
Porting some libraries from Arduino to XMOS and it became a hell rewrite all libraries, that I need from Arduino to XC.
[hr]
Solution 1: Write wrapper for xc calls
#p11787]combining XC and C++
#p4518] C++ interworking
Idea of such solution goes in such way - create simple header files with some silly functions, like:
Code: Select all
#ifdef __cplusplus
extern "C" {
#endif
void write_byte_to_port(unsigned int port, unsigned char value);
unsigned char read_byte_from_port(unsigned int port);
#ifdef __cplusplus
}
#endif
Code: Select all
void write_byte_to_port(port port_addr, unsigned char value)
{
port <: value;
}
unsigned char read_byte_from_port(unsigned int port_addr)
{
unsigned char byte;
port :> byte;
return byte;
}
- impossible to call from cpp some xc dialect functions - par
- impossible to define timers from cpp code
- impossible to define ports from cpp code
- every cpp code should call wrapped function
Solution 2: Write all code on C++
It is much better and easly way will be to write all code on C++. But to write it, I don't know how to:
- Define ports in C++ code
- Define timers in C++ code
- Chan / Channed types
- Read/Write from ports
- Call some specific XC functions, like configure_port, etc.
It will be cool, if someone will help to write XC "hello world" on C++