10,8 → 10,6 |
//#include <stdlib.h> |
//#include <input.c> //needed for the rs232 input routines |
|
|
int16 count=0xA5A5; |
const int8 buf_len=8; |
|
int8 buffer[buf_len]; // I2C buffer |
21,8 → 19,8 |
#include "..\common\dbloader.h" |
|
unsigned int16 timer0_overflow_count; |
float anemo=0; |
unsigned int8 rain; |
unsigned int16 anemo=0; |
unsigned int16 rain=0; |
|
//we are using the rtctimer.c library, in which a counter is incremented |
//every time the timer2 interrupt occurs (timer2 overflow). the time math |
44,8 → 42,10 |
address = incoming; |
if (incoming == 2) |
{ |
buffer[0]=make8(count,0); |
buffer[1]=make8(count,1); |
buffer[0]=make8(anemo,0); |
buffer[1]=make8(anemo,1); |
buffer[2]=make8(rain,0); |
buffer[3]=make8(rain,1); |
} |
} |
if(state == 2) //Second received byte is data |
62,7 → 62,7 |
void TIMER1_isr(void) |
{ |
// 32.768 kHz krystal pro timer1 oscilátor |
anemo = ((timer0_overflow_count * 0xFF) + get_timer0())/(0xFFFF/32768.0); // pocet pulzu za 1s |
anemo = ((timer0_overflow_count * 0xFF) + get_timer0()); // pocet pulzu za 1s |
|
timer0_overflow_count=0; //nulovani |
set_timer0(0); |
173,7 → 173,6 |
set_timer0(0); |
set_timer1(0); |
timer0_overflow_count=0; |
rain=0; |
|
buffer[2]=0; |
buffer[3]=0; |
180,15 → 179,12 |
buffer[4]=0; |
buffer[5]=0; |
|
|
welcome(); |
|
set_timer1(0); |
|
while(true) |
{ |
printf("count: %X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]); |
printf("%6.1f %u \n\r", anemo, rain); |
printf("%Lu %Lu \n\r", anemo, rain); |
|
delay_ms(1000); |
|