acifa.h File Reference


Detailed Description

ACIFA header for AVR32 UC3.

This file defines a useful set of functions for ACIFA on AVR UC3 devices.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file acifa.h.

#include <avr32/io.h>
#include "compiler.h"

Go to the source code of this file.

Defines

#define AVR32_ACIFA_AC0A_INSELN_AC0AN0   0
#define AVR32_ACIFA_AC0A_INSELN_AC0AN1   1
#define AVR32_ACIFA_AC0A_INSELN_AC0BP0   2
#define AVR32_ACIFA_AC0A_INSELN_AC0BP1   3
#define AVR32_ACIFA_AC0A_INSELN_AC1AN1   1
#define AVR32_ACIFA_AC0A_INSELN_AC1BP0   2
#define AVR32_ACIFA_AC0A_INSELN_AC1BP1   3
#define AVR32_ACIFA_AC0A_INSELN_DAC1_INT   5
#define AVR32_ACIFA_AC0A_INSELN_DAC1_INT   5
#define AVR32_ACIFA_AC0A_INSELN_VDDANA_SCALED   4
#define AVR32_ACIFA_AC0A_INSELN_VDDANA_SCALED   4
#define AVR32_ACIFA_AC0A_INSELP_AC0AP0   0
#define AVR32_ACIFA_AC0A_INSELP_AC0AP1   1
#define AVR32_ACIFA_AC0A_INSELP_DAC0_INT   2
#define AVR32_ACIFA_AC0B_INSELN_AC0BN0   0
#define AVR32_ACIFA_AC0B_INSELN_AC0BN1   1
#define AVR32_ACIFA_AC0B_INSELN_AC1BN1   1
#define AVR32_ACIFA_AC0B_INSELN_DAC1_INT   2
#define AVR32_ACIFA_AC0B_INSELN_DAC1_INT   2
#define AVR32_ACIFA_AC0B_INSELP_AC0AN0   0
#define AVR32_ACIFA_AC0B_INSELP_AC0AN1   1
#define AVR32_ACIFA_AC0B_INSELP_AC0BP0   2
#define AVR32_ACIFA_AC0B_INSELP_AC0BP1   3
#define AVR32_ACIFA_AC0B_INSELP_AC1AN1   1
#define AVR32_ACIFA_AC0B_INSELP_AC1BP0   2
#define AVR32_ACIFA_AC0B_INSELP_AC1BP1   3
#define AVR32_ACIFA_AC0B_INSELP_DAC0_INT   4
#define AVR32_ACIFA_AC0B_INSELP_DAC0_INT   4
#define AVR32_ACIFA_AC0B_INSELP_VDDANA_SCALED   5
#define AVR32_ACIFA_AC0B_INSELP_VDDANA_SCALED   5
#define AVR32_ACIFA_AC1A_INSELN_AC1AN0   0
#define AVR32_ACIFA_AC1A_INSELP_AC1AP0   0
#define AVR32_ACIFA_AC1A_INSELP_AC1AP1   1
#define AVR32_ACIFA_AC1A_INSELP_DAC0_INT   2
#define AVR32_ACIFA_AC1B_INSELN_AC1BN0   0
#define AVR32_ACIFA_AC1B_INSELP_AC1AN0   0
Comparator Selection
#define ACIFA_COMP_SELA   1
#define ACIFA_COMP_SELB   2
VCCSCALE Selection
#define ACIFA_VCCSCALE_SELA   1
#define ACIFA_VCCSCALE_SELB   2

Functions

void acifa_configure (volatile avr32_acifa_t *acifa, U8 comp_sel, U8 input_p, U8 input_n, U32 pb_hz)
 Configure ACIFA Normal Mode. Mandatory to call.
void acifa_configure_hysteresis (volatile avr32_acifa_t *acifa, U8 comp_sel, U8 level)
 Configure Hysteresis on comparator.
void acifa_configure_vccscale (volatile avr32_acifa_t *acifa, U8 vccscale_sel, U8 scale)
 Configure VCC Scale on comparator.
void acifa_configure_window (volatile avr32_acifa_t *acifa, U8 input_p, U8 input_n, U8 common_input, U32 pb_hz)
 Configure ACIFA Window Mode. Mandatory to call.
void acifa_enable_output (volatile avr32_acifa_t *acifa, U8 comp_sel)
 Enable Output on comparator.
