Question about FlexGUI/FastSpin _ Cordic Issue _

I try to write a cordic example in C with FlexGui (running with wine under Linux)
I want use the _rotxy - Function.
But i get a compiler error : error: unknown identifier _rotxy used in function call
Maybe not implemented yet ?

Then i make a quick and row workaround with own function and inline asm.
The list file and a test with spinsim looks good, i get the expected values.

But how can i use the functions with FastSpin ?
thank's for help


  • Yes, unfortunately _rotxy isn't implemented yet in fastspin's C libraries. It looks like your work-around is working though?

    I'll try to get some of those missing propeller2.h functions implemented before the next release.

  • Yes, I thought it was not implemented yet.
    It is a very helpful tool.
    The communication about structs I find a good solution.

  • works also with fastspin
    void my_rotxy (cartesian_t * input, cartesian_t * output, uint32_t angle)
    int32_t x = input->x;
    int32_t y = input->y;
    __asm {
    	setq	y		
    	qrotate	x,angle		
    	getqx	x		
    	getqy	y		
    output->x = x;
    output->y = y;

    function call example is
    cartesian_t rectangle;
    cartesian_t rot;
    rectangle.x = 100;
    rectangle.y = 100;

  • the inline assembler works very well.
    //Example:  Multiplication of 2 complex numbers
    //input:  z1 = real1,imag1
    //        z2 = real2,imag2
    //calc:   z3 = z1 * z2
    //output: real3,imag3
    //testcase: z2 = conj(z1)
    //expected: z3 is pure real. imag3 = 0. 
    //how to compile
    //wine ../../fastspin/fastspin.exe  -I ../../fastspin/include -l -2b --code=cog cplx_mult_c.c
    #include <propeller2.h>
    void cplx_mult (int32_t real1,   int32_t imag1,
    		          int32_t real2,   int32_t imag2,
    			  int32_t * real3, int32_t * imag3)
    int32_t _abs1;
    int32_t _arg1;
    int32_t _abs2;
    int32_t _arg2;
    int32_t _abs3;
    int32_t _arg3;
    int32_t result_lo = 0;
    int32_t result_hi = 0;
    __asm {
    	qvector	real1,imag1		//z1 to polar	
    	getqx	_abs1
    	getqy	_arg1
    	qvector	real2,imag2		//z2 to polar	
    	getqx	_abs2
    	getqy	_arg2
    	qmul	_abs1,_abs2		//multiply the abs
    	getqx	result_lo
    	getqy	result_hi
    	mov	_abs3,result_lo
    	add	_arg1,_arg2			//add the phase	
    	mov	_arg3,_arg1
    	qrotate	_abs3,_arg3		//z3 to cartesian
    	getqx	result_lo
    	getqy	result_hi	
    *real3 = result_lo;
    *imag3 = result_hi;
    void main(void)
    int32_t r1 = 100;
    int32_t i1 = 100;
    int32_t r2 = 100;
    int32_t i2 = -100;
    int32_t r;
    int32_t i;
    cplx_mult (r1,i1,r2,i2,&r,&i);//ok
    cplx_mult (100,100,100,-100,&r,&i);//ok
Sign In or Register to comment.