Author: sebastien.lelong
Date: Wed Oct  8 11:44:38 2008
New Revision: 372

Modified:
    trunk/unvalidated/include/peripheral/adc/adc_hardware.jal
    trunk/unvalidated/include/peripheral/data_eeprom/pic_data_eeprom.jal
    trunk/unvalidated/include/peripheral/usart/serial_hardware.jal
    trunk/unvalidated/include/peripheral/usart/serial_software.jal

Log:
3-space indented

Modified: trunk/unvalidated/include/peripheral/adc/adc_hardware.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/adc/adc_hardware.jal   (original)
+++ trunk/unvalidated/include/peripheral/adc/adc_hardware.jal   Wed Oct  8  
11:44:38 2008
@@ -21,16 +21,16 @@
  --     pin = output
  -- --
  -- relevant IO pins
---     * RA0 = AN0
---     * RA1 = AN1
---     * RA2 = AN2  or  -Vref
---     * RA3 = AN3  or  +Vref
---     * RA4 = no analog IO
---     * RA5 = AN4
---     * next pins only for 16F874 and 16F877
---     * RE0 = AN5
---     * RE1 = AN6
---     * RE2 = AN7
+--  * RA0 = AN0
+--  * RA1 = AN1
+--  * RA2 = AN2  or  -Vref
+--  * RA3 = AN3  or  +Vref
+--  * RA4 = no analog IO
+--  * RA5 = AN4
+--  * next pins only for 16F874 and 16F877
+--  * RE0 = AN5
+--  * RE1 = AN6
+--  * RE2 = AN7
  --


@@ -43,19 +43,19 @@
  -- Does an AD conversion with low resolution (8 bit) on the selected  
channel
  procedure _adc_read_low_res(byte in adc_chan, byte out adc_byte) is

