mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pwmout_api.c@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 227:7bd0639b8911
test with CLOCK_SETUP = 0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 84:f54042cbc282 | 1 | /* mbed Microcontroller Library |
mbed_official | 84:f54042cbc282 | 2 | ******************************************************************************* |
mbed_official | 84:f54042cbc282 | 3 | * Copyright (c) 2014, STMicroelectronics |
mbed_official | 84:f54042cbc282 | 4 | * All rights reserved. |
mbed_official | 84:f54042cbc282 | 5 | * |
mbed_official | 84:f54042cbc282 | 6 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 84:f54042cbc282 | 7 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 84:f54042cbc282 | 8 | * |
mbed_official | 84:f54042cbc282 | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 84:f54042cbc282 | 10 | * this list of conditions and the following disclaimer. |
mbed_official | 84:f54042cbc282 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 84:f54042cbc282 | 12 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 84:f54042cbc282 | 13 | * and/or other materials provided with the distribution. |
mbed_official | 84:f54042cbc282 | 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 84:f54042cbc282 | 15 | * may be used to endorse or promote products derived from this software |
mbed_official | 84:f54042cbc282 | 16 | * without specific prior written permission. |
mbed_official | 84:f54042cbc282 | 17 | * |
mbed_official | 84:f54042cbc282 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 84:f54042cbc282 | 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 84:f54042cbc282 | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 84:f54042cbc282 | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 84:f54042cbc282 | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 84:f54042cbc282 | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 84:f54042cbc282 | 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 84:f54042cbc282 | 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 84:f54042cbc282 | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 84:f54042cbc282 | 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 84:f54042cbc282 | 28 | ******************************************************************************* |
mbed_official | 84:f54042cbc282 | 29 | */ |
mbed_official | 227:7bd0639b8911 | 30 | #include "mbed_assert.h" |
mbed_official | 84:f54042cbc282 | 31 | #include "pwmout_api.h" |
mbed_official | 84:f54042cbc282 | 32 | |
mbed_official | 166:cb4253f91ada | 33 | #if DEVICE_PWMOUT |
mbed_official | 166:cb4253f91ada | 34 | |
mbed_official | 84:f54042cbc282 | 35 | #include "cmsis.h" |
mbed_official | 84:f54042cbc282 | 36 | #include "pinmap.h" |
mbed_official | 84:f54042cbc282 | 37 | |
mbed_official | 164:90c6009cba07 | 38 | // TIM1 cannot be used because already used by the us_ticker |
mbed_official | 84:f54042cbc282 | 39 | static const PinMap PinMap_PWM[] = { |
mbed_official | 164:90c6009cba07 | 40 | {PA_4, TIM_14, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_4)}, // TIM14_CH1 |
mbed_official | 164:90c6009cba07 | 41 | {PA_6, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_1)}, // TIM3_CH1 |
mbed_official | 164:90c6009cba07 | 42 | // {PA_6, TIM_16, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_5)}, // TIM16_CH1 |
mbed_official | 187:3c46d8ef3e7f | 43 | {PA_7, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_1)}, // TIM3_CH2 |
mbed_official | 164:90c6009cba07 | 44 | // {PA_7, TIM_14, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_4)}, // TIM14_CH1 |
mbed_official | 164:90c6009cba07 | 45 | // {PA_7, TIM_17, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_5)}, // TIM17_CH1 |
mbed_official | 164:90c6009cba07 | 46 | {PB_0, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_1)}, // TIM3_CH3 |
mbed_official | 164:90c6009cba07 | 47 | {PB_1, TIM_14, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_0)}, // TIM14_CH1 |
mbed_official | 164:90c6009cba07 | 48 | // {PB_1, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_1)}, // TIM3_CH4 |
mbed_official | 164:90c6009cba07 | 49 | {PB_4, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_1)}, // TIM3_CH1 |
mbed_official | 164:90c6009cba07 | 50 | {PB_5, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_1)}, // TIM3_CH2 |
mbed_official | 164:90c6009cba07 | 51 | {PB_6, TIM_16, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_2)}, // TIM16_CH1N |
mbed_official | 164:90c6009cba07 | 52 | {PB_7, TIM_17, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_2)}, // TIM17_CH1N |
mbed_official | 164:90c6009cba07 | 53 | {PB_8, TIM_16, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_2)}, // TIM16_CH1 |
mbed_official | 164:90c6009cba07 | 54 | {PB_9, TIM_17, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_2)}, // TIM17_CH1 |
mbed_official | 164:90c6009cba07 | 55 | {PB_14, TIM_15, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_1)}, // TIM15_CH1 |
mbed_official | 164:90c6009cba07 | 56 | {PB_15, TIM_15, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_1)}, // TIM15_CH2 |
mbed_official | 164:90c6009cba07 | 57 | // {PB_15, TIM_15, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_3)}, // TIM15_CH1N |
mbed_official | 164:90c6009cba07 | 58 | {PC_6, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_0)}, // TIM3_CH1 |
mbed_official | 84:f54042cbc282 | 59 | {PC_7, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_0)}, // TIM3_CH2 |
mbed_official | 164:90c6009cba07 | 60 | {PC_8, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_0)}, // TIM3_CH3 |
mbed_official | 164:90c6009cba07 | 61 | {PC_9, TIM_3, STM_PIN_DATA(GPIO_Mode_AF, GPIO_OType_PP, GPIO_PuPd_NOPULL, GPIO_AF_0)}, // TIM3_CH4 |
mbed_official | 84:f54042cbc282 | 62 | {NC, NC, 0} |
mbed_official | 84:f54042cbc282 | 63 | }; |
mbed_official | 84:f54042cbc282 | 64 | |
mbed_official | 216:577900467c9e | 65 | void pwmout_init(pwmout_t* obj, PinName pin) { |
mbed_official | 84:f54042cbc282 | 66 | // Get the peripheral name from the pin and assign it to the object |
mbed_official | 84:f54042cbc282 | 67 | obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); |
mbed_official | 227:7bd0639b8911 | 68 | MBED_ASSERT(obj->pwm != (PWMName)NC); |
mbed_official | 216:577900467c9e | 69 | |
mbed_official | 84:f54042cbc282 | 70 | // Enable TIM clock |
mbed_official | 84:f54042cbc282 | 71 | if (obj->pwm == TIM_3) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); |
mbed_official | 84:f54042cbc282 | 72 | if (obj->pwm == TIM_14) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM14, ENABLE); |
mbed_official | 164:90c6009cba07 | 73 | if (obj->pwm == TIM_15) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM15, ENABLE); |
mbed_official | 84:f54042cbc282 | 74 | if (obj->pwm == TIM_16) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM16, ENABLE); |
mbed_official | 164:90c6009cba07 | 75 | if (obj->pwm == TIM_17) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM17, ENABLE); |
mbed_official | 84:f54042cbc282 | 76 | |
mbed_official | 84:f54042cbc282 | 77 | // Configure GPIO |
mbed_official | 84:f54042cbc282 | 78 | pinmap_pinout(pin, PinMap_PWM); |
mbed_official | 216:577900467c9e | 79 | |
mbed_official | 84:f54042cbc282 | 80 | obj->pin = pin; |
mbed_official | 84:f54042cbc282 | 81 | obj->period = 0; |
mbed_official | 84:f54042cbc282 | 82 | obj->pulse = 0; |
mbed_official | 216:577900467c9e | 83 | |
mbed_official | 84:f54042cbc282 | 84 | pwmout_period_us(obj, 20000); // 20 ms per default |
mbed_official | 84:f54042cbc282 | 85 | } |
mbed_official | 84:f54042cbc282 | 86 | |
mbed_official | 84:f54042cbc282 | 87 | void pwmout_free(pwmout_t* obj) { |
mbed_official | 216:577900467c9e | 88 | // Configure GPIOs |
mbed_official | 216:577900467c9e | 89 | pin_function(obj->pin, STM_PIN_DATA(GPIO_Mode_IN, 0, GPIO_PuPd_NOPULL, 0xFF)); |
mbed_official | 84:f54042cbc282 | 90 | } |
mbed_official | 84:f54042cbc282 | 91 | |
mbed_official | 84:f54042cbc282 | 92 | void pwmout_write(pwmout_t* obj, float value) { |
mbed_official | 84:f54042cbc282 | 93 | TIM_TypeDef *tim = (TIM_TypeDef *)(obj->pwm); |
mbed_official | 84:f54042cbc282 | 94 | TIM_OCInitTypeDef TIM_OCInitStructure; |
mbed_official | 216:577900467c9e | 95 | |
mbed_official | 84:f54042cbc282 | 96 | if (value < 0.0) { |
mbed_official | 84:f54042cbc282 | 97 | value = 0.0; |
mbed_official | 84:f54042cbc282 | 98 | } else if (value > 1.0) { |
mbed_official | 84:f54042cbc282 | 99 | value = 1.0; |
mbed_official | 84:f54042cbc282 | 100 | } |
mbed_official | 216:577900467c9e | 101 | |
mbed_official | 84:f54042cbc282 | 102 | obj->pulse = (uint32_t)((float)obj->period * value); |
mbed_official | 216:577900467c9e | 103 | |
mbed_official | 164:90c6009cba07 | 104 | // Configure channels |
mbed_official | 164:90c6009cba07 | 105 | TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; |
mbed_official | 164:90c6009cba07 | 106 | TIM_OCInitStructure.TIM_Pulse = obj->pulse; |
mbed_official | 164:90c6009cba07 | 107 | TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; |
mbed_official | 164:90c6009cba07 | 108 | TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCPolarity_Low; |
mbed_official | 164:90c6009cba07 | 109 | TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset; |
mbed_official | 164:90c6009cba07 | 110 | TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Reset; |
mbed_official | 84:f54042cbc282 | 111 | |
mbed_official | 164:90c6009cba07 | 112 | switch (obj->pin) { |
mbed_official | 164:90c6009cba07 | 113 | // Channels 1 |
mbed_official | 164:90c6009cba07 | 114 | case PA_4: |
mbed_official | 164:90c6009cba07 | 115 | case PA_6: |
mbed_official | 164:90c6009cba07 | 116 | case PB_1: |
mbed_official | 164:90c6009cba07 | 117 | case PB_4: |
mbed_official | 164:90c6009cba07 | 118 | case PB_8: |
mbed_official | 164:90c6009cba07 | 119 | case PB_9: |
mbed_official | 164:90c6009cba07 | 120 | case PB_14: |
mbed_official | 164:90c6009cba07 | 121 | case PC_6: |
mbed_official | 164:90c6009cba07 | 122 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; |
mbed_official | 164:90c6009cba07 | 123 | TIM_OC1PreloadConfig(tim, TIM_OCPreload_Enable); |
mbed_official | 164:90c6009cba07 | 124 | TIM_OC1Init(tim, &TIM_OCInitStructure); |
mbed_official | 164:90c6009cba07 | 125 | break; |
mbed_official | 164:90c6009cba07 | 126 | // Channels 1N |
mbed_official | 164:90c6009cba07 | 127 | case PB_6: |
mbed_official | 164:90c6009cba07 | 128 | case PB_7: |
mbed_official | 164:90c6009cba07 | 129 | TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; |
mbed_official | 164:90c6009cba07 | 130 | TIM_OC1PreloadConfig(tim, TIM_OCPreload_Enable); |
mbed_official | 164:90c6009cba07 | 131 | TIM_OC1Init(tim, &TIM_OCInitStructure); |
mbed_official | 164:90c6009cba07 | 132 | break; |
mbed_official | 164:90c6009cba07 | 133 | // Channels 2 |
mbed_official | 187:3c46d8ef3e7f | 134 | case PA_7: |
mbed_official | 164:90c6009cba07 | 135 | case PB_5: |
mbed_official | 164:90c6009cba07 | 136 | case PC_7: |
mbed_official | 164:90c6009cba07 | 137 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; |
mbed_official | 164:90c6009cba07 | 138 | TIM_OC2PreloadConfig(tim, TIM_OCPreload_Enable); |
mbed_official | 164:90c6009cba07 | 139 | TIM_OC2Init(tim, &TIM_OCInitStructure); |
mbed_official | 216:577900467c9e | 140 | break; |
mbed_official | 164:90c6009cba07 | 141 | // Channels 3 |
mbed_official | 164:90c6009cba07 | 142 | case PB_0: |
mbed_official | 164:90c6009cba07 | 143 | case PC_8: |
mbed_official | 164:90c6009cba07 | 144 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; |
mbed_official | 164:90c6009cba07 | 145 | TIM_OC3PreloadConfig(tim, TIM_OCPreload_Enable); |
mbed_official | 164:90c6009cba07 | 146 | TIM_OC3Init(tim, &TIM_OCInitStructure); |
mbed_official | 164:90c6009cba07 | 147 | break; |
mbed_official | 216:577900467c9e | 148 | // Channels 4 |
mbed_official | 164:90c6009cba07 | 149 | // case PB_1: |
mbed_official | 164:90c6009cba07 | 150 | case PC_9: |
mbed_official | 164:90c6009cba07 | 151 | TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; |
mbed_official | 164:90c6009cba07 | 152 | TIM_OC4PreloadConfig(tim, TIM_OCPreload_Enable); |
mbed_official | 164:90c6009cba07 | 153 | TIM_OC4Init(tim, &TIM_OCInitStructure); |
mbed_official | 164:90c6009cba07 | 154 | break; |
mbed_official | 164:90c6009cba07 | 155 | default: |
mbed_official | 216:577900467c9e | 156 | return; |
mbed_official | 216:577900467c9e | 157 | } |
mbed_official | 216:577900467c9e | 158 | |
mbed_official | 216:577900467c9e | 159 | TIM_CtrlPWMOutputs(tim, ENABLE); |
mbed_official | 216:577900467c9e | 160 | |
mbed_official | 84:f54042cbc282 | 161 | } |
mbed_official | 84:f54042cbc282 | 162 | |
mbed_official | 84:f54042cbc282 | 163 | float pwmout_read(pwmout_t* obj) { |
mbed_official | 84:f54042cbc282 | 164 | float value = 0; |
mbed_official | 84:f54042cbc282 | 165 | if (obj->period > 0) { |
mbed_official | 84:f54042cbc282 | 166 | value = (float)(obj->pulse) / (float)(obj->period); |
mbed_official | 84:f54042cbc282 | 167 | } |
mbed_official | 84:f54042cbc282 | 168 | return ((value > 1.0) ? (1.0) : (value)); |
mbed_official | 84:f54042cbc282 | 169 | } |
mbed_official | 84:f54042cbc282 | 170 | |
mbed_official | 84:f54042cbc282 | 171 | void pwmout_period(pwmout_t* obj, float seconds) { |
mbed_official | 84:f54042cbc282 | 172 | pwmout_period_us(obj, seconds * 1000000.0f); |
mbed_official | 84:f54042cbc282 | 173 | } |
mbed_official | 84:f54042cbc282 | 174 | |
mbed_official | 84:f54042cbc282 | 175 | void pwmout_period_ms(pwmout_t* obj, int ms) { |
mbed_official | 84:f54042cbc282 | 176 | pwmout_period_us(obj, ms * 1000); |
mbed_official | 84:f54042cbc282 | 177 | } |
mbed_official | 84:f54042cbc282 | 178 | |
mbed_official | 84:f54042cbc282 | 179 | void pwmout_period_us(pwmout_t* obj, int us) { |
mbed_official | 84:f54042cbc282 | 180 | TIM_TypeDef *tim = (TIM_TypeDef *)(obj->pwm); |
mbed_official | 84:f54042cbc282 | 181 | TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; |
mbed_official | 84:f54042cbc282 | 182 | float dc = pwmout_read(obj); |
mbed_official | 84:f54042cbc282 | 183 | |
mbed_official | 216:577900467c9e | 184 | TIM_Cmd(tim, DISABLE); |
mbed_official | 216:577900467c9e | 185 | |
mbed_official | 84:f54042cbc282 | 186 | obj->period = us; |
mbed_official | 216:577900467c9e | 187 | |
mbed_official | 84:f54042cbc282 | 188 | TIM_TimeBaseStructure.TIM_Period = obj->period - 1; |
mbed_official | 84:f54042cbc282 | 189 | TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick |
mbed_official | 84:f54042cbc282 | 190 | TIM_TimeBaseStructure.TIM_ClockDivision = 0; |
mbed_official | 84:f54042cbc282 | 191 | TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; |
mbed_official | 84:f54042cbc282 | 192 | TIM_TimeBaseInit(tim, &TIM_TimeBaseStructure); |
mbed_official | 84:f54042cbc282 | 193 | |
mbed_official | 84:f54042cbc282 | 194 | // Set duty cycle again |
mbed_official | 84:f54042cbc282 | 195 | pwmout_write(obj, dc); |
mbed_official | 216:577900467c9e | 196 | |
mbed_official | 84:f54042cbc282 | 197 | TIM_ARRPreloadConfig(tim, ENABLE); |
mbed_official | 84:f54042cbc282 | 198 | |
mbed_official | 84:f54042cbc282 | 199 | TIM_Cmd(tim, ENABLE); |
mbed_official | 84:f54042cbc282 | 200 | } |
mbed_official | 84:f54042cbc282 | 201 | |
mbed_official | 84:f54042cbc282 | 202 | void pwmout_pulsewidth(pwmout_t* obj, float seconds) { |
mbed_official | 84:f54042cbc282 | 203 | pwmout_pulsewidth_us(obj, seconds * 1000000.0f); |
mbed_official | 84:f54042cbc282 | 204 | } |
mbed_official | 84:f54042cbc282 | 205 | |
mbed_official | 84:f54042cbc282 | 206 | void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) { |
mbed_official | 84:f54042cbc282 | 207 | pwmout_pulsewidth_us(obj, ms * 1000); |
mbed_official | 84:f54042cbc282 | 208 | } |
mbed_official | 84:f54042cbc282 | 209 | |
mbed_official | 84:f54042cbc282 | 210 | void pwmout_pulsewidth_us(pwmout_t* obj, int us) { |
mbed_official | 84:f54042cbc282 | 211 | float value = (float)us / (float)obj->period; |
mbed_official | 84:f54042cbc282 | 212 | pwmout_write(obj, value); |
mbed_official | 84:f54042cbc282 | 213 | } |
mbed_official | 166:cb4253f91ada | 214 | |
mbed_official | 166:cb4253f91ada | 215 | #endif |