This file defines a useful set of functions for ACIFA on AVR UC3 devices.
Definition in file acifa.h.
#include <avr32/io.h>
#include "compiler.h"
Go to the source code of this file.
#define ACIFA_COMP_SELA 1 |
Definition at line 116 of file acifa.h.
Referenced by acifa_configure(), acifa_configure_hysteresis(), acifa_enable_output(), acifa_start(), and main().
#define ACIFA_COMP_SELB 2 |
#define ACIFA_VCCSCALE_SELA 1 |
#define AVR32_ACIFA_AC0A_INSELN_AC0AN0 0 |
#define AVR32_ACIFA_AC0A_INSELP_AC0AP0 0 |
#define AVR32_ACIFA_AC0B_INSELN_AC0BN0 0 |
#define AVR32_ACIFA_AC0B_INSELP_AC0AN0 0 |
#define AVR32_ACIFA_AC1A_INSELN_AC1AN0 0 |
#define AVR32_ACIFA_AC1A_INSELP_AC1AP0 0 |
#define AVR32_ACIFA_AC1B_INSELN_AC1BN0 0 |
#define AVR32_ACIFA_AC1B_INSELP_AC1AN0 0 |
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.
*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.
*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.
*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.
*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.
*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 | ) |
int acifa_is_acb_inp_higher | ( | volatile avr32_acifa_t * | acifa | ) |
int acifa_is_ci_inside_window | ( | volatile avr32_acifa_t * | acifa | ) |
void acifa_start | ( | volatile avr32_acifa_t * | acifa, | |
U8 | comp_sel | |||
) |
Start comparator in Normal Mode.
*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.
*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 }