Library that allows for higher resolution and speed than standard mbed PWM library using same syntax (drop-in replacement).

Dependents:   PwmOscillator FastStepDriver TLC5940 CameraTest ... more

Issue: Pin def for NUCLEO_F303K8 and NUCLEO_F446RE (Closed: Accepted)

// Below is code for pin def NUCLEO_F303K8 and NUCLEO_F446RE
// I have only tested it on pin D7 : But hopefully have all pins correct.
// Please, add the code below to your library (  or similar code who support the two boards).


#ifdef TARGET_NUCLEO_F303K8 
__IO uint32_t* getChannel(TIM_TypeDef* pwm, PinName pin) {
    switch (pin) {
         // Channels 1
        case PA_12: case PA_8: case PB_5: case PB_4: case PA_2: case PA_7: case PA_6: 
        // Channels 1N
        case PB_7: case PB_6:
            return &pwm->CCR1;
            
        // Channels 2
        case PA_9: case PA_4: case PA_3:
        // Channels 2N
        case PB_0:
            return &pwm->CCR2;
            
        // Channels 3
        case PA_10: 
        // Channels 3N
        case PB_1: case PF_0: 
            return &pwm->CCR3;
 
        // Channels 4
        case PA_11: 
        // Channels 4N
        
            return &pwm->CCR4;
    }
    return NULL;
}
#endif


#ifdef TARGET_NUCLEO_F446RE
__IO uint32_t* getChannel(TIM_TypeDef* pwm, PinName pin) {
    switch (pin) {
        // Channels 1 : PWMx/1
        case PA_0: case PA_5: case PA_6: case PB_6: case PA_8: case PB_4:
        // Channels 1N
        case PA_7: 
            return &pwm->CCR1;
        
        // Channels 2 : PWMx/2
        case PA_1: case PC_7: case PA_9: case PB_5: case PB_3:
        // Channels 2N
        case PB_0:
            return &pwm->CCR2;
            
        // Channels 3 : PWMx/3
        case PB_8: case PB_10: case PA_10: case PA_2:   
            return &pwm->CCR3;
 
        // Channels 4 : PWMx/4
        case PB_9: case PA_3: 
            return &pwm->CCR4;
    }
    return NULL;
}
#endif

1 comment:

31 Jan 2016

You can also use pull requests for merging your code into it. Although they are broken, so this works better :). Only difference is then I would still be able to get it from a fork you then have to publish, so in the history it shows your name as the one who added it. But I included this, so it should work now :).