本文整理汇总了C++中pwmout_period_us函数的典型用法代码示例。如果您正苦于以下问题:C++ pwmout_period_us函数的具体用法?C++ pwmout_period_us怎么用?C++ pwmout_period_us使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pwmout_period_us函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin) {
// determine the channel
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
MBED_ASSERT(pwm != (PWMName)NC);
// power on
CPGSTBCR3 &= ~(1<<0);
obj->pwm = pwm;
if (((uint32_t)PORT[obj->pwm] & 0x00000010) != 0) {
obj->ch = 2;
PWMPWPR_2_BYTE_L = 0x00;
} else {
obj->ch = 1;
PWMPWPR_1_BYTE_L = 0x00;
}
// Wire pinout
pinmap_pinout(pin, PinMap_PWM);
// default to 491us: standard for servos, and fine for e.g. brightness control
pwmout_write(obj, 0);
if ((obj->ch == 2) && (init_period_ch2 == 0)) {
pwmout_period_us(obj, 491);
init_period_ch2 = 1;
}
if ((obj->ch == 1) && (init_period_ch1 == 0)) {
pwmout_period_us(obj, 491);
init_period_ch1 = 1;
}
}
开发者ID:1deus,项目名称:tmk_keyboard,代码行数:31,代码来源:pwmout_api.c
示例2: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin) {
// Get the peripheral name from the pin and assign it to the object
obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
if (obj->pwm == (PWMName)NC) {
error("PWM error: pinout mapping failed.");
}
// Enable TIM clock
if (obj->pwm == PWM_1) __TIM1_CLK_ENABLE();
if (obj->pwm == PWM_2) __TIM2_CLK_ENABLE();
if (obj->pwm == PWM_3) __TIM3_CLK_ENABLE();
if (obj->pwm == PWM_4) __TIM4_CLK_ENABLE();
if (obj->pwm == PWM_9) __TIM9_CLK_ENABLE();
if (obj->pwm == PWM_10) __TIM10_CLK_ENABLE();
if (obj->pwm == PWM_11) __TIM11_CLK_ENABLE();
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
obj->pin = pin;
obj->period = 0;
obj->pulse = 0;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:mbrudevoldlpd,项目名称:mbed_rtx_issue,代码行数:26,代码来源:pwmout_api.c
示例3: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin)
{
// Get the peripheral name from the pin and assign it to the object
obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
if (obj->pwm == (PWMName)NC) {
error("PWM error: pinout mapping failed.");
}
// Enable TIM clock
#if defined(TIM1_BASE)
if (obj->pwm == PWM_1) __TIM1_CLK_ENABLE();
#endif
#if defined(TIM2_BASE)
if (obj->pwm == PWM_2) __TIM2_CLK_ENABLE();
#endif
if (obj->pwm == PWM_3) __TIM3_CLK_ENABLE();
if (obj->pwm == PWM_14) __TIM14_CLK_ENABLE();
if (obj->pwm == PWM_15) __TIM15_CLK_ENABLE();
if (obj->pwm == PWM_16) __TIM16_CLK_ENABLE();
if (obj->pwm == PWM_17) __TIM17_CLK_ENABLE();
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
obj->pin = pin;
obj->period = 0;
obj->pulse = 0;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:nickmolo,项目名称:ECE477,代码行数:31,代码来源:pwmout_api.c
示例4: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin)
{
// Get the peripheral name from the pin and assign it to the object
obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
MBED_ASSERT(obj->pwm != (PWMName)NC);
// Get the functions (timer channel, (non)inverted) from the pin and assign it to the object
uint32_t function = pinmap_function(pin, PinMap_PWM);
MBED_ASSERT(function != (uint32_t)NC);
obj->channel = STM_PIN_CHANNEL(function);
obj->inverted = STM_PIN_INVERTED(function);
// Enable TIM clock
#if defined(TIM1_BASE)
if (obj->pwm == PWM_1) __HAL_RCC_TIM1_CLK_ENABLE();
#endif
#if defined(TIM2_BASE)
if (obj->pwm == PWM_2) __HAL_RCC_TIM2_CLK_ENABLE();
#endif
#if defined(TIM3_BASE)
if (obj->pwm == PWM_3) __HAL_RCC_TIM3_CLK_ENABLE();
#endif
#if defined(TIM4_BASE)
if (obj->pwm == PWM_4) __HAL_RCC_TIM4_CLK_ENABLE();
#endif
#if defined(TIM5_BASE)
if (obj->pwm == PWM_5) __HAL_RCC_TIM5_CLK_ENABLE();
#endif
#if defined(TIM8_BASE)
if (obj->pwm == PWM_8) __HAL_RCC_TIM8_CLK_ENABLE();
#endif
#if defined(TIM9_BASE)
if (obj->pwm == PWM_9) __HAL_RCC_TIM9_CLK_ENABLE();
#endif
#if defined(TIM10_BASE)
if (obj->pwm == PWM_10) __HAL_RCC_TIM10_CLK_ENABLE();
#endif
#if defined(TIM11_BASE)
if (obj->pwm == PWM_11) __HAL_RCC_TIM11_CLK_ENABLE();
#endif
#if defined(TIM12_BASE)
if (obj->pwm == PWM_12) __HAL_RCC_TIM12_CLK_ENABLE();
#endif
#if defined(TIM13_BASE)
if (obj->pwm == PWM_13) __HAL_RCC_TIM13_CLK_ENABLE();
#endif
#if defined(TIM14_BASE)
if (obj->pwm == PWM_14) __HAL_RCC_TIM14_CLK_ENABLE();
#endif
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
obj->pin = pin;
obj->period = 0;
obj->pulse = 0;
obj->prescaler = 1;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:60,代码来源:pwmout_api.c
示例5: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin) {
// Get the peripheral name from the pin and assign it to the object
obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
if (obj->pwm == (PWMName)NC) {
error("PWM pinout mapping failed");
}
// Enable TIM clock
if (obj->pwm == PWM_2) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
if (obj->pwm == PWM_3) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
if (obj->pwm == PWM_4) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
if (obj->pwm == PWM_5) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);
if (obj->pwm == PWM_9) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM9, ENABLE);
if (obj->pwm == PWM_10) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM10, ENABLE);
if (obj->pwm == PWM_11) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM11, ENABLE);
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
obj->pin = pin;
obj->period = 0;
obj->pulse = 0;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:ElAbbassi,项目名称:mbed,代码行数:26,代码来源:pwmout_api.c
示例6: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin)
{
// Get the peripheral name from the pin and assign it to the object
obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
MBED_ASSERT(obj->pwm != (PWMName)NC);
// Get the pin function and assign the used channel to the object
uint32_t function = pinmap_function(pin, PinMap_PWM);
MBED_ASSERT(function != (uint32_t)NC);
obj->channel = STM_PIN_CHANNEL(function);
obj->inverted = STM_PIN_INVERTED(function);
// Enable TIM clock
if (obj->pwm == PWM_2) __TIM2_CLK_ENABLE();
#if defined(TIM3_BASE)
if (obj->pwm == PWM_3) __TIM3_CLK_ENABLE();
#endif
if (obj->pwm == PWM_21) __TIM21_CLK_ENABLE();
#if defined(TIM22_BASE)
if (obj->pwm == PWM_22) __TIM22_CLK_ENABLE();
#endif
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
obj->pin = pin;
obj->period = 0;
obj->pulse = 0;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:DanKupiniak,项目名称:mbed,代码行数:31,代码来源:pwmout_api.c
示例7: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin)
{
uint32_t peripheral;
u32 pwm_idx;
u32 pin_sel;
DBG_PWM_INFO("%s: Init PWM for pin(0x%x)\n", __FUNCTION__, pin);
// Get the peripheral name from the pin and assign it to the object
peripheral = pinmap_peripheral(pin, PinMap_PWM);
if (unlikely(peripheral == NC)) {
DBG_PWM_ERR("%s: Cannot find matched pwm for this pin(0x%x)\n", __FUNCTION__, pin);
return;
}
pwm_idx = RTL_GET_PERI_IDX(peripheral);
pin_sel = RTL_GET_PERI_SEL(peripheral);
obj->pwm_idx = pwm_idx;
obj->pin_sel = pin_sel;
obj->period = 0;
obj->pulse = 0;
_memset((void *)&obj->pwm_hal_adp, 0, sizeof(HAL_PWM_ADAPTER));
if (HAL_OK != HAL_Pwm_Init(&obj->pwm_hal_adp, pwm_idx, pin_sel)) {
DBG_PWM_ERR("pwmout_init Err!\n");
return;
}
pwmout_period_us(obj, 20000); // 20 ms per default
HAL_Pwm_Enable(&obj->pwm_hal_adp);
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:31,代码来源:pwmout_api.c
示例8: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin) {
// Get the peripheral name from the pin and assign it to the object
obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
if (obj->pwm == (PWMName)NC) {
error("PWM pinout mapping failed");
}
// Enable TIM clock
if (obj->pwm == TIM_3) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
if (obj->pwm == TIM_14) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM14, ENABLE);
if (obj->pwm == TIM_15) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM15, ENABLE);
if (obj->pwm == TIM_16) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM16, ENABLE);
if (obj->pwm == TIM_17) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM17, ENABLE);
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
//pin_mode(pin, PullUp);
obj->pin = pin;
obj->period = 0;
obj->pulse = 0;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:nongxiaoming,项目名称:mbed,代码行数:25,代码来源:pwmout_api.c
示例9: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin)
{
// Get the peripheral name from the pin and assign it to the object
obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
MBED_ASSERT(obj->pwm != (PWMName)NC);
// Get the functions (timer channel, (non)inverted) from the pin and assign it to the object
uint32_t function = pinmap_function(pin, PinMap_PWM);
MBED_ASSERT(function != (uint32_t)NC);
obj->channel = STM_PIN_CHANNEL(function);
obj->inverted = STM_PIN_INVERTED(function);
// Enable TIM clock
if (obj->pwm == PWM_1) __TIM1_CLK_ENABLE();
if (obj->pwm == PWM_2) __TIM2_CLK_ENABLE();
if (obj->pwm == PWM_3) __TIM3_CLK_ENABLE();
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
obj->pin = pin;
obj->period = 0;
obj->pulse = 0;
obj->prescaler = 1;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:SolarTeamEindhoven,项目名称:mbed,代码行数:27,代码来源:pwmout_api.c
示例10: pinRemoveMode
uint8_t AmebaServo::attach(int pin, int min, int max)
{
pinRemoveMode( pin );
analogWrite( pin, 0 );
pwmout_period_us( (pwmout_t *)gpio_pin_struct[pin], 20000);
servoPin = pin;
this->min = min;
this->max = max;
return 0;
}
开发者ID:Ameba8195,项目名称:Arduino,代码行数:12,代码来源:AmebaServo.cpp
示例11: pwmout_pulsewidth_us
void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
timer_mr tid = pwm_timer_map[obj->pwm];
LPC_TMR_TypeDef *timer = Timers[tid.timer];
uint32_t t_on = (uint32_t)((((uint64_t)SystemCoreClock * (uint64_t)us) / (uint64_t)1000000) / (timer->PR + 1));
timer->TCR = TCR_RESET;
if (t_on > timer->MR3) {
pwmout_period_us(obj, us);
}
uint32_t t_off = timer->MR3 - t_on;
timer->MR[tid.mr] = t_off;
timer->TCR = TCR_CNT_EN;
}
开发者ID:ElAbbassi,项目名称:mbed,代码行数:13,代码来源:pwmout_api.c
示例12: pwmout_period_ms
void pwmout_period_ms(pwmout_t *obj, int ms)
{
// reught saturation < 0, quasi-max>
if (ms > MAX_PWM_PERIOD_MS)
{
ms = MAX_PWM_PERIOD_MS;
}
else if (ms < 0)
{
ms = 0; // f. pwmout_period_us will set period to min. value
}
int us = ms * 1000;
pwmout_period_us(obj, us);
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:16,代码来源:pwmout_api.c
示例13: pwmout_period
void pwmout_period(pwmout_t *obj, float seconds)
{
// raught saturation < 0, quasi-max>
if (seconds > MAX_PWM_PERIOD_S)
{
seconds = MAX_PWM_PERIOD_S;
}
else if (seconds < 0)
{
seconds = 0; // f. pwmout_period_us will set period to min. value
}
int us = seconds * 1000000;
pwmout_period_us(obj, us);
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:16,代码来源:pwmout_api.c
示例14: main
//int main_app(IN u16 argc, IN u8 *argv[])
void main(void)
{
int i;
for (i=0; i<4; i++) {
pwmout_init(&pwm_led[i], pwm_led_pin[i]);
pwmout_period_us(&pwm_led[i], PWM_PERIOD);
}
while (1) {
#if USE_FLOAT
for (i=0; i<4; i++) {
pwmout_write(&pwm_led[i], pwms[i]);
pwms[i] += steps[i];
if (pwms[i] >= 1.0) {
steps[i] = -PWM_STEP;
pwms[i] = 1.0;
}
if (pwms[i] <= 0.0) {
steps[i] = PWM_STEP;
pwms[i] = 0.0;
}
}
#else
for (i=0; i<4; i++) {
pwmout_pulsewidth_us(&pwm_led[i], pwms[i]);
pwms[i] += steps[i];
if (pwms[i] >= PWM_PERIOD) {
steps[i] = -PWM_STEP;
pwms[i] = PWM_PERIOD;
}
if (pwms[i] <= 0) {
steps[i] = PWM_STEP;
pwms[i] = 0;
}
}
#endif
// wait_ms(20);
// RtlMsleepOS(25);
pwm_delay();
}
}
开发者ID:alex1818,项目名称:rtk-8711af,代码行数:47,代码来源:main.c
示例15: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin)
{
// Get the peripheral name from the pin and assign it to the object
obj->PWM_CHx = (PWM_CHn_TypeDef *)pinmap_peripheral(pin, PinMap_PWM);
if (obj->PWM_CHx == (PWM_CHn_TypeDef *)NC) {
error("PWM error: pinout mapping failed.");
}
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
GetSystemClock();
obj->pin = pin;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:Babody,项目名称:mbed,代码行数:18,代码来源:pwmout_api.c
示例16: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin) {
// Get the peripheral name from the pin and assign it to the object
obj->pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
MBED_ASSERT(obj->pwm != (PWMName)NC);
// Enable TIM clock
if (obj->pwm == PWM_1) RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
if (obj->pwm == PWM_2) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
if (obj->pwm == PWM_3) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
if (obj->pwm == PWM_4) RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
// Configure GPIO
pinmap_pinout(pin, PinMap_PWM);
obj->pin = pin;
obj->period = 0;
obj->pulse = 0;
pwmout_period_us(obj, 20000); // 20 ms per default
}
开发者ID:23chrischen,项目名称:mbed,代码行数:20,代码来源:pwmout_api.c
示例17: pwmout_period
void pwmout_period(pwmout_t *obj, float seconds)
{
pwmout_period_us(obj, seconds * 1000000.0f);
}
开发者ID:pan-,项目名称:mbed,代码行数:4,代码来源:pwmout_api.c
示例18: pwmout_period
//******************************************************************************
void pwmout_period(pwmout_t* obj, float seconds)
{
pwmout_period_us(obj, (int)(seconds * 1000000.0));
}
开发者ID:1deus,项目名称:tmk_keyboard,代码行数:5,代码来源:pwmout_api.c
示例19: pwmout_init
void pwmout_init(pwmout_t* obj, PinName pin) {
// determine the channel
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
MBED_ASSERT(pwm != (PWMName)NC);
if (pwm >= MTU2_PWM_OFFSET) {
/* PWM by MTU2 */
int tmp_pwm;
// power on
CPGSTBCR3 &= ~(CPG_STBCR3_BIT_MSTP33);
obj->pwm = pwm;
tmp_pwm = (int)(obj->pwm - MTU2_PWM_OFFSET);
if (((uint32_t)MTU2_PORT[tmp_pwm] & 0x00000040) == 0x00000040) {
obj->ch = 4;
MTU2TOER |= 0x36;
} else if (((uint32_t)MTU2_PORT[tmp_pwm] & 0x00000030) == 0x00000030) {
obj->ch = 3;
MTU2TOER |= 0x09;
} else if (((uint32_t)MTU2_PORT[tmp_pwm] & 0x00000020) == 0x00000020) {
obj->ch = 2;
} else if (((uint32_t)MTU2_PORT[tmp_pwm] & 0x00000010) == 0x00000010) {
obj->ch = 1;
} else {
obj->ch = 0;
}
// Wire pinout
pinmap_pinout(pin, PinMap_PWM);
int bitmask = 1 << (pin & 0xf);
*PMSR(PINGROUP(pin)) = (bitmask << 16) | 0;
// default duty 0.0f
pwmout_write(obj, 0);
if (init_mtu2_period_ch[obj->ch] == 0) {
// default period 1ms
pwmout_period_us(obj, 1000);
init_mtu2_period_ch[obj->ch] = 1;
}
} else {
/* PWM */
// power on
CPGSTBCR3 &= ~(CPG_STBCR3_BIT_MSTP30);
obj->pwm = pwm;
if (((uint32_t)PORT[obj->pwm] & 0x00000010) == 0x00000010) {
obj->ch = 2;
PWMPWPR_2_BYTE_L = 0x00;
} else {
obj->ch = 1;
PWMPWPR_1_BYTE_L = 0x00;
}
// Wire pinout
pinmap_pinout(pin, PinMap_PWM);
// default to 491us: standard for servos, and fine for e.g. brightness control
pwmout_write(obj, 0);
if ((obj->ch == 2) && (init_period_ch2 == 0)) {
pwmout_period_us(obj, 491);
init_period_ch2 = 1;
}
if ((obj->ch == 1) && (init_period_ch1 == 0)) {
pwmout_period_us(obj, 491);
init_period_ch1 = 1;
}
}
}
开发者ID:SolarTeamEindhoven,项目名称:mbed,代码行数:70,代码来源:pwmout_api.c
示例20: pwmout_period_ms
void pwmout_period_ms(pwmout_t *obj, int ms)
{
pwmout_period_us(obj, ms * 1000);
}
开发者ID:pan-,项目名称:mbed,代码行数:4,代码来源:pwmout_api.c
注:本文中的pwmout_period_us函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论