/* * 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(); }
/* * 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(); }
/* * 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(); }
/* * GPT3 interrupt callback. Reenable transmit interrupts. */ static void transmit_unlock(GPTDriver *gptp) { (void) gptp; extChannelEnableI(&EXTD1, 0); //Reenable transmit interrupt chSysUnlockFromIsr(); }
/** * @brief Enables an EXT channel. * @pre The channel must not be in @p EXT_CH_MODE_DISABLED mode. * * @param[in] extp pointer to the @p EXTDriver object * @param[in] channel channel to be enabled * * @api */ void extChannelEnable(EXTDriver *extp, expchannel_t channel) { osalDbgCheck((extp != NULL) && (channel < (expchannel_t)EXT_MAX_CHANNELS)); osalSysLock(); osalDbgAssert((extp->state == EXT_ACTIVE) && ((extp->config->channels[channel].mode & EXT_CH_MODE_EDGES_MASK) != EXT_CH_MODE_DISABLED), "invalid state"); extChannelEnableI(extp, channel); osalSysUnlock(); }
/* * PWM callbacks. */ static void pwm1cb(PWMDriver *pwmp) { (void)pwmp; chSysLockFromIsr(); pwm_cycles++; if (pwm_cycles > 160) { pwmDisableChannelI(pwmp, 0); pwm_cycles = 0; extChannelEnableI(&EXT_DRIVER, ECHO); tmp2 = (&GPT_DRIVER)->tim->CNT; } chSysUnlockFromIsr(); }