CLEON  Version 1
Cloud-Offloaded GPS Receiver
sys_gps.c
Go to the documentation of this file.
1 
7 #include "cleon_conf.h"
8 #include "app_define.h"
9 #include "sys_define.h"
10 #include "hal_define.h"
11 #include "fs_define.h"
12 
13 // CLEON data structure
17 
18 // Flags
19 extern bool bFLAG_DMATransferCompleted;
20 
21 /*----------------------------------------------------------------------------*/
29 void SYS_GPS_Init(void)
30 {
31  // Initializing GPS control pins
33 
34  // Stop GPS operation before initialization
36 
37  // Program the GPS with pre-configured mode
39 
40  // Initializing GPS data pins
42 
43 #if GPS_TEST_ON_INITIALIZATION == _ENABLE_
44  // Check if GPS is functional by sampling a chunk of GPS signal and take a look inside
45  for(int i = 1 ; i < MAX_NUMBER_OF_GPS_TEST_COUNT; i++){
46  // If fail, allow more time to settle (100ms, 200ms, 300ms ...)
47  if(SYS_GPS_TestGPS(100 * i) == _SUCCESS_){
48  // Return if it passes GPS test
49  return;
50  }
51  }
52 
53  // If it fails the test, turn LED on
55 #endif
56 }
57 
58 /*----------------------------------------------------------------------------*/
67 {
76 
85 
94 
103 
112 
121 
130 
139 }
140 
141 /*----------------------------------------------------------------------------*/
150 {
151  // MAX2769 is in operation
154 
155  // MAX2769 is in operation
158 }
159 
160 /*----------------------------------------------------------------------------*/
169 {
170  // CLEON uses default device state 2 (PGM:1, CS:0, SCLK:0, SDATA:1)
171  // - IF: 4092000 Hz
172  // - Sampling rate: 16368 samples/sec
173  // - CMOS level I0 and I1
174 
175  // PGM pin is set to high
178 
179  // CS pin is set to low
182 
183  // SCLK pin is set to low
186 
187  // SDATA pin is set to high
190 }
191 
192 /*----------------------------------------------------------------------------*/
201 {
202  // LDO for GPS is turned on
204 }
205 
206 /*----------------------------------------------------------------------------*/
215 {
216  // LDO for GPS is in shutdown mode
218 }
219 
220 /*----------------------------------------------------------------------------*/
228 bool SYS_GPS_TestGPS(unsigned int uiDelay)
229 {
230  unsigned int uiTestCountFor0xFF = 0;
231  unsigned int uiTestCountFor0x00 = 0;
232 
233  // Start GPS operation
235 
236  // Allow GPS time to settle
237  SYS_GPS_TimingDealy(uiDelay);
238 
239  // Start DMA transfer
240  DMA0CTL |= DMAEN;
241 
242  // Wait until DMA transfer completed
243  while((DMA0CTL & DMAIFG) != DMAIFG);
244  DMA0CTL &= ~DMAIFG;
245 
246  // Count the number of '0xFF' and '0x00'
247  for(int i = 0 ; i < SIZE_OF_GPS_DATA_CHUNK_IN_BYTE ; i++ ){
248  if(uniCLEONGPSData.ucSignal[i] == 0xFF){
249  uiTestCountFor0xFF++;
250  }else if(uniCLEONGPSData.ucSignal[i] == 0x00){
251  uiTestCountFor0x00++;
252  }
253  }
254 
255  // Stop GPS operation
257 
258  // If number of '0xFF' or '0x00' exceeds half or total sampled signal, regards GPS chip is not functional
259  // (number of '0xFF' or '0x00' cannot exceed half of captured GPS signal due to signal's physical nature)
260  if((uiTestCountFor0xFF > (SIZE_OF_GPS_DATA_CHUNK_IN_BYTE/2))||(uiTestCountFor0x00 > (SIZE_OF_GPS_DATA_CHUNK_IN_BYTE/2))){
261  return _FAIL_;
262  }else{
263  return _SUCCESS_;
264  }
265 }
266 
267 
268 
269 
270 
271 
272 
273 
274 
275 
276 
277 
278 
279 
280 
281 
282 
283 
284