[Armadeus-commitlog] SF.net SVN: armadeus: [565] trunk/target/linux/modules/pwm
Brought to you by:
sszy
|
From: <ar...@us...> - 2007-01-30 20:58:22
|
Revision: 565
http://armadeus.svn.sourceforge.net/armadeus/?rev=565&view=rev
Author: artemys
Date: 2007-01-30 12:56:05 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
[LINUX DRIVER] Activate duty cycle modification access in PWM driver
Modified Paths:
--------------
trunk/target/linux/modules/pwm/core.c
trunk/target/linux/modules/pwm/test/testpwm.sh
Modified: trunk/target/linux/modules/pwm/core.c
===================================================================
--- trunk/target/linux/modules/pwm/core.c 2007-01-30 20:49:22 UTC (rev 564)
+++ trunk/target/linux/modules/pwm/core.c 2007-01-30 20:56:05 UTC (rev 565)
@@ -228,12 +228,7 @@
PWMP = PWMP_PERIOD(ppd->entry->period);
// Setup duty
- PWMS = PWMS_SAMPLE( ppd->entry->period / 2 ); // Fixed to 0.5 for the moment
- //PWMS = PWMS_SAMPLE( (uint32) (ppd->entry->period * ppd->duty / 1000) );
-
- if (ppd->active)
- {
- PWMC |= PWMC_EN;
+ PWMS = PWMS_SAMPLE( (u32) ((ppd->entry->period * ppd->duty) / 1000) );
/* unsigned duty;
if (ppd->duty == MAX_DUTY)
@@ -241,6 +236,10 @@
else
duty=((ppd->entry->max_period_val-1)*ppd->duty)/MAX_DUTY;
*/
+
+ if (ppd->active)
+ {
+ PWMC |= PWMC_EN;
}
else
{
@@ -970,7 +969,7 @@
ppd->reg=address;
ppd->entry=NULL;
ppd->active=0;
- ppd->duty=0;
+ ppd->duty=500; // = 50.O%
rc = class_device_register(&ppd->class_dev);
if (unlikely(rc)) {
Modified: trunk/target/linux/modules/pwm/test/testpwm.sh
===================================================================
--- trunk/target/linux/modules/pwm/test/testpwm.sh 2007-01-30 20:49:22 UTC (rev 564)
+++ trunk/target/linux/modules/pwm/test/testpwm.sh 2007-01-30 20:56:05 UTC (rev 565)
@@ -7,17 +7,20 @@
SYS_DIR="/sys/class/pwm/pwm0/"
PERIOD="1000 2000 3000 4000 5000 6000 7000 8000 9000 10000"
FREQUENCY="100 200 300 400 500 600"
+DUTY="001 250 333 500 666 750 999"
echo "Starting PWM test"
echo 1 > $SYS_DIR/active
+#Test frequency setting
for freq in $FREQUENCY
do
echo $freq > $SYS_DIR/frequency
echo "Setting PWM to $freq Hz"
sleep 5
done
-
+
+#Test period setting
for period in $PERIOD
do
echo $period > $SYS_DIR/period
@@ -26,5 +29,14 @@
done
+#Test duty cycle setting @1kHz -> duty value = positive width signal value
+echo 1000 > $SYS_DIR/frequency
+for duty in $DUTY
+do
+ echo $duty > $SYS_DIR/duty
+ echo "Setting duty cycle to $duty/1000 "
+ sleep 5
+done
+
echo 0 > $SYS_DIR/active
echo "End of PWM test"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|