-       if target_chip == PIC_12F675 then
-               ADCON0 = _adcon0_shadow | ((adc_chan & 0x03) << 2) -- setup 
multiplexer
-       else
-               ADCON0 = _adcon0_shadow | ((adc_chan & 0x07) << 3) -- setup 
multiplexer
-       end if
-       delay_10us(_adc_conversion_time)  -- wait acquisition time
-       ADCON0_GO = true                          -- start conversion
-       while ADCON0_GO loop end loop             -- wait till conversion 
finished
-       adc_byte = ADRESH                  -- read high byte
+   if target_chip == PIC_12F675 then
+      ADCON0 = _adcon0_shadow | ((adc_chan & 0x03) << 2) -- setup  
multiplexer
+   else
+      ADCON0 = _adcon0_shadow | ((adc_chan & 0x07) << 3) -- setup  
multiplexer
+   end if
+   delay_10us(_adc_conversion_time)  -- wait acquisition time
+   ADCON0_GO = true                          -- start conversion
+   while ADCON0_GO loop end loop             -- wait till conversion  
finished
+   adc_byte = ADRESH                  -- read high byte
                                       --   (low resolution is left  
justified !!
-       if target_clock <= (5_000_000 / 16)  then
-               delay_10us(1)                    -- to satisfy 2*Tad for next 
conversion
-       end if
+   if target_clock <= (5_000_000 / 16)  then
+      delay_10us(1)                    -- to satisfy 2*Tad for next  
conversion
+   end if
  end procedure


@@ -63,21 +63,21 @@
  -- returns the result as a 10-bits word
  -- It doesn't matter if ADC is set to low or high resolution
  function adc_read(byte in adc_chan) return word is
-       var word ad_value
-       var byte ax[2] at ad_value
-       
-       if adc_hardware_high_resolution then
-               _adc_read_low_res (adc_chan,ax[1])   -- do conversion and get 
high byte
-               ax[0] = ADRESL                       -- get low byte
-       else
-               _adc_read_low_res (adc_chan,ax[0])   -- do conversion and get 
low byte
-               ax[1] = 0                            -- clear high byte
-               -- shift 2 highest order bits form low byte to high byte,
-               -- to get a 10-bit result
-               ad_value = ad_value <<  2
-       end if
-       
-       return ad_value
+   var word ad_value
+   var byte ax[2] at ad_value
+
+   if adc_hardware_high_resolution then
+      _adc_read_low_res (adc_chan,ax[1])   -- do conversion and get high  
byte
+      ax[0] = ADRESL                       -- get low byte
+   else
+      _adc_read_low_res (adc_chan,ax[0])   -- do conversion and get low  
byte
+      ax[1] = 0                            -- clear high byte
+      -- shift 2 highest order bits form low byte to high byte,
+      -- to get a 10-bit result
+      ad_value = ad_value <<  2
+   end if
+
+   return ad_value
  end function


@@ -85,31 +85,31 @@
  -- returns the 10-bit result as 2 byte parameters
  -- It doesn't matter if ADC is set to low or high resolution
  procedure adc_read_bytes(byte in adc_chan, byte out adc_hbyte, byte out  
adc_lbyte) is
-       var word ad_value
-       var byte ax[2] at ad_value
-       ad_value = adc_read (adc_chan)
-       adc_hbyte = ax[1]
-       adc_lbyte = ax[0]
+   var word ad_value
+   var byte ax[2] at ad_value
+   ad_value = adc_read (adc_chan)
+   adc_hbyte = ax[1]
+   adc_lbyte = ax[0]
  end procedure


  -- Returns Low Resolution ADC-value as the RESULT
  -- It doesn't matter if ADC is set to low or high resolution
  function adc_read_low_res(byte in adc_chan) return byte is
-       var byte adc_value
-       var byte adc_hbyte
-       if ! adc_hardware_high_resolution then
-               _adc_read_low_res(adc_chan,adc_value)
-       else
-               _adc_read_low_res (adc_chan,adc_hbyte)
-               adc_value = ADRESL
-               -- shift the 2 highest order bits form high byte to low byte
-               asm  rrf   adc_hbyte,f
-               asm  rrf   adc_value,f
-               asm  rrf   adc_hbyte,f
-               asm  rrf   adc_value,f
-       end if
-       return adc_value
+   var byte adc_value
+   var byte adc_hbyte
+   if ! adc_hardware_high_resolution then
+      _adc_read_low_res(adc_chan,adc_value)
+   else
+      _adc_read_low_res (adc_chan,adc_hbyte)
+      adc_value = ADRESL
+      -- shift the 2 highest order bits form high byte to low byte
+      asm  rrf   adc_hbyte,f
+      asm  rrf   adc_value,f
+      asm  rrf   adc_hbyte,f
+      asm  rrf   adc_value,f
+   end if
+   return adc_value
  end function


@@ -117,56 +117,56 @@
  -- calculates aquisition time
  -- and determines if right or left justification is optimal
  procedure _ad_init_general() is
-       -- if high resolution, right justified, read H + L
-       -- if low  resolution, left  justified, only read H
-       if target_chip == PIC_12F675 then
-               if adc_hardware_high_resolution then
-                       _adcon0_shadow = _adcon0_shadow | 0x80
-               end if
-       else
-               if adc_hardware_high_resolution then
-                       ADCON1 = ADCON1 | 0x80
-               end if
-       end if
-       
-       -- select the highest possible clock rate
-       -- that satisfies Tad > 1.6 usec
-       -- AD converter is always turned ON
-       if target_chip == PIC_12F675 then
-               ADCON1 = ADCON1 & 0b_0000_1111
-               if target_clock > 40_000_000 then
-                       ADCON1 = ADCON1 | 0b_0111_0000
-               elsif target_clock > 20_000_000 then
-                       ADCON1 = ADCON1 | 0b_0110_0000
-               elsif target_clock > 10_000_000 then
-                       ADCON1 = ADCON1 | 0b_0010_0000
-               elsif target_clock >  5_000_000 then
-                       ADCON1 = ADCON1 | 0b_0101_0000
-               elsif target_clock > (5_000_000 / 2) then
-                       ADCON1 = ADCON1 | 0b_0001_0000
-               elsif target_clock > (5_000_000 / 4) then
-                       ADCON1 = ADCON1 | 0b_0100_0000
-               elsif target_clock > (5_000_000 / 8) then
-                       ADCON1 = ADCON1 | 0b_0000_0000
-               else
-                       ADCON1 = ADCON1 | 0b_0111_0000
-               end if
-       else
-               if target_clock >  5_000_000 then
-                       _adcon0_shadow = 0b_1000_0001
-               elsif target_clock > (5_000_000 / 4) then
-                       _adcon0_shadow = 0b_0100_0001
-               elsif target_clock > (5_000_000 / 16) then
-                       _adcon0_shadow = 0b_0000_0001
-               else
-                       _adcon0_shadow = 0b_1100_0001
-               end if
-       end if
-       
-       -- calculate AD-conversion time in 10 usec units
-       -- an extra 10 usec is added to ensure the minimum acquistion time
-       const adc_conversion_delay = (10 + 15 + (adc_hardware_rsource / 1_000  
))  
/ 10
-       _adc_conversion_time = adc_conversion_delay
+   -- if high resolution, right justified, read H + L
+   -- if low  resolution, left  justified, only read H
+   if target_chip == PIC_12F675 then
+      if adc_hardware_high_resolution then
+         _adcon0_shadow = _adcon0_shadow | 0x80
+      end if
+   else
+      if adc_hardware_high_resolution then
+         ADCON1 = ADCON1 | 0x80
+      end if
+   end if
+
+   -- select the highest possible clock rate
+   -- that satisfies Tad > 1.6 usec
+   -- AD converter is always turned ON
+   if target_chip == PIC_12F675 then
+      ADCON1 = ADCON1 & 0b_0000_1111
+      if target_clock > 40_000_000 then
+         ADCON1 = ADCON1 | 0b_0111_0000
+      elsif target_clock > 20_000_000 then
+         ADCON1 = ADCON1 | 0b_0110_0000
+      elsif target_clock > 10_000_000 then
+         ADCON1 = ADCON1 | 0b_0010_0000
+      elsif target_clock >  5_000_000 then
+         ADCON1 = ADCON1 | 0b_0101_0000
+      elsif target_clock > (5_000_000 / 2) then
+         ADCON1 = ADCON1 | 0b_0001_0000
+      elsif target_clock > (5_000_000 / 4) then
+         ADCON1 = ADCON1 | 0b_0100_0000
+      elsif target_clock > (5_000_000 / 8) then
+         ADCON1 = ADCON1 | 0b_0000_0000
+      else
+         ADCON1 = ADCON1 | 0b_0111_0000
+      end if
+   else
+      if target_clock >  5_000_000 then
+         _adcon0_shadow = 0b_1000_0001
+      elsif target_clock > (5_000_000 / 4) then
+         _adcon0_shadow = 0b_0100_0001
+      elsif target_clock > (5_000_000 / 16) then
+         _adcon0_shadow = 0b_0000_0001
+      else
+         _adcon0_shadow = 0b_1100_0001
+      end if
+   end if
+
+   -- calculate AD-conversion time in 10 usec units
+   -- an extra 10 usec is added to ensure the minimum acquistion time
+   const adc_conversion_delay = (10 + 15 + (adc_hardware_rsource / 1_000   
)) / 10
+   _adc_conversion_time = adc_conversion_delay
  end procedure


@@ -176,50 +176,50 @@
  -- Calculates aquisition time and determines if right or
  -- left justification is optimal
  procedure _adc_init_no_vref() is
-       if target_chip != PIC_12F675 then
-               -- start with left justified
-               if adc_hardware_nchan == 1 then  -- chan = 0
-                       ADCON1 = 0b_0000_1110
-                       pin_A0_direction = input
-               elsif adc_hardware_nchan == 3 then   -- chan = 0,1,3  (special 
case!!)
-                       ADCON1 = 0b_0000_0100
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A3_direction = input
-               elsif adc_hardware_nchan == 5 then   -- chan = 0,1,2,3,4
-                       ADCON1 = 0b_0000_0010
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input
-                       pin_A3_direction = input
-                       pin_A5_direction = input
-               elsif (adc_hardware_nchan == 6) & ((target_chip == PIC_16F877) 
|  
(target_chip == PIC_16F877A)) then -- chan = 0..5
-                       ADCON1 = 0b_0000_1001
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input
-                       pin_A3_direction = input
-                       pin_A5_direction = input
-                       pin_E0_direction = input
-               elsif (adc_hardware_nchan == 8) & ((target_chip == PIC_16F877) 
|  
(target_chip == PIC_16F877A)) then -- chan = 0..7
-                       ADCON1 = 0b_0000_0000
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input
-                       pin_A3_direction = input
-                       pin_A5_direction = input
-                       pin_E0_direction = input
-                       pin_E1_direction = input
-                       pin_E2_direction = input
-               else
-                       if adc_hardware_nvref == 0 then
-                               pragma error    -- this number of channels is 
not available
-                       end if
-               end if
-               
-               -- calculate aquisition delay and optimize justify
-               _ad_init_general()
-       end if
+   if target_chip != PIC_12F675 then
+      -- start with left justified
+      if adc_hardware_nchan == 1 then  -- chan = 0
+         ADCON1 = 0b_0000_1110
+         pin_A0_direction = input
+      elsif adc_hardware_nchan == 3 then   -- chan = 0,1,3  (special  
case!!)
+         ADCON1 = 0b_0000_0100
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A3_direction = input
+      elsif adc_hardware_nchan == 5 then   -- chan = 0,1,2,3,4
+         ADCON1 = 0b_0000_0010
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input
+         pin_A3_direction = input
+         pin_A5_direction = input
+      elsif (adc_hardware_nchan == 6) & ((target_chip == PIC_16F877) |  
(target_chip == PIC_16F877A)) then -- chan = 0..5
+         ADCON1 = 0b_0000_1001
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input
+         pin_A3_direction = input
+         pin_A5_direction = input
+         pin_E0_direction = input
+      elsif (adc_hardware_nchan == 8) & ((target_chip == PIC_16F877) |  
(target_chip == PIC_16F877A)) then -- chan = 0..7
+         ADCON1 = 0b_0000_0000
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input
+         pin_A3_direction = input
+         pin_A5_direction = input
+         pin_E0_direction = input
+         pin_E1_direction = input
+         pin_E2_direction = input
+      else
+         if adc_hardware_nvref == 0 then
+            pragma error    -- this number of channels is not available
+         end if
+      end if
+
+      -- calculate aquisition delay and optimize justify
+      _ad_init_general()
+   end if
  end procedure


@@ -229,46 +229,46 @@
  -- Calculates aquisition time and determines if right or
  -- left justification is optimal
  procedure _adc_init_1_vref() is
-       if target_chip != PIC_12F675 then
-               -- start with left justified
-               if adc_hardware_nchan == 2 then  -- chan = 0,1
-                       ADCON1 = 0b_0000_0101
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A3_direction = input                -- +Vref
-               elsif adc_hardware_nchan == 4 then   -- chan = 0,1,2
-                       ADCON1 = 0b_0000_0011
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input
-                       pin_A3_direction = input
-               elsif (adc_hardware_nchan == 5) & ((target_chip == PIC_16F877) 
|  
(target_chip == PIC_16F877A)) then -- chan = 0,1,2,4,5
-                       ADCON1 = 0b_0000_1001
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input
-                       pin_A3_direction = input
-                       pin_A5_direction = input
-                       pin_E0_direction = input
-               elsif (adc_hardware_nchan == 7) & ((target_chip == PIC_16F877) 
|  
(target_chip == PIC_16F877A))  then -- chan = 0,1,2,4,5,6,7
-                       ADCON1 = 0b_0000_0000
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input
-                       pin_A3_direction = input
-                       pin_A5_direction = input
-                       pin_E0_direction = input
-                       pin_E1_direction = input
-                       pin_E2_direction = input
-               else
-                       if adc_hardware_nvref == 1 then
-                               pragma error    -- this number of channels is 
not available
-                       end if
-               end if
-       
-               -- calculate aquisition delay and optimize justify
-               _ad_init_general()
-       end if
+   if target_chip != PIC_12F675 then
+      -- start with left justified
+      if adc_hardware_nchan == 2 then  -- chan = 0,1
+         ADCON1 = 0b_0000_0101
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A3_direction = input                -- +Vref
+      elsif adc_hardware_nchan == 4 then   -- chan = 0,1,2
+         ADCON1 = 0b_0000_0011
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input
+         pin_A3_direction = input
+      elsif (adc_hardware_nchan == 5) & ((target_chip == PIC_16F877) |  
(target_chip == PIC_16F877A)) then -- chan = 0,1,2,4,5
+         ADCON1 = 0b_0000_1001
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input
+         pin_A3_direction = input
+         pin_A5_direction = input
+         pin_E0_direction = input
+      elsif (adc_hardware_nchan == 7) & ((target_chip == PIC_16F877) |  
(target_chip == PIC_16F877A))  then -- chan = 0,1,2,4,5,6,7
+         ADCON1 = 0b_0000_0000
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input
+         pin_A3_direction = input
+         pin_A5_direction = input
+         pin_E0_direction = input
+         pin_E1_direction = input
+         pin_E2_direction = input
+      else
+         if adc_hardware_nvref == 1 then
+            pragma error    -- this number of channels is not available
+         end if
+      end if
+
+      -- calculate aquisition delay and optimize justify
+      _ad_init_general()
+   end if
  end procedure


@@ -278,53 +278,53 @@
  -- Calculates aquisition time and determines if right or
  -- left justification is optimal
  procedure _adc_init_2_vref() is
-       if target_chip != PIC_12F675 then
-               -- start with left justified
-               if    adc_hardware_nchan == 1 then  -- chan = 0
-                       ADCON1 = 0b_0000_1111
-                       pin_A0_direction = input
-                       pin_A2_direction = input                  -- -Vref
-                       pin_A3_direction = input                -- +Vref
-               elsif adc_hardware_nchan == 2 then  -- chan = 0,1
-                       ADCON1 = 0b_0000_1101
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input                  -- -Vref
-                       pin_A3_direction = input                -- +Vref
-               elsif adc_hardware_nchan == 3 then   -- chan = 0,1,4
-                       ADCON1 = 0b_0000_1100
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input                  -- -Vref
-                       pin_A3_direction = input                -- +Vref
-                       pin_A4_direction = input
-               elsif (adc_hardware_nchan == 4) & ((target_chip == PIC_16F877) 
|  
(target_chip == PIC_16F877A)) then -- chan = 0,1,4,5
-                       ADCON1 = 0b_0000_1011
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input                  -- -Vref
-                       pin_A3_direction = input                -- +Vref
-                       pin_A5_direction = input
-                       pin_E0_direction = input
-               elsif (adc_hardware_nchan == 6) & ((target_chip == PIC_16F877) 
|  
(target_chip == PIC_16F877A)) then -- chan = 0,1,4,5,6,7
-                       ADCON1 = 0b_0000_1000
-                       pin_A0_direction = input
-                       pin_A1_direction = input
-                       pin_A2_direction = input                  -- -Vref
-                       pin_A3_direction = input                -- +Vref
-                       pin_A5_direction = input
-                       pin_E0_direction = input
-                       pin_E1_direction = input
-                       pin_E2_direction = input
-               else
-                       if adc_hardware_nvref == 2 then
-                               pragma error    -- this number of channels is 
not available
-                       end if
-               end if
-               
-               -- calculate aquisition delay and optimize justify
-               _ad_init_general()
-       end if
+   if target_chip != PIC_12F675 then
+      -- start with left justified
+      if    adc_hardware_nchan == 1 then  -- chan = 0
+         ADCON1 = 0b_0000_1111
+         pin_A0_direction = input
+         pin_A2_direction = input                  -- -Vref
+         pin_A3_direction = input                -- +Vref
+      elsif adc_hardware_nchan == 2 then  -- chan = 0,1
+         ADCON1 = 0b_0000_1101
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input                  -- -Vref
+         pin_A3_direction = input                -- +Vref
+      elsif adc_hardware_nchan == 3 then   -- chan = 0,1,4
+         ADCON1 = 0b_0000_1100
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input                  -- -Vref
+         pin_A3_direction = input                -- +Vref
+         pin_A4_direction = input
+      elsif (adc_hardware_nchan == 4) & ((target_chip == PIC_16F877) |  
(target_chip == PIC_16F877A)) then -- chan = 0,1,4,5
+         ADCON1 = 0b_0000_1011
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input                  -- -Vref
+         pin_A3_direction = input                -- +Vref
+         pin_A5_direction = input
+         pin_E0_direction = input
+      elsif (adc_hardware_nchan == 6) & ((target_chip == PIC_16F877) |  
(target_chip == PIC_16F877A)) then -- chan = 0,1,4,5,6,7
+         ADCON1 = 0b_0000_1000
+         pin_A0_direction = input
+         pin_A1_direction = input
+         pin_A2_direction = input                  -- -Vref
+         pin_A3_direction = input                -- +Vref
+         pin_A5_direction = input
+         pin_E0_direction = input
+         pin_E1_direction = input
+         pin_E2_direction = input
+      else
+         if adc_hardware_nvref == 2 then
+            pragma error    -- this number of channels is not available
+         end if
+      end if
+
+      -- calculate aquisition delay and optimize justify
+      _ad_init_general()
+   end if
  end procedure


@@ -335,35 +335,35 @@
  -- Calculates aquisition time and determines if right or
  -- left justification is optimal
  procedure adc_init() is
-       if target_chip == PIC_12F675 then
-               if    adc_hardware_nvref == 0 then
-                       _adcon0_shadow = 1
-               else
-                       _adcon0_shadow = 0x41
-               end if
-               
-               ADCON1 = adc_hardware_nchan
-               
-               -- calculate aquisition delay and optimize justify
-               _ad_init_general()
-       else
-               if adc_hardware_nvref == 0 then
-                       _adc_init_no_vref()
-               elsif adc_hardware_nvref == 1 then
-                       _adc_init_1_vref()
-               else
-                       _adc_init_2_vref()
-               end if
-       end if
+   if target_chip == PIC_12F675 then
+      if    adc_hardware_nvref == 0 then
+         _adcon0_shadow = 1
+      else
+         _adcon0_shadow = 0x41
+      end if
+
+      ADCON1 = adc_hardware_nchan
+
+      -- calculate aquisition delay and optimize justify
+      _ad_init_general()
+   else
+      if adc_hardware_nvref == 0 then
+         _adc_init_no_vref()
+      elsif adc_hardware_nvref == 1 then
+         _adc_init_1_vref()
+      else
+         _adc_init_2_vref()
+      end if
+   end if
  end procedure


  -- Turns all ADC channels back on
  procedure adc_on() is
-       -- jallib: this is *not* the original meaning
-       -- It just turns adc on, while it previously
-       -- adc_init()
-       ADCON0_ADON = true
+   -- jallib: this is *not* the original meaning
+   -- It just turns adc on, while it previously
+   -- adc_init()
+   ADCON0_ADON = true
  end procedure



Modified:  
trunk/unvalidated/include/peripheral/data_eeprom/pic_data_eeprom.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/data_eeprom/pic_data_eeprom.jal        
 
(original)
+++ trunk/unvalidated/include/peripheral/data_eeprom/pic_data_eeprom.jal        
 
Wed Oct  8 11:44:38 2008
@@ -14,30 +14,30 @@
  -- Reads a byte from data eeprom at given address
  -- Result is stored in the passed in argument
  procedure data_eeprom_read( byte in address, byte out data ) is
-       EEADR = address
-       if defined(EECON1_EEPGD) == true then
-               EECON1_EEPGD = false                  ; select data EEprom
-       end if
-       EECON1_RD = true
-       data = EEDATA
+   EEADR = address
+   if defined(EECON1_EEPGD) == true then
+      EECON1_EEPGD = false                  ; select data EEprom
+   end if
+   EECON1_RD = true
+   data = EEDATA
  end procedure

  -- Reads a word from data eeprom at given address
  -- Result is stored in the passed in argument
  procedure data_eeprom_read_word( byte in address, word out data ) is
-       var byte temp[2] at data
-       data_eeprom_read(address,temp[0])
-       data_eeprom_read(address+1,temp[1])
+   var byte temp[2] at data
+   data_eeprom_read(address,temp[0])
+   data_eeprom_read(address+1,temp[1])
  end procedure

  -- Reads a dword from data eeprom at given address
  -- Result is stored in the passed in argument
  procedure data_eeprom_read_dword( byte in address, dword out data ) is
-       var byte temp[4] at data
-       data_eeprom_read(address,temp[0])
-       data_eeprom_read(address+1,temp[1])
-       data_eeprom_read(address+2,temp[2])
-       data_eeprom_read(address+3,temp[3])
+   var byte temp[4] at data
+   data_eeprom_read(address,temp[0])
+   data_eeprom_read(address+1,temp[1])
+   data_eeprom_read(address+2,temp[2])
+   data_eeprom_read(address+3,temp[3])
  end procedure


@@ -45,25 +45,25 @@
  -- Reads a byte from data eeprom at given address
  -- and return the result
  function data_eeprom(byte in address) return byte is
-       var byte data
-       data_eeprom_read(address,data)
-       return data
+   var byte data
+   data_eeprom_read(address,data)
+   return data
  end function

  -- Reads a word from data eeprom at given address
  -- and return the result
  function data_eeprom_word(byte in address) return word is
-       var word data
-       data_eeprom_read_word(address,data)
-       return data
+   var word data
+   data_eeprom_read_word(address,data)
+   return data
  end function

  -- Reads a dword from data eeprom at given address
  -- and return the result
  function data_eeprom_dword(byte in address) return dword is
-       var dword data
-       data_eeprom_read_dword(address,data)
-       return data
+   var dword data
+   data_eeprom_read_dword(address,data)
+   return data
  end function


@@ -71,46 +71,46 @@
  -- Waits untill finished
  procedure data_eeprom_write(byte in address, byte in data) is

-       var bit gie_old
-       
-       EEADR = address
-       EEDATA = data
-       
-       if defined(EECON1_EEPGD) == true then
-               EECON1_EEPGD = false               ; select data EEprom
-       end if
-       
-       gie_old = INTCON_GIE
-       EECON1_WREN = true
-       INTCON_GIE = false
-
-       -- requred sequence (see datasheet)
-       EECON2 = 0x55
-       EECON2 = 0xAA
-       EECON1_WR = true        -- start write operation
-       
-       INTCON_GIE = gie_old         ; restore interrupt status
-       EECON1_WREN = false          ; disable further writing
-       
-       while EECON1_WR loop end loop
+   var bit gie_old
+
+   EEADR = address
+   EEDATA = data
+
+   if defined(EECON1_EEPGD) == true then
+      EECON1_EEPGD = false               ; select data EEprom
+   end if
+
+   gie_old = INTCON_GIE
+   EECON1_WREN = true
+   INTCON_GIE = false
+
+   -- requred sequence (see datasheet)
+   EECON2 = 0x55
+   EECON2 = 0xAA
+   EECON1_WR = true   -- start write operation
+
+   INTCON_GIE = gie_old         ; restore interrupt status
+   EECON1_WREN = false          ; disable further writing
+
+   while EECON1_WR loop end loop

  end procedure

  -- Writes a word to data eeprom at given address
  -- (based on procedure `data_eeprom_write`)
  procedure data_eeprom_write_word(byte in address, word in data) is
-       var byte temp[2] at data
-       data_eeprom_write(address,temp[0])
-       data_eeprom_write(address+1,temp[1])
+   var byte temp[2] at data
+   data_eeprom_write(address,temp[0])
+   data_eeprom_write(address+1,temp[1])
  end procedure

  -- Writes a dword to data eeprom at given address
  -- (based on procedure `data_eeprom_write`)
  procedure data_eeprom_write_dword(byte in address, dword in data) is
-       var byte temp[4] at data
-       data_eeprom_write(address,temp[0])
-       data_eeprom_write(address+1,temp[1])
-       data_eeprom_write(address+2,temp[2])
-       data_eeprom_write(address+3,temp[3])
+   var byte temp[4] at data
+   data_eeprom_write(address,temp[0])
+   data_eeprom_write(address+1,temp[1])
+   data_eeprom_write(address+2,temp[2])
+   data_eeprom_write(address+3,temp[3])
  end procedure


Modified: trunk/unvalidated/include/peripheral/usart/serial_hardware.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/usart/serial_hardware.jal       
(original)
+++ trunk/unvalidated/include/peripheral/usart/serial_hardware.jal      Wed Oct 
  
8 11:44:38 2008
@@ -25,7 +25,7 @@
  -- some variables made available under a general (pic-independant) name

  var volatile bit serial_hw_data_available is PIR1_RCIF
-var volatile bit serial_hw_data_ready   is PIR1_TXIF
+var volatile bit serial_hw_data_ready is PIR1_TXIF


  -- internal function, calculates and sets baudrate divider
@@ -49,78 +49,78 @@
  --  * SPBRG = ( Fosc / ( 4 * Baudrate ) ) -1
  --
  procedure _calculate_and_set_baudrate() is
-       const max_deviation = 5  -- maximum % deviation of the realized baudrate
+   const max_deviation = 5  -- maximum % deviation of the realized baudrate

-       if usart_hw_serial then
-               -- SPBRG = ( Fosc / ( 4 * Baudrate ) ) -1
-               -- first try high baudrate, will generate highest accuarcy
-               -- to get the right rounding (5 + 10*f(x)) /10
-               const usart_div =((5 + ( ( 10 * target_clock ) / ( 16 *  
serial_hw_baudrate ))  ) / 10 ) - 1
-
-               -- special case if divider is 0,
-               -- test if deviation is not too much
-               if usart_div <= 0 then
-                       if (100 * (serial_hw_baudrate - (target_clock / 16) )) 
/  
serial_hw_baudrate >= max_deviation then
-                               pragma error  -- asynchronous baudrate is too 
high
-                       end if
-               end if
-
-               -- if divider small enough,
-               -- calculate divider and set high-speed
-               if usart_div <= 255 then
-                       if usart_div >= 0 then
-                               SPBRG = usart_div
-                       else
-                               SPBRG = 0
-                       end if
-                       TXSTA_BRGH = true
-                       -- try the low-speed mode
-               else
-                       const usart_div_low = ((((10 * target_clock) / ( 64 *  
serial_hw_baudrate )) + 5 ) / 10) - 1
-                       -- here divider will never be 0
-                       -- but special case to consider,
-                       -- if baudrate is just a little too low
-                       if (usart_div_low > 255) & (100 * ((target_clock / (64 
* 256 )) -  
serial_hw_baudrate)) / serial_hw_baudrate < max_deviation then
-                               SPBRG = 255
-                               TXSTA_BRGH = false
-                               -- now calculate divider and set high-speed / 
low-speed bit
-                       elsif usart_div_low <= 255 then
-                               if usart_div_low >= 0 then
-                                       SPBRG = usart_div_low
-                               else
-                                       SPBRG = 0
-                               end if
-                               TXSTA_BRGH = false
-                       else
-                               pragma error -- asynchronous baudrate is too low
-                       end if
-               end if
-
-       else  -- synchronous mode
-               const usart_div_sync = ( target_clock / ( 4 * 
serial_hw_baudrate )) - 1
-               
-               -- special case if divider is 0 or negative
-               -- test if baudrate is a little bit too high
-               if usart_div_sync <= 0 then
-                       if (100 * (serial_hw_baudrate - (target_clock / 4 ) )) 
/  
serial_hw_baudrate >= max_deviation then
-                               pragma error  -- synchronous baudrate is too 
high
-                       end if
-               end if
-               
-               -- special case to consider,
-               -- if baudrate is just a little too high
-               if (usart_div_sync > 255) & (100 * ((target_clock / (4 * 256)  
) -  
serial_hw_baudrate)) / serial_hw_baudrate < max_deviation then
-                       SPBRG = 255
-               elsif usart_div_sync <= 255 then
-                       if SPBRG >= 0 then
-                               SPBRG = usart_div_sync
-                       else
-                               SPBRG = 0
-                       end if
-               else
-                       pragma error -- synchronous baudrate is too low
-               end if
-       end if
+   if usart_hw_serial then
+      -- SPBRG = ( Fosc / ( 4 * Baudrate ) ) -1
+      -- first try high baudrate, will generate highest accuarcy
+      -- to get the right rounding (5 + 10*f(x)) /10
+      const usart_div =((5 + ( ( 10 * target_clock ) / ( 16 *  
serial_hw_baudrate ))  ) / 10 ) - 1
+
+      -- special case if divider is 0,
+      -- test if deviation is not too much
+      if usart_div <= 0 then
+         if (100 * (serial_hw_baudrate - (target_clock / 16) )) /  
serial_hw_baudrate >= max_deviation then
+            pragma error  -- asynchronous baudrate is too high
+         end if
+      end if
+
+      -- if divider small enough,
+      -- calculate divider and set high-speed
+      if usart_div <= 255 then
+           if usart_div >= 0 then
+            SPBRG = usart_div
+         else
+            SPBRG = 0
+         end if
+           TXSTA_BRGH = true
+         -- try the low-speed mode
+      else
+           const usart_div_low = ((((10 * target_clock) / ( 64 *  
serial_hw_baudrate )) + 5 ) / 10) - 1
+         -- here divider will never be 0
+         -- but special case to consider,
+         -- if baudrate is just a little too low
+         if (usart_div_low > 255) & (100 * ((target_clock / (64 * 256 )) -  
serial_hw_baudrate)) / serial_hw_baudrate < max_deviation then
+            SPBRG = 255
+            TXSTA_BRGH = false
+            -- now calculate divider and set high-speed / low-speed bit
+           elsif usart_div_low <= 255 then
+            if usart_div_low >= 0 then
+               SPBRG = usart_div_low
+            else
+               SPBRG = 0
+            end if
+            TXSTA_BRGH = false
+           else
+            pragma error -- asynchronous baudrate is too low
+           end if
+      end if
+
+   else  -- synchronous mode
+      const usart_div_sync = ( target_clock / ( 4 * serial_hw_baudrate ))  
- 1
+
+      -- special case if divider is 0 or negative
+      -- test if baudrate is a little bit too high
+      if usart_div_sync <= 0 then
+         if (100 * (serial_hw_baudrate - (target_clock / 4 ) )) /  
serial_hw_baudrate >= max_deviation then
+            pragma error  -- synchronous baudrate is too high
+         end if
+      end if
+
+      -- special case to consider,
+      -- if baudrate is just a little too high
+      if (usart_div_sync > 255) & (100 * ((target_clock / (4 * 256)  ) -  
serial_hw_baudrate)) / serial_hw_baudrate < max_deviation then
+         SPBRG = 255
+      elsif usart_div_sync <= 255 then
+         if SPBRG >= 0 then
+            SPBRG = usart_div_sync
+         else
+            SPBRG = 0
+         end if
+      else
+         pragma error -- synchronous baudrate is too low
+      end if
+   end if

  end procedure

@@ -131,19 +131,19 @@
  -- Only after "asynch_disable_hw" it's necessary to call this routine,
  -- to enable the RS232 hardware again.
  procedure serial_hw_init() is
-       -- Calculate and Load baudrate generator
-       _calculate_and_set_baudrate()
-       
-       -- disable all USART interrupts
-       PIE1_RCIE = false
-       PIE1_TXIE = false
-       
-       -- Enable transmitter : TXSTA_TXEN=1 (preserve TXSTA_BRGH)
-       TXSTA_TXEN = true
-
-       -- Enable serial port : RCSTA_SPEN=1
-       -- Enable receiving   : RCSTA_CREN=1
-       RCSTA = 0x90
+   -- Calculate and Load baudrate generator
+   _calculate_and_set_baudrate()
+
+   -- disable all USART interrupts
+   PIE1_RCIE = false
+   PIE1_TXIE = false
+
+   -- Enable transmitter : TXSTA_TXEN=1 (preserve TXSTA_BRGH)
+   TXSTA_TXEN = true
+
+   -- Enable serial port : RCSTA_SPEN=1
+   -- Enable receiving   : RCSTA_CREN=1
+   RCSTA = 0x90

  end procedure

@@ -152,17 +152,17 @@
  -- so ports can be used (temporary) for other purposes.
  -- USART can be enabled again by calling serial_hw_enable()
  procedure serial_hw_disable() is
-       -- wait till running transmissions are finished
-       while !TXSTA_TRMT loop end loop
-       -- Disable Serial port:
-       RCSTA_SPEN = false
+   -- wait till running transmissions are finished
+   while !TXSTA_TRMT loop end loop
+   -- Disable Serial port:
+   RCSTA_SPEN = false
  end procedure


  -- Enables USART (wether used as RS232 or SPI),
  procedure serial_hw_enable() is
-       -- Enable Serial port
-       RCSTA_SPEN = true
+   -- Enable Serial port
+   RCSTA_SPEN = true
  end procedure


@@ -172,45 +172,45 @@
  --
  -- remark: PIR1-register (containing _TXIF-flag) must be in bank0 !!
  procedure serial_hw_write(byte in data) is
-       -- wait until TXREG is empty
-       while ! PIR1_TXIF loop end loop
-       -- then put new byte in TXREG (prepare for transmission)
-       TXREG = data
+   -- wait until TXREG is empty
+   while ! PIR1_TXIF loop end loop
+   -- then put new byte in TXREG (prepare for transmission)
+   TXREG = data
  end procedure


  -- like Serial_H_write, but then with a word as input
  -- The MSB is outputed first
  procedure serial_hw_write_word(word in data) is
-       var byte DX[2] at data
-       -- can be blocked by debugging
-       while ! PIR1_TXIF loop end loop
-       TXREG = DX[1]
-       asm nop         -- this is necessary for damned good optimized compilers
-                               -- loading of the TXREG doesn't immediatly set 
PIR1_TXIF !!!!
-       while ! PIR1_TXIF loop end loop
-       TXREG = DX[0]
+   var byte DX[2] at data
+   -- can be blocked by debugging
+   while ! PIR1_TXIF loop end loop
+   TXREG = DX[1]
+   asm nop      -- this is necessary for damned good optimized compilers
+            -- loading of the TXREG doesn't immediatly set PIR1_TXIF !!!!
+   while ! PIR1_TXIF loop end loop
+   TXREG = DX[0]
  end procedure


  -- Returns true if a character was received, otherwise returns false.
  -- Overrun error flag is cleared.
  function serial_hw_read(byte out data) return bit is
-       -- test if byte available, and if so,
-       -- get byte and transport to outer world
-       if PIR1_RCIF then
-               data = RCREG
-               PIR1_RCIF       = false                 -- [EMAIL PROTECTED] 
12-sept-08
-       else
-               return false  ;result = false
-       end if
-       
-       if RCSTA_OERR then
-               RCSTA_CREN = false
-               RCSTA_CREN =true
-       end if
+   -- test if byte available, and if so,
+   -- get byte and transport to outer world
+   if PIR1_RCIF then
+      data = RCREG
+      PIR1_RCIF   = false       -- [EMAIL PROTECTED] 12-sept-08
+   else
+      return false  ;result = false
+   end if
+
+   if RCSTA_OERR then
+      RCSTA_CREN = false
+      RCSTA_CREN =true
+   end if

-       return true
+   return true
  end function

  -- Here Serial read and write are definied as pseudo variables
@@ -232,20 +232,20 @@
  -- }}}
  --
  procedure serial_hw_data'put(byte in data) is