int acifa_is_aca_inp_higher (volatile avr32_acifa_t *acifa)
 Return comparator A status.
int acifa_is_acb_inp_higher (volatile avr32_acifa_t *acifa)
 Return comparator B status.
int acifa_is_ci_inside_window (volatile avr32_acifa_t *acifa)
 Return Window status.
void acifa_start (volatile avr32_acifa_t *acifa, U8 comp_sel)
 Start comparator in Normal Mode.
void acifa_start_window (volatile avr32_acifa_t *acifa)
 Start comparator in Window Mode.


Define Documentation

#define ACIFA_COMP_SELA   1

#define ACIFA_COMP_SELB   2

Definition at line 117 of file acifa.h.

Referenced by acifa_start(), and main().

#define ACIFA_VCCSCALE_SELA   1

Definition at line 124 of file acifa.h.

Referenced by acifa_configure_vccscale().

#define ACIFA_VCCSCALE_SELB   2

Definition at line 125 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_AC0AN0   0

Local Definition for Negative Inputs Comparator 0 Instance A used by the ACIFA

Definition at line 61 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_AC0AN1   1

Definition at line 62 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_AC0BP0   2

Definition at line 63 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_AC0BP1   3

Definition at line 64 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_AC1AN1   1

Definition at line 92 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_AC1BP0   2

Definition at line 93 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_AC1BP1   3

Definition at line 94 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_DAC1_INT   5

Definition at line 96 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_DAC1_INT   5

Definition at line 96 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_VDDANA_SCALED   4

Definition at line 95 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELN_VDDANA_SCALED   4

Definition at line 95 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELP_AC0AP0   0

Local Definition for Positive Inputs Comparator 0 Instance A used by the ACIFA

Definition at line 55 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELP_AC0AP1   1

Definition at line 56 of file acifa.h.

#define AVR32_ACIFA_AC0A_INSELP_DAC0_INT   2

Definition at line 57 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELN_AC0BN0   0

Local Definition for Negative Inputs Comparator 0 Instance B used by the ACIFA

Definition at line 79 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELN_AC0BN1   1

Definition at line 80 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELN_AC1BN1   1

Definition at line 110 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELN_DAC1_INT   2

Definition at line 111 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELN_DAC1_INT   2

Definition at line 111 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_AC0AN0   0

Local Definition for Positive Inputs Comparator 0 Instance B used by the ACIFA

Definition at line 70 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_AC0AN1   1

Definition at line 71 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_AC0BP0   2

Definition at line 72 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_AC0BP1   3

Definition at line 73 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_AC1AN1   1

Definition at line 101 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_AC1BP0   2

Definition at line 102 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_AC1BP1   3

Definition at line 103 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_DAC0_INT   4

Definition at line 104 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_DAC0_INT   4

Definition at line 104 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_VDDANA_SCALED   5

Definition at line 105 of file acifa.h.

#define AVR32_ACIFA_AC0B_INSELP_VDDANA_SCALED   5

Definition at line 105 of file acifa.h.

#define AVR32_ACIFA_AC1A_INSELN_AC1AN0   0

Local Definition for Negative Inputs Comparator 1 Instance A used by the ACIFA

Definition at line 91 of file acifa.h.

#define AVR32_ACIFA_AC1A_INSELP_AC1AP0   0

Local Definition for Positive Inputs Comparator 1 Instance A used by the ACIFA

Definition at line 85 of file acifa.h.

#define AVR32_ACIFA_AC1A_INSELP_AC1AP1   1

Definition at line 86 of file acifa.h.

#define AVR32_ACIFA_AC1A_INSELP_DAC0_INT   2

Definition at line 87 of file acifa.h.

#define AVR32_ACIFA_AC1B_INSELN_AC1BN0   0

Local Definition for Negative Inputs Comparator 1 Instance B used by the ACIFA

Definition at line 109 of file acifa.h.

#define AVR32_ACIFA_AC1B_INSELP_AC1AN0   0

Local Definition for Positive Inputs Comparator 1 Instance B used by the ACIFA

Definition at line 100 of file acifa.h.


Function Documentation

void acifa_configure ( volatile avr32_acifa_t *  acifa,
U8  comp_sel,
U8  input_p,
U8  input_n,
U32  pb_hz 
)

Configure ACIFA Normal Mode. Mandatory to call.

