I'm a bit confused if I can use #define to point to a function. I have a codec / DSP that automatically creates code pages as follows:
SIGMA_WRITE_REGISTER(address, data, length); SIGMA_WRITE_REGISTER(address, data, length); SIGMA_WRITE_REGISTER(address, data, length); ....
Then in another .h file they do this:
#define SIGMA_WRITE_REGISTER( address, data, length ) { }
That nothing helps in writing registers. This is great, although I wrote code for my microuser to write registers in I2C, and it seems to work. Now I donβt want to just paste this code into the above definition and instantiate it 1000 times. I was hoping I could just use the definition as an alias for my function?
Sort of:
#define SIGMA_WRITE_REGISTER(address, data, length) { my_i2_c_func(address, data, length)}
I tried something like this and it compiled, but I'm not sure if it works. Is this the right thing, or am I barking the wrong tree?
source share