I2C gps testing
This commit is contained in:
		
							parent
							
								
									bb37aba2c3
								
							
						
					
					
						commit
						85e9368c6e
					
				| @ -15,8 +15,8 @@ | ||||
| ;env_default = ttgov1 | ||||
| ;env_default = ttgov2 | ||||
| ;env_default = ttgov21 | ||||
| ;env_default = ttgobeam | ||||
| env_default = lopy | ||||
| env_default = ttgobeam | ||||
| ;env_default = lopy | ||||
| ;env_default = lopy4 | ||||
| ;env_default = fipy | ||||
| ;env_default = lolin32lite | ||||
| @ -143,6 +143,7 @@ upload_speed = 921600 | ||||
| lib_deps =  | ||||
|     ${common_env_data.lib_deps_all} | ||||
|     ${common_env_data.lib_deps_rgbled} | ||||
|     ${common_env_data.lib_deps_gps} | ||||
| build_flags =  | ||||
|     ${common_env_data.build_flags} | ||||
|     -include "src/hal/lopy.h" | ||||
| @ -157,6 +158,7 @@ upload_speed = 921600 | ||||
| lib_deps = | ||||
|     ${common_env_data.lib_deps_all} | ||||
|     ${common_env_data.lib_deps_rgbled} | ||||
|     ${common_env_data.lib_deps_gps} | ||||
| build_flags = | ||||
|     ${common_env_data.build_flags} | ||||
|     -include "src/hal/lopy4.h" | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| #ifdef HAS_GPS | ||||
| 
 | ||||
| #include "globals.h" | ||||
| #include <Wire.h> | ||||
| 
 | ||||
| // Local logging tag
 | ||||
| static const char TAG[] = "main"; | ||||
| @ -22,8 +23,8 @@ void gps_loop(void *pvParameters) { | ||||
| // initialize and, if needed, configure, GPS
 | ||||
| #if defined GPS_SERIAL | ||||
|   HardwareSerial GPS_Serial(1); | ||||
| #elif defined GPS_I2C | ||||
|                                                // to be done
 | ||||
| #elif defined GPS_QUECTEL_L76 | ||||
|   Wire.begin(GPS_QUECTEL_L76, 400000); // I2C connect to GPS device with 400
 | ||||
| #endif | ||||
| 
 | ||||
|   while (1) { | ||||
| @ -44,30 +45,29 @@ void gps_loop(void *pvParameters) { | ||||
|       // after GPS function was disabled, close connect to GPS device
 | ||||
|       GPS_Serial.end(); | ||||
| 
 | ||||
| #elif defined GPS_I2C | ||||
| #elif defined GPS_QUECTEL_L76 | ||||
| 
 | ||||
|       // I2C connect to GPS device with 100 kHz
 | ||||
|       Wire.begin(GPS_I2C_PINS, 100000); | ||||
|       Wire.beginTransmission(GPS_I2C_ADDRESS_WRITE); | ||||
|       Wire.write(0x00); | ||||
|       Wire.write(0x00); // dummy write to start read
 | ||||
|       Wire.endTransmission(); | ||||
| 
 | ||||
|       i2c_ret == Wire.beginTransmission(GPS_I2C_ADDRESS_READ); | ||||
|       if (i2c_ret == 0) { // check if device seen on i2c bus
 | ||||
|         while (cfg.gpsmode) { | ||||
|           // feed GPS decoder with serial NMEA data from GPS device
 | ||||
|           while (Wire.available()) { | ||||
|             Wire.requestFrom(GPS_I2C_ADDRESS_READ, 255); | ||||
|             gps.encode(Wire.read()); | ||||
|             vTaskDelay(1 / portTICK_PERIOD_MS); // reset watchdog
 | ||||
|           } | ||||
|       Wire.beginTransmission(GPS_I2C_ADDRESS_READ); | ||||
|       while (cfg.gpsmode) { | ||||
|         Wire.requestFrom(GPS_I2C_ADDRESS_READ, 32); | ||||
|         while (Wire.available()) { | ||||
|           gps.encode(Wire.read()); | ||||
|           vTaskDelay(500 / portTICK_PERIOD_MS); // polling mode: 500ms sleep
 | ||||
|         } | ||||
|         // after GPS function was disabled, close connect to GPS device
 | ||||
| 
 | ||||
|         Wire.endTransmission(); | ||||
|         Wire.setClock(400000); // Set back to 400KHz to speed up OLED
 | ||||
|         ESP_LOGI(TAG, "GPS NMEA data: passed %d / failed: %d / with fix: %d", | ||||
|                  gps.passedChecksum(), gps.failedChecksum(), | ||||
|                  gps.sentencesWithFix()); | ||||
|       } | ||||
|       // after GPS function was disabled, close connect to GPS device
 | ||||
| 
 | ||||
| #endif | ||||
|       Wire.endTransmission(); | ||||
| 
 | ||||
| #endif // GPS Type
 | ||||
|     } | ||||
| 
 | ||||
|     vTaskDelay(1 / portTICK_PERIOD_MS); // reset watchdog
 | ||||
|  | ||||
| @ -7,12 +7,12 @@ | ||||
| // !!EXPERIMENTAL - not tested yet!!
 | ||||
| // uncomment this only if your LoPy runs on a Pytrack expansion board with GPS
 | ||||
| // see http://www.quectel.com/UploadImage/Downlad/Quectel_L76-L_I2C_Application_Note_V1.0.pdf
 | ||||
| //#define HAS_GPS 1
 | ||||
| //#define GPS_I2C_PINS GPIO_NUM_25, GPIO_NUM_26 // SDA (P22), SCL (P21)
 | ||||
| //#define GPS_I2C_ADDRESS_READ 0x21
 | ||||
| //#define GPS_I2C_ADDRESS_WRITE 0x20
 | ||||
| //#define HAS_BUTTON GPIO_NUM_37 // (P14)
 | ||||
| //define BUTTON_PULLUP 1  // Button need pullup instead of default pulldown
 | ||||
| #define HAS_GPS 1 | ||||
| #define GPS_QUECTEL_L76 GPIO_NUM_25, GPIO_NUM_26 // SDA (P22), SCL (P21)
 | ||||
| #define GPS_I2C_ADDRESS_READ 0x21 | ||||
| #define GPS_I2C_ADDRESS_WRITE 0x20 | ||||
| #define HAS_BUTTON GPIO_NUM_37 // (P14)
 | ||||
| #define BUTTON_PULLUP 1  // Button need pullup instead of default pulldown
 | ||||
| 
 | ||||
| // Hardware pin definitions for Pycom LoPy board
 | ||||
| #define PIN_SPI_SS    GPIO_NUM_17 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user