summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/stm32/stm32_tim.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-17 00:21:10 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-17 00:21:10 +0000
commit92fa94abca72e56d10118754de5c419f392d6d5f (patch)
treeeb43fad1ef29effb3c92d57325fb5b5b550ef898 /nuttx/arch/arm/src/stm32/stm32_tim.c
parentca08ac22269b1fe54d9d959d5facf27e6ca322b5 (diff)
downloadpx4-nuttx-92fa94abca72e56d10118754de5c419f392d6d5f.tar.gz
px4-nuttx-92fa94abca72e56d10118754de5c419f392d6d5f.tar.bz2
px4-nuttx-92fa94abca72e56d10118754de5c419f392d6d5f.zip
STM32 ADC update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4194 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32_tim.c')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_tim.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_tim.c b/nuttx/arch/arm/src/stm32/stm32_tim.c
index e25f02df4..55e59ceaf 100644
--- a/nuttx/arch/arm/src/stm32/stm32_tim.c
+++ b/nuttx/arch/arm/src/stm32/stm32_tim.c
@@ -87,43 +87,43 @@
#if defined(CONFIG_STM32_TIM1_PWM) || defined (CONFIG_STM32_TIM1_ADC) || defined(CONFIG_STM32_TIM1_DAC)
# undef CONFIG_STM32_TIM1
#endif
-#if defined(CONFIG_STM32_TIM2_PWM || defined (CONFIG_STM32_TIM2_ADC) || defined(CONFIG_STM32_TIM2_DAC)
+#if defined(CONFIG_STM32_TIM2_PWM) || defined (CONFIG_STM32_TIM2_ADC) || defined(CONFIG_STM32_TIM2_DAC)
# undef CONFIG_STM32_TIM2
#endif
-#if defined(CONFIG_STM32_TIM3_PWM || defined (CONFIG_STM32_TIM3_ADC) || defined(CONFIG_STM32_TIM3_DAC)
+#if defined(CONFIG_STM32_TIM3_PWM) || defined (CONFIG_STM32_TIM3_ADC) || defined(CONFIG_STM32_TIM3_DAC)
# undef CONFIG_STM32_TIM3
#endif
-#if defined(CONFIG_STM32_TIM4_PWM || defined (CONFIG_STM32_TIM4_ADC) || defined(CONFIG_STM32_TIM4_DAC)
+#if defined(CONFIG_STM32_TIM4_PWM) || defined (CONFIG_STM32_TIM4_ADC) || defined(CONFIG_STM32_TIM4_DAC)
# undef CONFIG_STM32_TIM4
#endif
-#if defined(CONFIG_STM32_TIM5_PWM || defined (CONFIG_STM32_TIM5_ADC) || defined(CONFIG_STM32_TIM5_DAC)
+#if defined(CONFIG_STM32_TIM5_PWM) || defined (CONFIG_STM32_TIM5_ADC) || defined(CONFIG_STM32_TIM5_DAC)
# undef CONFIG_STM32_TIM5
#endif
-#if defined(CONFIG_STM32_TIM6_PWM || defined (CONFIG_STM32_TIM6_ADC) || defined(CONFIG_STM32_TIM6_DAC)
+#if defined(CONFIG_STM32_TIM6_PWM) || defined (CONFIG_STM32_TIM6_ADC) || defined(CONFIG_STM32_TIM6_DAC)
# undef CONFIG_STM32_TIM6
#endif
-#if defined(CONFIG_STM32_TIM7_PWM || defined (CONFIG_STM32_TIM7_ADC) || defined(CONFIG_STM32_TIM7_DAC)
+#if defined(CONFIG_STM32_TIM7_PWM) || defined (CONFIG_STM32_TIM7_ADC) || defined(CONFIG_STM32_TIM7_DAC)
# undef CONFIG_STM32_TIM7
#endif
-#if defined(CONFIG_STM32_TIM8_PWM || defined (CONFIG_STM32_TIM8_ADC) || defined(CONFIG_STM32_TIM8_DAC)
+#if defined(CONFIG_STM32_TIM8_PWM) || defined (CONFIG_STM32_TIM8_ADC) || defined(CONFIG_STM32_TIM8_DAC)
# undef CONFIG_STM32_TIM8
#endif
-#if defined(CONFIG_STM32_TIM9_PWM || defined (CONFIG_STM32_TIM9_ADC) || defined(CONFIG_STM32_TIM9_DAC)
+#if defined(CONFIG_STM32_TIM9_PWM) || defined (CONFIG_STM32_TIM9_ADC) || defined(CONFIG_STM32_TIM9_DAC)
# undef CONFIG_STM32_TIM9
#endif
-#if defined(CONFIG_STM32_TIM10_PWM || defined (CONFIG_STM32_TIM10_ADC) || defined(CONFIG_STM32_TIM10_DAC)
+#if defined(CONFIG_STM32_TIM10_PWM) || defined (CONFIG_STM32_TIM10_ADC) || defined(CONFIG_STM32_TIM10_DAC)
# undef CONFIG_STM32_TIM10
#endif
-#if defined(CONFIG_STM32_TIM11_PWM || defined (CONFIG_STM32_TIM11_ADC) || defined(CONFIG_STM32_TIM11_DAC)
+#if defined(CONFIG_STM32_TIM11_PWM) || defined (CONFIG_STM32_TIM11_ADC) || defined(CONFIG_STM32_TIM11_DAC)
# undef CONFIG_STM32_TIM11
#endif
-#if defined(CONFIG_STM32_TIM12_PWM || defined (CONFIG_STM32_TIM12_ADC) || defined(CONFIG_STM32_TIM12_DAC)
+#if defined(CONFIG_STM32_TIM12_PWM) || defined (CONFIG_STM32_TIM12_ADC) || defined(CONFIG_STM32_TIM12_DAC)
# undef CONFIG_STM32_TIM12
#endif
-#if defined(CONFIG_STM32_TIM13_PWM || defined (CONFIG_STM32_TIM13_ADC) || defined(CONFIG_STM32_TIM13_DAC)
+#if defined(CONFIG_STM32_TIM13_PWM) || defined (CONFIG_STM32_TIM13_ADC) || defined(CONFIG_STM32_TIM13_DAC)
# undef CONFIG_STM32_TIM13
#endif
-#if defined(CONFIG_STM32_TIM14_PWM || defined (CONFIG_STM32_TIM14_ADC) || defined(CONFIG_STM32_TIM14_DAC)
+#if defined(CONFIG_STM32_TIM14_PWM) || defined (CONFIG_STM32_TIM14_ADC) || defined(CONFIG_STM32_TIM14_DAC)
# undef CONFIG_STM32_TIM14
#endif
@@ -147,19 +147,16 @@ struct stm32_tim_priv_s {
uint32_t base; /** TIMn base address */
};
-
/************************************************************************************
* Private Functions
************************************************************************************/
-
/** Get register value by offset */
static inline uint16_t stm32_tim_getreg(FAR struct stm32_tim_dev_s *dev, uint8_t offset)
{
return getreg16( ((struct stm32_tim_priv_s *)dev)->base + offset);
}
-
/** Put register value by offset */
static inline void stm32_tim_putreg(FAR struct stm32_tim_dev_s *dev, uint8_t offset, uint16_t value)
{
@@ -167,14 +164,12 @@ static inline void stm32_tim_putreg(FAR struct stm32_tim_dev_s *dev, uint8_t off
putreg16(value, ((struct stm32_tim_priv_s *)dev)->base + offset);
}
-
/** Modify register value by offset */
static inline void stm32_tim_modifyreg(FAR struct stm32_tim_dev_s *dev, uint8_t offset, uint16_t clearbits, uint16_t setbits)
{
modifyreg16( ((struct stm32_tim_priv_s *)dev)->base + offset, clearbits, setbits);
}
-
static void stm32_tim_reload_counter(FAR struct stm32_tim_dev_s *dev)
{
uint16_t val = stm32_tim_getreg(dev, STM32_BTIM_EGR_OFFSET);
@@ -182,7 +177,6 @@ static void stm32_tim_reload_counter(FAR struct stm32_tim_dev_s *dev)
stm32_tim_putreg(dev, STM32_BTIM_EGR_OFFSET, val);
}
-
static void stm32_tim_enable(FAR struct stm32_tim_dev_s *dev)
{
uint16_t val = stm32_tim_getreg(dev, STM32_BTIM_CR1_OFFSET);
@@ -191,7 +185,6 @@ static void stm32_tim_enable(FAR struct stm32_tim_dev_s *dev)
stm32_tim_putreg(dev, STM32_BTIM_CR1_OFFSET, val);
}
-
static void stm32_tim_disable(FAR struct stm32_tim_dev_s *dev)
{
uint16_t val = stm32_tim_getreg(dev, STM32_BTIM_CR1_OFFSET);
@@ -199,7 +192,6 @@ static void stm32_tim_disable(FAR struct stm32_tim_dev_s *dev)
stm32_tim_putreg(dev, STM32_BTIM_CR1_OFFSET, val);
}
-
/** Reset timer into system default state, but do not affect output/input pins */
static void stm32_tim_reset(FAR struct stm32_tim_dev_s *dev)
{
@@ -207,7 +199,6 @@ static void stm32_tim_reset(FAR struct stm32_tim_dev_s *dev)
stm32_tim_disable(dev);
}
-
static void stm32_tim_gpioconfig(uint32_t cfg, stm32_tim_channel_t mode)
{
/** \todo Added support for input capture and bipolar dual outputs for TIM8 */
@@ -220,7 +211,6 @@ static void stm32_tim_gpioconfig(uint32_t cfg, stm32_tim_channel_t mode)
}
}
-
/************************************************************************************
* Basic Functions
************************************************************************************/
@@ -257,14 +247,12 @@ static int stm32_tim_setclock(FAR struct stm32_tim_dev_s *dev, uint32_t freq)
return prescaler;
}
-
static void stm32_tim_setperiod(FAR struct stm32_tim_dev_s *dev, uint16_t period)
{
ASSERT(dev);
stm32_tim_putreg(dev, STM32_BTIM_ARR_OFFSET, period);
}
-
static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev, int (*handler)(int irq, void *context), int source)
{
int vectorno;
@@ -323,28 +311,23 @@ static int stm32_tim_setisr(FAR struct stm32_tim_dev_s *dev, int (*handler)(int
return OK;
}
-
static void stm32_tim_enableint(FAR struct stm32_tim_dev_s *dev, int source)
{
ASSERT(dev);
stm32_tim_modifyreg(dev, STM32_BTIM_DIER_OFFSET, 0, ATIM_DIER_UIE);
}
-
static void stm32_tim_disableint(FAR struct stm32_tim_dev_s *dev, int source)
{
ASSERT(dev);
stm32_tim_modifyreg(dev, STM32_BTIM_DIER_OFFSET, ATIM_DIER_UIE, 0);
}
-
static void stm32_tim_ackint(FAR struct stm32_tim_dev_s *dev, int source)
{
stm32_tim_putreg(dev, STM32_BTIM_SR_OFFSET, ~ATIM_SR_UIF);
}
-
-
/************************************************************************************
* General Functions
************************************************************************************/
@@ -410,7 +393,6 @@ static int stm32_tim_setmode(FAR struct stm32_tim_dev_s *dev, stm32_tim_mode_t m
return OK;
}
-
static int stm32_tim_setchannel(FAR struct stm32_tim_dev_s *dev, uint8_t channel, stm32_tim_channel_t mode)
{
uint16_t ccmr_val = 0;
@@ -542,7 +524,6 @@ static int stm32_tim_setchannel(FAR struct stm32_tim_dev_s *dev, uint8_t channel
return OK;
}
-
static int stm32_tim_setcompare(FAR struct stm32_tim_dev_s *dev, uint8_t channel, uint16_t compare)
{
ASSERT(dev);
@@ -557,7 +538,6 @@ static int stm32_tim_setcompare(FAR struct stm32_tim_dev_s *dev, uint8_t channel
return OK;
}
-
static int stm32_tim_getcapture(FAR struct stm32_tim_dev_s *dev, uint8_t channel)
{
ASSERT(dev);
@@ -571,7 +551,6 @@ static int stm32_tim_getcapture(FAR struct stm32_tim_dev_s *dev, uint8_t channel
return ERROR;
}
-
/************************************************************************************
* Advanced Functions
************************************************************************************/