CLEON  Version 1
Cloud-Offloaded GPS Receiver
sys_gps.h
Go to the documentation of this file.
1 
7 #ifndef __SYS_GPS_H__
8 #define __SYS_GPS_H__
9 
10 #include <hal_define.h>
11 
12 #define SIZE_OF_GPS_DATA_CHUNK_IN_BYTE 8184 // 2ms @ sampling frequency of 16.368MHz
13 #define MAX_NUMBER_OF_GPS_TEST_COUNT 3 // Maximum number of attempts for GPS test
14 
15 #define MAX2769_SHDN_N_HIGH() MAX2769_SHDN_N_PORT(OUT) |= BV(MAX2769_SHDN_N_PIN);
16 #define MAX2769_SHDN_N_LOW() MAX2769_SHDN_N_PORT(OUT) &= ~BV(MAX2769_SHDN_N_PIN);
17 
18 #define MAX2769_IDLE_N_HIGH() MAX2769_IDLE_N_PORT(OUT) |= BV(MAX2769_IDLE_N_PIN);
19 #define MAX2769_IDLE_N_LOW() MAX2769_IDLE_N_PORT(OUT) &= ~BV(MAX2769_IDLE_N_PIN);
20 
21 // (n * 1ms) delay @ 12MHz
22 #define SYS_GPS_TimingDealy(n) do{ \
23  for(int z = 0 ; z < n ; z++){ \
24  __delay_cycles(12000); \
25  } \
26 }while(0)
27 
28 // Receiver setting
29 typedef union{
30  unsigned char ucSingleByte[4]; // 4 bytes
31  unsigned long ulOriginalVar; // 4 bytes
32 }samples_per_ms_u; // 4 bytes
33 
34 typedef union{
35  unsigned char ucSingleByte[8]; // 8 bytes
36  double dOriginalVar; // 8 bytes
37 }intermediate_frequency_u; // 8 bytes
38 
39 typedef struct{
42 }receiver_setting_s; // 12 bytes
43 
44 // Chunk count
45 typedef union{
46  unsigned char ucSingleByte[4]; // 4 bytes
47  unsigned long ulOriginalVar; // 4 bytes
48 }chunk_count_u; // 4 bytes
49 
50 // Chunk size
51 typedef union{
52  unsigned char ucSingleByte[4]; // 4 bytes
53  unsigned long ulOriginalVar; // 4 bytes
54 }chunk_size_ms_u; // 4 bytes
55 
56 // Chunk gap
57 typedef union{
58  unsigned char ucSingleByte[4]; // 4 bytes
59  unsigned long ulOriginalVar; // 4 bytes
60 }chunk_gap_ms_u; // 4 bytes
61 
62 // Signal data format
63 typedef union{
64  unsigned char ucSingleByte[4]; // 4 bytes
65  unsigned long ulOriginalVar; // 4 bytes
66 }gps_signal_data_format_u; // 4 bytes
67 
68 // GPS signal data
69 typedef union {
70  unsigned char ucSingleByte[SIZE_OF_GPS_DATA_CHUNK_IN_BYTE]; // 8184 bytes
71  unsigned char ucSignal[SIZE_OF_GPS_DATA_CHUNK_IN_BYTE]; // 8184 bytes
72 }cleon_gps_data_u; // 8184 bytes
73 
74 void SYS_GPS_Init(void);
75 void SYS_GPS_InitDataIO(void);
76 void SYS_GPS_InitControlIO(void);
77 void SYS_GPS_InitProgramIO(void);
78 void SYS_GPS_StartOperation(void);
79 void SYS_GPS_StopOperation(void);
80 bool SYS_GPS_TestGPS(unsigned int uiDelay);
81 
82 #endif