00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef DAC_DRV_H
00015 #define DAC_DRV_H
00016
00017
00018
00019
00023
00024
00028
00032 #define Enable_dac() (DACON |= (1<<DAEN))
00034
00038 #define Disable_dac() (DACON &= ~(1<<DAEN))
00040
00044 #define Right_adjust_dac_input() (DACON &= ~(1<<DALA))
00045 #define Left_adjust_dac_input() (DACON |= (1<<DALA))
00047
00048
00052 #define Enable_dac_output() (DACON |= (1<<DAOE))
00053 #define Disable_dac_output() (DACON &= ~(1<<DAOE))
00055
00059 #define Set_dac_8_bits(dac_in) (DACH = (U8)(dac_in))
00060 #define Set_dac_10_bits(dac_in) (DACL = LOW((U16)(dac_in)), DACH = HIGH((U16)(dac_in)))
00062
00063 #define Right_adjust_dac_result() (DACON &= ~(1<<DALA))
00064 #define Left_adjust_dac_result() (DACON |= (1<<DALA))
00065
00066 #define Enable_internal_vref() (ADMUX |= ((1<<REFS1)|(1<<REFS0)) )
00067 #define Enable_external_vref() (ADMUX &= ~((1<<REFS1)|(1<<REFS0)) )
00068 #define Enable_vcc_vref() (ADMUX &= ~(1<<REFS1), ADMUX |= (1<<REFS0) )
00069
00070 #define Output_dac_enable() (DACON |= (1<<DAOE))
00071 #define Output_dac_disabled() (DACON &= ~(1<<DAOE))
00072
00073
00074
00075
00076
00080
00082 void init_dac(void);
00083
00085
00087
00088 #endif // DAC_DRV_H