Best way to call API's with only a different number?

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

cross mob
Anonymous
Not applicable

How is the best way to call API's with only a different number? Example:

   

        PWM1_Start();
        PWM2_Start();
         ......
        PWM12_Start();
   
OR

   

        PWM1_Stop();
        PWM2_Stop();
        .....
        PWM12_Stop();
     

   

like:

   

        for(i=1;i<=12;i++) {

   

                PWM_Stop();

   

         }

   

Regards,

   

Michael

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

Use an array of pointers to functions which you assign the addresses of the needed _Start() and _Stop() functions to. In the program you can use an index into the array to call the respective API. See more here:

   

 

   

Bob

0 Likes