Parameters:
*acifa Base address of the ACIFA
comp_sel Comparator Selection
input_p Input Positive Selection
input_n Input Negative Selection
pb_hz Periphal Bus frequency

Definition at line 66 of file acifa.c.

References ACIFA_COMP_SELA.

Referenced by main().

00071 {
00072   Assert( acifa!=NULL );
00073   if (comp_sel == ACIFA_COMP_SELA)
00074   {
00075     acifa->confa = ((input_p << AVR32_ACIFA_CONFA_INSELP_OFFSET)&AVR32_ACIFA_CONFA_INSELP_MASK) |
00076                    ((input_n << AVR32_ACIFA_CONFA_INSELN_OFFSET)&AVR32_ACIFA_CONFA_INSELN_MASK) ; 
00077   }
00078   else
00079   {
00080     acifa->confb = ((input_p << AVR32_ACIFA_CONFB_INSELP_OFFSET)&AVR32_ACIFA_CONFB_INSELP_MASK) | 
00081                    ((input_n << AVR32_ACIFA_CONFB_INSELN_OFFSET)&AVR32_ACIFA_CONFB_INSELN_MASK) ; 
00082   }  
00083   // Startup Time of up to 10us max.
00084   acifa->sut = (pb_hz/100000);
00085 }

void acifa_configure_hysteresis ( volatile avr32_acifa_t *  acifa,
U8  comp_sel,
U8  level 
)

Configure Hysteresis on comparator.

Parameters:
*acifa Base address of the ACIFA
comp_sel Comparator Selection
level Level On Hysteresis

Definition at line 115 of file acifa.c.

References ACIFA_COMP_SELA.

00118 {
00119   Assert( acifa!=NULL );
00120   
00121   // Hysteresis Configuration
00122   if (comp_sel == ACIFA_COMP_SELA)
00123   {
00124     acifa->confa |= ((level << AVR32_ACIFA_CONFA_HS_OFFSET)& AVR32_ACIFA_CONFA_HS_MASK); 
00125   }
00126   else
00127   {
00128     acifa->confb |= ((level << AVR32_ACIFA_CONFB_HS_OFFSET)& AVR32_ACIFA_CONFB_HS_MASK); 
00129   }  
00130 }

void acifa_configure_vccscale ( volatile avr32_acifa_t *  acifa,
U8  vccscale_sel,
U8  scale 
)

Configure VCC Scale on comparator.

Parameters:
*acifa Base address of the ACIFA
vccscale_sel VCC Scale Selection
scale Scale

Definition at line 132 of file acifa.c.

References ACIFA_VCCSCALE_SELA.

00135 {
00136   Assert( acifa!=NULL );
00137   
00138   // VCC Scale Configuration
00139   if (vcc_sel == ACIFA_VCCSCALE_SELA)
00140   {
00141     acifa->scfa |= ((scale << AVR32_ACIFA_SCFA_SCALEFACTOR_OFFSET)& AVR32_ACIFA_SCFA_SCALEFACTOR_MASK)|AVR32_ACIFA_SCFA_EN_MASK; 
00142   }
00143   else
00144   {
00145     acifa->scfb |= ((scale << AVR32_ACIFA_SCFB_SCALEFACTOR_OFFSET)& AVR32_ACIFA_SCFB_SCALEFACTOR_MASK)|AVR32_ACIFA_SCFB_EN_MASK; 
00146   }  
00147 }

void acifa_configure_window ( volatile avr32_acifa_t *  acifa,
U8  input_p,
U8  input_n,
U8  common_input,
U32  pb_hz 
)

Configure ACIFA Window Mode. Mandatory to call.

Parameters:
*acifa Base address of the ACIFA
input_p Input Positive Selection for window mode
input_n Input Negative Selection for window mode
common_input Common Input Selection for window mode
pb_hz Periphal Bus frequency

Definition at line 87 of file acifa.c.

00092 {
00093   Assert( acifa!=NULL );
00094   
00095   acifa->wconf |= ((common_input << AVR32_ACIFA_WCONF_WINSEL_OFFSET)&AVR32_ACIFA_WCONF_WINSEL_MASK); 
00096   acifa->confa = ((input_p << AVR32_ACIFA_CONFA_INSELP_OFFSET)&AVR32_ACIFA_CONFA_INSELP_MASK) ; 
00097   acifa->confb = ((input_n << AVR32_ACIFA_CONFB_INSELN_OFFSET)&AVR32_ACIFA_CONFB_INSELN_MASK) ;     
00098   // Startup Time of up to 10us max.
00099   acifa->sut = (pb_hz/100000);
00100 }

