52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
#include "clock.hpp"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "flash/flash.hpp"
|
|
#include "io/io.hpp"
|
|
#include "uart/uart.hpp"
|
|
|
|
#define ADC_INT_VECTOR
|
|
#include "adc/adc.hpp"
|
|
|
|
#define UART0_INT_VECTORS
|
|
#include "uart/hardware0.hpp"
|
|
|
|
#include "thermistor.hpp"
|
|
|
|
int main()
|
|
{
|
|
uart::Uart0<> serial;
|
|
serial.init();
|
|
|
|
serial << F("Thermistor reader\r\n");
|
|
|
|
using adc_conf = adc::Config<adc::SingleMode>;
|
|
|
|
adc::Adc<adc_conf, io::P, io::P::C0> adcPin;
|
|
adcPin.init();
|
|
|
|
Thermistor temp;
|
|
|
|
while (true) {
|
|
const auto adcSample = temp.sampleAdc(adcPin, 1000);
|
|
const auto thermistorResistance = temp.getResistance(adcSample);
|
|
const auto temperature = temp.getTemperature(thermistorResistance);
|
|
|
|
char floatBuffer[16];
|
|
|
|
sprintf(floatBuffer, "%.2f", adcSample);
|
|
serial << F("Read ADC: ") << floatBuffer << F("\r\n");
|
|
sprintf(floatBuffer, "%.2f", thermistorResistance);
|
|
serial << F("Resistance: ") << floatBuffer << F("\r\n");
|
|
sprintf(floatBuffer, "%.2f", temperature);
|
|
serial << F("Temperature: ") << floatBuffer << F(" C \r\n");
|
|
|
|
_delay_ms(1000);
|
|
}
|
|
|
|
serial.flushTx();
|
|
|
|
return 0;
|
|
}
|