Esempio n. 1
0
/**
 * @brief   Changes the period the PWM peripheral.
 * @details This function changes the period of a PWM unit that has already
 *          been activated using @p pwmStart().
 * @pre     The PWM unit must have been activated using @p pwmStart().
 * @post    The PWM unit period is changed to the new value.
 * @note    If a period is specified that is shorter than the pulse width
 *          programmed in one of the channels then the behavior is not
 *          guaranteed.
 *
 * @param[in] pwmp      pointer to a @p PWMDriver object
 * @param[in] period    new cycle time in ticks
 *
 * @api
 */
void pwmChangePeriod(PWMDriver *pwmp, pwmcnt_t period) {

  osalDbgCheck(pwmp != NULL);

  osalSysLock();
  osalDbgAssert(pwmp->state == PWM_READY, "invalid state");
  pwmChangePeriodI(pwmp, period);
  osalSysUnlock();
}
Esempio n. 2
0
File: pwm.c Progetto: Kreyl/Quetta
/**
 * @brief   Changes the period the PWM peripheral.
 * @details This function changes the period of a PWM unit that has already
 *          been activated using @p pwmStart().
 * @pre     The PWM unit must have been activated using @p pwmStart().
 * @post    The PWM unit period is changed to the 0; // new value.
 * @note    If a period is specified that is shorter than the pulse width
 *          programmed in one of the channels then the behavior is not
 *          guaranteed.
 *
 * @param[in] pwmp      pointer to a @p PWMDriver object
 * @param[in] period    0; // new cycle time in ticks
 *
 * @api
 */
void pwmChangePeriod(PWMDriver *pwmp, pwmcnt_t period) {

  chDbgCheck(pwmp != NULL, "pwmChangePeriod");

  chSysLock();
  chDbgAssert(pwmp->state == PWM_READY,
              "pwmChangePeriod(), #1", "invalid state");
  pwmChangePeriodI(pwmp, period);
  chSysUnlock();
}
Esempio n. 3
0
/*
 * Disable PLLB interrupt, enable PLLG, PLLR interrupts, switch to Blue LED
 */
void Blue_Team(void) {

  //Disable further PLLB interrupts
  extChannelDisableI(&EXTD1, PLLB_EXTCHAN);
  //Enable PLLG, PLLR interrupts
  extChannelEnableI(&EXTD1, PLLG_EXTCHAN);
  extChannelEnableI(&EXTD1, PLLR_EXTCHAN);
  //Change PWM frequency to PLLB Frequency
  pwmChangePeriodI(&PWMD2, BLUE_PERIOD);
  //Turn on Blue LED, turn off Red, Green LED's
  Blue_LED();
}
Esempio n. 4
0
/*
 * Disable PLLG interrupt, enable PLLR, PLLB interrupts, switch to Green LED
 */
void Green_Team(void) {

  //Disable further PLLG interrupts
  extChannelDisableI(&EXTD1, PLLG_EXTCHAN);
  //Enable PLLR, PLLB interrupts
  extChannelEnableI(&EXTD1, PLLR_EXTCHAN);
  extChannelEnableI(&EXTD1, PLLB_EXTCHAN);
  //Change PWM frequency to PLLG Frequency
  pwmChangePeriodI(&PWMD2, GREEN_PERIOD);
  //Turn on Green LED, turn off Red, Blue LED's
  Green_LED();
}
Esempio n. 5
0
/*
 * Disable PLLR interrupt, enable PLLG, PLLB interrupts, switch to Red LED
 */
void Red_Team(void) {

  //Disable further PLLR interrupts
  extChannelDisableI(&EXTD1, PLLR_EXTCHAN);
  //Enable PLLG, PLLB interrupts
  extChannelEnableI(&EXTD1, PLLG_EXTCHAN);
  extChannelEnableI(&EXTD1, PLLB_EXTCHAN);
  //Change PWM frequency to PLLR Frequency
  pwmChangePeriodI(&PWMD2, RED_PERIOD);
  //Turn on Red LED, turn off Green, Blue LED's
  Red_LED();
}
Esempio n. 6
0
bool Pwm_chibios::set_period_us(uint16_t period_us)
{
    pwmChangePeriodI(driver_, period_us);
    return true;
}