当前位置: 首页>>代码示例>>C++>>正文


C++ pwmStart函数代码示例

本文整理汇总了C++中pwmStart函数的典型用法代码示例。如果您正苦于以下问题:C++ pwmStart函数的具体用法?C++ pwmStart怎么用?C++ pwmStart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pwmStart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pwmOutputStart

/**
 * @brief  Starts the PWM output.
 * @note   The pwmStart() function used in this code is not
 *         the original ChibiOS HAL function, but modified
 *         one with STM32_TIM_CR1_CEN flag removed.
 * @return none.
 */
void pwmOutputStart(void) {
#if STM32_PWM_USE_ADVANCED
  /* Get dead-time generator value for TIM1. */
  uint32_t bdtr_dt = pwmOutputGetBDTRDeadTime(g_pwmOutput[PWM_OUT_ROLL].dt_cmd_id & PWM_OUT_DT_ID_MASK);
  pwmcfg_d1_d8.bdtr |= bdtr_dt;
#endif
  pwmStart(&PWMD1, &pwmcfg_d1_d8);

#if STM32_PWM_USE_ADVANCED
  /* Clear bdtr_dt value from previous calculation. */
  pwmcfg_d1_d8.bdtr &= ~bdtr_dt;
  /* Get dead-time generator value for TIM8. */
  bdtr_dt = pwmOutputGetBDTRDeadTime(g_pwmOutput[PWM_OUT_PITCH].dt_cmd_id & PWM_OUT_DT_ID_MASK);
  pwmcfg_d1_d8.bdtr |= bdtr_dt;
#endif
  /* Configure TIM8 as master timer: */
  pwmcfg_d1_d8.cr2 = STM32_TIM_CR2_MMS(1); // Master mode set to Enable;
  pwmStart(&PWMD8, &pwmcfg_d1_d8);

  switch (g_pwmOutput[PWM_OUT_YAW].dt_cmd_id & PWM_OUT_DT_ID_MASK) {
  case PWM_OUT_DT750NS:
    pwmOutTIM4_5_DT = PWM_OUT_TIM4_5_DT_US7;
    break;
  case PWM_OUT_DT1000NS:
    pwmOutTIM4_5_DT = PWM_OUT_TIM4_5_DT_1US;
    break;
  case PWM_OUT_DT2000NS:
    pwmOutTIM4_5_DT = PWM_OUT_TIM4_5_DT_2US;
    break;
  case PWM_OUT_DT3000NS:
    pwmOutTIM4_5_DT = PWM_OUT_TIM4_5_DT_3US;
    break;
  case PWM_OUT_DT4000NS:
    pwmOutTIM4_5_DT = PWM_OUT_TIM4_5_DT_4US;
    break;
  case PWM_OUT_DT5000NS:
    pwmOutTIM4_5_DT = PWM_OUT_TIM4_5_DT_5US;
    break;
  default:
    pwmOutTIM4_5_DT = PWM_OUT_TIM4_5_DT_5US;
  }
  pwmStart(&PWMD4, &pwmcfg_d4);
  pwmStart(&PWMD5, &pwmcfg_d5);

  /* Configure TIM5 as slave timer: */
  PWMD5.tim->SMCR =
    STM32_TIM_SMCR_SMS(6) | // Trigger Mode;
    STM32_TIM_SMCR_TS(3);   // Trigger event comes from TIM8;

  /* Configure TIM4 as slave timer: */
  PWMD4.tim->SMCR =
    STM32_TIM_SMCR_SMS(6) | // Trigger Mode;
    STM32_TIM_SMCR_TS(3);   // Trigger event comes from TIM8;

  /* Switch to center-aligned mode 1 and start timers. */
  PWMD5.tim->CR1 |= (STM32_TIM_CR1_CMS(1)); // This is a slave timer - do not start;
  PWMD4.tim->CR1 |= (STM32_TIM_CR1_CMS(1)); // This is a slave timer - do not start;
  PWMD1.tim->CR1 |= (STM32_TIM_CR1_CMS(1) | STM32_TIM_CR1_CEN);
  PWMD8.tim->CR1 |= (STM32_TIM_CR1_CMS(1) | STM32_TIM_CR1_CEN); // Start TIM8, TIM4 and TIM5 simultaneously;
}
开发者ID:Jister,项目名称:EvvGC-PLUS,代码行数:67,代码来源:pwmio.c

