Page 2 of 2

Re: Using startKIT ADC and Flash in the same application

Posted: Sun Aug 17, 2014 8:53 am
by gkrusi
alfanick, would you be ready to post your changed code here?

Thank you,
Gregor Krušič

Re: Using startKIT ADC and Flash in the same application

Posted: Mon Jun 19, 2017 8:59 am
by robertxmos
As resource in your code are implemented as opaque pointers (think void*), I would discourage the use of pointers when passing them around.

Resources should be passed by value (the opaque resource handle).

N.B. 'chan' and 'interface' are declarations that give you an implicit pair of handles of connected-resouce-ends for passing by value viz: 'interface client', 'interface server' 'chanend'.
They should be viewed as handy ways to declare paired resources but not resources themselves!
(The syntax is not nice as there implicit coercion going on - sorry)

If you are passing resources by value in a way the compiler can't check you are safe (e.g via global variables), use 'unsafe' viz:
unsafe chanend gc;
unsafe void foo(chanend c) { gc = c; } // copy opaque resource handle.

Only use pointers if you really want the address of a resource's handle and make sure it does not go out of scope and leave you with a dangling pointer viz:
chanend * unsafe pc;
unsafe void foo(chanend c) { pc = &c; } // oops, variable 'c' has gone!