Created
November 6, 2022 22:29
-
-
Save dj1711572002/f0977877d8b2ad03b86ea74075926433 to your computer and use it in GitHub Desktop.
Teensy4.1 ArduinoIDE 3GNSSBoards F9P+F9H+M9N recieving test Program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//STA22 のIP用システムの初期動作チェック | |
// | |
//-----SD log parameters---------------------- | |
//#include <SD.h> | |
#include "SdFat.h" | |
//#include <SPI.h> | |
#ifdef USE_EXTERNAL_SD | |
const uint8_t SD_CS_PIN = SS; | |
#define SPI_CLOCK SD_SCK_MHZ(10) | |
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK) | |
#else // Use built in SD card. | |
// Why does this #ifdef have to be here? I do not understand. If it is defined | |
// then why does the compiler give this error without the #ifdef/#endif: | |
// "ReadWrite:39: error: 'SDCARD_SS_PIN' was not declared in this scope" | |
// Either it is defined previously or it is not right??? | |
// This one has me stumped. Uncomment the #ifdef and #endif and you will see what | |
// happens. I am probably missing something again! | |
#ifdef SDCARD_SS_PIN | |
const uint8_t SD_CS_PIN = SDCARD_SS_PIN; | |
#endif // SDCARD_SS_PIN | |
// Setup for built in SD card. | |
#define SPI_CLOCK SD_SCK_MHZ(50) | |
#define SD_CONFIG SdioConfig(FIFO_SDIO) | |
#endif // USE_EXTERNAL_SD | |
SdFs sd; | |
FsFile myFile;//UBX_base pvt relposned | |
FsFile myFileR;//UBX_rover pvt relposned | |
FsFile myFileT;//TXT_rtk status statics | |
FsFile myFileI;//TXT_imu & pvt | |
int epNosd,epNosd_1; | |
int n;//counter | |
int i, j,jj, k,l,m; | |
//Data------------ | |
uint8_t baseNo;//USb 0 or 1 | |
uint8_t Buf172[172]; | |
static uint8_t dBuf0[172], dBuf4[172],dBuf5[100];//バッファなので32の倍数でないといけない | |
int PVT1startNo; | |
uint8_t PVTdata[172];//userialb0 PVT | |
uint8_t RELPOSdata[172];//userialb0 RELPOS | |
uint8_t PVT1data[172];//userialb1 PVT | |
uint8_t RELPOS1data[172];//userialb1 RELPOS | |
long PVTval[33]; | |
long PVT1val[33]; | |
long RELPOSval[21]; | |
long RELPOS1val[21]; | |
//USB0-USB1=> base-rover | |
long PVTBval[33]; | |
long PVTRval[33]; | |
long RELPOSBval[21]; | |
long RELPOSRval[21]; | |
uint8_t RELPOSBdata[172];//base line RELPOS | |
volatile uint8_t RELPOS1Bdata[172];//base line RELPOS | |
uint8_t epflag0,epflag1; | |
uint8_t fdata[4]; | |
int Num0, Num0_1, Num1, Num1_1; | |
int flag0, flag1; | |
char keyin; | |
//int time0, time0_1, time1, time1_1; | |
int trcv0,trcv1,tsdbin0,tsdbin1,tsdtxt0,tsdtxt1,timu0,timu1; | |
int starttime; | |
//----Hardware Serial Set--------------- | |
//32の倍数でバッファ定義 | |
int dcount; | |
static uint8_t serialbuffer1[192];//Base PVT+RELPOS172bytes | |
static uint8_t serialbuffer2[256];//BlueTooth | |
static uint8_t serialbuffer4[192];//Rover PVT+RELPOS172bytes | |
static uint8_t serialbuffer5[128];//M9N PVT100bytes | |
const int ledPin = 13; | |
void setup() { | |
Serial.begin(115200); | |
if (!sd.begin(SD_CONFIG)) { | |
Serial.println("SD CARD initialization failed!"); | |
return; | |
} | |
Serial.println("SD initialization done."); | |
//Serial1 def Base | |
Serial1.begin(115200);//RX1(p0)-TX1(p1) PVT+RELPOS from Base UART2 rcv=ubx ,tx=RTCM3 | |
Serial1.addMemoryForRead(serialbuffer1, sizeof(serialbuffer1)); | |
//Serial2 def Bluetooth | |
Serial2.begin(115200);//Rx2(p7)-Tx2(p8) from BlueTooth | |
Serial2.addMemoryForRead(serialbuffer2, sizeof(serialbuffer2)); | |
//Serial4 def Rover | |
Serial4.begin(115200);//Rx4(p16)-Tx4(p17) PVT+RELPOS from RoverF9P uart1 | |
Serial4.addMemoryForRead(serialbuffer4, sizeof(serialbuffer4)); | |
//Serial5 def m9N | |
Serial5.begin(115200);//Rx5(p21)-Tx5(p20) PVT from M9N uart1 | |
Serial5.addMemoryForRead(serialbuffer5, sizeof(serialbuffer5)); | |
while (!Serial && (millis() < 5000)) ; // wait for Arduino Serial Monitor | |
Serial1.begin(115200); // We will echo stuff Through Serial1... | |
pinMode(ledPin, OUTPUT); | |
} | |
void loop() { | |
//===Serial1Base data read========================================================= | |
if(Serial1.available()>171){ //バッファ1が172バイトになるまで処理しない | |
i=0; | |
while(i<172){ | |
digitalWrite(ledPin, HIGH); // set the LED on | |
Serial.printf("Base:%d,",millis()); | |
while(Serial1.available()){ | |
dBuf0[i]=Serial1.read();//read from serialbuffer1[] | |
//Serial.printf("dBuf0[%d]=%x\n\r",i,dBuf0[i]); | |
//Serial.print(dBuf0[i],HEX); | |
i++; | |
} | |
Serial.println(millis()); | |
digitalWrite(ledPin, LOW); // set the LED on | |
} | |
} | |
//delay(3); | |
//===Serial4 Rover read========================================================= | |
//Serial.printf("Serial4.available=%d\n\r",Serial4.available()); | |
if(Serial4.available()>171){ //バッファ4が172バイトになるまで処理しない | |
//Serial.println(); | |
j=0;//Rover Serial4 counter | |
while(j<172){ | |
digitalWrite(ledPin, HIGH); // set the LED on | |
Serial.printf("Rover:%d,",millis()); | |
while(Serial4.available()){ | |
dBuf4[j]=Serial4.read(); | |
//Serial.print(dBuf4[j],HEX); | |
j++; | |
} | |
} | |
//delay(3); | |
Serial.println(millis()); | |
digitalWrite(ledPin, LOW); // set the LED on | |
}// | |
//===Serial5 M9N read========================================================= | |
// Serial.printf("Serial5.available=%d\n\r",Serial5.available()); | |
if(Serial5.available()>99){ //バッファ5が100バイトになるまで処理しない | |
//Serial.println(); | |
k=0;//Rover Serial5 counter | |
while(k<100){ | |
// digitalWrite(ledPin, HIGH); // set the LED on | |
Serial.printf("M9N:%d,",millis()); | |
while(Serial5.available()){ | |
dBuf5[k]=Serial5.read(); | |
//Serial.print(dBuf5[k],HEX); | |
k++; | |
} | |
} | |
//delay(3); | |
Serial.println(millis()); | |
//digitalWrite(ledPin, LOW); // set the LED on | |
}// | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment