Author: sebastien.lelong
Date: Sat Oct 11 13:14:08 2008
New Revision: 391

Modified:
    trunk/tools/pwm_ccpx.tmpl

Log:
3-spaces indented template

Modified: trunk/tools/pwm_ccpx.tmpl
==============================================================================
--- trunk/tools/pwm_ccpx.tmpl   (original)
+++ trunk/tools/pwm_ccpx.tmpl   Sat Oct 11 13:14:08 2008
@@ -29,9 +29,9 @@
  -- This means if duty$num = 0, there's no pwm, if duty$num = 255, you're  
closed to
  -- (but not at) the maximum pwm
  procedure pwm${num}_set_dutycycle(byte in duty) is
-       ${ccprxl}_shadow = duty
-       $CCPRXL  = ${ccprxl}_shadow   -- reload 8 high order bits of dutycycle
-       $CCPXCON = ${ccpxcon}_shadow  -- reload 2 low  order bits of dutycycle
+   ${ccprxl}_shadow = duty
+   $CCPRXL  = ${ccprxl}_shadow   -- reload 8 high order bits of dutycycle
+   $CCPXCON = ${ccpxcon}_shadow  -- reload 2 low  order bits of dutycycle
  end procedure


@@ -45,33 +45,33 @@
  -- If not active yet, calling this procedure will enable PWM
  procedure pwm${num}_set_dutycycle_highres(word in duty) is

-       -- split word into 8 MSb and 2LSb
-       var word dutyl = duty & 0b_0000_0011
-       var word dutyh = duty >> 2
-
-       ${ccprxl}_shadow = byte(dutyh)
-       ${ccpxcon}_shadow = (byte(dutyl) & 0b_0000_0011) << 4
-       
-       $CCPRXL  = ${ccprxl}_shadow
-       -- reload while (re)activating pwm
-       ${ccpxcon}_shadow = ${ccpxcon}_shadow | 0b_0000_1100
-       $CCPXCON = ${ccpxcon}_shadow
+   -- split word into 8 MSb and 2LSb
+   var word dutyl = duty & 0b_0000_0011
+   var word dutyh = duty >> 2
+
+   ${ccprxl}_shadow = byte(dutyh)
+   ${ccpxcon}_shadow = (byte(dutyl) & 0b_0000_0011) << 4
+
+   $CCPRXL  = ${ccprxl}_shadow
+   -- reload while (re)activating pwm
+   ${ccpxcon}_shadow = ${ccpxcon}_shadow | 0b_0000_1100
+   $CCPXCON = ${ccpxcon}_shadow
  end procedure
  #end def


  #def pwm_on_off
  procedure pwm${num}_on() is
-       -- pwm mode on, while keeping 2 LSbits
-       ${ccpxcon}_shadow = ${ccpxcon}_shadow | 0b_0000_1100
-       $CCPXCON = ${ccpxcon}_shadow
+   -- pwm mode on, while keeping 2 LSbits
+   ${ccpxcon}_shadow = ${ccpxcon}_shadow | 0b_0000_1100
+   $CCPXCON = ${ccpxcon}_shadow
  end procedure


  procedure pwm${num}_off() is
-       -- pwm mode off, but keep 2 LSbits values
-       ${ccpxcon}_shadow = ${ccpxcon}_shadow ^ 0b_0000_1100 -- ;; Note
-       $CCPXCON = ${ccpxcon}_shadow
+   -- pwm mode off, but keep 2 LSbits values
+   ${ccpxcon}_shadow = ${ccpxcon}_shadow ^ 0b_0000_1100 -- ;; Note
+   $CCPXCON = ${ccpxcon}_shadow
  end procedure
  #end def

@@ -90,43 +90,43 @@
  -- it converts the duty percent to a value suitable for the
  -- selected pwm frequency.
  procedure pwm${num}_set_percent_dutycycle(byte in percent) is
