psoc5lp passing objects into functions, no datatypes

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I have done a lot of programming with the cypress fx3 and everything was created with datatypes and objects that could be passed around.  I can't seem to find pass objects around with the psoc5lp.  for example

   

void set_divider(clock_t clock, uint32_t val) {

   

clock.set_divider(val);

   

}

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you #include the right libraries you may use types like uint32_t. I am not quite sure where it is defined, might be cytypes.h. looks like a bit of searchwork which reveiled inttypes.h

   

 

   

Bob

0 Likes
Anonymous
Not applicable

My my question is not about integer datatypes but more so objects. I cant seem to pass things like a clock or pwm into functions.  I just have functions for objects like pwm_1_start() or pwm_2_start().  the only way i can think of to make a function to start them via number would be be

   

function change_pwm(int which_pwm) {

   

 

   

 

   

if( which_pwm == 1)

   

     pwm_1_start() 

   

elseif( which_pwm == 2) 

   

     pwm_2_start()    

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

We are here (still) in the world of C, not C++. The components are not objects in the sense C++ understands that.

   

So what comes near  to what you want can be arranged with pointers to functions.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Thru use of function pointers ?

   

 

   

    

   

          

   

http://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work

   

http://denniskubes.com/2013/03/22/basics-of-function-pointers-in-c/

   

 

   

   

 

   

Regards, Dana.

0 Likes