void acifa_enable_output ( volatile avr32_acifa_t *  acifa,
U8  comp_sel 
)

Enable Output on comparator.

Parameters:
*acifa Base address of the ACIFA
comp_sel Comparator Selection

Definition at line 102 of file acifa.c.

References ACIFA_COMP_SELA.

00104 {
00105   if (comp_sel == ACIFA_COMP_SELA)
00106   {
00107     acifa->confa |= AVR32_ACIFA_CONFA_OEN_MASK; 
00108   }
00109   else
00110   {
00111     acifa->confb |= AVR32_ACIFA_CONFB_OEN_MASK;
00112   }
00113 }

int acifa_is_aca_inp_higher ( volatile avr32_acifa_t *  acifa  ) 

Return comparator A status.

Parameters:
*acifa Base address of the ACIFA return 1: ACA Input P is higher than Input N / 0: ACA Input P is Lower than Input N

Definition at line 178 of file acifa.c.

Referenced by main().

00179 {
00180   return (acifa->sr & AVR32_ACIFA_SR_ACACS_MASK) != 0;
00181 }

int acifa_is_acb_inp_higher ( volatile avr32_acifa_t *  acifa  ) 

Return comparator B status.

Parameters:
*acifa Base address of the ACIFA return 1: ACB Input P is higher than Input N / 0: ACB Input P is Lower than Input N

Definition at line 183 of file acifa.c.

Referenced by main().

00184 {
00185   return (acifa->sr & AVR32_ACIFA_SR_ACBCS_MASK) != 0;
00186 }

int acifa_is_ci_inside_window ( volatile avr32_acifa_t *  acifa  ) 

Return Window status.

Parameters:
*acifa Base address of the ACIFA return 1: Common Input Signal inside the window / 0: Common Input Signal outside the window

Definition at line 188 of file acifa.c.

00189 {
00190   return (acifa->sr & AVR32_ACIFA_SR_WFCS_MASK) != 0;
00191 }

void acifa_start ( volatile avr32_acifa_t *  acifa,
U8  comp_sel 
)

Start comparator in Normal Mode.

Parameters:
*acifa Base address of the ACIFA
comp_sel Comparator Selection

Definition at line 149 of file acifa.c.

References ACIFA_COMP_SELA, ACIFA_COMP_SELB, acifa_is_aca_ready(), and acifa_is_acb_ready().

Referenced by main().

00151 {
00152   Assert( acifa!=NULL );
00153   
00154   if (comp_sel == ACIFA_COMP_SELA)
00155   {
00156     acifa->en = (AVR32_ACIFA_EN_ACAEN_MASK) | (AVR32_ACIFA_EN_ACACPEN_MASK); 
00157     while(!acifa_is_aca_ready(acifa));
00158   }
00159   else if (comp_sel == ACIFA_COMP_SELB)
00160   {
00161     acifa->en = (AVR32_ACIFA_EN_ACBEN_MASK) | (AVR32_ACIFA_EN_ACBCPEN_MASK);
00162     while(!acifa_is_acb_ready(acifa));  
00163   }  
00164   else
00165   {
00166     acifa->en = (AVR32_ACIFA_EN_ACAEN_MASK) | (AVR32_ACIFA_EN_ACACPEN_MASK)| (AVR32_ACIFA_EN_ACBEN_MASK) | (AVR32_ACIFA_EN_ACBCPEN_MASK);
00167     while(!acifa_is_aca_ready(acifa));
00168     while(!acifa_is_acb_ready(acifa));  
00169   }  
00170 }

void acifa_start_window ( volatile avr32_acifa_t *  acifa  ) 

Start comparator in Window Mode.

Parameters:
*acifa Base address of the ACIFA

Definition at line 172 of file acifa.c.

References acifa_is_wf_ready().

00173 {
00174       acifa->en = (AVR32_ACIFA_EN_WFEN_MASK);
00175       while(!acifa_is_wf_ready(acifa));   
00176 }      


Generated on Fri Feb 19 02:24:10 2010 for AVR32 - ACIFA Driver by  doxygen 1.5.5