示例2: InitPWM

void InitPWM(void) {
  /*
   * Initializes the PWM drivers
   */
  pwmStart(&PWMD3, &pwmcfg);
  pwmStart(&PWMD4, &pwmcfg);
  pwmStart(&PWMD5, &pwmcfg);
//  pwmStart(&PWMD8, &pwmcfg);
}
开发者ID:MaxPayne86,项目名称:axoloti,代码行数:9,代码来源:axoloti_board.c

示例3: bldcInit

/* This function will start the PWM generator.
 */
extern void bldcInit(void) {
  bldc.scheme = &pwmScheme;
  bldc.state = 0;          //Default to first state
  bldc.nextState = 0;
  bldc.directionFwd = TRUE;
  bldc.stateChangeInterval = MS2RTT(20);
  bldc.prevStateChange = halGetCounterValue();
  bldc.nextStateChange = bldc.prevStateChange + bldc.stateChangeInterval;
  bldc.pwmOutT0 = 0;
  bldc.pwmOutT1 = 0;
  bldc.stateCount = sizeof(pwmScheme)/3;
  bldc.dutyCycle = 1800;

  palWriteGroup (PWM_OUT_PORT, PWM_OUT_PORT_MASK, PWM_OUT_OFFSET,  PWM_OFF);
  palSetGroupMode (PWM_OUT_PORT, PWM_OUT_PORT_MASK, PWM_OUT_OFFSET, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode (GPIOA, GPIOA_PIN1, PAL_MODE_INPUT_ANALOG);

  pwmStart(&PWMD1, &pwmcfg);

  // ADC trigger channel. This will trigger the ADC read at 95% of the cycle,
  // when all the PWM outputs are set to 0
  pwmEnableChannel (&PWMD1, PWM_ADCTRIG_CH, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, PWM_MAX_DUTY_CYCLE));

  // Start the ADC
  adcStart(&ADCD1, NULL);

}
开发者ID:kjellhar,项目名称:chibi-bldc,代码行数:29,代码来源:bldc.c

示例4: goToPos

	void goToPos(int32_t new_pos){
		if(new_pos == position)
			return;
		config.frequency = clk_freq;
		config.period = clk_freq / initial_freq;
		config.callback = cb;
		current_freq = initial_freq;
		config.channels[0] = {PWM_OUTPUT_DISABLED, NULL};
		config.channels[1] = {PWM_OUTPUT_DISABLED, NULL};
		config.channels[2] = {PWM_OUTPUT_DISABLED, NULL};
		config.channels[3] = {PWM_OUTPUT_DISABLED, NULL};
		config.channels[channel] = {PWM_OUTPUT_ACTIVE_HIGH, NULL};
		config.cr2 = 0;
		config.dier = 0;

		dir_positive = new_pos > position;
		target_position = new_pos;

		dir_pin.assign(dir_positive);

		ramp_length = (new_pos > position) ?
			((max_pos_freq - initial_freq) / ramp) :
			((max_neg_freq - initial_freq) / ramp);

		pwmStart(driver, &config);
		pwmEnableChannel(driver, channel, 10);
		pwmEnablePeriodicNotificationI(driver);
	}
开发者ID:timothydgreer,项目名称:turing_machine,代码行数:28,代码来源:motor.hpp

示例5: main

int main(void)
{
  halInit();
  chSysInit();
  
  palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATE(2)); // alt mode is PWM-enabled TIM3
  palSetPadMode(GPIOB, INAPIN, PAL_MODE_OUTPUT_PUSHPULL); // set INA to be an output
  palSetPadMode(GPIOB, INBPIN, PAL_MODE_OUTPUT_PUSHPULL); // set INB to be an output
   
  pwmStart(&PWMD3, &pwmcfg); // TIM3 for motors
 
  while (TRUE) {
    // one direction (possibly forward)
    pwmEnableChannel(&PWMD3, 3, 500);
    palSetPad(GPIOB, INAPIN);
    palClearPad(GPIOB, INBPIN);
    chThdSleepMilliseconds(3000);

    // the other direction (possibly backward)
    pwmEnableChannel(&PWMD3, 3, 500);
    palSetPad(GPIOB, INBPIN);
    palClearPad(GPIOB, INAPIN);
    chThdSleepMilliseconds(3000);
  }
}
开发者ID:wicker,项目名称:Self-Driving-RC-Car,代码行数:25,代码来源:main.c

