Function pointers are not supported in the .c file. I did a test in /module_i2c_shared/src/i2c_shared.c of the project sw_usb_audio-[sw]_6.15.2 and found that the pointer function cannot be used. The error reported when compiling app_usb_aud_xk_216_mc is as follows:
/home/username/workspace-xmos1/module_usb_audio/main.xc:(.dp.data.4+0x4): Error: Meta information ("i2c_shared_master_init.nstackwords") for function "i2c_shared_master_init" cannot be determined.
/home/username/workspace-xmos1/module_usb_audio/main.xc:(.dp.data.4+0x4): Error: lower bound could not be calculated (function is recursive?).
How to solve this problem?
The test code is:
typedef void (*func_ptr)(void);
func_ptr fPtr;
void* get_func_pointer()
{
return (void*)fPtr;
}
void call_func_pointer(void *f)
{
((func_ptr)f)();
}
void i2c_shared_master_init(REFERENCE_PARAM(struct r_i2c, i2cPorts))
{
//test code
void *x = get_func_pointer();
call_func_pointer(x);
//ori code
...
}
Function pointers are not supported in the .c file. Topic is solved
-
- Member++
- Posts: 17
- Joined: Mon Nov 13, 2017 9:53 am
-
- XCore Addict
- Posts: 246
- Joined: Mon Jan 08, 2018 4:14 pm
the concept for a multi task / multicore program for xmos is that the compiler (linker) needs to know the stack size of each task. This is calculated by summing the stack size needed for each function called.
you should solve this with the statement
#pragma stackfunction 1000
just replace 1000 by the number of 32bits words used by your function for its local variables addressed by the stack pointer SP.
This has to be written in the line just above the function "i2c_shared_master_init"
I m using this with the XCScheduler library shared on this site here :
https://www.xcore.com/viewtopic.php?f=21&t=7272
you should solve this with the statement
#pragma stackfunction 1000
just replace 1000 by the number of 32bits words used by your function for its local variables addressed by the stack pointer SP.
This has to be written in the line just above the function "i2c_shared_master_init"
I m using this with the XCScheduler library shared on this site here :
https://www.xcore.com/viewtopic.php?f=21&t=7272
-
- Member++
- Posts: 17
- Joined: Mon Nov 13, 2017 9:53 am
This problem has been solved, thank you very much.