mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
Fix the way that tone_alarm idles the GPIO and make it idle safely for v2 boards.
This commit is contained in:
@@ -494,7 +494,7 @@ ToneAlarm::init()
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* configure the GPIO to the idle state */
|
/* configure the GPIO to the idle state */
|
||||||
stm32_configgpio(GPIO_TONE_ALARM);
|
stm32_configgpio(GPIO_TONE_ALARM_IDLE);
|
||||||
|
|
||||||
/* clock/power on our timer */
|
/* clock/power on our timer */
|
||||||
modifyreg32(STM32_RCC_APB1ENR, 0, TONE_ALARM_CLOCK_ENABLE);
|
modifyreg32(STM32_RCC_APB1ENR, 0, TONE_ALARM_CLOCK_ENABLE);
|
||||||
@@ -606,6 +606,8 @@ ToneAlarm::start_note(unsigned note)
|
|||||||
rEGR = GTIM_EGR_UG; // force a reload of the period
|
rEGR = GTIM_EGR_UG; // force a reload of the period
|
||||||
rCCER |= TONE_CCER; // enable the output
|
rCCER |= TONE_CCER; // enable the output
|
||||||
|
|
||||||
|
// configure the GPIO to enable timer output
|
||||||
|
stm32_configgpio(GPIO_TONE_ALARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -616,10 +618,8 @@ ToneAlarm::stop_note()
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the GPIO is not driving the speaker.
|
* Make sure the GPIO is not driving the speaker.
|
||||||
*
|
|
||||||
* XXX this presumes PX4FMU and the onboard speaker driver FET.
|
|
||||||
*/
|
*/
|
||||||
stm32_gpiowrite(GPIO_TONE_ALARM, 0);
|
stm32_configgpio(GPIO_TONE_ALARM_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -326,6 +326,7 @@
|
|||||||
*/
|
*/
|
||||||
#define TONE_ALARM_TIMER 3 /* timer 3 */
|
#define TONE_ALARM_TIMER 3 /* timer 3 */
|
||||||
#define TONE_ALARM_CHANNEL 3 /* channel 3 */
|
#define TONE_ALARM_CHANNEL 3 /* channel 3 */
|
||||||
|
#define GPIO_TONE_ALARM_IDLE (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN8)
|
||||||
#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF2|GPIO_SPEED_2MHz|GPIO_FLOAT|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN8)
|
#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF2|GPIO_SPEED_2MHz|GPIO_FLOAT|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN8)
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
|||||||
@@ -311,7 +311,8 @@
|
|||||||
*/
|
*/
|
||||||
#define TONE_ALARM_TIMER 2 /* timer 2 */
|
#define TONE_ALARM_TIMER 2 /* timer 2 */
|
||||||
#define TONE_ALARM_CHANNEL 1 /* channel 1 */
|
#define TONE_ALARM_CHANNEL 1 /* channel 1 */
|
||||||
#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF1|GPIO_SPEED_2MHz|GPIO_FLOAT|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN15)
|
#define GPIO_TONE_ALARM_IDLE (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN15)
|
||||||
|
#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF1|GPIO_SPEED_2MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN15)
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
|
|||||||
Reference in New Issue
Block a user