PWM driver works

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4205 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-12-20 17:31:06 +00:00
parent 6cf205e36e
commit e292c452c1
3 changed files with 39 additions and 17 deletions

View File

@ -269,9 +269,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 GPIO_TIM4_CH2 GPIO_TIM4_CH2_2

View File

@ -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

View File

@ -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 */
pwm = stm32_pwminitialize(STM3240G_EVAL_PWMTIMER);
if (!pwm)
{
dbg("Failed to get the STM32 PWM lower half\n");
return -ENODEV;
}
/* 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;
}
/* Register the PWM driver at "/dev/pwm0" */
ret = pwm_register("/dev/pwm0", pwm);
if (ret < 0)
{
adbg("pwm_register failed: %d\n", ret);
}
return OK;
}
#endif /* HAVE_PWM */