-       
-       -- due to a limitation in JAL, the brackects below are VERY essential
-       var dword _duty${num}_1  = ((percent * 4) * _pr2_1) / 100
-       var dword _duty${num}_4  = ((percent * 4) * _pr2_4) / 100
-       var dword _duty${num}_16 = ((percent * 4) * _pr2_16) / 100
-
-       var byte dutyh
-       var byte dutyl
-       -- select suitable duty value
-       if _pr2_1 == 0 then
-               ;;pragma error    -- pwm frequency is too high
-       elsif _pr2_1 <= 256 then
-               ;;${ccprxl}_shadow = byte(_duty${num}_1 / 4)        -- 8 high 
order bits  
of dutycycle
-               ;;${ccpxcon}_shadow = byte((_duty${num}_1 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty${num}_1 / 4)        -- 8 high order bits of 
dutycycle
-               dutyl = byte((_duty${num}_1 & 0b_0000_0011) * 16)
-       elsif _pr2_4 <= 256 then
-               ;;${ccprxl}_shadow = byte(_duty${num}_4 / 4)
-               ;;${ccpxcon}_shadow = byte((_duty${num}_4 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty${num}_4 / 4)
-               dutyl = byte((_duty${num}_4 & 0b_0000_0011) * 16)
-               
-       elsif _pr2_16 <= 256 then
-               -- Stef is a sioux: x * 16 <=> x << 4 !!!
-               ;;${ccprxl}_shadow = byte(_duty${num}_16 / 4)
-               ;;${ccpxcon}_shadow = byte((_duty${num}_16 & 0b_0000_0011) * 16)
-               dutyh = byte(_duty${num}_16 / 4)
-               dutyl = byte((_duty${num}_16 & 0b_0000_0011) * 16)
-       else
-               ;;pragma error  -- pwm frequency is too low to be realized by 
this  
routine,
-               -- use the post scaler and interrupt
-       end if
-
-       -- build a word storing duty cycle high resolution'ed
-       var word duty_tmp = dutyh << 2
-       duty_tmp = dutyh | dutyl
-       pwm${num}_set_dutycycle_highres(duty_tmp)
+
+   -- due to a limitation in JAL, the brackects below are VERY essential
+   var dword _duty${num}_1  = ((percent * 4) * _pr2_1) / 100
+   var dword _duty${num}_4  = ((percent * 4) * _pr2_4) / 100
+   var dword _duty${num}_16 = ((percent * 4) * _pr2_16) / 100
+
+   var byte dutyh
+   var byte dutyl
+   -- select suitable duty value
+   if _pr2_1 == 0 then
+      ;;pragma error    -- pwm frequency is too high
+   elsif _pr2_1 <= 256 then
+      ;;${ccprxl}_shadow = byte(_duty${num}_1 / 4)        -- 8 high order  
bits of dutycycle
+      ;;${ccpxcon}_shadow = byte((_duty${num}_1 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty${num}_1 / 4)        -- 8 high order bits of  
dutycycle
+      dutyl = byte((_duty${num}_1 & 0b_0000_0011) * 16)
+   elsif _pr2_4 <= 256 then
+      ;;${ccprxl}_shadow = byte(_duty${num}_4 / 4)
+      ;;${ccpxcon}_shadow = byte((_duty${num}_4 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty${num}_4 / 4)
+      dutyl = byte((_duty${num}_4 & 0b_0000_0011) * 16)
+
+   elsif _pr2_16 <= 256 then
+      -- Stef is a sioux: x * 16 <=> x << 4 !!!
+      ;;${ccprxl}_shadow = byte(_duty${num}_16 / 4)
+      ;;${ccpxcon}_shadow = byte((_duty${num}_16 & 0b_0000_0011) * 16)
+      dutyh = byte(_duty${num}_16 / 4)
+      dutyl = byte((_duty${num}_16 & 0b_0000_0011) * 16)
+   else
+      ;;pragma error  -- pwm frequency is too low to be realized by this  
routine,
+      -- use the post scaler and interrupt
+   end if
+
+   -- build a word storing duty cycle high resolution'ed
+   var word duty_tmp = dutyh << 2
+   duty_tmp = dutyh | dutyl
+   pwm${num}_set_dutycycle_highres(duty_tmp)


  end procedure

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to