mirror of
https://github.com/markqvist/OpenModem.git
synced 2025-05-17 05:42:18 -04:00
Implemented variable VREF for DAC and ADC
This commit is contained in:
parent
cf186ba64a
commit
8b2e66eb57
7 changed files with 51 additions and 5 deletions
30
hardware/VREF.c
Normal file
30
hardware/VREF.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "VREF.h"
|
||||
|
||||
uint8_t adcReference = CONFIG_ADC_REF;
|
||||
uint8_t dacReference = CONFIG_DAC_REF;
|
||||
|
||||
void VREF_init(void) {
|
||||
//DDRD |= _BV(7);
|
||||
DDRD = 0xFF;
|
||||
|
||||
TCCR2A = _BV(WGM20) |
|
||||
_BV(WGM21) |
|
||||
_BV(COM2A1)|
|
||||
_BV(COM2B1);
|
||||
|
||||
TCCR2B = _BV(CS20);
|
||||
|
||||
OCR2A = adcReference;
|
||||
OCR2B = dacReference;
|
||||
}
|
||||
|
||||
|
||||
void vref_setADC(uint8_t value) {
|
||||
adcReference = value;
|
||||
OCR2A = adcReference;
|
||||
}
|
||||
|
||||
void vref_setDAC(uint8_t value) {
|
||||
dacReference = value;
|
||||
OCR2B = dacReference;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue