projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add reg definition for adc driver.
[bertos.git]
/
bertos
/
drv
/
pwm.c
diff --git
a/bertos/drv/pwm.c
b/bertos/drv/pwm.c
index 3946188262263c0f406062adef2fac522a19d77b..d09d9627caa16a0d9da491ee06409ac376203d94 100644
(file)
--- a/
bertos/drv/pwm.c
+++ b/
bertos/drv/pwm.c
@@
-32,21
+32,30
@@
*
* \brief PWM driver (implementation)
*
*
* \brief PWM driver (implementation)
*
- * \version $Id$
*
* \author Francesco Sacchi <batt@develer.com>
* \author Daniele Basile <asterix@develer.com>
*/
*
* \author Francesco Sacchi <batt@develer.com>
* \author Daniele Basile <asterix@develer.com>
*/
-#include <cpu/types.h>
-#include <cpu/irq.h>
-
-#include <drv/pwm.h>
-#include <drv/pwm_at91.h>
+#include "cfg/cfg_pwm.h"
#include <cfg/macros.h>
#include <cfg/macros.h>
+#include <cfg/module.h>
+
+// Define logging setting (for cfg/log.h module).
+#define LOG_LEVEL PWM_LOG_LEVEL
+#define LOG_VERBOSITY PWM_LOG_FORMAT
+
+#include <cfg/log.h>
#include <cfg/debug.h>
#include <cfg/debug.h>
+#include <drv/pwm.h>
+
+#include CPU_HEADER(pwm)
+
+#include <cpu/types.h>
+#include <cpu/irq.h>
+
/**
* Set duty of pwm channel \p dev.
/**
* Set duty of pwm channel \p dev.
@@
-56,13
+65,13
@@
void pwm_setDuty(PwmDev dev, pwm_duty_t duty)
pwm_period_t period = 0;
pwm_duty_t real_duty = 0;
pwm_period_t period = 0;
pwm_duty_t real_duty = 0;
- duty = MIN(duty,
(pwm_duty_t)
PWM_MAX_DUTY);
+ duty = MIN(duty, PWM_MAX_DUTY);
period = pwm_hw_getPeriod(dev);
real_duty = (uint64_t)(duty * period) >> (uint64_t)PWM_MAX_PERIOD_LOG2;
period = pwm_hw_getPeriod(dev);
real_duty = (uint64_t)(duty * period) >> (uint64_t)PWM_MAX_PERIOD_LOG2;
-
// kprintf
("real_duty[%d] duty[%d], period[%d]\n", real_duty, duty, period);
+
LOG_INFO
("real_duty[%d] duty[%d], period[%d]\n", real_duty, duty, period);
pwm_hw_setDutyUnlock(dev, real_duty);
}
pwm_hw_setDutyUnlock(dev, real_duty);
}
@@
-85,23
+94,26
@@
void pwm_enable(PwmDev dev, bool state)
pwm_hw_disable(dev);
}
pwm_hw_disable(dev);
}
+MOD_DEFINE(pwm);
+
/**
* Initialize PWM hw.
*/
void pwm_init(void)
{
/**
* Initialize PWM hw.
*/
void pwm_init(void)
{
- cpuflags_t flags;
+ cpu
_
flags_t flags;
PwmDev dev;
IRQ_SAVE_DISABLE(flags);
PwmDev dev;
IRQ_SAVE_DISABLE(flags);
+ pwm_hw_init();
+
/* set all pwm to 0 */
for (dev = 0; dev < PWM_CNT; dev++)
pwm_setDuty(dev, 0);
/* set all pwm to 0 */
for (dev = 0; dev < PWM_CNT; dev++)
pwm_setDuty(dev, 0);
- pwm_hw_init();
-
IRQ_RESTORE(flags);
IRQ_RESTORE(flags);
+ MOD_INIT(pwm);
}
}