diff --git a/meson.build b/meson.build
index 96e1bcb8..74a2293c 100644
--- a/meson.build
+++ b/meson.build
@@ -385,7 +385,8 @@ md3x0_src = ['platform/drivers/CPS/cps_io_native_MD3x0.c',
'platform/drivers/keyboard/keyboard_MD3x.c',
'platform/drivers/display/HX8353_MD3x.cpp',
'platform/drivers/backlight/backlight_MDx.c',
- 'platform/drivers/GPS/GPS_MDx.cpp',
+ 'platform/drivers/GPS/gps_stm32.cpp',
+ 'platform/drivers/GPS/nmea_rbuf.c',
'platform/targets/MD-3x0/platform.c',
'platform/targets/MD-3x0/hwconfig.c']
diff --git a/platform/targets/MD-3x0/hwconfig.c b/platform/targets/MD-3x0/hwconfig.c
index 8e5c6980..fdbae249 100644
--- a/platform/targets/MD-3x0/hwconfig.c
+++ b/platform/targets/MD-3x0/hwconfig.c
@@ -18,13 +18,28 @@
* along with this program; if not, see *
***************************************************************************/
+#include
#include
#include
#include
#include
+#include
#include
#include
#include
+#include
+
+static void gpsEnable(void *priv)
+{
+ gpio_setPin(GPS_EN);
+ gpsStm32_enable(priv);
+}
+
+static void gpsDisable(void *priv)
+{
+ gpio_clearPin(GPS_EN);
+ gpsStm32_disable(priv);
+}
const struct spiConfig spiPllCfg =
{
@@ -57,3 +72,11 @@ const struct sky73210 pll =
.cs = { PLL_CS },
.refClk = 16800000
};
+
+const struct gpsDevice gps =
+{
+ .priv = NULL,
+ .enable = gpsEnable,
+ .disable = gpsDisable,
+ .getSentence = gpsStm32_getNmeaSentence
+};
diff --git a/platform/targets/MD-3x0/hwconfig.h b/platform/targets/MD-3x0/hwconfig.h
index 199cb371..4fdf6264 100644
--- a/platform/targets/MD-3x0/hwconfig.h
+++ b/platform/targets/MD-3x0/hwconfig.h
@@ -35,6 +35,7 @@ enum adcChannel
ADC_RSSI_CH = 8
};
+extern const struct gpsDevice gps;
extern const struct spiDevice nvm_spi;
extern const struct spiCustomDevice pll_spi;
extern const struct spiCustomDevice c5000_spi;
@@ -46,6 +47,8 @@ extern const struct Adc adc1;
/* Device supports an optional GPS chip */
#define CONFIG_GPS
+#define CONFIG_GPS_STM32_USART3
+#define CONFIG_NMEA_RBUF_SIZE 128
/* Device has a channel selection knob */
#define CONFIG_KNOB_ABSOLUTE
diff --git a/platform/targets/MD-3x0/platform.c b/platform/targets/MD-3x0/platform.c
index 653273f9..93db2054 100644
--- a/platform/targets/MD-3x0/platform.c
+++ b/platform/targets/MD-3x0/platform.c
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -27,6 +28,8 @@
#include
#include
#include
+#include
+#include
static hwInfo_t hwInfo;
@@ -74,6 +77,7 @@ void platform_terminate()
/* Shut down all the modules */
adcStm32_terminate(&adc1);
+ gpsStm32_terminate();
nvm_terminate();
toneGen_terminate();
audio_terminate();
@@ -225,3 +229,28 @@ const hwInfo_t *platform_getHwInfo()
{
return &hwInfo;
}
+
+const struct gpsDevice *platform_initGps()
+{
+ const struct gpsDevice *dev = NULL;
+
+ // Turn on the GPS and check if there is voltage on the RXD pin
+ gpio_setMode(GPS_DATA, INPUT_PULL_DOWN);
+ gpio_setMode(GPS_EN, OUTPUT);
+ gpio_setPin(GPS_EN);
+
+ for(size_t i = 0; i < 50; i++) {
+ if(gpio_readPin(GPS_DATA) != 0) {
+ dev = &gps;
+ gpsStm32_init(9600);
+ break;
+ }
+
+ sleepFor(0, 1);
+ }
+
+ gpio_clearPin(GPS_EN);
+ gpio_setMode(GPS_DATA, ALTERNATE | ALTERNATE_FUNC(7));
+
+ return dev;
+}