Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit751aee4

Browse files
committed
Make TIMER_TONE and TIMER_SERVO definitions optional
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parentb10696d commit751aee4

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

‎cores/arduino/stm32/timer.c‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,14 @@ void TimerPinInit(stimer_t *obj, uint32_t frequency, uint32_t duration)
587587
return;
588588
}
589589

590-
obj->timer=TIMER_TONE;
590+
if (obj->timer==NULL) {
591+
#ifdefTIMER_TONE
592+
obj->timer=TIMER_TONE;
593+
#else
594+
return;
595+
#endif
596+
}
597+
591598
obj->pinInfo.state=0;
592599

593600
if (frequency==0) {
@@ -635,8 +642,10 @@ void TimerPinInit(stimer_t *obj, uint32_t frequency, uint32_t duration)
635642
*/
636643
voidTimerPinDeinit(stimer_t*obj)
637644
{
638-
TimerHandleDeinit(obj);
639-
pin_function(obj->pin,STM_PIN_DATA(STM_MODE_INPUT,GPIO_NOPULL,0));
645+
if (obj->timer!=NULL) {
646+
TimerHandleDeinit(obj);
647+
pin_function(obj->pin,STM_PIN_DATA(STM_MODE_INPUT,GPIO_NOPULL,0));
648+
}
640649
}
641650

642651
/**
@@ -652,7 +661,11 @@ void TimerPulseInit(stimer_t *obj, uint16_t period, uint16_t pulseWidth, void (*
652661
TIM_HandleTypeDef*handle=&(obj->handle);
653662

654663
if (obj->timer==NULL) {
664+
#ifdefTIMER_SERVO
655665
obj->timer=TIMER_SERVO;
666+
#else
667+
return;
668+
#endif
656669
}
657670

658671
//min pulse = 1us - max pulse = 65535us
@@ -683,13 +696,15 @@ void TimerPulseDeinit(stimer_t *obj)
683696
obj->irqHandleOC_CH3=NULL;
684697
obj->irqHandleOC_CH4=NULL;
685698

686-
HAL_NVIC_DisableIRQ(getTimerIrq(obj->timer));
699+
if (obj->timer!=NULL) {
700+
HAL_NVIC_DisableIRQ(getTimerIrq(obj->timer));
687701

688-
if (HAL_TIM_OC_DeInit(handle)!=HAL_OK) {
689-
return;
690-
}
691-
if (HAL_TIM_OC_Stop_IT(handle,TIM_CHANNEL_1)!=HAL_OK) {
692-
return;
702+
if (HAL_TIM_OC_DeInit(handle)!=HAL_OK) {
703+
return;
704+
}
705+
if (HAL_TIM_OC_Stop_IT(handle,TIM_CHANNEL_1)!=HAL_OK) {
706+
return;
707+
}
693708
}
694709
}
695710

‎variants/board_template/variant.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ extern "C" {
113113
//#define PIN_WIRE_SDA 14 // Default for Arduino connector compatibility
114114
//#define PIN_WIRE_SCL 15 // Default for Arduino connector compatibility
115115

116-
// Timer Definitions
116+
// Timer Definitions (optional)
117117
//Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
118118
#defineTIMER_TONE TIMx
119119

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp