Implementation/myPWM.c
void PWM_pinmap(PWM_t *pwm){
   if (pwm->port == GPIOA && (pwm->pin == 8)) {
      pwm->timer = TIM1;
      pwm->ch = 1;
   }
   else if (pwm->port == GPIOA && (pwm->pin == 9)) {
      pwm->timer = TIM1;
      pwm->ch = 2;
   }
   else if (pwm->port == GPIOA && (pwm->pin == 10)) {
      pwm->timer = TIM1;
      pwm->ch = 3;
   }
   else if (pwm->port == GPIOA && (pwm->pin == 11)) {
      pwm->timer = TIM1;
      pwm->ch = 4;
   }
   else if (pwm -> port == GPIOA && (pwm ->pin == 5 || pwm ->pin == 0 || pwm ->pin == 15)){   
      pwm -> timer = TIM2;
      pwm -> ch = 1;
   }
   else if   ((pwm -> port == GPIOA && pwm->pin == 1)||(pwm -> port == GPIOB && pwm->pin == 3)){
      pwm -> timer = TIM2;
      pwm -> ch = 2;
   }
   else if   (pwm -> port == GPIOB && pwm->pin == 10){
      pwm -> timer = TIM2;
      pwm -> ch = 3;
   }
   else if   ((pwm -> port == GPIOA && pwm->pin == 6)||(pwm -> port == GPIOB && pwm->pin == 4)||(pwm -> port == GPIOC && pwm->pin == 6)){
      pwm -> timer = TIM3;
      pwm -> ch = 1;
   }
   else if   ((pwm -> port == GPIOB && pwm->pin == 5)||(pwm -> port == GPIOC && pwm->pin == 7)){
      pwm -> timer = TIM3;
      pwm -> ch = 2;
   }
   else if   (pwm -> port == GPIOC && pwm->pin == 8){
      pwm -> timer = TIM3;
      pwm -> ch = 3;
   }
   else if   (pwm -> port == GPIOC && pwm->pin == 9){
      pwm -> timer = TIM3;
      pwm -> ch = 4;
   }
   else if (pwm->port == GPIOB && pwm->pin == 6) {
      pwm->timer = TIM4;
      pwm->ch = 1;
   }
   else if (pwm->port == GPIOB && pwm->pin == 7) {
      pwm->timer = TIM4;
      pwm->ch = 2;
   }
   else if (pwm->port == GPIOB && pwm->pin == 8) {
      pwm->timer = TIM4;
      pwm->ch = 3;
   }
   else if (pwm->port == GPIOB && pwm->pin == 9) {
      pwm->timer = TIM4;
      pwm->ch = 4;
   }
}
// connect proper pwm pin with the timer and channels

connect proper pwm pin with the timer and channels
connect proper pwm pin with the timer and channels
void PWM_pinmap(PWM_t *pwm){
   if (pwm->port == GPIOA && (pwm->pin == 8)) {
      pwm->timer = TIM1;
      pwm->ch = 1;
   }
   else if (pwm->port == GPIOA && (pwm->pin == 9)) {
      pwm->timer = TIM1;
      pwm->ch = 2;
   }
   else if (pwm->port == GPIOA && (pwm->pin == 10)) {
      pwm->timer = TIM1;
      pwm->ch = 3;
   }
   else if (pwm->port == GPIOA && (pwm->pin == 11)) {
      pwm->timer = TIM1;
      pwm->ch = 4;
   }
   else if (pwm -> port == GPIOA && (pwm ->pin == 5 || pwm ->pin == 0 || pwm ->pin == 15)){   
      pwm -> timer = TIM2;
      pwm -> ch = 1;
   }
   else if   ((pwm -> port == GPIOA && pwm->pin == 1)||(pwm -> port == GPIOB && pwm->pin == 3)){
      pwm -> timer = TIM2;
      pwm -> ch = 2;
   }
   else if   (pwm -> port == GPIOB && pwm->pin == 10){
      pwm -> timer = TIM2;
      pwm -> ch = 3;
   }
   else if   ((pwm -> port == GPIOA && pwm->pin == 6)||(pwm -> port == GPIOB && pwm->pin == 4)||(pwm -> port == GPIOC && pwm->pin == 6)){
      pwm -> timer = TIM3;
      pwm -> ch = 1;
   }
   else if   ((pwm -> port == GPIOB && pwm->pin == 5)||(pwm -> port == GPIOC && pwm->pin == 7)){
      pwm -> timer = TIM3;
      pwm -> ch = 2;
   }
   else if   (pwm -> port == GPIOC && pwm->pin == 8){
      pwm -> timer = TIM3;
      pwm -> ch = 3;
   }
   else if   (pwm -> port == GPIOC && pwm->pin == 9){
      pwm -> timer = TIM3;
      pwm -> ch = 4;
   }
   else if (pwm->port == GPIOB && pwm->pin == 6) {
      pwm->timer = TIM4;
      pwm->ch = 1;
   }
   else if (pwm->port == GPIOB && pwm->pin == 7) {
      pwm->timer = TIM4;
      pwm->ch = 2;
   }
   else if (pwm->port == GPIOB && pwm->pin == 8) {
      pwm->timer = TIM4;
      pwm->ch = 3;
   }
   else if (pwm->port == GPIOB && pwm->pin == 9) {
      pwm->timer = TIM4;
      pwm->ch = 4;
   }
}
void PWM_pinmap ( PWM_t * pwm ) { if ( pwm -> port == GPIOA && ( pwm -> pin == 8 ) ) { pwm -> timer = TIM1 ; pwm -> ch = 1 ; } else if ( pwm -> port == GPIOA && ( pwm -> pin == 9 ) ) { pwm -> timer = TIM1 ; pwm -> ch = 2 ; } else if ( pwm -> port == GPIOA && ( pwm -> pin == 10 ) ) { pwm -> timer = TIM1 ; pwm -> ch = 3 ; } else if ( pwm -> port == GPIOA && ( pwm -> pin == 11 ) ) { pwm -> timer = TIM1 ; pwm -> ch = 4 ; } else if ( pwm -> port == GPIOA && ( pwm -> pin == 5 || pwm -> pin == 0 || pwm -> pin == 15 ) ) { pwm -> timer = TIM2 ; pwm -> ch = 1 ; } else if ( ( pwm -> port == GPIOA && pwm -> pin == 1 ) || ( pwm -> port == GPIOB && pwm -> pin == 3 ) ) { pwm -> timer = TIM2 ; pwm -> ch = 2 ; } else if ( pwm -> port == GPIOB && pwm -> pin == 10 ) { pwm -> timer = TIM2 ; pwm -> ch = 3 ; } else if ( ( pwm -> port == GPIOA && pwm -> pin == 6 ) || ( pwm -> port == GPIOB && pwm -> pin == 4 ) || ( pwm -> port == GPIOC && pwm -> pin == 6 ) ) { pwm -> timer = TIM3 ; pwm -> ch = 1 ; } else if ( ( pwm -> port == GPIOB && pwm -> pin == 5 ) || ( pwm -> port == GPIOC && pwm -> pin == 7 ) ) { pwm -> timer = TIM3 ; pwm -> ch = 2 ; } else if ( pwm -> port == GPIOC && pwm -> pin == 8 ) { pwm -> timer = TIM3 ; pwm -> ch = 3 ; } else if ( pwm -> port == GPIOC && pwm -> pin == 9 ) { pwm -> timer = TIM3 ; pwm -> ch = 4 ; } else if ( pwm -> port == GPIOB && pwm -> pin == 6 ) { pwm -> timer = TIM4 ; pwm -> ch = 1 ; } else if ( pwm -> port == GPIOB && pwm -> pin == 7 ) { pwm -> timer = TIM4 ; pwm -> ch = 2 ; } else if ( pwm -> port == GPIOB && pwm -> pin == 8 ) { pwm -> timer = TIM4 ; pwm -> ch = 3 ; } else if ( pwm -> port == GPIOB && pwm -> pin == 9 ) { pwm -> timer = TIM4 ; pwm -> ch = 4 ; } }
connect proper pwm pin with the timer and channels
connect proper pwm pin with the timer and channels