Skip to content

Commit 2769510

Browse files
authored
Merge pull request #7 from NoahRosa/master
Added VirtualCOMPort example
2 parents e486aed + caf6480 commit 2769510

2 files changed

Lines changed: 86 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This device uses alternatively I2C or UART to communicate. An I2C or UART instan
77

88
## Examples
99

10-
There are 4 examples with the X-NUCLEO-GNSS1A1 library.
10+
There are 5 examples with the X-NUCLEO-GNSS1A1 library.
1111

1212
* X_NUCLEO_GNSS1A1_HelloWorld_I2C: This example code provides a simple command line interface
1313
to communicate with the sensor via I2C protocol
@@ -21,12 +21,19 @@ There are 4 examples with the X-NUCLEO-GNSS1A1 library.
2121
* X_NUCLEO_GNSS1A1_MicroNMEA_UART: This example code shows how to communicate with the sensor via
2222
UART protocol using the lightweight Arduino MicroNMEA library.
2323

24+
* X_NUCLEO_GNSS1A1_VirtualCOMPort: This example code should be uploaded to the board in order to perform a
25+
firmware upgrade using the Flash Updater java application.
26+
2427
## Dependencies
2528

2629
The X-NUCLEO-GNSS1A1 library requires the following Arduino library:
2730

2831
* MicroNMEA: https://github.com/stevemarple/MicroNMEA
2932

33+
In order to perform the firmware upgrade, the following Java application should be used:
34+
35+
* Flash Updater: https://github.com/stm32duino/Teseo-LIV3F-Flash-Updater
36+
3037
## Note
3138

3239
The device works only in an outdoor enviroment with a clear view of the sky.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
******************************************************************************
3+
* @file X_NUCLEO_GNSS1A1_VirtualCOMPort.ino
4+
* @author AST
5+
* @version V1.0.0
6+
* @date January 2018
7+
* @brief Arduino test application for the STMicrolectronics X-NUCLEO-GNSS1A1
8+
* GNSS module expansion board based on TeseoLIV3F.
9+
******************************************************************************
10+
* @attention
11+
*
12+
* <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
13+
*
14+
* Redistribution and use in source and binary forms, with or without modification,
15+
* are permitted provided that the following conditions are met:
16+
* 1. Redistributions of source code must retain the above copyright notice,
17+
* this list of conditions and the following disclaimer.
18+
* 2. Redistributions in binary form must reproduce the above copyright notice,
19+
* this list of conditions and the following disclaimer in the documentation
20+
* and/or other materials provided with the distribution.
21+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
22+
* may be used to endorse or promote products derived from this software
23+
* without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35+
*
36+
******************************************************************************
37+
*/
38+
39+
//NOTE: for compatibility with the Arduino Due some additional cabling needs to be performed:
40+
// pin D8 should be connected to pin D18 and pin D2 should be connected to pin D19
41+
42+
//NOTE: this sketch should be uploaded in order to perform a Firmware Upgrade procedure using
43+
// the Flash Updater Java tool provided at https://github.com/stm32duino/Teseo-LIV3F-Flash-Updater
44+
45+
volatile uint8_t fromPC[16];
46+
volatile uint8_t fromGNSS[16];
47+
volatile unsigned long idxPC = 0;
48+
volatile unsigned long idxGNSS = 0;
49+
50+
#ifdef ARDUINO_ARCH_STM32
51+
HardwareSerial Serial1(PA10, PA9);
52+
#endif
53+
54+
void setup() {
55+
Serial.begin(115200);
56+
Serial1.begin(115200);
57+
pinMode(7, OUTPUT);
58+
digitalWrite(7, LOW);
59+
delay(1000);
60+
digitalWrite(7,HIGH);
61+
delay(50);
62+
}
63+
64+
65+
void loop() {
66+
if(Serial.available()){
67+
fromPC[idxPC]= Serial.read();
68+
Serial1.write(fromPC[idxPC]);
69+
idxPC++;
70+
idxPC %= 16;
71+
}
72+
if(Serial1.available()){
73+
fromGNSS[idxGNSS]= Serial1.read();
74+
Serial.write(fromGNSS[idxGNSS]);
75+
idxGNSS++;
76+
idxGNSS %= 16;
77+
}
78+
}

0 commit comments

Comments
 (0)