Author: sebastien.lelong
Date: Thu May 14 08:06:28 2009
New Revision: 985

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

Log:
first draft to handle VCFG bits

Modified: trunk/include/peripheral/adc/adc_channels.jal
==============================================================================
--- trunk/include/peripheral/adc/adc_channels.jal       (original)
+++ trunk/include/peripheral/adc/adc_channels.jal       Thu May 14 08:06:28 2009
@@ -30,6 +30,14 @@
  include adc_pindef


+-- -----------------------------------------
+-- FIRST CASE:
+--  - PCFG bits exist,
+--  - analog are dependent from each other
+--  - Vref config is done via PCFG bits
+--    combination
+-- -----------------------------------------
+
  if target_chip == PIC_18F6585 | target_chip == PIC_18F6680 | target_chip  
== PIC_18F8585 | target_chip == PIC_18F8680 | target_chip == PIC_16F870 |  
target_chip == PIC_16F871 | target_chip == PIC_16F73 | target_chip ==  
PIC_16F74 | target_chip == PIC_16F76 | target_chip == PIC_16F77 |  
target_chip == PIC_16F737 | target_chip == PIC_16F747 | target_chip ==  
PIC_16F767 | target_chip == PIC_16F777 | target_chip == PIC_16F72 |  
target_chip == PIC_16F873A | target_chip == PIC_16F874A | target_chip ==  
PIC_16F876A | target_chip == PIC_16F877A | target_chip == PIC_16F716 |  
target_chip == PIC_18F2439 | target_chip == PIC_18F2539 | target_chip ==  
PIC_18F4439 | target_chip == PIC_18F4539 | target_chip == PIC_16F873 |  
target_chip == PIC_16F874 | target_chip == PIC_16F876 | target_chip ==  
PIC_16F877 | target_chip == PIC_16F872 | target_chip == PIC_16F818 |  
target_chip == PIC_16F819 then

     -- Datasheet: 30491C
@@ -856,6 +864,14 @@



+
+-- --------------------------------------------
+-- SECOND CASE:
+--  - PCFG bits exist
+--  - analog are independent from each other
+--  - Vref config is done via VCFG bits
+-- --------------------------------------------
+
  elsif target_cpu == PIC_16 & (defined(ANCON0_PCFG0) |  
defined(ANCON0_PCFG1) | defined(ANCON0_PCFG2) | defined(ANCON0_PCFG3) |  
defined(ANCON0_PCFG4) | defined(ANCON0_PCFG5) | defined(ANCON0_PCFG6) |  
defined(ANCON0_PCFG7) | defined(ANCON1_PCFG10) | defined(ANCON1_PCFG11) |  
defined(ANCON1_PCFG12) | defined(ANCON1_PCFG8) | defined(ANCON1_PCFG9)) then

     -- Selecting the number of ADC channels is done using PCFG bits
@@ -1090,10 +1106,47 @@
     end if


+   -- Normalize for VCFG format
+   var byte vcfg_shadow = ADC_NVREF
+   if ADC_NVREF == 2 then
+         vcfg_shadow = 3   -- 0b_10 | 0b_01 => 0b_11 => one bit per VCFG bit*2
+   end if
+
+   if defined(ADCON0_VCFG) == true then
+         ADCON0_VCFG = vcfg_shadow
+   elsif defined(ADCON1_VCFG) == true then
+         ADCON1_VCFG = vcfg_shadow
+   else
+         _error "There should be VCFG bits, I've made a mistake..."
+   end if
+
+
+
+-- --------------------------------------------
+-- THIRD CASE:
+--  - ANS bits exist,
+--  - analog are independent from each other
+--  - Vref config is done via VCFG bits
+-- --------------------------------------------

  else
     -- Selecting the number of ADC channels is done using ANS bits
     asm nop
+
+   -- Normalize for VCFG format
+   var byte vcfg_shadow = ADC_NVREF
+   if ADC_NVREF == 2 then
+         vcfg_shadow = 3   -- 0b_10 | 0b_01 => 0b_11 => one bit per VCFG bit*2
+   end if
+
+   if defined(ADCON0_VCFG) == true then
+         ADCON0_VCFG = vcfg_shadow
+   elsif defined(ADCON1_VCFG) == true then
+         ADCON1_VCFG = vcfg_shadow
+   else
+         _error "There should be VCFG bits, I've made a mistake..."
+   end if
+


  end if

Modified: trunk/tools/adc_channels.jal.tmpl
==============================================================================
--- trunk/tools/adc_channels.jal.tmpl   (original)
+++ trunk/tools/adc_channels.jal.tmpl   Thu May 14 08:06:28 2009
@@ -379,26 +379,66 @@
     asm nop
  #end def

-#def vcfg
+
+#def vcfg()
+   -- Normalize for VCFG format
+   var byte vcfg_shadow = ADC_NVREF
+   if ADC_NVREF == 2 then
+         vcfg_shadow = 3   -- 0b_10 | 0b_01 => 0b_11 => one bit per VCFG bit*2
+   end if
+
+   if defined(ADCON0_VCFG) == true then
+         ADCON0_VCFG = vcfg_shadow
+   elsif defined(ADCON1_VCFG) == true then
+         ADCON1_VCFG = vcfg_shadow
+   else
+         _error "There should be VCFG bits, I've made a mistake..."
+   end if

  #end def

+
  #def main
  $header
  $deps
  #set pcfg_combination_condition = " | ".join(map(lambda x: "target_chip ==  
PIC_%s" % x.upper(),$pcfg_combination_pics))

+-- -----------------------------------------
+-- FIRST CASE:
+--  - PCFG bits exist,
+--  - analog are dependent from each other
+--  - Vref config is done via PCFG bits
+--    combination
+-- -----------------------------------------
+
  ## Check PICs which use PCFG bits as combinations
  if $pcfg_combination_condition then
  $pcfg_combination

+
+-- --------------------------------------------
+-- SECOND CASE:
+--  - PCFG bits exist
+--  - analog are independent from each other
+--  - Vref config is done via VCFG bits
+-- --------------------------------------------
+
  ## 18F PICs, which use PCFG bits
  elsif target_cpu == PIC_16 & (defined(ANCON0_PCFG0) |  
defined(ANCON0_PCFG1) | defined(ANCON0_PCFG2) | defined(ANCON0_PCFG3) |  
defined(ANCON0_PCFG4) | defined(ANCON0_PCFG5) | defined(ANCON0_PCFG6) |  
defined(ANCON0_PCFG7) | defined(ANCON1_PCFG10) | defined(ANCON1_PCFG11) |  
defined(ANCON1_PCFG12) | defined(ANCON1_PCFG8) | defined(ANCON1_PCFG9)) then
  $pcfg_18f
+$vcfg
+
+-- --------------------------------------------
+-- THIRD CASE:
+--  - ANS bits exist,
+--  - analog are independent from each other
+--  - Vref config is done via VCFG bits
+-- --------------------------------------------

  ## So these are PICs which use ANS bits, wether non-18F or 18F
  else
  $ans
+$vcfg

  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