mirror of https://github.com/rusefi/ChibiOS.git
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5437 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
f0b4615ece
commit
9f9d400604
|
@ -38,7 +38,7 @@ static PWMConfig pwmcfg = {
|
||||||
10000, /* Initial PWM period 1S. */
|
10000, /* Initial PWM period 1S. */
|
||||||
pwmpcb,
|
pwmpcb,
|
||||||
{
|
{
|
||||||
{PWM_OUTPUT_ACTIVE_HIGH, pwmc1cb},
|
{PWM_OUTPUT_ACTIVE_LOW, pwmc1cb},
|
||||||
{PWM_OUTPUT_DISABLED, NULL},
|
{PWM_OUTPUT_DISABLED, NULL},
|
||||||
{PWM_OUTPUT_DISABLED, NULL},
|
{PWM_OUTPUT_DISABLED, NULL},
|
||||||
{PWM_OUTPUT_DISABLED, NULL}
|
{PWM_OUTPUT_DISABLED, NULL}
|
||||||
|
@ -61,7 +61,7 @@ static void icuperiodcb(ICUDriver *icup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static ICUConfig icucfg = {
|
static ICUConfig icucfg = {
|
||||||
ICU_INPUT_ACTIVE_HIGH,
|
ICU_INPUT_ACTIVE_LOW,
|
||||||
10000, /* 10kHz ICU clock frequency. */
|
10000, /* 10kHz ICU clock frequency. */
|
||||||
icuwidthcb,
|
icuwidthcb,
|
||||||
icuperiodcb,
|
icuperiodcb,
|
||||||
|
@ -85,13 +85,13 @@ int main(void) {
|
||||||
chSysInit();
|
chSysInit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initializes the PWM driver 2 and ICU driver 3.
|
* Initializes the PWM driver 5 and ICU driver 3.
|
||||||
* GPIOA15 is the PWM output.
|
* GPIOC0 is the PWM output.
|
||||||
* GPIOC6 is the ICU input.
|
* GPIOC6 is the ICU input.
|
||||||
* The two pins have to be externally connected together.
|
* The two pins have to be externally connected together.
|
||||||
*/
|
*/
|
||||||
pwmStart(&PWMD2, &pwmcfg);
|
pwmStart(&PWMD5, &pwmcfg);
|
||||||
palSetPadMode(GPIOA, 15, PAL_MODE_ALTERNATE(1));
|
palSetPadMode(GPIOC, 0, PAL_MODE_ALTERNATE(2));
|
||||||
icuStart(&ICUD3, &icucfg);
|
icuStart(&ICUD3, &icucfg);
|
||||||
palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2));
|
palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2));
|
||||||
icuEnable(&ICUD3);
|
icuEnable(&ICUD3);
|
||||||
|
@ -100,37 +100,35 @@ int main(void) {
|
||||||
/*
|
/*
|
||||||
* Starts the PWM channel 0 using 75% duty cycle.
|
* Starts the PWM channel 0 using 75% duty cycle.
|
||||||
*/
|
*/
|
||||||
pwmEnableChannel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 7500));
|
pwmEnableChannel(&PWMD5, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD5, 7500));
|
||||||
chThdSleepMilliseconds(5000);
|
chThdSleepMilliseconds(5000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Changes the PWM channel 0 to 50% duty cycle.
|
* Changes the PWM channel 0 to 50% duty cycle.
|
||||||
*/
|
*/
|
||||||
pwmEnableChannel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 5000));
|
pwmEnableChannel(&PWMD5, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD5, 5000));
|
||||||
chThdSleepMilliseconds(5000);
|
chThdSleepMilliseconds(5000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Changes the PWM channel 0 to 25% duty cycle.
|
* Changes the PWM channel 0 to 25% duty cycle.
|
||||||
*/
|
*/
|
||||||
pwmEnableChannel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 2500));
|
pwmEnableChannel(&PWMD5, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD5, 2500));
|
||||||
chThdSleepMilliseconds(5000);
|
chThdSleepMilliseconds(5000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Changes PWM period to half second the duty cycle becomes 50%
|
* Changes PWM period to half second the duty cycle becomes 50%
|
||||||
* implicitly.
|
* implicitly.
|
||||||
*/
|
*/
|
||||||
pwmChangePeriod(&PWMD2, 5000);
|
pwmChangePeriod(&PWMD5, 5000);
|
||||||
chThdSleepMilliseconds(5000);
|
chThdSleepMilliseconds(5000);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disables channel 0 and stops the drivers.
|
* Disables channel 0 and stops the drivers.
|
||||||
*/
|
*/
|
||||||
pwmDisableChannel(&PWMD2, 0);
|
pwmDisableChannel(&PWMD5, 0);
|
||||||
pwmStop(&PWMD2);
|
pwmStop(&PWMD5);
|
||||||
icuDisable(&ICUD3);
|
icuDisable(&ICUD3);
|
||||||
icuStop(&ICUD3);
|
icuStop(&ICUD3);
|
||||||
palClearPad(GPIOC, GPIOC_LED1);
|
|
||||||
palClearPad(GPIOC, GPIOC_LED2);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normal main() thread activity, in this demo it does nothing.
|
* Normal main() thread activity, in this demo it does nothing.
|
||||||
|
|
|
@ -104,7 +104,7 @@
|
||||||
#define STM32_ICU_USE_TIM2 FALSE
|
#define STM32_ICU_USE_TIM2 FALSE
|
||||||
#define STM32_ICU_USE_TIM3 TRUE
|
#define STM32_ICU_USE_TIM3 TRUE
|
||||||
#define STM32_ICU_USE_TIM4 TRUE
|
#define STM32_ICU_USE_TIM4 TRUE
|
||||||
#define STM32_ICU_USE_TIM5 TRUE
|
#define STM32_ICU_USE_TIM5 FALSE
|
||||||
#define STM32_ICU_TIM2_IRQ_PRIORITY 7
|
#define STM32_ICU_TIM2_IRQ_PRIORITY 7
|
||||||
#define STM32_ICU_TIM3_IRQ_PRIORITY 7
|
#define STM32_ICU_TIM3_IRQ_PRIORITY 7
|
||||||
#define STM32_ICU_TIM4_IRQ_PRIORITY 7
|
#define STM32_ICU_TIM4_IRQ_PRIORITY 7
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
#define STM32_PWM_USE_TIM2 TRUE
|
#define STM32_PWM_USE_TIM2 TRUE
|
||||||
#define STM32_PWM_USE_TIM3 FALSE
|
#define STM32_PWM_USE_TIM3 FALSE
|
||||||
#define STM32_PWM_USE_TIM4 FALSE
|
#define STM32_PWM_USE_TIM4 FALSE
|
||||||
#define STM32_PWM_USE_TIM5 FALSE
|
#define STM32_PWM_USE_TIM5 TRUE
|
||||||
#define STM32_PWM_TIM2_IRQ_PRIORITY 7
|
#define STM32_PWM_TIM2_IRQ_PRIORITY 7
|
||||||
#define STM32_PWM_TIM3_IRQ_PRIORITY 7
|
#define STM32_PWM_TIM3_IRQ_PRIORITY 7
|
||||||
#define STM32_PWM_TIM4_IRQ_PRIORITY 7
|
#define STM32_PWM_TIM4_IRQ_PRIORITY 7
|
||||||
|
|
|
@ -12,7 +12,7 @@ The demo runs on an STMicroelectronics STM32373C-EVAL board.
|
||||||
|
|
||||||
** Board Setup **
|
** Board Setup **
|
||||||
|
|
||||||
- Connect PA15 and PC6 together.
|
- Connect PC0 and PC6 together.
|
||||||
|
|
||||||
** Build Procedure **
|
** Build Procedure **
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue