--- trunk/Embedded/main.c 2007/12/09 15:07:32 201 +++ trunk/Embedded/main.c 2007/12/11 09:27:51 228 @@ -7,7 +7,7 @@ #include "lcd.h" #include "Delay.h" -#define BUFFER 128 +#define BUFFER 160 #define PWRFAIL RB1 #define FIREDET RB2 #define FEEDING RB3 @@ -16,8 +16,8 @@ unsigned char global_Pot_Hi, global_Pot_Lo; unsigned char global_serial_send[BUFFER], global_serial_recieve_buffer[BUFFER]; -bit global_recieve_done = 0, global_interval_changed = 0; -unsigned int global_serial_byte_counter = 0, global_sms_counter = 1, global_time_counter = 0, global_time_counter_image = 0; +bit global_recieve_done = 0; +unsigned int global_serial_byte_counter = 0, global_sms_counter = 1, global_time_counter = 0; unsigned int global_emergency_counter = 600, global_time_interval = 3600; unsigned char global_temp = 0; @@ -45,7 +45,7 @@ void serial_recieved(void); void serial_send(void); void update_lcd(void); -void convertTemp(void); +void convert_temp(void); void timer1_interrupt(void); void on_recieve(void); void on_initial_recieve(void); @@ -59,9 +59,7 @@ global_recieve_done = 0; global_message_buffer_length1 = 0; - //global_message_buffer1[0] = 0; global_message_buffer_length2 = 0; - //global_message_buffer2[0] = 0; memset(global_message_buffer1, 0, BUFFER); memset(global_message_buffer2, 0, BUFFER); @@ -86,8 +84,8 @@ ADCS1 = 0; ADCS2 = 0; - //Select AN0/RA0 for AD source - // In this (000) setup, it's only RA0/AN0 that does ad convertion. + //Select AN0/RA0 for AD source. + // In this (000) setup, it's only RA0/AN0 that does ad convertion. CHS0=0; CHS1=0; CHS2=0; @@ -126,16 +124,16 @@ void timer_init(void) { - TMR1CS = 1; //use external clock + TMR1CS = 1; //use external clock - T1CKPS1 = 1; //1:8 prescale + T1CKPS1 = 1; //1:8 prescale T1CKPS0 = 1; TMR1H = 0xEF; TMR1L = 0xFF; - T1OSCEN = 1; //enable oscillator circuit - RD16 = 0; //normal 8 bit writes + T1OSCEN = 1; //enable oscillator circuit + RD16 = 0; //normal 8 bit writes TMR1ON = 1; } @@ -218,20 +216,9 @@ void on_initial_recieve(void) { - char imei[16]; - char* ptr; - char i; - char buf[2]; - if (strstr(global_serial_recieve_buffer,"+WIND: 11") != 0) { global_modem_init = 1; - - ptr = strstr(global_serial_recieve_buffer,"cgsn"); - ptr +=4; - strncpy(imei, ptr,15); - imei[15] = 0; - reset_recieve_buffer(); } } @@ -304,14 +291,13 @@ TMR1L = 0xFF; global_time_counter++; global_emergency_counter++; - RA1 = !RA1; } + ////////// ORDENARY FUNKTIONS ////////// void update_lcd(void) { if(global_temp_update_display != global_time_counter) { - // lcd_clear(); lcd_goto(0x00); sprintf(global_lcd_buf, "Temp: %3d", global_temp); @@ -346,7 +332,7 @@ } } -void convert_temp() +void convert_temp(void) { short adVal; adVal = (global_Pot_Hi << 8) | global_Pot_Lo; @@ -492,7 +478,7 @@ DelayMs(50); reset_recieve_buffer(); - RA5 = 0; // Inits are done, and RA1 will now work as a error notifier. + RA5 = 0; // Inits are done, and RA1 will now work as a error notifier. while(1) { @@ -513,12 +499,6 @@ if( global_emergency_counter > 7200 ) global_emergency_counter = 600; - // Checks if there has been recieved a config sms. - if(global_interval_changed ) - { - eeprom_writer(); - global_interval_changed = 0; - } // Checking if A/D convertion is done, and save the data in global_Pot_?? if(GODONE==0) {