From 889952790fba7f8abe24cd8435cfa1303e520376 Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Wed, 8 Jan 2014 10:58:51 +0100 Subject: [PATCH] PWM - mux addition --- .../TARGET_K20D5M/pwmout_api.c | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c index 899c75ca14..d925c8730c 100644 --- a/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c +++ b/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c @@ -21,17 +21,30 @@ static const PinMap PinMap_PWM[] = { // LEDs - {LED_RED , PWM_3 , 3}, // PTC3, FTM0 CH2 - {LED_GREEN, PWM_5, 3}, // PTD4, FTM0 CH4 + {LED_RED , PWM_3 , 4}, // PTC3, FTM0 CH2 + {LED_GREEN, PWM_5, 4}, // PTD4, FTM0 CH4 {LED_BLUE , PWM_8 , 3}, // PTA2, FTM0 CH7 // Arduino digital pinout - {D3, PWM_5 , 3}, // PTD4, FTM0 CH4 + {D3, PWM_5 , 4}, // PTD4, FTM0 CH4 {D5, PWM_7 , 3}, // PTA1, FTM0 CH6 - {D6, PWM_3 , 3}, // PTC3, FTM0 CH2 - {D9, PWM_8 , 4}, // PTD2, FTM0 CH7 + {D6, PWM_3 , 4}, // PTC3, FTM0 CH2 + {D9, PWM_6 , 4}, // PTD5, FTM0 CH6 {D10, PWM_2 , 4}, // PTC2, FTM0 CH1 + {PTA0, PWM_6 , 3}, // PTA0, FTM0 CH5 + {PTA3, PWM_0 , 3}, // PTA3, FTM0 CH0 + {PTA4, PWM_1 , 3}, // PTA4, FTM0 CH1 + {PTA5, PWM_3 , 3}, // PTA5, FTM0 CH2 + {PTA12, PWM_9 , 3}, // PTA12, FTM1 CH0 + {PTA13, PWM_10, 3}, // PTA13, FTM1 CH1 + {PTB0, PWM_9 , 3}, // PTB0, FTM1 CH0 + {PTB1, PWM_10, 3}, // PTB1, FTM1 CH1 + {PTC1, PWM_0 , 4}, // PTC1, FTM0 CH0 + {PTD4, PWM_4 , 4}, // PTD4, FTM0 CH3 + {PTD6, PWM_7 , 4}, // PTD6, FTM0 CH6 + {PTD7, PWM_8 , 4}, // PTD7, FTM0 CH7 + {NC , NC , 0} }; @@ -51,7 +64,6 @@ void pwmout_init(pwmout_t* obj, PinName pin) { SIM->SCGC6 |= 1 << (SIM_SCGC6_FTM0_SHIFT + ftm_n); FTM_Type *ftm = (FTM_Type *)(FTM0_BASE + 0x1000 * ftm_n); - ftm->MODE |= FTM_MODE_WPDIS_MASK; //write protection disabled ftm->CONF |= FTM_CONF_BDMMODE(3); ftm->SC = FTM_SC_CLKS(1) | FTM_SC_PS(6); // (48)MHz / 64 = (0.75)MHz ftm->CONTROLS[ch_n].CnSC = (FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK); /* No Interrupts; High True pulses on Edge Aligned PWM */ @@ -59,7 +71,6 @@ void pwmout_init(pwmout_t* obj, PinName pin) { obj->CnV = &ftm->CONTROLS[ch_n].CnV; obj->MOD = &ftm->MOD; obj->CNT = &ftm->CNT; - obj->PWMLOAD = &ftm->PWMLOAD; // default to 20ms: standard for servos, and fine for e.g. brightness control pwmout_period_ms(obj, 20); @@ -79,8 +90,6 @@ void pwmout_write(pwmout_t* obj, float value) { } *obj->CnV = (uint32_t)((float)(*obj->MOD) * value); - *obj->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; - *obj->CNT = 0; } float pwmout_read(pwmout_t* obj) { @@ -113,5 +122,4 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) { void pwmout_pulsewidth_us(pwmout_t* obj, int us) { *obj->CnV = PWM_CLOCK_MHZ * us; - *obj->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; }