CLEON  Version 1
Cloud-Offloaded GPS Receiver
sys_gps.h File Reference

GPS related functions. More...

#include <hal_define.h>
Include dependency graph for sys_gps.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  samples_per_ms_u
 
union  intermediate_frequency_u
 
struct  receiver_setting_s
 
union  chunk_count_u
 
union  chunk_size_ms_u
 
union  chunk_gap_ms_u
 
union  gps_signal_data_format_u
 
union  cleon_gps_data_u
 

Macros

#define SIZE_OF_GPS_DATA_CHUNK_IN_BYTE   8184
 
#define MAX_NUMBER_OF_GPS_TEST_COUNT   3
 
#define MAX2769_SHDN_N_HIGH()   MAX2769_SHDN_N_PORT(OUT) |= BV(MAX2769_SHDN_N_PIN);
 
#define MAX2769_SHDN_N_LOW()   MAX2769_SHDN_N_PORT(OUT) &= ~BV(MAX2769_SHDN_N_PIN);
 
#define MAX2769_IDLE_N_HIGH()   MAX2769_IDLE_N_PORT(OUT) |= BV(MAX2769_IDLE_N_PIN);
 
#define MAX2769_IDLE_N_LOW()   MAX2769_IDLE_N_PORT(OUT) &= ~BV(MAX2769_IDLE_N_PIN);
 
#define SYS_GPS_TimingDealy(n)
 

Functions

void SYS_GPS_Init (void)
 Initializing GPS.
 
void SYS_GPS_InitDataIO (void)
 Initializing GPS data pins.
 
void SYS_GPS_InitControlIO (void)
 Initializing GPS control pins.
 
void SYS_GPS_InitProgramIO (void)
 Initializing GPS control pins.
 
void SYS_GPS_StartOperation (void)
 Starting GPS operation.
 
void SYS_GPS_StopOperation (void)
 Starting GPS operation.
 
bool SYS_GPS_TestGPS (unsigned int uiDelay)
 Test if GPS is initalized properly.
 

Detailed Description

GPS related functions.

Definition in file sys_gps.h.

Macro Definition Documentation

#define MAX2769_IDLE_N_HIGH ( )    MAX2769_IDLE_N_PORT(OUT) |= BV(MAX2769_IDLE_N_PIN);

Definition at line 18 of file sys_gps.h.

#define MAX2769_IDLE_N_LOW ( )    MAX2769_IDLE_N_PORT(OUT) &= ~BV(MAX2769_IDLE_N_PIN);

Definition at line 19 of file sys_gps.h.

#define MAX2769_SHDN_N_HIGH ( )    MAX2769_SHDN_N_PORT(OUT) |= BV(MAX2769_SHDN_N_PIN);

Definition at line 15 of file sys_gps.h.

#define MAX2769_SHDN_N_LOW ( )    MAX2769_SHDN_N_PORT(OUT) &= ~BV(MAX2769_SHDN_N_PIN);

Definition at line 16 of file sys_gps.h.

#define MAX_NUMBER_OF_GPS_TEST_COUNT   3

Definition at line 13 of file sys_gps.h.

#define SIZE_OF_GPS_DATA_CHUNK_IN_BYTE   8184

Definition at line 12 of file sys_gps.h.

#define SYS_GPS_TimingDealy (   n)
Value:
do{ \
for(int z = 0 ; z < n ; z++){ \
__delay_cycles(12000); \
} \
}while(0)

Definition at line 22 of file sys_gps.h.

Function Documentation

void SYS_GPS_Init ( void  )

Initializing GPS.

Returns
void
Parameters
void

Definition at line 29 of file sys_gps.c.

{
// Initializing GPS control pins
// Stop GPS operation before initialization
// Program the GPS with pre-configured mode
// Initializing GPS data pins
#if GPS_TEST_ON_INITIALIZATION == _ENABLE_
// Check if GPS is functional by sampling a chunk of GPS signal and take a look inside
for(int i = 1 ; i < MAX_NUMBER_OF_GPS_TEST_COUNT; i++){
// If fail, allow more time to settle (100ms, 200ms, 300ms ...)
if(SYS_GPS_TestGPS(100 * i) == _SUCCESS_){
// Return if it passes GPS test
return;
}
}
// If it fails the test, turn LED on
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_GPS_InitControlIO ( void  )

Initializing GPS control pins.

Returns
void
Parameters
void

Definition at line 149 of file sys_gps.c.

Here is the caller graph for this function:

void SYS_GPS_InitDataIO ( void  )

Initializing GPS data pins.

Returns
void
Parameters
void

Definition at line 66 of file sys_gps.c.

{
}

Here is the caller graph for this function:

void SYS_GPS_InitProgramIO ( void  )

Initializing GPS control pins.

Returns
void
Parameters
void

Definition at line 168 of file sys_gps.c.

{
// CLEON uses default device state 2 (PGM:1, CS:0, SCLK:0, SDATA:1)
// - IF: 4092000 Hz
// - Sampling rate: 16368 samples/sec
// - CMOS level I0 and I1
// PGM pin is set to high
// CS pin is set to low
// SCLK pin is set to low
// SDATA pin is set to high
}

Here is the caller graph for this function:

void SYS_GPS_StartOperation ( void  )

Starting GPS operation.

Returns
void
Parameters
void

Definition at line 200 of file sys_gps.c.

{
// LDO for GPS is turned on
}

Here is the caller graph for this function:

void SYS_GPS_StopOperation ( void  )

Starting GPS operation.

Returns
void
Parameters
void

Definition at line 214 of file sys_gps.c.

{
// LDO for GPS is in shutdown mode
}

Here is the caller graph for this function:

bool SYS_GPS_TestGPS ( unsigned int  uiDelay)

Test if GPS is initalized properly.

Returns
void
Parameters
uiDelay- time for GPS to settle down (in milliseconds)

Definition at line 228 of file sys_gps.c.

{
unsigned int uiTestCountFor0xFF = 0;
unsigned int uiTestCountFor0x00 = 0;
// Start GPS operation
// Allow GPS time to settle
// Start DMA transfer
DMA0CTL |= DMAEN;
// Wait until DMA transfer completed
while((DMA0CTL & DMAIFG) != DMAIFG);
DMA0CTL &= ~DMAIFG;
// Count the number of '0xFF' and '0x00'
for(int i = 0 ; i < SIZE_OF_GPS_DATA_CHUNK_IN_BYTE ; i++ ){
if(uniCLEONGPSData.ucSignal[i] == 0xFF){
uiTestCountFor0xFF++;
}else if(uniCLEONGPSData.ucSignal[i] == 0x00){
uiTestCountFor0x00++;
}
}
// Stop GPS operation
// If number of '0xFF' or '0x00' exceeds half or total sampled signal, regards GPS chip is not functional
// (number of '0xFF' or '0x00' cannot exceed half of captured GPS signal due to signal's physical nature)
if((uiTestCountFor0xFF > (SIZE_OF_GPS_DATA_CHUNK_IN_BYTE/2))||(uiTestCountFor0x00 > (SIZE_OF_GPS_DATA_CHUNK_IN_BYTE/2))){
return _FAIL_;
}else{
return _SUCCESS_;
}
}

Here is the call graph for this function:

Here is the caller graph for this function: