kopia lustrzana https://github.com/OpenRTX/OpenRTX
MD3x0: using new STM32 GPS driver
rodzic
29ebf95966
commit
5d50439312
|
@ -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']
|
||||
|
||||
|
|
|
@ -18,13 +18,28 @@
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <peripherals/gpio.h>
|
||||
#include <spi_bitbang.h>
|
||||
#include <spi_custom.h>
|
||||
#include <spi_stm32.h>
|
||||
#include <adc_stm32.h>
|
||||
#include <gps_stm32.h>
|
||||
#include <SKY72310.h>
|
||||
#include <hwconfig.h>
|
||||
#include <pinmap.h>
|
||||
#include <gps.h>
|
||||
|
||||
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
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <peripherals/gpio.h>
|
||||
#include <interfaces/nvmem.h>
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <hwconfig.h>
|
||||
#include <string.h>
|
||||
#include <adc_stm32.h>
|
||||
|
@ -27,6 +28,8 @@
|
|||
#include <toneGenerator_MDx.h>
|
||||
#include <peripherals/rtc.h>
|
||||
#include <interfaces/audio.h>
|
||||
#include <gps_stm32.h>
|
||||
#include <gps.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue