2019-01-01 15:48:54 +00:00
|
|
|
#include "time.h"
|
|
|
|
#include "usart.h"
|
2019-01-17 18:41:08 +00:00
|
|
|
#include "analogin.h"
|
|
|
|
#include "configuration.h"
|
2019-01-01 15:48:54 +00:00
|
|
|
#include <util/delay.h>
|
2019-01-17 18:41:08 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <avr/io.h>
|
|
|
|
|
2019-04-07 18:35:05 +00:00
|
|
|
volatile int measurement_complete;
|
|
|
|
volatile unsigned char channel_measured;
|
|
|
|
volatile unsigned int value_measured;
|
|
|
|
|
2019-01-17 18:41:08 +00:00
|
|
|
void
|
|
|
|
on_channel_measured(unsigned char channel
|
|
|
|
, unsigned int value)
|
|
|
|
{
|
2019-04-07 18:35:05 +00:00
|
|
|
measurement_complete = 1;
|
|
|
|
channel_measured = channel;
|
|
|
|
value_measured = value;
|
|
|
|
PORTB ^= _BV(PB2);
|
2019-01-17 18:41:08 +00:00
|
|
|
}
|
|
|
|
|
2019-01-01 15:48:54 +00:00
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2019-04-07 18:35:05 +00:00
|
|
|
unsigned char channel;
|
|
|
|
unsigned int value;
|
|
|
|
|
2019-01-17 18:41:08 +00:00
|
|
|
configuration_init();
|
2019-01-01 15:48:54 +00:00
|
|
|
time_init();
|
|
|
|
usart_init();
|
2019-01-17 18:41:08 +00:00
|
|
|
analogin_init();
|
|
|
|
|
|
|
|
DDRB |= _BV(PB1);
|
|
|
|
DDRB |= _BV(PB2);
|
2019-01-01 15:48:54 +00:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2019-04-07 18:35:05 +00:00
|
|
|
if(measurement_complete)
|
|
|
|
{
|
|
|
|
measurement_complete = 0;
|
|
|
|
|
|
|
|
channel = channel_measured;
|
|
|
|
value = value_measured;
|
|
|
|
|
|
|
|
struct eigentime_s eigentime;
|
|
|
|
get_eigentime(&eigentime);
|
|
|
|
char buffer[32];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
utoa(eigentime.high, buffer, 16);
|
|
|
|
i = 0;
|
|
|
|
while(buffer[i])
|
|
|
|
{
|
|
|
|
usart_putc(buffer[i++]);
|
|
|
|
}
|
|
|
|
usart_putc(',');
|
|
|
|
utoa(eigentime.low, buffer, 16);
|
|
|
|
i = 0;
|
|
|
|
while(buffer[i])
|
|
|
|
{
|
|
|
|
usart_putc(buffer[i++]);
|
|
|
|
}
|
|
|
|
usart_putc(',');
|
|
|
|
usart_putc('0' + channel);
|
|
|
|
usart_putc(',');
|
|
|
|
|
|
|
|
utoa(value, buffer, 16);
|
|
|
|
i = 0;
|
|
|
|
while(buffer[i])
|
|
|
|
{
|
|
|
|
usart_putc(buffer[i++]);
|
|
|
|
}
|
|
|
|
for(i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
usart_putc('\n');
|
|
|
|
}
|
|
|
|
PORTB ^= _BV(PB1);
|
|
|
|
|
|
|
|
}
|
2019-01-17 18:41:08 +00:00
|
|
|
|
2019-01-01 15:48:54 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|