OpenModem/hardware/VREF.c

28 lines
547 B
C
Raw Normal View History

#include "VREF.h"
2019-02-08 07:18:49 -05:00
#include "util/Config.h"
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);
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;
}
void vref_setADC(uint8_t value) {
2019-02-08 07:18:49 -05:00
config_input_gain = value;
2019-04-05 07:26:53 -04:00
OCR2A = 0xFF - config_input_gain;
}
void vref_setDAC(uint8_t value) {
2019-02-08 07:18:49 -05:00
config_output_gain = value;
OCR2B = config_output_gain;
}