//#DOC Main, program entry and main loop
#include "main.h"
#include <otSerial.h>
#include <otTimer.h>
#include <otPrintf.h>
#include <otSMBus.h>
#include <otFPGA.h>
#include <otMLX90614.h>
#include <otPort.h>
otMLX90614 irt;
F64 to, ta;
void setup()
{
UartEnableSignals(UART0);
UartSetBaud(UART0, 115200);
setStdout(4096, UART0); // printf output is now directed on UART0
// PF15 is clock, PF13 is data
SMBusInit(PP_F, 15, PP_F, 13);
DelayMs(1000);
if(!irt.init())
{
printf("MLX90614 not found!\n");
IDLE;
}
}
void loop()
{
U32 i = 1;
while(1)
{
irt.readObjectTemp(to);
irt.readAmbientTemp(ta);
printf("[%4u] Obj: %.1lf C, Env: %.1lf C\n", i++, to, ta);
DelayMs(500);
}
}