GPS GMS-6 Module
Diff: GPSGms6.cpp
- Revision:
- 7:333d46845050
- Parent:
- 5:9dd9ab613497
- Child:
- 9:12519423b85f
diff -r 5e30784ffd54 -r 333d46845050 GPSGms6.cpp --- a/GPSGms6.cpp Thu May 19 06:51:52 2016 +0000 +++ b/GPSGms6.cpp Thu May 19 10:44:48 2016 +0000 @@ -1,3 +1,12 @@ +/** + ****************************************************************************** + * @file GPSGms6.cpp + * @author Narut T + * @version V1 + * @date 19/05/2016 + * @brief Library for GPS GMS6 + ******************************************************************************/ + #include "mbed.h" #include "GPSGms6.h" #include <string> @@ -25,7 +34,7 @@ * This table contain 3 element which are index, section size and pointer to variable * Once GPS process routine is called data will be populated in variable that define in third column */ -GPRMC_Tbl_TypeDef gprms_tbl[] = { +const GPRMC_Tbl_TypeDef gprms_tbl[] = { // index , section size , variable {GPS_Process_Start , INVALID_VALUE ,(char *)INVALID_VALUE}, {GPS_Process_Header , HEADER_SIZE , m_gprmc.header}, @@ -45,6 +54,13 @@ }; +/* Private function prototypes -----------------------------------------------*/ +static void GPSGMS6_CompleteCallback(); +static GPS_ProcessStatus GPSGMS6_ProcessGprmcSection(GPS_ProcessState state,char * buf , unsigned int buf_index,unsigned int buf_size, unsigned int section_size, char * ret_value); +static void GPSGMS6_ByteCallback(); +static void GPSGMS6_ProcessGpsData(char * buf, unsigned int size); + + /** * @brief Utility for processing GPRMC message from the GPS * @note @@ -55,7 +71,7 @@ * @param section size : size of the processing section * @retval pointer of return value */ -static GPS_ProcessStatus GPSGms6_ProcessGprmcSection(GPS_ProcessState state,char * buf , unsigned int buf_index,unsigned int buf_size, unsigned int section_size, char * ret_value) +static GPS_ProcessStatus GPSGMS6_ProcessGprmcSection(GPS_ProcessState state,char * buf , unsigned int buf_index,unsigned int buf_size, unsigned int section_size, char * ret_value) { /* Initialize status */ GPS_ProcessStatus status = GPS_Status_Valid; @@ -91,7 +107,7 @@ * @param buf size : size of the buffer * @retval variable that define in the table will be populated the data */ -static void GPSGms6_ProcessGpsData(char * buf, unsigned int size) +static void GPSGMS6_ProcessGpsData(char * buf, unsigned int size) { unsigned int index; unsigned int adv_index = 0; @@ -148,7 +164,7 @@ else { /* Process GRPMC section */ - status = GPSGms6_ProcessGprmcSection(state, buf ,index, size, GET_GPRMC_SECTION_SIZE(state), GET_GPRMC_VARIABLE_ADDR(state)); + status = GPSGMS6_ProcessGprmcSection(state, buf ,index, size, GET_GPRMC_SECTION_SIZE(state), GET_GPRMC_VARIABLE_ADDR(state)); /* Move to the next section */ adv_index = GET_GPRMC_SECTION_SIZE(state); @@ -182,17 +198,17 @@ * @note Rx Serial Interrupt must be properly started * @retval */ -void complete_callback() +static void GPSGMS6_CompleteCallback() { /* Process GPS Data once message is completed read */ - GPSGms6_ProcessGpsData(m_RxBuf, RX_BUF_SIZE); + GPSGMS6_ProcessGpsData(m_RxBuf, RX_BUF_SIZE); } /** * @brief Callback function that process when a charector is transfered * @note Rx Serial Interrupt must be properly started * @retval */ -void byte_callback() +static void GPSGMS6_ByteCallback() { /* Note: you need to actually read from the serial to clear the RX interrupt */ m_RxBuf[m_index] = serial_gps.getc(); @@ -201,7 +217,7 @@ { /* Buffer is full, call complete callback */ m_index = 0; - complete_callback(); + GPSGMS6_CompleteCallback(); } } @@ -230,7 +246,7 @@ void GPSGms6::start_GPS() { /* Start Rx interrupt */ - serial_gps.attach(&byte_callback); + serial_gps.attach(&GPSGMS6_ByteCallback); } /** @@ -238,19 +254,19 @@ * @note * @retval latest GPRMC data */ -GPRMC_Data_TypeDef GPSGms6::latestGPRMC() +GPRMC_Data_TypeDef * GPSGms6::latestGPRMC() { - return (m_gprmc); + return (&m_gprmc); } /** * @brief Function to get latest and valid GPRMC * @note * @retval valid GPRMC data */ -GPRMC_Data_TypeDef GPSGms6::validGPRMC() +GPRMC_Data_TypeDef * GPSGms6::validGPRMC() { m_available = false; - return (m_valid_gprmc); + return (&m_valid_gprmc); } /**