/[H9]/trunk/Embedded/main.c
ViewVC logotype

Diff of /trunk/Embedded/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 178 by hedin, Thu Dec 6 14:19:51 2007 UTC revision 205 by hedin, Sun Dec 9 21:01:04 2007 UTC
# Line 6  Line 6 
6    
7  #include "lcd.h"  #include "lcd.h"
8  #include "Delay.h"  #include "Delay.h"
 // Delay.h is included inside lcd.c  
9    
10  #define BUFFER 128  #define BUFFER 128
11  #define PWRFAIL RB1  #define PWRFAIL RB1
# Line 46  __EEPROM_DATA( '1', '7', '8', '4',0,0,0, Line 45  __EEPROM_DATA( '1', '7', '8', '4',0,0,0,
45  void serial_recieved(void);  void serial_recieved(void);
46  void serial_send(void);  void serial_send(void);
47  void update_lcd(void);  void update_lcd(void);
48  void convertTemp(void);  void convert_temp(void);
49  void timer1_interrupt(void);  void timer1_interrupt(void);
50  void on_recieve(void);  void on_recieve(void);
51  void on_initial_recieve(void);  void on_initial_recieve(void);
# Line 152  void rs232_init(void) Line 151  void rs232_init(void)
151          RCSTA   = 0x90; // 0x90 enables SPEN and CREN in the RCSTA register          RCSTA   = 0x90; // 0x90 enables SPEN and CREN in the RCSTA register
152  }  }
153    
154  void sms_init(void)  void modem_init(void)
155  {  {
156          int i;          int i;
157          char buf[2];          char buf[2];
# Line 219  void serial_send(void) Line 218  void serial_send(void)
218    
219  void on_initial_recieve(void)  void on_initial_recieve(void)
220  {  {
221          char imei[16];  // can't se what the outcommented lines in here sould do, that make any sence.
222          char* ptr;  //      char imei[16];
223          char i;  //      char* ptr;
224          char buf[2];  //      char i;
225    //      char buf[2];
226                    
227          if (strstr(global_serial_recieve_buffer,"+WIND: 11") != 0)          if (strstr(global_serial_recieve_buffer,"+WIND: 11") != 0)
228          {          {
229                  global_modem_init = 1;                  global_modem_init = 1;
230    
231                  ptr = strstr(global_serial_recieve_buffer,"cgsn");  //              ptr = strstr(global_serial_recieve_buffer,"cgsn");
232                  ptr +=4;  //              ptr +=4;
233                  strncpy(imei, ptr,15);  //              strncpy(imei, ptr,15);
234                  imei[15] = 0;  //              imei[15] = 0;
235                                    
236                  reset_recieve_buffer();                  reset_recieve_buffer();
237          }          }
# Line 305  void timer1_interrupt(void) Line 305  void timer1_interrupt(void)
305          TMR1L = 0xFF;          TMR1L = 0xFF;
306          global_time_counter++;          global_time_counter++;
307          global_emergency_counter++;          global_emergency_counter++;
308          RA1 = !RA1;  //      RA1 = !RA1;
309  }  }
310  //////////  ORDENARY FUNKTIONS  //////////  //////////  ORDENARY FUNKTIONS  //////////
311  void update_lcd(void)  void update_lcd(void)
# Line 347  void send_sms(const unsigned char* paylo Line 347  void send_sms(const unsigned char* paylo
347          }          }
348  }        }      
349    
350  void convert_temp()  void convert_temp(void)
351  {  {
352          short adVal;          short adVal;
353          adVal = (global_Pot_Hi << 8) | global_Pot_Lo;          adVal = (global_Pot_Hi << 8) | global_Pot_Lo;
# Line 405  void on_recieve(void) Line 405  void on_recieve(void)
405          if (strstr(global_message_buffer1,"CMTI") != 0) // here we handles a incomming SMS          if (strstr(global_message_buffer1,"CMTI") != 0) // here we handles a incomming SMS
406          {          {
407                  ptr = strstr(global_message_buffer1,",");       // finds the point just before the nr. of the SMS.                  ptr = strstr(global_message_buffer1,",");       // finds the point just before the nr. of the SMS.
408                  strcat(tmp,ptr+1);                                                      // puts that number in tmp                  strcat(tmp,ptr+1);                      // puts that number in tmp
409                  global_sms_recieve_number[0] = 0;                       // wanna be sure that we write the new number from global_sms_recieve_number[0]                  global_sms_recieve_number[0] = 0;       // wanna be sure that we write the new number from global_sms_recieve_number[0]
410                  strcat(global_sms_recieve_number, tmp);         // puts the sms number into the global variable.                  strcat(global_sms_recieve_number, tmp); // puts the sms number into the global variable.
411                  sms_recieved();                  sms_recieved();
412          }                }      
413          reset_recieve_buffer();          reset_recieve_buffer();
# Line 455  void sms_recieved(void) Line 455  void sms_recieved(void)
455                                    
456                  global_time_interval = atoi(buf);                  global_time_interval = atoi(buf);
457                  global_time_interval *= 60;                  global_time_interval *= 60;
458                  eeprom_writer();                        // writes the new cell nr. and time interval to the eeprom.                  eeprom_writer();  // writes the new cell nr. and time interval to the eeprom.
459                  send_sms("conf ok");                  send_sms("conf ok");
460          }          }
461                    
# Line 476  void main() Line 476  void main()
476    
477          // Running init for various components.          // Running init for various components.
478          pic18_io_init();          pic18_io_init();
479          RA5 = 1;                        // Indicates that the board is running inits.          RA5 = 1;                // Indicates that the board is running inits.
480                    
481          rs232_init();          rs232_init();
482          ad_init();          ad_init();
# Line 485  void main() Line 485  void main()
485          lcd_home();          lcd_home();
486          interrupt_init();          interrupt_init();
487          timer_init();          timer_init();
488          sms_init();          modem_init();
489          eeprom_reader();          eeprom_reader();
490  ///////////////  ///////////////
491  // Main loop //  // Main loop //

Legend:
Removed from v.178  
changed lines
  Added in v.205

  ViewVC Help
Powered by ViewVC 1.1.20