1 | /**
|
2 | *
|
3 | * Project: Automatic WIFI Network
|
4 | * Package: Default
|
5 | *
|
6 | *
|
7 | * File: Test.c
|
8 | * Author: Soenke Paschko
|
9 | * Maintainer: Soenke Paschko
|
10 | *
|
11 | * Created on: 21. July 2009, 21:33
|
12 | *
|
13 | * Content:
|
14 | * A testfile for implementation and testing the drivers
|
15 | *
|
16 | * Revision history:
|
17 | * 21.07.09 1. revision Paschko - First version
|
18 | * 08.08.08 2. revision Paschko - initialization function with start screen
|
19 | */
|
20 |
|
21 |
|
22 | //################### Includes ###################
|
23 |
|
24 | #include "main.h" // default header file
|
25 |
|
26 | //################### Functions ###################
|
27 |
|
28 | int main(); // main program
|
29 | void SPI_INIT();
|
30 | void initiazion();
|
31 |
|
32 | //################### variables ###################
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | /**
|
39 | * The main function
|
40 | */
|
41 | int main(){
|
42 |
|
43 | // initializes all main functions
|
44 | initiazion();
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | // mainloop
|
52 | while(1){
|
53 | /*
|
54 | txDataWIFI("Hallo\n\r ", 7);
|
55 | _delay_ms(1000);
|
56 |
|
57 | sendStringWIFI("Hello here i am");
|
58 | _delay_ms(1000);
|
59 | sendStringWIFI("\n\n\n");
|
60 | _delay_ms(1000);
|
61 | */
|
62 |
|
63 | /*
|
64 | //receiveStringWIFI(string);
|
65 | char data[128]="";
|
66 | setPowerWIFI(0, 6); // 1mW Outputforce, 120k
|
67 | rxDataWIFI(data);
|
68 | //txDataWIFI(data, 128);
|
69 | setPowerWIFI(1, 6); // 1mW Outputforce, 120k
|
70 |
|
71 | sendStringRS232(data);
|
72 | */
|
73 |
|
74 | _delay_ms(500);
|
75 | PORTC = 0b00000001;
|
76 | _delay_ms(500);
|
77 | PORTC = 0b00000010;
|
78 | _delay_ms(500);
|
79 | PORTC = 0b00000100;
|
80 | _delay_ms(500);
|
81 | PORTC = 0b00001000;
|
82 | _delay_ms(500);
|
83 | PORTC = 0b00010000;
|
84 | _delay_ms(500);
|
85 | PORTC = 0b00100000;
|
86 | _delay_ms(500);
|
87 | PORTC = 0b01000000;
|
88 | _delay_ms(500);
|
89 | PORTC = 0b10000000;
|
90 | }
|
91 |
|
92 | return 0;
|
93 | }
|
94 |
|
95 |
|
96 | /**
|
97 | * This function initializes the SPI Interface (Has to be moved to an other file)
|
98 | */
|
99 | void SPI_INIT(){
|
100 | //Activates the SPI - Bus, Clock = Idel LOW
|
101 | //SPI Clock divided by 128, Enable SPI, SPI in Master Mode
|
102 | SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0)|(1<<SPR1);
|
103 | SPSR &= ~(0<<SPI2X);
|
104 | }
|
105 |
|
106 |
|
107 | /**
|
108 | * This function makes a basic initialization
|
109 | */
|
110 | void initiazion(){
|
111 |
|
112 | // port initialization
|
113 | DDRA = 0xFF; // LED
|
114 | DDRB = 0b01000111; // Encoder / WIFI module
|
115 | DDRC = 0xFF;
|
116 | DDRD = 0xFF; // PORT D Output
|
117 | DDRE = 0xFF; // PORT D Output
|
118 |
|
119 |
|
120 |
|
121 | beep_short(); // To show that the module is online
|
122 |
|
123 | // USART initialization
|
124 | initRS232();
|
125 |
|
126 | // USART output
|
127 | sendStringRS232("\x1B[2J \x1B[0;0f"); /* clear screen and cursor home */
|
128 |
|
129 | // output UART welcome screen
|
130 | sendStringRS232("\a\r\n\r\n\r\n");
|
131 | sendStringRS232(" \x1B[41m*****************************\r\n\x1B[47m"); // \x1B[47m setzt den Hintergrund auf grau
|
132 | sendStringRS232(" \x1B[41m*** " PROGNAME " ***\r\n\x1B[47m");
|
133 | sendStringRS232(" \x1B[41m*** "VERSION" ***\r\n\x1B[47m");
|
134 | sendStringRS232(" \x1B[41m*** ***\r\n\x1B[47m");
|
135 | sendStringRS232(" \x1B[41m*** ***\r\n\x1B[47m");
|
136 | sendStringRS232(" \x1B[41m*****************************\r\n\r\n\x1B[47m");
|
137 |
|
138 |
|
139 | sendStringRS232("UART init successful\r\n");
|
140 |
|
141 |
|
142 | // LC Display basic initialization
|
143 | initLCD();
|
144 | sendStringRS232("LCD init successful\r\n");
|
145 |
|
146 |
|
147 | // Welcome screen LCD
|
148 | clearLCD();
|
149 | setCursorLCD(0,1);
|
150 | sendStringLCD(" " PROGNAME " ***");
|
151 | setCursorLCD(0,2);
|
152 | sendStringLCD(" "VERSION" ***");
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | // SPI init
|
158 | SPI_INIT();
|
159 | sendStringRS232("SPI init successful\r\n");
|
160 |
|
161 |
|
162 | // WIFI init
|
163 | initialiseWIFI(RF12FREQ(433.92),9600);
|
164 | setBandwidthWIFI(5, 1, 4); // 200kHz bandwidth, -6dB gain, DRSSI threshold: -79dBm
|
165 | setPowerWIFI(0, 6); // 1mW output force, 120k
|
166 | sendStringRS232("RFM12 init successful\r\n");
|
167 |
|
168 |
|
169 | _delay_ms(1000);
|
170 | txDataWIFI("Hallo\n\r ", 7);
|
171 | //_delay_ms(1000);
|
172 |
|
173 | // Global interrupt enable
|
174 | sei();
|
175 | sendStringRS232("Global Interrupt enabled\r\n");
|
176 |
|
177 | //initialisazion of the event queue
|
178 | initEventQueue();
|
179 | sendStringRS232("EventQueue init successful\r\n");
|
180 |
|
181 | beep_short();
|
182 |
|
183 |
|
184 | }
|