From 53b499637980ee6a4f0061dbb216e3becc8934c4 Mon Sep 17 00:00:00 2001 From: Henry Zhang Date: Fri, 21 Oct 2016 15:54:56 +0800 Subject: [PATCH] MindPX: Use TIM14 CH1 for tone alarm output. --- src/drivers/boards/mindpx-v2/board_config.h | 6 ++--- src/drivers/stm32/tone_alarm/tone_alarm.cpp | 26 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/drivers/boards/mindpx-v2/board_config.h b/src/drivers/boards/mindpx-v2/board_config.h index 54da4c41c5..bf1bdd51f0 100644 --- a/src/drivers/boards/mindpx-v2/board_config.h +++ b/src/drivers/boards/mindpx-v2/board_config.h @@ -229,10 +229,10 @@ //#define GPIO_VDD_5V_PERIPH_OC (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN15) /* Tone alarm output */ -#define TONE_ALARM_TIMER 2 /* timer 2 */ +#define TONE_ALARM_TIMER 14 /* timer 14 */ #define TONE_ALARM_CHANNEL 1 /* channel 1 */ -#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) +#define GPIO_TONE_ALARM_IDLE (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN7) +#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF9|GPIO_SPEED_2MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN7) /* PWM * diff --git a/src/drivers/stm32/tone_alarm/tone_alarm.cpp b/src/drivers/stm32/tone_alarm/tone_alarm.cpp index 7540c6be17..d4732f5b01 100644 --- a/src/drivers/stm32/tone_alarm/tone_alarm.cpp +++ b/src/drivers/stm32/tone_alarm/tone_alarm.cpp @@ -198,8 +198,32 @@ # ifdef CONFIG_STM32_TIM11 # error Must not set CONFIG_STM32_TIM11 when TONE_ALARM_TIMER is 11 # endif +#elif TONE_ALARM_TIMER == 12 +# define TONE_ALARM_BASE STM32_TIM12_BASE +# define TONE_ALARM_CLOCK STM32_APB1_TIM12_CLKIN +# define TONE_ALARM_CLOCK_POWER_REG STM32_RCC_APB1ENR +# define TONE_ALARM_CLOCK_ENABLE RCC_APB1ENR_TIM12EN +# ifdef CONFIG_STM32_TIM12 +# error Must not set CONFIG_STM32_TIM12 when TONE_ALARM_TIMER is 12 +# endif +#elif TONE_ALARM_TIMER == 13 +# define TONE_ALARM_BASE STM32_TIM13_BASE +# define TONE_ALARM_CLOCK STM32_APB1_TIM12_CLKIN +# define TONE_ALARM_CLOCK_POWER_REG STM32_RCC_APB1ENR +# define TONE_ALARM_CLOCK_ENABLE RCC_APB1ENR_TIM13EN +# ifdef CONFIG_STM32_TIM13 +# error Must not set CONFIG_STM32_TIM13 when TONE_ALARM_TIMER is 13 +# endif +#elif TONE_ALARM_TIMER == 14 +# define TONE_ALARM_BASE STM32_TIM14_BASE +# define TONE_ALARM_CLOCK STM32_APB1_TIM12_CLKIN +# define TONE_ALARM_CLOCK_POWER_REG STM32_RCC_APB1ENR +# define TONE_ALARM_CLOCK_ENABLE RCC_APB1ENR_TIM14EN +# ifdef CONFIG_STM32_TIM14 +# error Must not set CONFIG_STM32_TIM14 when TONE_ALARM_TIMER is 14 +# endif #else -# error Must set TONE_ALARM_TIMER to one of the timers between 1 and 11 (inclusive) to use this driver. +# error Must set TONE_ALARM_TIMER to one of the timers between 1 and 14 (inclusive) to use this driver. #endif #if TONE_ALARM_CHANNEL == 1