|
1 | | -# STM32-GNSS |
2 | | -Library for modules supporting Global Navigation Satellite Systems for u-blox devices: MAX-M8, NEO-M8, NEO-M9N |
| 1 | +# STM32 GNSS |
| 2 | + |
| 3 | +## STM32 library with DMA support for u-blox devices supporting Global Navigation Satellite Systems and UBX standard |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +# Example: |
| 8 | + |
| 9 | + /* USER CODE BEGIN 2 */ |
| 10 | + GNSS_Init(&GNSS_Handle, &huart1); |
| 11 | + HAL_Delay(1000); |
| 12 | + GNSS_LoadConfig(&GNSS_Handle); |
| 13 | + uint32_t Timer = HAL_GetTick(); |
| 14 | + /* USER CODE END 2 */ |
| 15 | + /* Infinite loop */ |
| 16 | + /* USER CODE BEGIN WHILE */ |
| 17 | + while (1) { |
| 18 | + |
| 19 | + if ((HAL_GetTick() - Timer) > 1000) { |
| 20 | + HAL_GPIO_TogglePin(LED_D2_GPIO_Port, LED_D2_Pin); |
| 21 | + |
| 22 | + //getNavigatorData |
| 23 | + GNSS_GetUniqID(&GNSS_Handle); |
| 24 | + GNSS_ParseBuffer(&GNSS_Handle); |
| 25 | + HAL_Delay(250); |
| 26 | + GNSS_GetPVTData(&GNSS_Handle); |
| 27 | + GNSS_ParseBuffer(&GNSS_Handle); |
| 28 | + printf("Day: %d-%d-%d \r\n", GNSS_Handle.day, GNSS_Handle.month,GNSS_Handle.year); |
| 29 | + printf("Time: %d:%d:%d \r\n", GNSS_Handle.hour, GNSS_Handle.min,GNSS_Handle.sec); |
| 30 | + printf("Status of fix: %d \r\n", GNSS_Handle.fixType); |
| 31 | + printf("Latitude: %f \r\n", GNSS_Handle.fLat); |
| 32 | + printf("Longitude: %f \r\n",(float) GNSS_Handle.lon / 10000000.0); |
| 33 | + printf("Height above ellipsoid: %d \r\n", GNSS_Handle.height); |
| 34 | + printf("Height above mean sea level: %d \r\n", GNSS_Handle.hMSL); |
| 35 | + printf("Ground Speed (2-D): %d \r\n", GNSS_Handle.gSpeed); |
| 36 | + printf("Unique ID: %04X %04X %04X %04X %04X \n\r", |
| 37 | + GNSS_Handle.uniqueID[0], GNSS_Handle.uniqueID[1], |
| 38 | + GNSS_Handle.uniqueID[2], GNSS_Handle.uniqueID[3], |
| 39 | + GNSS_Handle.uniqueID[4], GNSS_Handle.uniqueID[5]); |
| 40 | + Timer = HAL_GetTick(); |
| 41 | + } |
| 42 | + /* USER CODE END WHILE */ |
| 43 | + /* USER CODE BEGIN 3 */ |
| 44 | + } |
| 45 | + /* USER CODE END 3 */ |
| 46 | + |
| 47 | +# Successfully tested on: |
| 48 | +- [x] MAX-M8Q |
| 49 | +- [x] NEO-M8 |
| 50 | +- [x] NEO-M9N |
| 51 | + |
| 52 | +# DMA configuration: |
| 53 | + |
| 54 | +| DMA request | Stream | Direction | Priority | |
| 55 | +|-------------|---------------|----------------------|----------| |
| 56 | +| USART1_RX | DMA1_Channel3 | Peripheral To Memory | Low | |
| 57 | +| USART1_TX | DMA1_Channel4 | Memory To Peripheral | Low | |
| 58 | + |
| 59 | +# IPs and Middleware Configuration: |
| 60 | +| Type | Mode | Baud Rate | Word Length | Parity | Stop Bits | Data Direction | |
| 61 | +|--------|--------------|-----------|---------------------------|--------|-----------|----------------------| |
| 62 | +| USART1 | Asynchronous | **9600** | 8 Bits (including Parity) | None | 1 | Receive and Transmit | |
| 63 | + |
| 64 | +# UBX configuration: |
| 65 | + |
| 66 | + //Setting input and output only for UBX standard |
| 67 | + static 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,0x9A,0x79}; |
| 68 | + |
| 69 | + //Changing the NMEA version to 4.10 |
| 70 | + static 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,0x75,0x57}; |
| 71 | + |
| 72 | + //Activation of navigation system: Galileo, Glonass, GPS, SBAS, IMES |
| 73 | + static 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,0xDF,0xFB}; |
| 74 | + |
| 75 | + |
| 76 | +# Pins configuration: |
| 77 | + |
| 78 | +| PERIPHERALS | MODES | FUNCTIONS | PINS | |
| 79 | +|-------------|-----------------------|----------------|-------------------| |
| 80 | +| USART1 | Asynchronous | I2C1_SCL | PB6 | |
| 81 | +| USART1 | Asynchronous | I2C1_SDA | PB10 | |
| 82 | +| SYS | Trace Asynchronous Sw | SYS_JTMS-SWDIO | PA13 | |
| 83 | +| SYS | Trace Asynchronous Sw | SYS_JTCK-SWCLK | PA14 | |
| 84 | +| SYS | Trace Asynchronous Sw | SYS_JTDO-SWO | PB3 | |
| 85 | +| SYS | SysTick | SYS_VS_Systick | VP_SYS_VS_Systick | |
| 86 | +| USART2 | Asynchronous | USART2_RX | PA3 | |
| 87 | +| USART2 | Asynchronous | USART2_TX | PA2 | |
| 88 | + |
| 89 | + |
| 90 | +### **For using printf with float should be add flag -u _printf_float in C compiler** |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +### More information can be found in [u-blox M8 Receiver description](https://www.u-blox.com/sites/default/files/products/documents/u-blox8-M8_ReceiverDescrProtSpec_%28UBX-13003221%29.pdf) |
0 commit comments