-       -- -----------------------------------------------
-       -- BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG      
-       -- -----------------------------------------------
-       -- this doesn't work (always?)
-         serial_hw_write(data)
-       -- tested by putting the next statement instead
-       ;  serial_hw_write(0x33)
+   -- -----------------------------------------------
+   -- BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG
+   -- -----------------------------------------------
+   -- this doesn't work (always?)
+     serial_hw_write(data)
+   -- tested by putting the next statement instead
+   ;  serial_hw_write(0x33)
  end procedure


  function serial_hw_data'get() return byte is
-       var byte data
-       while ! serial_hw_read(data) loop end loop
-       return data
+   var byte data
+   while ! serial_hw_read(data) loop end loop
+   return data
  end function


@@ -253,10 +253,10 @@
  -- the user is totally responsible for testing the transmit/receive
  -- flag before using these functions
  procedure serial_hw_data_raw'put(byte in data) is
-       TXREG = data
+   TXREG = data
  end procedure

  function serial_hw_data_raw'get() return byte is
-       return RCREG
+   return RCREG
  end function


Modified: trunk/unvalidated/include/peripheral/usart/serial_software.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/usart/serial_software.jal       
(original)
+++ trunk/unvalidated/include/peripheral/usart/serial_software.jal      Wed Oct 
  
