2019-01-04 10:13:29 -05:00
|
|
|
#include "VREF.h"
|
2019-02-08 07:18:49 -05:00
|
|
|
#include "util/Config.h"
|
2019-01-04 10:13:29 -05:00
|
|
|
|
|
|
|
void VREF_init(void) {
|
2019-01-05 07:47:46 -05:00
|
|
|
// Enable output for OC2A and OC2B (PD7 and PD6)
|
2019-01-12 09:12:51 -05:00
|
|
|
VREF_DDR |= _BV(7) | _BV(6);
|
2019-01-04 10:13:29 -05:00
|
|
|
|
|
|
|
TCCR2A = _BV(WGM20) |
|
|
|
|
_BV(WGM21) |
|
|
|
|
_BV(COM2A1)|
|
|
|
|
_BV(COM2B1);
|
|
|
|
|
|
|
|
TCCR2B = _BV(CS20);
|
|
|
|
|
2019-02-08 07:18:49 -05:00
|
|
|
OCR2A = config_input_gain;
|
|
|
|
OCR2B = config_output_gain;
|
2019-01-04 10:13:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void vref_setADC(uint8_t value) {
|
2019-02-08 07:18:49 -05:00
|
|
|
config_input_gain = value;
|
|
|
|
OCR2A = config_input_gain;
|
2019-01-04 10:13:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void vref_setDAC(uint8_t value) {
|
2019-02-08 07:18:49 -05:00
|
|
|
config_output_gain = value;
|
|
|
|
OCR2B = config_output_gain;
|
2019-01-04 10:13:29 -05:00
|
|
|
}
|