示例6: palSetPadMode

void PwmBacklight::Init()
{
	palSetPadMode(BACKLIGHT_PORT, BACKLIGHT_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
	pwmStart(&PWMD4, &pwmconfig);

	FadeIn();
}
开发者ID:kubanecxxx,项目名称:homeautomation,代码行数:7,代码来源:PwmBacklight.cpp

示例7: convStart

void convStart( void )
{
    /*
    pwmStart( &PWMD2, &pwmCfg );
    palSetPadMode( GPIOA, 0, PAL_MODE_STM32_ALTERNATE_PUSHPULL );
    palSetPadMode( GPIOA, 1, PAL_MODE_STM32_ALTERNATE_PUSHPULL );
    //palSetPadMode( GPIOA, 2, PAL_MODE_STM32_ALTERNATE_PUSHPULL );
    pwmEnableChannel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH( &PWMD2, 9500 ) );
    pwmEnableChannel(&PWMD2, 1, PWM_PERCENTAGE_TO_WIDTH( &PWMD2, 3030 ) );
    //pwmEnableChannel(&PWMD2, 2, PWM_PERCENTAGE_TO_WIDTH( &PWMD2, 3030 ) );
    */

	// Start PWM peripherial.
    pwmStart( &CONV_PWM, &pwmCfg );
	// Init PWM pins.
    palSetPadMode( CONV_PORT, CONV_BUCK_PIN,  PAL_MODE_STM32_ALTERNATE_PUSHPULL );
    palSetPadMode( CONV_PORT, CONV_BOOST_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL );
    // Set zero active period.
    pwmEnableChannel(&CONV_PWM, PWM_BOOST_CHAN, PWM_PERCENTAGE_TO_WIDTH( &CONV_PWM, 0000 ) );
    pwmEnableChannel(&CONV_PWM, PWM_BUCK_CHAN,  PWM_PERCENTAGE_TO_WIDTH( &CONV_PWM, 0000 ) );

    // Init ADC.
    palSetGroupMode(CONV_ADC_PORT, PAL_PORT_BIT( CONV_BUCK_FB_PIN ) |
    	                           PAL_PORT_BIT( CONV_BOOST_FB_PIN ) |
    	                           PAL_PORT_BIT( CONV_INPUT_FB_PIN ),
                                   0, PAL_MODE_INPUT_ANALOG);
    adcStart( &ADCD1, NULL );

    adcStartConversion( &ADCD1, &adcGroup, adcSamples, ADC_BUF_DEPTH );
}
开发者ID:z80,项目名称:robocam,代码行数:30,代码来源:conv_ctrl.c

示例8: ow_bus_active

/**
 * @brief     Put bus in active mode.
 */
static void ow_bus_active(onewireDriver *owp) {
  pwmStart(owp->config->pwmd, owp->config->pwmcfg);
#if defined(STM32F1XX)
  palSetPadMode(owp->config->port, owp->config->pad,
      owp->config->pad_mode_active);
#endif
}
开发者ID:awygle,项目名称:ChibiOS-Contrib,代码行数:10,代码来源:hal_onewire.c

示例9: main

/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();
  pwmStart(&PWMD1, &pwmcfg);

  /*
   * Activates the serial driver 2 using the driver default configuration.
   */

  palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(2));

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and check the button state.
   */
  while (true) {
    if (TRUE)  //(!palReadPad(GPIOC, GPIOC_BUTTON))
      //TestThread(&SD1);
    chThdSleepMilliseconds(5000);
  }
}
开发者ID:aktos-io,项目名称:chibi-examples,代码行数:37,代码来源:main.c

示例10: palSetPadMode