8 11:44:38 2008
@@ -23,12 +23,12 @@


  procedure serial_sw_init() is
-       -- ouput/tx pin active or not according to invert
-       if serial_sw_invert then
-               serial_sw_tx_pin = high
-       else
-               serial_sw_tx_pin = low
-       end if
+   -- ouput/tx pin active or not according to invert
+   if serial_sw_invert then
+      serial_sw_tx_pin = high
+   else
+      serial_sw_tx_pin = low
+   end if
  end procedure


@@ -47,7 +47,7 @@

  ;; for small values, the value is truncated in stead of rounded, so add 1
  if _IL_TX < 10 then
-       IL_TX = _IL_TX + 1
+   IL_TX = _IL_TX + 1
  end if

  --  
-----------------------------------------------------------------------------
@@ -84,34 +84,34 @@
  var byte ilval0

  if serial_sw_baudrate < 200_000 then
-       const _olval  = ( _NINSTR / ( 3 * 255 )) + 1
-       const _ilval  = ( ( _NINSTR - ( 4 * _olval ) ) - 15 ) / ( 3 * _olval )
-       const _ilval0 = ( ( _NINSTR2 - ( 4 * _olval ) ) - 5 ) / ( 3 * _olval )
-       
-       
-       ilval  = _ilval
-       olval  = _olval
-       ;due to rounding the next value can slightly below 1
-       if _ilval0 > 0 then
-               ilval0 = _ilval0
-       else
-               ilval0 = 1
-       end if
-       ilval0 = _ilval0
-       
-       -- test if baudrate valid for the chosen Xtal frequency
-       if _olval > 255 then
-               pragma error  -- baudrate too low for this Xtal
-       end if
-       if _olval == 0 then
-               pragma error  -- baudrate too high for this Xtal
-       end if
-       
+   const _olval  = ( _NINSTR / ( 3 * 255 )) + 1
+   const _ilval  = ( ( _NINSTR - ( 4 * _olval ) ) - 15 ) / ( 3 * _olval )
+   const _ilval0 = ( ( _NINSTR2 - ( 4 * _olval ) ) - 5 ) / ( 3 * _olval )
+
+
+   ilval  = _ilval
+   olval  = _olval
+   ;due to rounding the next value can slightly below 1
+   if _ilval0 > 0 then
+      ilval0 = _ilval0
+   else
+      ilval0 = 1
+   end if
+   ilval0 = _ilval0
+
+   -- test if baudrate valid for the chosen Xtal frequency
+   if _olval > 255 then
+      pragma error  -- baudrate too low for this Xtal
+   end if
+   if _olval == 0 then
+      pragma error  -- baudrate too high for this Xtal
+   end if
+
  else
