This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e65d54  Add OUTTOGGLE mode to STM32H7 timer driver (#541)
4e65d54 is described below

commit 4e65d543d869b9236dc86d20f1b21bd8c6a91458
Author: Andrey Zabolotnyi <[email protected]>
AuthorDate: Wed Mar 11 15:18:43 2020 +0300

    Add OUTTOGGLE mode to STM32H7 timer driver (#541)
    
    * stm32h7: New timer output mode STM32_TIM_CH_OUTTOGGLE.
    In this mode timer generates a square waveform on given timer channel.
    The maximal waveform freq is timer clock divided by 4 (prescaler 1, period 
1 results in 2 clocks '0' and 2 clocks '1').
    
    * stm32_tim.h styling fixes.
---
 arch/arm/src/stm32h7/stm32_tim.c | 5 +++++
 arch/arm/src/stm32h7/stm32_tim.h | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/src/stm32h7/stm32_tim.c b/arch/arm/src/stm32h7/stm32_tim.c
index 6761cfd..464d1f6 100644
--- a/arch/arm/src/stm32h7/stm32_tim.c
+++ b/arch/arm/src/stm32h7/stm32_tim.c
@@ -904,6 +904,11 @@ static int stm32_tim_setchannel(FAR struct stm32_tim_dev_s 
*dev,
       case STM32_TIM_CH_DISABLED:
         break;
 
+      case STM32_TIM_CH_OUTTOGGLE:
+        ccmr_val  = (ATIM_CCMR_MODE_OCREFTOG << ATIM_CCMR1_OC1M_SHIFT);
+        ccer_val |= ATIM_CCER_CC1E << (channel << 2);
+        break;
+
       case STM32_TIM_CH_OUTPWM:
         ccmr_val  = (ATIM_CCMR_MODE_PWM1 << ATIM_CCMR1_OC1M_SHIFT) +
                     ATIM_CCMR1_OC1PE;
diff --git a/arch/arm/src/stm32h7/stm32_tim.h b/arch/arm/src/stm32h7/stm32_tim.h
index ab935cd..f1b3a99 100644
--- a/arch/arm/src/stm32h7/stm32_tim.h
+++ b/arch/arm/src/stm32h7/stm32_tim.h
@@ -137,11 +137,12 @@ typedef enum
 
   /* MODES: */
 
-  STM32_TIM_CH_MODE_MASK      = 0x06,
+  STM32_TIM_CH_MODE_MASK      = 0x0e,
 
   /* Output Compare Modes */
 
   STM32_TIM_CH_OUTPWM         = 0x04,    /* Enable standard PWM mode, active 
high when counter < compare */
+  STM32_TIM_CH_OUTTOGGLE      = 0x08,    /* Toggle TIM_CHx output on UEV */
 #if 0
   STM32_TIM_CH_OUTCOMPARE     = 0x06,
 
@@ -181,7 +182,7 @@ struct stm32_tim_ops_s
 };
 
 /****************************************************************************
- * Public Functions
+ * Public Function Prototypes
  ****************************************************************************/
 
 /* Power-up timer and get its structure */

Reply via email to