Author: sebastien.lelong
Date: Sat May 23 09:07:58 2009
New Revision: 1009

Modified:
    trunk/include/peripheral/adc/adc_channels.jal
    trunk/tools/adc_channels.jal.tmpl

Log:
when ANS bits are present, the number of ADC channels is explicitely set  
using set_analog_pin()

Modified: trunk/include/peripheral/adc/adc_channels.jal
==============================================================================
--- trunk/include/peripheral/adc/adc_channels.jal       (original)
+++ trunk/include/peripheral/adc/adc_channels.jal       Sat May 23 09:07:58 2009
@@ -1306,119 +1306,119 @@
     --     - set_analog_pin(4) will do the same for AN4
     procedure set_analog_pin(byte in an_pin_num) is
        if defined(JALLIB_ANS0) == true then
-                if an_pin_num == 0 then
-                       JALLIB_ANS0 = true
-                end if
+         if an_pin_num == 0 then
+            JALLIB_ANS0 = true
+         end if
        end if
        if defined(JALLIB_ANS1) == true then
-                if an_pin_num == 1 then
-                       JALLIB_ANS1 = true
-                end if
+         if an_pin_num == 1 then
+            JALLIB_ANS1 = true
+         end if
        end if
        if defined(JALLIB_ANS2) == true then
-                if an_pin_num == 2 then
-                       JALLIB_ANS2 = true
-                end if
+         if an_pin_num == 2 then
+            JALLIB_ANS2 = true
+         end if
        end if
        if defined(JALLIB_ANS3) == true then
-                if an_pin_num == 3 then
-                       JALLIB_ANS3 = true
-                end if
+         if an_pin_num == 3 then
+            JALLIB_ANS3 = true
+         end if
        end if
        if defined(JALLIB_ANS4) == true then
-                if an_pin_num == 4 then
-                       JALLIB_ANS4 = true
-                end if
+         if an_pin_num == 4 then
+            JALLIB_ANS4 = true
+         end if
        end if
        if defined(JALLIB_ANS5) == true then
-                if an_pin_num == 5 then
-                       JALLIB_ANS5 = true
-                end if
+         if an_pin_num == 5 then
+            JALLIB_ANS5 = true
+         end if
        end if
        if defined(JALLIB_ANS6) == true then
-                if an_pin_num == 6 then
-                       JALLIB_ANS6 = true
-                end if
+         if an_pin_num == 6 then
+            JALLIB_ANS6 = true
+         end if
        end if
        if defined(JALLIB_ANS7) == true then
-                if an_pin_num == 7 then
-                       JALLIB_ANS7 = true
-                end if
+         if an_pin_num == 7 then
+            JALLIB_ANS7 = true
+         end if
        end if
        if defined(JALLIB_ANS8) == true then
-                if an_pin_num == 8 then
-                       JALLIB_ANS8 = true
-                end if
+         if an_pin_num == 8 then
+            JALLIB_ANS8 = true
+         end if
        end if
        if defined(JALLIB_ANS9) == true then
-                if an_pin_num == 9 then
-                       JALLIB_ANS9 = true
-                end if
+         if an_pin_num == 9 then
+            JALLIB_ANS9 = true
+         end if
        end if
        if defined(JALLIB_ANS10) == true then
-                if an_pin_num == 10 then
-                       JALLIB_ANS10 = true
-                end if
+         if an_pin_num == 10 then
+            JALLIB_ANS10 = true
+         end if
        end if
        if defined(JALLIB_ANS11) == true then
-                if an_pin_num == 11 then
-                       JALLIB_ANS11 = true
-                end if
+         if an_pin_num == 11 then
+            JALLIB_ANS11 = true
+         end if
        end if
        if defined(JALLIB_ANS12) == true then
-                if an_pin_num == 12 then
-                       JALLIB_ANS12 = true
-                end if
+         if an_pin_num == 12 then
+            JALLIB_ANS12 = true
+         end if
        end if
        if defined(JALLIB_ANS13) == true then
-                if an_pin_num == 13 then
-                       JALLIB_ANS13 = true
-                end if
+         if an_pin_num == 13 then
+            JALLIB_ANS13 = true
+         end if
        end if
        if defined(JALLIB_ANS14) == true then
-                if an_pin_num == 14 then
-                       JALLIB_ANS14 = true
-                end if
+         if an_pin_num == 14 then
+            JALLIB_ANS14 = true
+         end if
        end if
        if defined(JALLIB_ANS15) == true then
-                if an_pin_num == 15 then
-                       JALLIB_ANS15 = true
-                end if
+         if an_pin_num == 15 then
+            JALLIB_ANS15 = true
+         end if
        end if
        if defined(JALLIB_ANS16) == true then