-       const _ilval = 1
-       const _olval = ((target_clock / (4 * serial_sw_baudrate)) - 15 ) / (4 + 
3  
* _ilval)
-       ilval = _ilval
-       olval = _olval
+   const _ilval = 1
+   const _olval = ((target_clock / (4 * serial_sw_baudrate)) - 15 ) / (4 +  
3 * _ilval)
+   ilval = _ilval
+   olval = _olval

  end if

@@ -141,50 +141,50 @@
  -- Also here the code is doubled (inverting and non-inverting)
  -- and selection is done by a compiler-directive.
  procedure serial_sw_write(byte in data) is
-       var bit old_gie    ;status of interrupt enable on entrance
-       ;; jallib(seb): this is a way to act on tx pin
-       ;;var bit pp at serial_sw_out_port : serial_sw_out_nr
-       var bit pp is serial_sw_tx_pin
-       var bit data_bit at data : 0
-       
-       -- stop interrupts and be sure they are stopped
-       -- save old interrupt status
-       old_gie = INTCON_GIE
-       while INTCON_GIE loop
-               INTCON_GIE = false
-       end loop
-       
-       if serial_sw_invert then
-               pp = low
-               _usec_delay((1_000_000/serial_sw_baudrate)-2)
-               for 8 loop
-                       -- wait a whole bittime, less some usec for other 
actions
-                       pp = data_bit
-                       data = data >> 1
-                       _usec_delay((1_000_000/serial_sw_baudrate)-2)
-               end loop
-               -- add 2 stop bits
-               pp = high
-               _usec_delay((2_000_000/serial_sw_baudrate))
-               
-       else
-               -- invert the data
-               data = ! data
-               pp = high
-               _usec_delay((1_000_000/serial_sw_baudrate)-2)
-               for 8 loop
-                       -- wait a whole bittime, less some usec for other 
actions
-                       pp = data_bit
-                       data = data >> 1
-                       _usec_delay((1_000_000/serial_sw_baudrate)-2)
-               end loop
-               -- add 2 stop bits
-               pp = low
-               _usec_delay((2_000_000/serial_sw_baudrate))
-       end if
-       
-       -- restore old interrupt status
-       INTCON_GIE = old_gie
+   var bit old_gie    ;status of interrupt enable on entrance
+   ;; jallib(seb): this is a way to act on tx pin
+   ;;var bit pp at serial_sw_out_port : serial_sw_out_nr
+   var bit pp is serial_sw_tx_pin
+   var bit data_bit at data : 0
+
+   -- stop interrupts and be sure they are stopped
+   -- save old interrupt status
+   old_gie = INTCON_GIE
+   while INTCON_GIE loop
+      INTCON_GIE = false
+   end loop
+
+   if serial_sw_invert then
+      pp = low
+      _usec_delay((1_000_000/serial_sw_baudrate)-2)
+      for 8 loop
+         -- wait a whole bittime, less some usec for other actions
+         pp = data_bit
+         data = data >> 1
+         _usec_delay((1_000_000/serial_sw_baudrate)-2)
+      end loop
+      -- add 2 stop bits
+      pp = high
+      _usec_delay((2_000_000/serial_sw_baudrate))
+
+   else
+      -- invert the data
+      data = ! data
+      pp = high
+      _usec_delay((1_000_000/serial_sw_baudrate)-2)
+      for 8 loop
+         -- wait a whole bittime, less some usec for other actions
+         pp = data_bit
+         data = data >> 1
+         _usec_delay((1_000_000/serial_sw_baudrate)-2)
+      end loop
+      -- add 2 stop bits
+      pp = low
+      _usec_delay((2_000_000/serial_sw_baudrate))
+   end if
+
+   -- restore old interrupt status
+   INTCON_GIE = old_gie

  end procedure