void PwmBacklight::Init()
{
	palSetPadMode(GPIOB, 6, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
	pwmStart(&PWMD4, &pwmconfig);

	FadeIn();
}
开发者ID:kubanecxxx,项目名称:termostat,代码行数:7,代码来源:PwmBacklight.cpp

示例11: pwmStart

PWMPlatform::PWMPlatform() {
  pwmStart(&PWMD1, &MOTOR_PWM_CONFIG);
  palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 7, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 8, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 9, PAL_MODE_ALTERNATE(4));
}
开发者ID:OSURoboticsClub,项目名称:aerial_control,代码行数:7,代码来源:pwm_platform.cpp

示例12: pwm2sub_node

msg_t pwm2sub_node(void * arg) {
	Node node("pwm2sub");
	Subscriber<PWM2Msg, 5> sub(callback);

	(void) arg;

	chRegSetThreadName("pwm2sub");

	palSetPad(DRIVER_GPIO, DRIVER_RESET);
	chThdSleepMilliseconds(500);
	pwmStart(&PWM_DRIVER, &pwmcfg);

	node.subscribe(sub, "pwm2");

	for (;;) {
		if (!node.spin(Time::ms(100))) {
			// Stop motor if no messages for 100 ms
			chSysLock()
			;
			pwm_lld_enable_channel(&PWM_DRIVER, 0, 0);
			pwm_lld_enable_channel(&PWM_DRIVER, 0, 0);
			chSysUnlock();
		}
	}
	return CH_SUCCESS;
}
开发者ID:AIRLab-POLIMI,项目名称:BasketBot_old,代码行数:26,代码来源:motor.cpp

示例13: demo_led_init

void demo_led_init(void)
{
    /*
     * PWM configuration structure.
     * Cyclic callback enabled, channels 1 and 4 enabled without callbacks,
     * the active state is a logic one.
     */
    static const PWMConfig pwmcfg = {
        100000,                                   /* 100kHz PWM clock frequency.  */
        128,                                      /* PWM period is 128 cycles.    */
        NULL,
        {
         {PWM_OUTPUT_ACTIVE_HIGH, NULL},
         {PWM_OUTPUT_ACTIVE_HIGH, NULL},
         {PWM_OUTPUT_ACTIVE_HIGH, NULL},
         {PWM_OUTPUT_ACTIVE_HIGH, NULL}
},
        /* HW dependent part.*/
        0,
        0
    };

    /*
     * Initializes the PWM driver 4, routes the TIM4 outputs to the board LEDs.
     */
    pwmStart(&PWMD4, &pwmcfg);
    palSetPadMode(GPIOD, GPIOD_LED4, PAL_MODE_ALTERNATE(2));      /* Green.   */
    palSetPadMode(GPIOD, GPIOD_LED3, PAL_MODE_ALTERNATE(2));      /* Orange.  */
    palSetPadMode(GPIOD, GPIOD_LED5, PAL_MODE_ALTERNATE(2));      /* Red.     */
    palSetPadMode(GPIOD, GPIOD_LED6, PAL_MODE_ALTERNATE(2));      /* Blue.    */
}
开发者ID:epfl-mobots,项目名称:stm32f4-discovery-aseba,代码行数:31,代码来源:leds.c

示例14: motor_init

void motor_init(void) {
	pwmStart(&PWMD2, &pwmcfg);
	
	pwmEnableChannel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 500)); // 1mS Pulse
	pwmEnableChannel(&PWMD2, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 500)); // 1mS Pulse
	pwmEnableChannel(&PWMD2, 2, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 500)); // 1mS Pulse
	pwmEnableChannel(&PWMD2, 3, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 500)); // 1mS Pulse
}
开发者ID:dancollins,项目名称:Quad-Rotor,代码行数:8,代码来源:motor.c

示例15: pwmStop

bool Pwm_chibios::init(void)
{
    pwmStop(driver_);
    pwmStart(driver_, &config_);
    pwmEnablePeriodicNotification(driver_);
    pwmEnableChannelNotification(driver_, channel_);
    return true;
}
开发者ID:lis-epfl,项目名称:MAVRIC_Library,代码行数:8,代码来源:pwm_chibios.cpp


注:本文中的pwmStart函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。