-                if an_pin_num == 16 then
-                       JALLIB_ANS16 = true
-                end if
+         if an_pin_num == 16 then
+            JALLIB_ANS16 = true
+         end if
        end if
        if defined(JALLIB_ANS17) == true then
-                if an_pin_num == 17 then
-                       JALLIB_ANS17 = true
-                end if
+         if an_pin_num == 17 then
+            JALLIB_ANS17 = true
+         end if
        end if
        if defined(JALLIB_ANS18) == true then
-                if an_pin_num == 18 then
-                       JALLIB_ANS18 = true
-                end if
+         if an_pin_num == 18 then
+            JALLIB_ANS18 = true
+         end if
        end if
        if defined(JALLIB_ANS19) == true then
-                if an_pin_num == 19 then
-                       JALLIB_ANS19 = true
-                end if
+         if an_pin_num == 19 then
+            JALLIB_ANS19 = true
+         end if
        end if
        if defined(JALLIB_ANS20) == true then
-                if an_pin_num == 20 then
-                       JALLIB_ANS20 = true
-                end if
+         if an_pin_num == 20 then
+            JALLIB_ANS20 = true
+         end if
        end if
        if defined(JALLIB_ANS21) == true then
-                if an_pin_num == 21 then
-                       JALLIB_ANS21 = true
-                end if
+         if an_pin_num == 21 then
+            JALLIB_ANS21 = true
+         end if
        end if
        if defined(JALLIB_ANS22) == true then
-                if an_pin_num == 22 then
-                       JALLIB_ANS22 = true
-                end if
+         if an_pin_num == 22 then
+            JALLIB_ANS22 = true
+         end if
        end if
     end procedure

@@ -1435,121 +1435,130 @@
     -- Note: the pin direction is not modified
     procedure set_digital_pin(byte in an_pin_num) is
        if defined(JALLIB_ANS0) == true then
-                if an_pin_num == 0 then
-                       JALLIB_ANS0 = false
-                end if
+         if an_pin_num == 0 then
+            JALLIB_ANS0 = false
+         end if
        end if
        if defined(JALLIB_ANS1) == true then
-                if an_pin_num == 1 then
-                       JALLIB_ANS1 = false
-                end if
+         if an_pin_num == 1 then
+            JALLIB_ANS1 = false
+         end if
        end if
        if defined(JALLIB_ANS2) == true then
-                if an_pin_num == 2 then
-                       JALLIB_ANS2 = false
-                end if
+         if an_pin_num == 2 then
+            JALLIB_ANS2 = false
+         end if
        end if
        if defined(JALLIB_ANS3) == true then
-                if an_pin_num == 3 then
-                       JALLIB_ANS3 = false
-                end if
+         if an_pin_num == 3 then
+            JALLIB_ANS3 = false
+         end if
        end if
        if defined(JALLIB_ANS4) == true then
-                if an_pin_num == 4 then
-                       JALLIB_ANS4 = false
-                end if
+         if an_pin_num == 4 then
+            JALLIB_ANS4 = false
+         end if
        end if
        if defined(JALLIB_ANS5) == true then
-                if an_pin_num == 5 then
-                       JALLIB_ANS5 = false
-                end if
+         if an_pin_num == 5 then
+            JALLIB_ANS5 = false
+         end if
        end if
        if defined(JALLIB_ANS6) == true then
-                if an_pin_num == 6 then
-                       JALLIB_ANS6 = false
-                end if
+         if an_pin_num == 6 then
+            JALLIB_ANS6 = false
+         end if
        end if
        if defined(JALLIB_ANS7) == true then
-                if an_pin_num == 7 then
-                       JALLIB_ANS7 = false
-                end if
+         if an_pin_num == 7 then
+            JALLIB_ANS7 = false
+         end if
        end if
        if defined(JALLIB_ANS8) == true then
-                if an_pin_num == 8 then
-                       JALLIB_ANS8 = false
-                end if
+         if an_pin_num == 8 then
+            JALLIB_ANS8 = false
+         end if
        end if
        if defined(JALLIB_ANS9) == true then
-                if an_pin_num == 9 then
-                       JALLIB_ANS9 = false
-                end if
+         if an_pin_num == 9 then
+            JALLIB_ANS9 = false
+         end if
        end if
        if defined(JALLIB_ANS10) == true then
-                if an_pin_num == 10 then
-                       JALLIB_ANS10 = false
-                end if
+         if an_pin_num == 10 then
+            JALLIB_ANS10 = false
+         end if
        end if
        if defined(JALLIB_ANS11) == true then
-                if an_pin_num == 11 then
-                       JALLIB_ANS11 = false
-                end if
+         if an_pin_num == 11 then
+            JALLIB_ANS11 = false
+         end if
        end if
        if defined(JALLIB_ANS12) == true then