@@ -194,82 +194,82 @@
  -- Also here the code is doubled (inverting and non-inverting)
  -- and selection is done by a compiler-directive.
  procedure serial_sw_read_wait(byte out data) is
-       var bit  ie_old    ;status of interrupt enable on entrance
-       var bit ready
-       ;; jallib(seb): this is a way to act on rx pin
-       ;;var bit pp at serial_sw_in_port : serial_sw_in_nr
-       var bit pp is serial_sw_rx_pin
-       
-       -- stop interrupts and be sure they are stopped
-       -- save old interrupt status
-       ie_old = INTCON_GIE
-       while INTCON_GIE loop
-               INTCON_GIE = false
-       end loop
-       
-       if serial_sw_invert then
-               -- wait for serial line inactive
-               while !pp loop end loop
-
-               ready = false
-               while !ready loop
-                       -- wait for startbit
-                       while pp loop end loop
-                       
-                       -- wait half a bit time, less 5 usec for other actions
-                       _usec_delay((1_000_000/(2*serial_sw_baudrate))-1)
-                       
-                       -- test if still startbit, otherwise restart
-                       if !pp then
-                               -- now fetch 8 bits
-                               for 8 loop
-                                       -- wait a whole bittime, less 5 usec 
for other actions
-                                       
_usec_delay((1_000_000/serial_sw_baudrate)-1)
-                                       -- shift new bit in
-                                       data = data >> 1
-                                       if pp then
-                                               data = data | 0x80
-                                       end if
-                               end loop
-                               ready = true
-                       else
-                               ready = false
-                       end if
-               end loop
-       else  ;NOT inverted
-               -- wait for serial line inactive
-               while pp loop end loop
-               
-               ready = false
-               while !ready loop
-                       -- wait for startbit
-                       while !pp loop end loop
-                       
-                       -- wait half a bit time, less 5 usec for other actions
-                       _usec_delay((1_000_000/(2*serial_sw_baudrate))-1)
-                       
-                       -- test if still startbit, otherwise restart
-                       if pp then
-                               -- now fetch 8 bits
-                               for 8 loop
-                                       -- wait a whole bittime, less 5 usec 
for other actions
-                                       
_usec_delay((1_000_000/serial_sw_baudrate)-1)
-                                       -- shift new bit in
-                                       data = data >> 1
-                                       if !pp then
-                                               data = data | 0x80
-                                       end if
-                               end loop
-                               ready = true
-                       else
-                               ready = false
-                       end if
-               end loop
-       end if
-       
-       -- restore old interrupt status
-       INTCON_GIE = ie_old
-       
+   var bit  ie_old    ;status of interrupt enable on entrance
+   var bit ready
+   ;; jallib(seb): this is a way to act on rx pin
+   ;;var bit pp at serial_sw_in_port : serial_sw_in_nr
+   var bit pp is serial_sw_rx_pin
+
+   -- stop interrupts and be sure they are stopped
+   -- save old interrupt status
+   ie_old = INTCON_GIE
+   while INTCON_GIE loop
+      INTCON_GIE = false
+   end loop
+
+   if serial_sw_invert then
+      -- wait for serial line inactive
+      while !pp loop end loop
+
+      ready = false
+      while !ready loop
+         -- wait for startbit
+         while pp loop end loop
+
+         -- wait half a bit time, less 5 usec for other actions
+         _usec_delay((1_000_000/(2*serial_sw_baudrate))-1)
+
+         -- test if still startbit, otherwise restart
+         if !pp then
+            -- now fetch 8 bits
+            for 8 loop
+               -- wait a whole bittime, less 5 usec for other actions
+               _usec_delay((1_000_000/serial_sw_baudrate)-1)
+               -- shift new bit in
+               data = data >> 1
+               if pp then
+                  data = data | 0x80
+               end if
+            end loop
+            ready = true
+         else
+            ready = false
+         end if
+      end loop
+   else  ;NOT inverted
+      -- wait for serial line inactive
+      while pp loop end loop
+
+      ready = false
+      while !ready loop
+         -- wait for startbit
+         while !pp loop end loop
+
+         -- wait half a bit time, less 5 usec for other actions
+         _usec_delay((1_000_000/(2*serial_sw_baudrate))-1)
+
+         -- test if still startbit, otherwise restart
+         if pp then
+            -- now fetch 8 bits
+            for 8 loop
+               -- wait a whole bittime, less 5 usec for other actions
+               _usec_delay((1_000_000/serial_sw_baudrate)-1)
+               -- shift new bit in
+               data = data >> 1
+               if !pp then
+                  data = data | 0x80
+               end if
+            end loop
+            ready = true
+         else
+            ready = false
+         end if
+      end loop
+   end if
+
+   -- restore old interrupt status
+   INTCON_GIE = ie_old
+
  end procedure


