Hi
In your case I would pass pointers to the TPM and port instances, plus the port B bit value.
void timerGeneral(TPM *ptrTPM, PT *ptrPT, unsigned long ulLED, volatile int* iterator, int* dtyCycMrkr, int* flag, float seconds, float dutyCycle){
if(*flag){
*iterator *= seconds; *flag = 0;
*dtyCycMrkr = dutyCycle * *iterator;
}
if(ptrTPM->SC & 0x80){
if(*iterator == 0 || *iterator == *dtyCycMrkr){
ptrPT->PTOR |= ulLED;
if(*iterator == 0)*iterator = seconds * 650;
}
ptrTPM->SC |= 0x80;
*iterator -= 1;
}
}
which gives your main loop of:
#define RED_LED 0x40000
#define BLUE_LED 0x02
define GREEN_LED 0x80000
while(1){
timerRed (TPM0, PTB, RED_LED, rItrPtr, rDtyCycMrkrPtr, rFlgPtr, 3.0, 0.8);
timerGreen(TPM1, PTB, GREEN_LED, gItrPtr, gDtyCycMrkrPtr, gFlgPtr, 0.5, 0.2);
timerBlue (TPM2, PTD, BLUE_LED, bItrPtr, bDtyCycMrkrPtr, bFlgPtr, 4.0, 0.3);
}
You just need to find out what the name of TPM and PD structs actually are in your environment.
Regards
Mark
Complete Kinetis solutions for professional needs, training and support: http://www.utasker.com/kinetis.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html
Open Source version at https://github.com/uTasker/uTasker-Kinetis
https://community.nxp.com/thread/512558