/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if USE_AVR_PWM1 || defined(__DOXYGEN__) pwmObjectInit(&PWMD1); TCCR1A = (0<<WGM11) | (1<<WGM10); //fast pwm 8 bit TCCR1B = (1<<WGM12) | (0<<WGM13); //fast pwm 8 bit #endif #if USE_AVR_PWM2 || defined(__DOXYGEN__) pwmObjectInit(&PWMD2); TCCR2A = (1<<WGM21) | (1<<WGM20); //fast pwm 8 bit TCCR2B = (0<<WGM22); //fast pwm 8 bit #endif #if USE_AVR_PWM3 || defined(__DOXYGEN__) pwmObjectInit(&PWMD3); TCCR3A = (0<<WGM11) | (1<<WGM10); //fast pwm 8 bit TCCR3B = (1<<WGM12) | (0<<WGM13); //fast pwm 8 bit #endif #if USE_AVR_PWM4 || defined(__DOXYGEN__) pwmObjectInit(&PWMD4); TCCR4A = (0<<WGM11) | (1<<WGM10); //fast pwm 8 bit TCCR4B = (1<<WGM12) | (0<<WGM13); //fast pwm 8 bit #endif #if USE_AVR_PWM5 || defined(__DOXYGEN__) pwmObjectInit(&PWMD5); TCCR5A = (0<<WGM11) | (1<<WGM10); //fast pwm 8 bit TCCR5B = (1<<WGM12) | (0<<WGM13); //fast pwm 8 bit #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if AVR_PWM_USE_TIM1 || defined(__DOXYGEN__) pwmObjectInit(&PWMD1); TCCR1A = (1 << WGM11) | (1 << WGM10); TCCR1B = (0 << WGM13) | (1 << WGM12); #endif #if AVR_PWM_USE_TIM2 || defined(__DOXYGEN__) pwmObjectInit(&PWMD2); TCCR2A = (1 << WGM21) | (1 << WGM20); TCCR2B = (0 << WGM22); #endif #if AVR_PWM_USE_TIM3 || defined(__DOXYGEN__) pwmObjectInit(&PWMD3); TCCR3A = (1 << WGM31) | (1 << WGM30); TCCR3B = (0 << WGM33) | (1 << WGM32); #endif #if AVR_PWM_USE_TIM4 || defined(__DOXYGEN__) pwmObjectInit(&PWMD4); TCCR4A = (1 << WGM41) | (1 << WGM40); TCCR4B = (0 << WGM43) | (1 << WGM42); #endif #if AVR_PWM_USE_TIM5 || defined(__DOXYGEN__) pwmObjectInit(&PWMD5); TCCR5A = (1 << WGM51) | (1 << WGM50); TCCR5B = (0 << WGM53) | (1 << WGM52); #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if SAM3XA_PWM_USE_CH0 pwmObjectInit(&PWMD1); #endif #if SAM3XA_PWM_USE_CH1 pwmObjectInit(&PWMD2); #endif #if SAM3XA_PWM_USE_CH2 pwmObjectInit(&PWMD3); #endif #if SAM3XA_PWM_USE_CH3 pwmObjectInit(&PWMD4); #endif #if SAM3XA_PWM_USE_CH4 pwmObjectInit(&PWMD5); #endif #if SAM3XA_PWM_USE_CH5 pwmObjectInit(&PWMD6); #endif #if SAM3XA_PWM_USE_CH6 pwmObjectInit(&PWMD7); #endif #if SAM3XA_PWM_USE_CH7 pwmObjectInit(&PWMD8); #endif // Enable clock and interrupt vector pmc_enable_peripheral_clock(ID_PWM); nvicEnableVector(PWM_IRQn, CORTEX_PRIORITY_MASK(SAM3XA_PWM_DEFAULT_IRQ_PRIORITY)); }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if PLATFORM_PWM_USE_PWM1 == TRUE /* Driver initialization.*/ pwmObjectInit(&PWMD1); #endif }
Motor(PWMDriver * driver, uint32_t pwm_index, uint32_t max_neg_freq, uint32_t max_pos_freq, uint32_t channel, gpio_pin_t enable_pin, gpio_pin_t dir_pin) : driver(driver), pwm_index(pwm_index), channel(channel), max_neg_freq(max_neg_freq), max_pos_freq(max_pos_freq), position(0), target_position(0), current_freq(0), enable_pin(enable_pin), dir_pin(dir_pin) { dir_pin.clear(); enable_pin.clear(); dir_pin.set_mode(gpio_pin_t::MODE_OUTPUT); enable_pin.set_mode(gpio_pin_t::MODE_OUTPUT); pwmObjectInit(driver); pwmStop(driver); motors[pwm_index] = this; switch(pwm_index){ case 0: cb = tickM1; break; case 1: cb = tickM2; break; case 2: cb = tickM3; break; case 3: cb = tickM4; break; case 4: cb = tickM5; break; case 5: cb = tickM6; break; case 6: cb = tickM7; break; case 7: cb = tickM8; break; case 8: cb = tickM9; break; default: while(1); } config.frequency = clk_freq; config.period = clk_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.cr2 = 0; config.dier = 0; }
/** * @brief Low level PWM driver initialization. */ void pwm_lld_init(void) { #if USE_STM32_PWM1 /* TIM1 reset, ensures reset state in order to avoid trouble with JTAGs.*/ RCC->APB2RSTR = RCC_APB2RSTR_TIM1RST; RCC->APB2RSTR = 0; /* Driver initialization.*/ pwmObjectInit(&PWMD1); PWMD1.pd_enabled_channels = 0; PWMD1.pd_tim = TIM1; #endif #if USE_STM32_PWM2 /* TIM2 reset, ensures reset state in order to avoid trouble with JTAGs.*/ RCC->APB1RSTR = RCC_APB1RSTR_TIM2RST; RCC->APB1RSTR = 0; /* Driver initialization.*/ pwmObjectInit(&PWMD2); PWMD2.pd_enabled_channels = 0; PWMD2.pd_tim = TIM2; #endif #if USE_STM32_PWM3 /* TIM2 reset, ensures reset state in order to avoid trouble with JTAGs.*/ RCC->APB1RSTR = RCC_APB1RSTR_TIM3RST; RCC->APB1RSTR = 0; /* Driver initialization.*/ pwmObjectInit(&PWMD3); PWMD3.pd_enabled_channels = 0; PWMD3.pd_tim = TIM3; #endif #if USE_STM32_PWM4 /* TIM2 reset, ensures reset state in order to avoid trouble with JTAGs.*/ RCC->APB1RSTR = RCC_APB1RSTR_TIM4RST; RCC->APB1RSTR = 0; /* Driver initialization.*/ pwmObjectInit(&PWMD4); PWMD4.pd_enabled_channels = 0; PWMD4.pd_tim = TIM4; #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if NRF5_PWM_USE_TIMER0 pwmObjectInit(&PWMD1); PWMD1.channels = PWM_CHANNELS; PWMD1.timer = NRF_TIMER0; #endif #if NRF5_PWM_USE_TIMER1 pwmObjectInit(&PWMD2); PWMD2.channels = PWM_CHANNELS; PWMD2.timer = NRF_TIMER1; #endif #if NRF5_PWM_USE_TIMER2 pwmObjectInit(&PWMD3); PWMD3.channels = PWM_CHANNELS; PWMD3.timer = NRF_TIMER2; #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if KINETIS_PWM_USE_TPM0 pwmObjectInit(&PWMD1); PWMD1.channels = KINETIS_TPM0_CHANNELS; PWMD1.tpm = TPM0; #endif #if KINETIS_PWM_USE_TPM1 pwmObjectInit(&PWMD2); PWMD2.channels = KINETIS_TPM1_CHANNELS; PWMD2.tpm = TPM1; #endif #if KINETIS_PWM_USE_TPM2 pwmObjectInit(&PWMD3); PWMD3.channels = KINETIS_TPM2_CHANNELS; PWMD3.tpm = TPM2; #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if STM32_PWM_USE_TIM1 /* Driver initialization.*/ pwmObjectInit(&PWMD1); PWMD1.channels = STM32_TIM1_CHANNELS; PWMD1.tim = STM32_TIM1; #endif #if STM32_PWM_USE_TIM2 /* Driver initialization.*/ pwmObjectInit(&PWMD2); PWMD2.channels = STM32_TIM2_CHANNELS; PWMD2.tim = STM32_TIM2; #endif #if STM32_PWM_USE_TIM3 /* Driver initialization.*/ pwmObjectInit(&PWMD3); PWMD3.channels = STM32_TIM3_CHANNELS; PWMD3.tim = STM32_TIM3; #endif #if STM32_PWM_USE_TIM4 /* Driver initialization.*/ pwmObjectInit(&PWMD4); PWMD4.channels = STM32_TIM4_CHANNELS; PWMD4.tim = STM32_TIM4; #endif #if STM32_PWM_USE_TIM5 /* Driver initialization.*/ pwmObjectInit(&PWMD5); PWMD5.channels = STM32_TIM5_CHANNELS; PWMD5.tim = STM32_TIM5; #endif #if STM32_PWM_USE_TIM8 /* Driver initialization.*/ pwmObjectInit(&PWMD8); PWMD8.channels = STM32_TIM8_CHANNELS; PWMD8.tim = STM32_TIM8; #endif #if STM32_PWM_USE_TIM9 /* Driver initialization.*/ pwmObjectInit(&PWMD9); PWMD9.channels = STM32_TIM9_CHANNELS; PWMD9.tim = STM32_TIM9; #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if STM32_PWM_USE_TIM1 /* Driver initialization.*/ pwmObjectInit(&PWMD1); PWMD1.tim = STM32_TIM1; #endif #if STM32_PWM_USE_TIM2 /* Driver initialization.*/ pwmObjectInit(&PWMD2); PWMD2.tim = STM32_TIM2; #endif #if STM32_PWM_USE_TIM3 /* Driver initialization.*/ pwmObjectInit(&PWMD3); PWMD3.tim = STM32_TIM3; #endif #if STM32_PWM_USE_TIM4 /* Driver initialization.*/ pwmObjectInit(&PWMD4); PWMD4.tim = STM32_TIM4; #endif #if STM32_PWM_USE_TIM5 /* Driver initialization.*/ pwmObjectInit(&PWMD5); PWMD5.tim = STM32_TIM5; #endif #if STM32_PWM_USE_TIM8 /* Driver initialization.*/ pwmObjectInit(&PWMD8); PWMD8.tim = STM32_TIM8; #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { #if LPC122x_PWM_USE_CT16B0 /* Driver initialization.*/ pwmObjectInit(&PWMD1); PWMD1.tim = LPC_CT16B0; #if LPC122x_PWM_USE_CT16B0_CH0 #if LPC122x_PWM_CT16B0_CH0_SELECTOR == PWM_CT16B0_CH0_IS_PIO0_11 LPC_IOCON->PIO0_11 = 0x84; #elif LPC122x_PWM_CT16B0_CH0_SELECTOR == PWM_CT16B0_CH0_IS_PIO0_28 LPC_IOCON->PIO0_28 = 0x84; #else /* LPC122x_PWM_CT16B0_CH0_SELECTOR == PWM_CT16B0_CH0_IS_PIO2_0 */ LPC_IOCON->PIO2_0 = 0x84; #endif #endif #if LPC122x_PWM_USE_CT16B0_CH1 #if LPC122x_PWM_CT16B0_CH1_SELECTOR == PWM_CT16B0_CH1_IS_PIO0_12 LPC_IOCON->PIO0_12 = 0x84; #elif LPC122x_PWM_CT16B0_CH1_SELECTOR == PWM_CT16B0_CH1_IS_PIO0_29 LPC_IOCON->PIO0_29 = 0x84; #else /* LPC122x_PWM_CT16B0_CH1_SELECTOR == PWM_CT16B0_CH1_IS_PIO2_1 */ LPC_IOCON->PIO2_1 = 0x83; #endif #endif #endif #if LPC122x_PWM_USE_CT16B1 /* Driver initialization.*/ pwmObjectInit(&PWMD2); PWMD2.tim = LPC_CT16B1; #if LPC122x_PWM_USE_CT16B1_CH0 #if LPC122x_PWM_CT16B1_CH0_SELECTOR == PWM_CT16B1_CH0_IS_PIO0_15 LPC_IOCON->PIO0_15 = 0x84; #elif LPC122x_PWM_CT16B1_CH0_SELECTOR == PWM_CT16B1_CH0_IS_PIO1_5 LPC_IOCON->PIO1_5 = 0x83; #else /* LPC122x_PWM_CT16B1_CH0_SELECTOR == PWM_CT16B1_CH0_IS_PIO2_2 */ LPC_IOCON->PIO2_2 = 0x83; #endif #endif #if LPC122x_PWM_USE_CT16B1_CH1 #if LPC122x_PWM_CT16B1_CH1_SELECTOR == PWM_CT16B1_CH1_IS_PIO0_16 LPC_IOCON->PIO0_16 = 0x84; #elif LPC122x_PWM_CT16B1_CH1_SELECTOR == PWM_CT16B1_CH1_IS_PIO1_6 LPC_IOCON->PIO1_6 = 0x82; #else /* LPC122x_PWM_CT16B1_CH1_SELECTOR == PWM_CT16B1_CH1_IS_PIO2_3 */ LPC_IOCON->PIO2_3 = 0x83; #endif #endif #endif #if LPC122x_PWM_USE_CT32B0 /* Driver initialization.*/ pwmObjectInit(&PWMD3); PWMD3.tim = LPC_CT32B0; #if LPC122x_PWM_USE_CT32B0_CH0 #if LPC122x_PWM_CT32B0_CH0_SELECTOR == PWM_CT32B0_CH0_IS_PIO0_1 LPC_IOCON->PIO0_1 = 0x84; #elif LPC122x_PWM_CT32B0_CH0_SELECTOR == PWM_CT32B0_CH0_IS_PIO0_18 LPC_IOCON->PIO0_18 = 0x84; #else /* LPC122x_PWM_CT32B0_CH0_SELECTOR == PWM_CT32B0_CH0_IS_PIO2_4 */ LPC_IOCON->PIO2_4 = 0x83; #endif #endif #if LPC122x_PWM_USE_CT32B0_CH1 #if LPC122x_PWM_CT32B0_CH1_SELECTOR == PWM_CT32B0_CH1_IS_PIO0_2 LPC_IOCON->PIO0_2 = 0x84; #elif LPC122x_PWM_CT32B0_CH1_SELECTOR == PWM_CT32B0_CH1_IS_PIO0_19 LPC_IOCON->PIO0_19 = 0x84; #else /* LPC122x_PWM_CT32B0_CH1_SELECTOR == PWM_CT32B0_CH1_IS_PIO2_5 */ LPC_IOCON->PIO2_5 = 0x83; #endif #endif #endif #if LPC122x_PWM_USE_CT32B1 /* Driver initialization.*/ pwmObjectInit(&PWMD4); PWMD4.tim = LPC_CT32B1; #if LPC122x_PWM_USE_CT32B1_CH0 #if LPC122x_PWM_CT32B1_CH0_SELECTOR == PWM_CT32B1_CH0_IS_PIO0_6 LPC_IOCON->PIO0_6 = 0x84; #elif LPC122x_PWM_CT32B1_CH0_SELECTOR == PWM_CT32B1_CH0_IS_PIO0_23 LPC_IOCON->PIO0_23 = 0x84; #else /* LPC122x_PWM_CT32B1_CH0_SELECTOR == PWM_CT32B1_CH0_IS_PIO2_8 */ LPC_IOCON->PIO2_8 = 0x83; #endif #endif #if LPC122x_PWM_USE_CT32B1_CH1 #if LPC122x_PWM_CT32B1_CH1_SELECTOR == PWM_CT32B1_CH1_IS_PIO0_7 LPC_IOCON->PIO0_7 = 0x84; #elif LPC122x_PWM_CT32B1_CH1_SELECTOR == PWM_CT32B1_CH1_IS_PIO0_24 LPC_IOCON->PIO0_24 = 0x84; #else /* LPC122x_PWM_CT32B1_CH1_SELECTOR == PWM_CT32B1_CH1_IS_PIO2_9 */ LPC_IOCON->PIO2_9 = 0x83; #endif #endif #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { /* eMIOSx channels initially all not in use.*/ reset_emios_active_channels(); #if SPC5_PWM_USE_EMIOS_CH0 /* Driver initialization.*/ pwmObjectInit(&PWMD1); PWMD1.emiosp = &EMIOS; PWMD1.ch_number = 0U; #endif /* SPC5_PWM_USE_EMIOS_CH0 */ #if SPC5_PWM_USE_EMIOS_CH8 /* Driver initialization.*/ pwmObjectInit(&PWMD2); PWMD2.emiosp = &EMIOS; PWMD2.ch_number = 8U; #endif /* SPC5_PWM_USE_EMIOS_CH8 */ #if SPC5_PWM_USE_EMIOS_CH9 /* Driver initialization.*/ pwmObjectInit(&PWMD3); PWMD3.emiosp = &EMIOS; PWMD3.ch_number = 9U; #endif /* SPC5_PWM_USE_EMIOS_CH9 */ #if SPC5_PWM_USE_EMIOS_CH10 /* Driver initialization.*/ pwmObjectInit(&PWMD4); PWMD4.emiosp = &EMIOS; PWMD4.ch_number = 10U; #endif /* SPC5_PWM_USE_EMIOS_CH10 */ #if SPC5_PWM_USE_EMIOS_CH12 /* Driver initialization.*/ pwmObjectInit(&PWMD5); PWMD5.emiosp = &EMIOS; PWMD5.ch_number = 12U; #endif /* SPC5_PWM_USE_EMIOS_CH12 */ #if SPC5_PWM_USE_EMIOS_CH14 /* Driver initialization.*/ pwmObjectInit(&PWMD6); PWMD6.emiosp = &EMIOS; PWMD6.ch_number = 14U; #endif /* SPC5_PWM_USE_EMIOS_CH14 */ #if SPC5_PWM_USE_EMIOS_CH15 /* Driver initialization.*/ pwmObjectInit(&PWMD7); PWMD7.emiosp = &EMIOS; PWMD7.ch_number = 15U; #endif /* SPC5_PWM_USE_EMIOS_CH15 */ #if SPC5_PWM_USE_EMIOS_CH23 /* Driver initialization.*/ pwmObjectInit(&PWMD8); PWMD8.emiosp = &EMIOS; PWMD8.ch_number = 23U; #endif /* SPC5_PWM_USE_EMIOS_CH23 */ #if SPC5_EMIOS_NUM_CHANNELS == 24 #if SPC5_PWM_USE_EMIOS_CH19 /* Driver initialization.*/ pwmObjectInit(&PWMD9); PWMD9.emiosp = &EMIOS; PWMD9.ch_number = 19U; #endif /* SPC5_PWM_USE_EMIOS_CH19 */ #if SPC5_PWM_USE_EMIOS_CH20 /* Driver initialization.*/ pwmObjectInit(&PWMD10); PWMD10.emiosp = &EMIOS; PWMD10.ch_number = 20U; #endif /* SPC5_PWM_USE_EMIOS_CH20 */ #if SPC5_PWM_USE_EMIOS_CH21 /* Driver initialization.*/ pwmObjectInit(&PWMD11); PWMD11.emiosp = &EMIOS; PWMD11.ch_number = 21U; #endif /* SPC5_PWM_USE_EMIOS_CH21 */ #if SPC5_PWM_USE_EMIOS_CH22 /* Driver initialization.*/ pwmObjectInit(&PWMD12); PWMD12.emiosp = &EMIOS; PWMD12.ch_number = 22U; #endif /* SPC5_PWM_USE_EMIOS_CH22 */ #endif #if SPC5_PWM_USE_EMIOS #if SPC5_EMIOS_NUM_CHANNELS == 16 INTC.PSR[SPC5_EMIOS_FLAG_F0_NUMBER].R = SPC5_EMIOS_FLAG_F0_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F8_NUMBER].R = SPC5_EMIOS_FLAG_F8_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F9_NUMBER].R = SPC5_EMIOS_FLAG_F9_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F10_NUMBER].R = SPC5_EMIOS_FLAG_F10_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F12_NUMBER].R = SPC5_EMIOS_FLAG_F12_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F14_NUMBER].R = SPC5_EMIOS_FLAG_F14_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F15_NUMBER].R = SPC5_EMIOS_FLAG_F15_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F23_NUMBER].R = SPC5_EMIOS_FLAG_F23_PRIORITY; #endif #if SPC5_EMIOS_NUM_CHANNELS == 24 INTC.PSR[SPC5_EMIOS_FLAG_F0_NUMBER].R = SPC5_EMIOS_FLAG_F0_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F8_NUMBER].R = SPC5_EMIOS_FLAG_F8_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F9_NUMBER].R = SPC5_EMIOS_FLAG_F9_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F10_NUMBER].R = SPC5_EMIOS_FLAG_F10_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F12_NUMBER].R = SPC5_EMIOS_FLAG_F12_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F14_NUMBER].R = SPC5_EMIOS_FLAG_F14_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F15_NUMBER].R = SPC5_EMIOS_FLAG_F15_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F19_NUMBER].R = SPC5_EMIOS_FLAG_F19_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F20_NUMBER].R = SPC5_EMIOS_FLAG_F20_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F21_NUMBER].R = SPC5_EMIOS_FLAG_F21_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F22_NUMBER].R = SPC5_EMIOS_FLAG_F22_PRIORITY; INTC.PSR[SPC5_EMIOS_FLAG_F23_NUMBER].R = SPC5_EMIOS_FLAG_F23_PRIORITY; #endif #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { /* FlexPWM initially all not in use.*/ flexpwm_active_submodules0 = 0; flexpwm_active_submodules1 = 0; #if (SPC5_PWM_USE_SMOD0) /* Driver initialization.*/ pwmObjectInit(&PWMD1); PWMD1.flexpwmp = &SPC5_FLEXPWM_0; INTC.PSR[SPC5_FLEXPWM0_RF0_NUMBER].R = SPC5_PWM_SMOD0_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_COF0_NUMBER].R = SPC5_PWM_SMOD0_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_CAF0_NUMBER].R = SPC5_PWM_SMOD0_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_FFLAG_NUMBER].R = SPC5_PWM_SMOD0_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_REF_NUMBER].R = SPC5_PWM_SMOD0_PRIORITY; #endif #if (SPC5_PWM_USE_SMOD1) /* Driver initialization.*/ pwmObjectInit(&PWMD2); PWMD2.flexpwmp = &SPC5_FLEXPWM_0; INTC.PSR[SPC5_FLEXPWM0_RF1_NUMBER].R = SPC5_PWM_SMOD1_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_COF1_NUMBER].R = SPC5_PWM_SMOD1_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_CAF1_NUMBER].R = SPC5_PWM_SMOD1_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_FFLAG_NUMBER].R = SPC5_PWM_SMOD1_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_REF_NUMBER].R = SPC5_PWM_SMOD1_PRIORITY; #endif #if (SPC5_PWM_USE_SMOD2) /* Driver initialization.*/ pwmObjectInit(&PWMD3); PWMD3.flexpwmp = &SPC5_FLEXPWM_0; INTC.PSR[SPC5_FLEXPWM0_RF2_NUMBER].R = SPC5_PWM_SMOD2_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_COF2_NUMBER].R = SPC5_PWM_SMOD2_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_CAF2_NUMBER].R = SPC5_PWM_SMOD2_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_FFLAG_NUMBER].R = SPC5_PWM_SMOD2_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_REF_NUMBER].R = SPC5_PWM_SMOD2_PRIORITY; #endif #if (SPC5_PWM_USE_SMOD3) /* Driver initialization.*/ pwmObjectInit(&PWMD4); PWMD4.flexpwmp = &SPC5_FLEXPWM_0; INTC.PSR[SPC5_FLEXPWM0_RF3_NUMBER].R = SPC5_PWM_SMOD3_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_COF3_NUMBER].R = SPC5_PWM_SMOD3_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_CAF3_NUMBER].R = SPC5_PWM_SMOD3_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_FFLAG_NUMBER].R = SPC5_PWM_SMOD3_PRIORITY; INTC.PSR[SPC5_FLEXPWM0_REF_NUMBER].R = SPC5_PWM_SMOD3_PRIORITY; #endif #if (SPC5_PWM_USE_SMOD4) /* Driver initialization.*/ pwmObjectInit(&PWMD5); PWMD5.flexpwmp = &SPC5_FLEXPWM_1; INTC.PSR[SPC5_FLEXPWM1_RF0_NUMBER].R = SPC5_PWM_SMOD4_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_COF0_NUMBER].R = SPC5_PWM_SMOD4_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_CAF0_NUMBER].R = SPC5_PWM_SMOD4_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_FFLAG_NUMBER].R = SPC5_PWM_SMOD4_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_REF_NUMBER].R = SPC5_PWM_SMOD4_PRIORITY; #endif #if (SPC5_PWM_USE_SMOD5) /* Driver initialization.*/ pwmObjectInit(&PWMD6); PWMD6.flexpwmp = &SPC5_FLEXPWM_1; INTC.PSR[SPC5_FLEXPWM1_RF1_NUMBER].R = SPC5_PWM_SMOD5_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_COF1_NUMBER].R = SPC5_PWM_SMOD5_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_CAF1_NUMBER].R = SPC5_PWM_SMOD5_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_FFLAG_NUMBER].R = SPC5_PWM_SMOD5_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_REF_NUMBER].R = SPC5_PWM_SMOD5_PRIORITY; #endif #if (SPC5_PWM_USE_SMOD6) /* Driver initialization.*/ pwmObjectInit(&PWMD7); PWMD7.flexpwmp = &SPC5_FLEXPWM_1; INTC.PSR[SPC5_FLEXPWM1_RF2_NUMBER].R = SPC5_PWM_SMOD6_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_COF2_NUMBER].R = SPC5_PWM_SMOD6_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_CAF2_NUMBER].R = SPC5_PWM_SMOD6_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_FFLAG_NUMBER].R = SPC5_PWM_SMOD6_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_REF_NUMBER].R = SPC5_PWM_SMOD6_PRIORITY; #endif #if (SPC5_PWM_USE_SMOD7) /* Driver initialization.*/ pwmObjectInit(&PWMD8); PWMD8.flexpwmp = &SPC5_FLEXPWM_1; INTC.PSR[SPC5_FLEXPWM1_RF3_NUMBER].R = SPC5_PWM_SMOD7_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_COF3_NUMBER].R = SPC5_PWM_SMOD7_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_CAF3_NUMBER].R = SPC5_PWM_SMOD7_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_FFLAG_NUMBER].R = SPC5_PWM_SMOD7_PRIORITY; INTC.PSR[SPC5_FLEXPWM1_REF_NUMBER].R = SPC5_PWM_SMOD7_PRIORITY; #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { /* eMIOSx channels initially all not in use.*/ reset_emios_active_channels(); #if SPC5_PWM_USE_EMIOS_CH0 /* Driver initialization.*/ pwmObjectInit(&PWMD1); PWMD1.emiosp = &EMIOS; PWMD1.ch_number = 0U; #endif /* SPC5_PWM_USE_EMIOS_CH0 */ #if SPC5_PWM_USE_EMIOS_CH1 /* Driver initialization.*/ pwmObjectInit(&PWMD2); PWMD2.emiosp = &EMIOS; PWMD2.ch_number = 1U; #endif /* SPC5_PWM_USE_EMIOS_CH1 */ #if SPC5_PWM_USE_EMIOS_CH2 /* Driver initialization.*/ pwmObjectInit(&PWMD3); PWMD3.emiosp = &EMIOS; PWMD3.ch_number = 2U; #endif /* SPC5_PWM_USE_EMIOS_CH2 */ #if SPC5_PWM_USE_EMIOS_CH3 /* Driver initialization.*/ pwmObjectInit(&PWMD4); PWMD4.emiosp = &EMIOS; PWMD4.ch_number = 3U; #endif /* SPC5_PWM_USE_EMIOS_CH3 */ #if SPC5_PWM_USE_EMIOS_CH4 /* Driver initialization.*/ pwmObjectInit(&PWMD5); PWMD5.emiosp = &EMIOS; PWMD5.ch_number = 4U; #endif /* SPC5_PWM_USE_EMIOS_CH4 */ #if SPC5_PWM_USE_EMIOS_CH5 /* Driver initialization.*/ pwmObjectInit(&PWMD6); PWMD6.emiosp = &EMIOS; PWMD6.ch_number = 5U; #endif /* SPC5_PWM_USE_EMIOS_CH5 */ #if SPC5_PWM_USE_EMIOS_CH6 /* Driver initialization.*/ pwmObjectInit(&PWMD7); PWMD7.emiosp = &EMIOS; PWMD7.ch_number = 6U; #endif /* SPC5_PWM_USE_EMIOS_CH6 */ #if SPC5_PWM_USE_EMIOS_CH7 /* Driver initialization.*/ pwmObjectInit(&PWMD8); PWMD8.emiosp = &EMIOS; PWMD8.ch_number = 7U; #endif /* SPC5_PWM_USE_EMIOS_CH7 */ #if SPC5_PWM_USE_EMIOS_CH8 /* Driver initialization.*/ pwmObjectInit(&PWMD9); PWMD9.emiosp = &EMIOS; PWMD9.ch_number = 8U; #endif /* SPC5_PWM_USE_EMIOS_CH8 */ #if SPC5_PWM_USE_EMIOS_CH9 /* Driver initialization.*/ pwmObjectInit(&PWMD10); PWMD10.emiosp = &EMIOS; PWMD10.ch_number = 9U; #endif /* SPC5_PWM_USE_EMIOS_CH9 */ #if SPC5_PWM_USE_EMIOS_CH10 /* Driver initialization.*/ pwmObjectInit(&PWMD11); PWMD11.emiosp = &EMIOS; PWMD11.ch_number = 10U; #endif /* SPC5_PWM_USE_EMIOS_CH10 */ #if SPC5_PWM_USE_EMIOS_CH11 /* Driver initialization.*/ pwmObjectInit(&PWMD12); PWMD12.emiosp = &EMIOS; PWMD12.ch_number = 11U; #endif /* SPC5_PWM_USE_EMIOS_CH11 */ #if SPC5_PWM_USE_EMIOS_CH12 /* Driver initialization.*/ pwmObjectInit(&PWMD13); PWMD13.emiosp = &EMIOS; PWMD13.ch_number = 12U; #endif /* SPC5_PWM_USE_EMIOS_CH12 */ #if SPC5_PWM_USE_EMIOS_CH13 /* Driver initialization.*/ pwmObjectInit(&PWMD14); PWMD14.emiosp = &EMIOS; PWMD14.ch_number = 13U; #endif /* SPC5_PWM_USE_EMIOS_CH13 */ #if SPC5_PWM_USE_EMIOS_CH14 /* Driver initialization.*/ pwmObjectInit(&PWMD15); PWMD15.emiosp = &EMIOS; PWMD15.ch_number = 14U; #endif /* SPC5_PWM_USE_EMIOS_CH14 */ #if SPC5_PWM_USE_EMIOS_CH15 /* Driver initialization.*/ pwmObjectInit(&PWMD16); PWMD16.emiosp = &EMIOS; PWMD16.ch_number = 15U; #endif /* SPC5_PWM_USE_EMIOS_CH15 */ #if SPC5_PWM_USE_EMIOS_CH16 /* Driver initialization.*/ pwmObjectInit(&PWMD17); PWMD17.emiosp = &EMIOS; PWMD17.ch_number = 16U; #endif /* SPC5_PWM_USE_EMIOS_CH16 */ #if SPC5_PWM_USE_EMIOS_CH17 /* Driver initialization.*/ pwmObjectInit(&PWMD18); PWMD18.emiosp = &EMIOS; PWMD18.ch_number = 17U; #endif /* SPC5_PWM_USE_EMIOS_CH17 */ #if SPC5_PWM_USE_EMIOS_CH18 /* Driver initialization.*/ pwmObjectInit(&PWMD19); PWMD19.emiosp = &EMIOS; PWMD19.ch_number = 18U; #endif /* SPC5_PWM_USE_EMIOS_CH18 */ #if SPC5_PWM_USE_EMIOS_CH19 /* Driver initialization.*/ pwmObjectInit(&PWMD20); PWMD20.emiosp = &EMIOS; PWMD20.ch_number = 19U; #endif /* SPC5_PWM_USE_EMIOS_CH19 */ #if SPC5_PWM_USE_EMIOS_CH20 /* Driver initialization.*/ pwmObjectInit(&PWMD21); PWMD21.emiosp = &EMIOS; PWMD21.ch_number = 20U; #endif /* SPC5_PWM_USE_EMIOS_CH20 */ #if SPC5_PWM_USE_EMIOS_CH21 /* Driver initialization.*/ pwmObjectInit(&PWMD22); PWMD22.emiosp = &EMIOS; PWMD22.ch_number = 21U; #endif /* SPC5_PWM_USE_EMIOS_CH21 */ #if SPC5_PWM_USE_EMIOS_CH22 /* Driver initialization.*/ pwmObjectInit(&PWMD23); PWMD23.emiosp = &EMIOS; PWMD23.ch_number = 22U; #endif /* SPC5_PWM_USE_EMIOS_CH22 */ #if SPC5_PWM_USE_EMIOS_CH23 /* Driver initialization.*/ pwmObjectInit(&PWMD24); PWMD24.emiosp = &EMIOS; PWMD24.ch_number = 23U; #endif /* SPC5_PWM_USE_EMIOS_CH23 */ #if SPC5_PWM_USE_EMIOS #if SPC5_PWM_USE_EMIOS_CH0 INTC.PSR[SPC5_EMIOS_FLAG_F0_NUMBER].R = SPC5_EMIOS_FLAG_F0_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH0 */ #if SPC5_PWM_USE_EMIOS_CH1 INTC.PSR[SPC5_EMIOS_FLAG_F1_NUMBER].R = SPC5_EMIOS_FLAG_F1_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH1 */ #if SPC5_PWM_USE_EMIOS_CH2 INTC.PSR[SPC5_EMIOS_FLAG_F2_NUMBER].R = SPC5_EMIOS_FLAG_F2_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH2 */ #if SPC5_PWM_USE_EMIOS_CH3 INTC.PSR[SPC5_EMIOS_FLAG_F3_NUMBER].R = SPC5_EMIOS_FLAG_F3_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH3 */ #if SPC5_PWM_USE_EMIOS_CH4 INTC.PSR[SPC5_EMIOS_FLAG_F4_NUMBER].R = SPC5_EMIOS_FLAG_F4_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH4 */ #if SPC5_PWM_USE_EMIOS_CH5 INTC.PSR[SPC5_EMIOS_FLAG_F5_NUMBER].R = SPC5_EMIOS_FLAG_F5_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH5 */ #if SPC5_PWM_USE_EMIOS_CH6 INTC.PSR[SPC5_EMIOS_FLAG_F6_NUMBER].R = SPC5_EMIOS_FLAG_F6_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH6 */ #if SPC5_PWM_USE_EMIOS_CH7 INTC.PSR[SPC5_EMIOS_FLAG_F7_NUMBER].R = SPC5_EMIOS_FLAG_F7_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH7 */ #if SPC5_PWM_USE_EMIOS_CH8 INTC.PSR[SPC5_EMIOS_FLAG_F8_NUMBER].R = SPC5_EMIOS_FLAG_F8_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH8 */ #if SPC5_PWM_USE_EMIOS_CH9 INTC.PSR[SPC5_EMIOS_FLAG_F9_NUMBER].R = SPC5_EMIOS_FLAG_F9_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH9 */ #if SPC5_PWM_USE_EMIOS_CH10 INTC.PSR[SPC5_EMIOS_FLAG_F10_NUMBER].R = SPC5_EMIOS_FLAG_F10_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH10 */ #if SPC5_PWM_USE_EMIOS_CH11 INTC.PSR[SPC5_EMIOS_FLAG_F11_NUMBER].R = SPC5_EMIOS_FLAG_F11_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH11 */ #if SPC5_PWM_USE_EMIOS_CH12 INTC.PSR[SPC5_EMIOS_FLAG_F12_NUMBER].R = SPC5_EMIOS_FLAG_F12_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH12 */ #if SPC5_PWM_USE_EMIOS_CH13 INTC.PSR[SPC5_EMIOS_FLAG_F13_NUMBER].R = SPC5_EMIOS_FLAG_F13_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH13 */ #if SPC5_PWM_USE_EMIOS_CH14 INTC.PSR[SPC5_EMIOS_FLAG_F14_NUMBER].R = SPC5_EMIOS_FLAG_F14_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH14 */ #if SPC5_PWM_USE_EMIOS_CH15 INTC.PSR[SPC5_EMIOS_FLAG_F15_NUMBER].R = SPC5_EMIOS_FLAG_F15_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH15 */ #if SPC5_PWM_USE_EMIOS_CH16 INTC.PSR[SPC5_EMIOS_FLAG_F16_NUMBER].R = SPC5_EMIOS_FLAG_F16_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH16 */ #if SPC5_PWM_USE_EMIOS_CH17 INTC.PSR[SPC5_EMIOS_FLAG_F17_NUMBER].R = SPC5_EMIOS_FLAG_F17_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH17 */ #if SPC5_PWM_USE_EMIOS_CH18 INTC.PSR[SPC5_EMIOS_FLAG_F18_NUMBER].R = SPC5_EMIOS_FLAG_F18_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH18 */ #if SPC5_PWM_USE_EMIOS_CH19 INTC.PSR[SPC5_EMIOS_FLAG_F19_NUMBER].R = SPC5_EMIOS_FLAG_F19_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH19 */ #if SPC5_PWM_USE_EMIOS_CH20 INTC.PSR[SPC5_EMIOS_FLAG_F20_NUMBER].R = SPC5_EMIOS_FLAG_F20_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH20 */ #if SPC5_PWM_USE_EMIOS_CH21 INTC.PSR[SPC5_EMIOS_FLAG_F21_NUMBER].R = SPC5_EMIOS_FLAG_F21_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH21 */ #if SPC5_PWM_USE_EMIOS_CH22 INTC.PSR[SPC5_EMIOS_FLAG_F22_NUMBER].R = SPC5_EMIOS_FLAG_F22_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH22 */ #if SPC5_PWM_USE_EMIOS_CH23 INTC.PSR[SPC5_EMIOS_FLAG_F23_NUMBER].R = SPC5_EMIOS_FLAG_F23_PRIORITY; #endif /* SPC5_PWM_USE_EMIOS_CH23 */ #endif }
/** * @brief Low level PWM driver initialization. * * @notapi */ void pwm_lld_init(void) { pwmObjectInit(&PWMD1); }