mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c
- Revision:
- 227:7bd0639b8911
- Parent:
- 82:0b31dbcd4769
- Child:
- 264:91fcbf887208
diff -r b062af740e40 -r 7bd0639b8911 targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c --- a/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c Wed Jun 11 09:45:09 2014 +0100 +++ b/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c Wed Jun 11 16:00:09 2014 +0100 @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "mbed_assert.h" #include "pwmout_api.h" #include "cmsis.h" #include "pinmap.h" -#include "error.h" #include "clk_freqs.h" #include "PeripheralPins.h" @@ -26,9 +26,8 @@ void pwmout_init(pwmout_t* obj, PinName pin) { // determine the channel PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); - if (pwm == (PWMName)NC) - error("PwmOut pin mapping failed"); - + MBED_ASSERT(pwm != (PWMName)NC); + uint32_t clkdiv = 0; float clkval; if (mcgpllfll_frequency()) { @@ -37,11 +36,11 @@ } else { SIM->SOPT2 |= SIM_SOPT2_TPMSRC(2); // Clock source: ExtOsc clkval = extosc_frequency() / 1000000.0f; - } + } while (clkval > 1) { clkdiv++; - clkval /= 2.0; + clkval /= 2.0; if (clkdiv == 7) break; }