Mercurial > public > ostc4
view Small_CPU/Inc/GNSS.h @ 1046:1d7c7a36df15 GasConsumption
Bugfix OSTC5 BT and enabling fast mode:
The OSTC5 BT was operating at default speed of 115200. To enable the faster communication some init steps have been added to set speed to 460800. Having the UART enabled while the module was shut down caused problems during initialisation. To avoid these the BT UART is now initialized after the the module is powered on and deinitialized while the module is switched off.
| author | Ideenmodellierer |
|---|---|
| date | Fri, 14 Nov 2025 18:54:20 +0100 |
| parents | efb7d18cc564 |
| children |
line wrap: on
line source
/* * GNSS.h * * Created on: 03.10.2020 * Author: SimpleMethod * *Copyright 2020 SimpleMethod * *Permission is hereby granted, free of charge, to any person obtaining a copy of *this software and associated documentation files (the "Software"), to deal in *the Software without restriction, including without limitation the rights to *use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies *of the Software, and to permit persons to whom the Software is furnished to do *so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *THE SOFTWARE. ****************************************************************************** */ #ifndef INC_GNSS_H_ #define INC_GNSS_H_ #include "stm32f4xx_hal.h" union u_Short { uint8_t bytes[2]; unsigned short uShort; }; union i_Short { uint8_t bytes[2]; signed short iShort; }; union u_Long { uint8_t bytes[4]; unsigned long uLong; }; union i_Long { uint8_t bytes[4]; signed long iLong; }; typedef struct { UART_HandleTypeDef *huart; uint8_t uniqueID[4]; uint8_t uartWorkingBuffer[255]; unsigned short year; uint8_t yearBytes[2]; uint8_t month; uint8_t day; uint8_t hour; uint8_t min; uint8_t sec; uint8_t fixType; signed long lon; uint8_t lonBytes[4]; signed long lat; uint8_t latBytes[4]; float fLon; float fLat; signed long height; signed long hMSL; uint8_t hMSLBytes[4]; unsigned long hAcc; unsigned long vAcc; signed long gSpeed; uint8_t gSpeedBytes[4]; signed long headMot; uint8_t numSat; uint8_t statSat[4]; uint8_t alive; float last_fLon; /* last known position storage and time stamp */ float last_fLat; float last_hour; }GNSS_StateHandle; GNSS_StateHandle GNSS_Handle; typedef struct { uint8_t header1; uint8_t header2; uint8_t msgClass; uint8_t msgID; uint16_t length; uint8_t type; uint8_t version; uint8_t ref; uint8_t leapsec; uint16_t year; uint8_t month; uint8_t day; uint8_t hour; uint8_t minute; uint8_t second; uint8_t flags; uint32_t nanoseconds; uint16_t accuracy_seconds; uint16_t reserved; uint32_t accuracy_nano; } __attribute__((packed)) UBX_MGA_INI_TIME_UTC_t; typedef struct { uint8_t header1; uint8_t header2; uint8_t class_id; uint8_t msg_id; uint16_t length; uint8_t type; uint8_t version; uint16_t reserved; int32_t latitude; int32_t longitude; int32_t altitude; uint32_t accuracy; } __attribute__((packed)) UBX_MGA_INI_POS_LLH_t; enum GNSSMode{Portable=0, Stationary=1, Pedestrian=2, Automotiv=3, Airbone1G=5, Airbone2G=6,Airbone4G=7,Wirst=8,Bike=9}; static const uint8_t configUBX[]={0xB5,0x62,0x06,0x00,0x14,0x00,0x01,0x00,0x00,0x00,0xD0,0x08,0x00,0x00,0x80,0x25,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00}; static const uint8_t setNMEA410[]={0xB5,0x62,0x06,0x17,0x14,0x00,0x00,0x41,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //Activation of navigation system: Galileo, Glonass, GPS, SBAS, IMES static const uint8_t setGNSS[]={0xB5,0x62,0x06,0x3E,0x24,0x00,0x00,0x00,0x20,0x04,0x00,0x08,0x10,0x00,0x01,0x00,0x01,0x01,0x01,0x01,0x03,0x00,0x01,0x00,0x01,0x01,0x02,0x04,0x08,0x00,0x01,0x00,0x01,0x01,0x06,0x08,0x0E,0x00,0x01,0x00,0x01,0x01}; static const uint8_t getDeviceID[]={0xB5,0x62,0x27,0x03,0x00,0x00}; static const uint8_t getNavigatorData[]={0xB5,0x62,0x01,0x21,0x00,0x00}; static const uint8_t getPOSLLHData[]={0xB5,0x62,0x01,0x02,0x00,0x00}; static const uint8_t getPVTData[]={0xB5,0x62,0x01,0x07,0x00,0x00}; static const uint8_t getNavSat[]={0xB5,0x62,0x01,0x35,0x00,0x00}; static const uint8_t setPowerLow[]={0xB5,0x62,0x06,0x86,0x08,0x00,0x00,0x02,0x10,0x0E,0x14,0x00,0x00,0x00}; static const uint8_t setPowerNormal[]={0xB5,0x62,0x06,0x86,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; /* UBX-CFG-NAV5 */ static const uint8_t setPortableMode[]={0xB5,0x62,0x06,0x24,0x24,0x00,0xFF,0xFF,0x00,0x03,0x00,0x00,0x00,0x00,0x10,0x27,0x00,0x00,0x05,0x00,0xFA,0x00,0xFA,0x00,0x64,0x00,0x5E,0x01,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; static const uint8_t setPedestrianMode[]={0xB5,0x62,0x06,0x24,0x24,0x00,0xFF,0xFF,0x03,0x03,0x00,0x00,0x00,0x00,0x10,0x27,0x00,0x00,0x05,0x00,0xFA,0x00,0xFA,0x00,0x64,0x00,0x5E,0x01,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; static const uint8_t setConfig[]={0xB5,0x62,0x06,0x09,0x0D,0x00, 0x00,0x00,0x00,0x00, 0x18,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x01}; /* UBX-MGA-INI-TIME_UTC */ static const uint8_t setDateTime[] = {0xB5,0x62,0x13,0x40,0x18,0x00,0x10,0x00,0x00,0x80,0x07,0xE9,0x01,0x02,0x03,0x04,0x05,0x00,0x01,0x02,0x03,0x04,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00}; static const uint8_t setPortableType[]={}; void GNSS_Init(GNSS_StateHandle *GNSS, UART_HandleTypeDef *huart); void GNSS_LoadConfig(GNSS_StateHandle *GNSS); uint8_t GNSS_ParseBuffer(GNSS_StateHandle *GNSS); void GNSS_GetUniqID(GNSS_StateHandle *GNSS); void GNSS_ParseUniqID(GNSS_StateHandle *GNSS); void GNSS_GetNavigatorData(GNSS_StateHandle *GNSS); void GNSS_ParseNavigatorData(GNSS_StateHandle *GNSS); void GNSS_ParseNavSatData(GNSS_StateHandle *GNSS); void GNSS_GetPOSLLHData(GNSS_StateHandle *GNSS); void GNSS_ParsePOSLLHData(GNSS_StateHandle *GNSS); void GNSS_GetPVTData(GNSS_StateHandle *GNSS); void GNSS_ParsePVTData(GNSS_StateHandle *GNSS); void GNSS_SetMode(GNSS_StateHandle *GNSS, short gnssMode); #endif /* INC_GNSS_H_ */
