summaryrefslogtreecommitdiffstats
path: root/nuttx/configs/stm3240g-eval/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-12-20 17:31:06 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-12-20 17:31:06 +0000
commita1a13d684317cef5ad1d1e117ea417b84a34439a (patch)
treeebe1e294a128f4d43bfe8f71d39e7e8fda3154f9 /nuttx/configs/stm3240g-eval/src
parent3485f6cd2a2570a60631506d7f0b62ed4c4f451c (diff)
PWM driver works
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4205 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/configs/stm3240g-eval/src')
-rw-r--r--nuttx/configs/stm3240g-eval/src/stm3240g-internal.h8
-rw-r--r--nuttx/configs/stm3240g-eval/src/up_pwm.c38
2 files changed, 32 insertions, 14 deletions
diff --git a/nuttx/configs/stm3240g-eval/src/stm3240g-internal.h b/nuttx/configs/stm3240g-eval/src/stm3240g-internal.h
index 4158311912..0ccdaf40a3 100644
--- a/nuttx/configs/stm3240g-eval/src/stm3240g-internal.h
+++ b/nuttx/configs/stm3240g-eval/src/stm3240g-internal.h
@@ -90,9 +90,13 @@
* a pulse train using TIM4 CH2. This pin is used by FSMC is connect to CN5 just for this
* purpose:
*
- * PD13 FSMC_A18 / MC_TIM4_CH2 pin 33 (EnB)
+ * PD13 FSMC_A18 / MC_TIM4_CH2 pin 33 (EnB)
*
- * FSMC must be disabled in this case!
+ * FSMC must be disabled in this case! PD13 is available at:
+ *
+ * Daughterboard Extension Connector, CN3, pin 32 - available
+ * TFT LCD Connector, CN19, pin 17 -- not available without removing the LCD.
+ * Motor Control Connector CN15, pin 33 -- no available unless to connect SB14.
*/
#define STM3240G_EVAL_PWMTIMER 4
diff --git a/nuttx/configs/stm3240g-eval/src/up_pwm.c b/nuttx/configs/stm3240g-eval/src/up_pwm.c
index 503e260733..d0701b2b29 100644
--- a/nuttx/configs/stm3240g-eval/src/up_pwm.c
+++ b/nuttx/configs/stm3240g-eval/src/up_pwm.c
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
+#include <errno.h>
#include <debug.h>
#include <nuttx/pwm.h>
@@ -102,27 +103,40 @@
*
************************************************************************************/
-void pwm_devinit(void)
+int pwm_devinit(void)
{
+ static bool initialized = false;
struct pwm_lowerhalf_s *pwm;
int ret;
- /* Call stm32_pwminitialize() to get an instance of the PWM interface */
+ /* Have we already initialized? */
- pwm = stm32_pwminitialize(STM3240G_EVAL_PWMTIMER);
- if (!pwm)
+ if (!initialized)
{
- dbg("Failed to get the STM32 PWM lower half\n");
- return;
- }
+ /* Call stm32_pwminitialize() to get an instance of the PWM interface */
- /* Register the PWM driver at "/dev/pwm0" */
+ pwm = stm32_pwminitialize(STM3240G_EVAL_PWMTIMER);
+ if (!pwm)
+ {
+ dbg("Failed to get the STM32 PWM lower half\n");
+ return -ENODEV;
+ }
- ret = pwm_register("/dev/pwm0", pwm);
- if (ret < 0)
- {
- adbg("pwm_register failed: %d\n", ret);
+ /* Register the PWM driver at "/dev/pwm0" */
+
+ ret = pwm_register("/dev/pwm0", pwm);
+ if (ret < 0)
+ {
+ adbg("pwm_register failed: %d\n", ret);
+ return ret;
+ }
+
+ /* Now we are initialized */
+
+ initialized = true;
}
+
+ return OK;
}
#endif /* HAVE_PWM */