OpenModem/hardware/VREF.c

28 lines
547 B
C
Raw Normal View History

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