Transmit ADC value through UART
This commit is contained in:
32
src/ad_converter.c
Normal file
32
src/ad_converter.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "BA45F5250.h"
|
||||
#include "stdint.h"
|
||||
#include "build-in.h"
|
||||
#include "ad_converter.h"
|
||||
#include "eeprom_rw.h"
|
||||
#include "uart_configuration.h"
|
||||
|
||||
void adc_config()
|
||||
{
|
||||
_sadc0 = 0b00000000;
|
||||
_sadc1 = 0b01101011;
|
||||
_ade = 0;
|
||||
}
|
||||
|
||||
uint8_t read_adc()
|
||||
{
|
||||
uint8_t temp;
|
||||
_adcen = 1;
|
||||
GCC_DELAY(12);
|
||||
_start = 0;
|
||||
_start = 1;
|
||||
_start = 0;
|
||||
while(_adbz);
|
||||
_adcen = 0;
|
||||
temp = _sadoh;
|
||||
if(_adrfs != 0)
|
||||
{
|
||||
temp = (temp << 8) | _sadol;
|
||||
}
|
||||
uart_transmit(temp);
|
||||
return temp;
|
||||
}
|
||||
Reference in New Issue
Block a user