Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2010
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <avr/io.h>
  3. #include <string.h>
  4. #include <avr/interrupt.h>
  5. #include <avr/signal.h>
  6. #include <avr/pgmspace.h>
  7. #include <util/delay.h>
  8. #include "lcd.h"
  9. #include "uart.h"
  10.  
  11. #ifndef F_CPU
  12. #define F_CPU 16000000
  13. #endif
  14.  
  15. #define UART_BAUD_RATE 4800 //Baud = 4800
  16. #define LENGTH 7 //Textl�nge ab welcher Empfangen beendet wird
  17.  
  18. int main(void)
  19. {
  20. uint8_t i;
  21. char c;
  22. char* s;
  23. char string[LENGTH];
  24. char gpgga[] = "$GPGGA";
  25.  
  26. uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU));
  27.  
  28. sei();
  29.  
  30. lcd_init(LCD_DISP_ON);
  31.  
  32. lcd_clrscr();
  33. lcd_home();
  34. lcd_puts("Bereit");
  35.  
  36. i = LENGTH;
  37. while(1)
  38. {
  39. c = uart_getc();
  40.  
  41. if(c == '$')
  42. {
  43. i = 1; //i'tes Zeichen. dh (i-1) Zeichen bereits empfangen
  44. s = string;
  45. }
  46.  
  47. if(i < LENGTH)
  48. {
  49. *s = c;
  50. s++;
  51. i++;
  52. }
  53.  
  54. if(i == LENGTH)
  55. {
  56. *s = 0x00; //terminierung
  57.  
  58. if(strcmp(gpgga, string) == 0)
  59. {
  60. lcd_clrscr();
  61. lcd_home();
  62. lcd_puts(string);
  63. _delay_ms(300);
  64. }
  65. else
  66. {
  67. lcd_clrscr();
  68. lcd_home();
  69. lcd_puts("Noe");
  70. _delay_ms(300);
  71. }
  72. i++;
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement