TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle

Library Functions. More...

Functions

void TM_GPS_Init (TM_GPS_t *GPS_Data, uint32_t baudrate)
 Initializes GPS and USART peripheral. More...
 
TM_GPS_Result_t TM_GPS_Update (TM_GPS_t *GPS_Data)
 Update GPS data. More...
 
float TM_GPS_ConvertSpeed (float SpeedInKnots, TM_GPS_Speed_t toSpeed)
 Converts speed in knots (from GPS) to user selectable speed. More...
 
void TM_GPS_ConvertFloat (float num, TM_GPS_Float_t *Float_Data, uint8_t decimals)
 Converts float number into integer and decimal part. More...
 
void TM_GPS_DistanceBetween (TM_GPS_Distance_t *Distance_Data)
 Calculates distance between 2 coordinates on earth and bearing from start to end point in relation to the north. More...
 
TM_GPS_Custom_tTM_GPS_AddCustom (TM_GPS_t *GPS_Data, char *GPG_Statement, uint8_t TermNumber)
 Adds custom GPG statement to array of user selectable statements. Array is available to user using TM_GPS_t workign structure. More...
 

Detailed Description

Library Functions.

Function Documentation

TM_GPS_Custom_t* TM_GPS_AddCustom ( TM_GPS_t GPS_Data,
char *  GPG_Statement,
uint8_t  TermNumber 
)

Adds custom GPG statement to array of user selectable statements. Array is available to user using TM_GPS_t workign structure.

Note
Functions uses malloc() function to allocate memory, so make sure you have enough heap memory available.
Also note, that your GPS receiver HAVE TO send statement type you use in this function, or TM_GPS_Update() function will always return that there is not data available to read.
Parameters
*GPS_DataPointer to working TM_GPS_t structure
*GPG_StatementString of NMEA starting line address, including "$" at beginning
TermNumberPosition in NMEA statement
Return values
Successstatus:
  • NULL: Malloc() failed or you reached limit of user selectable custom statements:
  • > NULL: Function succeded, pointer to TM_GPS_Custom_t structure
void TM_GPS_ConvertFloat ( float  num,
TM_GPS_Float_t Float_Data,
uint8_t  decimals 
)

Converts float number into integer and decimal part.

Parameters
numFloat number to split into 2 parts
*Float_DataPointer to TM_GPS_Float_t structure where to save result
decimalsNumber of decimal places for conversion
Note
Example: You have number 15.002 in float format.
  • You want to split this to integer and decimal part with 6 decimal places.
  • Call TM_GPS_ConvertFloat(15.002, &Float_Struct, 6);
  • Result will be: Integer: 15; Decimal: 2000 (0.002 * 10^6)
Return values
None
float TM_GPS_ConvertSpeed ( float  SpeedInKnots,
TM_GPS_Speed_t  toSpeed 
)

Converts speed in knots (from GPS) to user selectable speed.

Parameters
speedInKnotsfloat value from GPS module
toSpeedSelect to which speed you want conversion from knot. This parameter ca be a value of TM_GPS_Speed_t enumeration.
Return values
Calculatedspeed from knots to user selectable format
void TM_GPS_DistanceBetween ( TM_GPS_Distance_t Distance_Data)

Calculates distance between 2 coordinates on earth and bearing from start to end point in relation to the north.

Parameters
*Distance_DataPointer to TM_GPS_Distance_t structure with latitude and longitude set values
Note
Calculation results will be saved in *Distance_Data TM_GPS_Distance_t structure
Return values
None
void TM_GPS_Init ( TM_GPS_t GPS_Data,
uint32_t  baudrate 
)

Initializes GPS and USART peripheral.

Parameters
*GPS_DataPointer to TM_GPS_t structure to set default values
baudrateSpecify GPS baudrate for USART. Most common are 9600 or 115200 bauds
Note
GPS baudrate can have other values. Check GPS datasheet for proper info.
Return values
None
TM_GPS_Result_t TM_GPS_Update ( TM_GPS_t GPS_Data)

Update GPS data.

Note
This function must be called periodically, as fast as possible. It basically checks if data is available on GPS USART and parse it to useful data for user.
- When you first call this function and there is not available data from GPS, this function will return TM_GPS_Result_FirstTimeWaiting.
  • This will be returning all the time we don't have any useful data.
  • When first time useful data is received from GPS (everything parsed), TM_GPS_Result_NewData will be returned.
  • When we have already new data, next time we call this function, TM_GPS_Result_OldData will be returning until we don't receive new packet of useful data.
If you are making GPS logger, then when you receive TM_GPS_Result_NewData it is time to save your data.
Parameters
*GPS_DataPointer to working TM_GPS_t structure
Return values
Returnsvalue of TM_GPS_Result_t structure