|
| 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>© 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