@@ -280,7 +280,7 @@
  --    serial_sw_write = 0x33
  -- }}}
  procedure serial_sw_data'put(byte in data) is
-       serial_sw_write(data)
+   serial_sw_write(data)
  end procedure

  -- Here the serial_sw_read_wait procedure is declared as a pseudo variable
@@ -289,9 +289,9 @@
  --    Data = serial_sw_write
  -- }}}
  function serial_sw_data'get() return byte is
-       var byte data
-       serial_sw_read_wait( data )
-       return data
+   var byte data
+   serial_sw_read_wait( data )
+   return data
  end function

  -- Waits untill a character is received or time out is reached.
@@ -299,62 +299,62 @@
  -- Also here the code is doubled (inverting and non-inverting)
  -- and selection is done by a compiler-directive.
  function serial_sw_read(byte out data) return bit is
-       var bit ie_old    ;status of interrupt enable on entrance
-       ;; jallib(seb): this is a way to act on rx pin
-       ;;var bit pp at serial_sw_in_port : serial_sw_in_nr
-       var bit pp is serial_sw_rx_pin
-       
-       if serial_sw_invert != pp then
-               return false
-       end if
-
-       -- stop interrupts and be sure they are stopped
-       -- save old interrupt status
-       ie_old = INTCON_GIE
-       while INTCON_GIE loop
-               INTCON_GIE = false
-       end loop
-       
-       if serial_sw_invert then
-       -- wait for startbit
-               while pp loop end loop
-               
-               -- wait half a bit time, less 5 usec for other actions
-               _usec_delay((1_000_000/(2*serial_sw_baudrate))-1)
-               
-               -- now fetch 8 bits
-               for 8 loop
-                       -- wait a whole bittime, less 5 usec for other actions
-                       _usec_delay((1_000_000/serial_sw_baudrate)-1)
-                       -- shift new bit in
-                       data = data >> 1
-                       if pp then
-                               data = data | 0x80
-                       end if
-               end loop
-       else  ;NOT inverted
-               -- wait for startbit
-               while !pp loop end loop
-               
-               -- wait half a bit time, less 5 usec for other actions
-               _usec_delay((1_000_000/(2*serial_sw_baudrate))-1)
-               
-               -- now fetch 8 bits
-               for 8 loop
-                       -- wait a whole bittime, less 5 usec for other actions
-                       _usec_delay((1_000_000/serial_sw_baudrate)-1)
-                       -- shift new bit in
-                       data = data >> 1
-                       if !pp then
-                               data = data | 0x80
-                       end if
-               end loop
-       end if
-       
-       -- restore old interrupt status
-       INTCON_GIE = ie_old
-       
-       return true
+   var bit ie_old    ;status of interrupt enable on entrance
+   ;; jallib(seb): this is a way to act on rx pin
+   ;;var bit pp at serial_sw_in_port : serial_sw_in_nr
+   var bit pp is serial_sw_rx_pin
+
+   if serial_sw_invert != pp then
+      return false
+   end if
+
+   -- stop interrupts and be sure they are stopped
+   -- save old interrupt status
+   ie_old = INTCON_GIE
+   while INTCON_GIE loop
+      INTCON_GIE = false
+   end loop
+
+   if serial_sw_invert then
+       -- wait for startbit
+      while pp loop end loop
+
+      -- wait half a bit time, less 5 usec for other actions
+      _usec_delay((1_000_000/(2*serial_sw_baudrate))-1)
+
+      -- now fetch 8 bits
+      for 8 loop
+         -- wait a whole bittime, less 5 usec for other actions
+         _usec_delay((1_000_000/serial_sw_baudrate)-1)
+         -- shift new bit in
+         data = data >> 1
+         if pp then
+            data = data | 0x80
+         end if
+      end loop
+   else  ;NOT inverted
+      -- wait for startbit
+      while !pp loop end loop
+
+      -- wait half a bit time, less 5 usec for other actions
+      _usec_delay((1_000_000/(2*serial_sw_baudrate))-1)
+
+      -- now fetch 8 bits
+      for 8 loop
+         -- wait a whole bittime, less 5 usec for other actions
+         _usec_delay((1_000_000/serial_sw_baudrate)-1)
+         -- shift new bit in
+         data = data >> 1
+         if !pp then
+            data = data | 0x80
+         end if
+      end loop
+   end if
+
+   -- restore old interrupt status
+   INTCON_GIE = ie_old
+
+   return true

  end function


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