-                if an_pin_num == 12 then
-                       JALLIB_ANS12 = false
-                end if
+         if an_pin_num == 12 then
+            JALLIB_ANS12 = false
+         end if
        end if
        if defined(JALLIB_ANS13) == true then
-                if an_pin_num == 13 then
-                       JALLIB_ANS13 = false
-                end if
+         if an_pin_num == 13 then
+            JALLIB_ANS13 = false
+         end if
        end if
        if defined(JALLIB_ANS14) == true then
-                if an_pin_num == 14 then
-                       JALLIB_ANS14 = false
-                end if
+         if an_pin_num == 14 then
+            JALLIB_ANS14 = false
+         end if
        end if
        if defined(JALLIB_ANS15) == true then
-                if an_pin_num == 15 then
-                       JALLIB_ANS15 = false
-                end if
+         if an_pin_num == 15 then
+            JALLIB_ANS15 = false
+         end if
        end if
        if defined(JALLIB_ANS16) == true then
-                if an_pin_num == 16 then
-                       JALLIB_ANS16 = false
-                end if
+         if an_pin_num == 16 then
+            JALLIB_ANS16 = false
+         end if
        end if
        if defined(JALLIB_ANS17) == true then
-                if an_pin_num == 17 then
-                       JALLIB_ANS17 = false
-                end if
+         if an_pin_num == 17 then
+            JALLIB_ANS17 = false
+         end if
        end if
        if defined(JALLIB_ANS18) == true then
-                if an_pin_num == 18 then
-                       JALLIB_ANS18 = false
-                end if
+         if an_pin_num == 18 then
+            JALLIB_ANS18 = false
+         end if
        end if
        if defined(JALLIB_ANS19) == true then
-                if an_pin_num == 19 then
-                       JALLIB_ANS19 = false
-                end if
+         if an_pin_num == 19 then
+            JALLIB_ANS19 = false
+         end if
        end if
        if defined(JALLIB_ANS20) == true then
-                if an_pin_num == 20 then
-                       JALLIB_ANS20 = false
-                end if
+         if an_pin_num == 20 then
+            JALLIB_ANS20 = false
+         end if
        end if
        if defined(JALLIB_ANS21) == true then
-                if an_pin_num == 21 then
-                       JALLIB_ANS21 = false
-                end if
+         if an_pin_num == 21 then
+            JALLIB_ANS21 = false
+         end if
        end if
        if defined(JALLIB_ANS22) == true then
-                if an_pin_num == 22 then
-                       JALLIB_ANS22 = false
-                end if
+         if an_pin_num == 22 then
+            JALLIB_ANS22 = false
+         end if
        end if
     end procedure
+
+   -- Because there are many different combinations when specifying the  
number of
+   -- wanted adc channles, because I think it's more user-friendly to use
+   -- set_analog_pin() instead of specifying ADC_NCHANNEL and then always  
wondering
+   -- which ADC pin to use, and finally, because I'm lazy, there won't be  
automatic
+   -- ADC_NCHANNEL settings in this case
+   if defined(ADC_NCHANNEL) == true then
+      _error "You can't specify the number of ADC channel with  
ADC_NCHANNEL, you have to use set_analog_pin(...)"
+   end if




Modified: trunk/tools/adc_channels.jal.tmpl
==============================================================================
--- trunk/tools/adc_channels.jal.tmpl   (original)
+++ trunk/tools/adc_channels.jal.tmpl   Sat May 23 09:07:58 2009
@@ -520,9 +520,9 @@
     procedure set_analog_pin(byte in an_pin_num) is
        #for i in range(23)
        if defined(JALLIB_ANS$i) == true then
-                if an_pin_num == $i then
-                       JALLIB_ANS$i = true
-                end if
+         if an_pin_num == $i then
+            JALLIB_ANS$i = true
+         end if
        end if
        #end for
     end procedure
@@ -541,12 +541,21 @@
     procedure set_digital_pin(byte in an_pin_num) is
        #for i in range(23)
        if defined(JALLIB_ANS$i) == true then
-                if an_pin_num == $i then
-                       JALLIB_ANS$i = false
-                end if
+         if an_pin_num == $i then
+            JALLIB_ANS$i = false
+         end if
        end if
        #end for
     end procedure
+
+   -- Because there are many different combinations when specifying the  
number of
+   -- wanted adc channles, because I think it's more user-friendly to use
+   -- set_analog_pin() instead of specifying ADC_NCHANNEL and then always  
wondering
+   -- which ADC pin to use, and finally, because I'm lazy, there won't be  
automatic
+   -- ADC_NCHANNEL settings in this case
+   if defined(ADC_NCHANNEL) == true then
+      _error "You can't specify the number of ADC channel with  
ADC_NCHANNEL, you have to use set_analog_pin(...)"
+   end if

  #end def


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