kopia lustrzana https://github.com/OpenRTX/OpenRTX
MD-UV3x0: using new STM32 GPS driver
rodzic
5d50439312
commit
6cdec19cb7
|
@ -403,7 +403,8 @@ md3x0_def += openrtx_def + stm32f405_def
|
|||
mduv3x0_src = ['platform/drivers/CPS/cps_io_native_MDUV3x0.c',
|
||||
'platform/targets/MD-UV3x0/platform.c',
|
||||
'platform/targets/MD-UV3x0/hwconfig.c',
|
||||
'platform/drivers/GPS/GPS_MDx.cpp',
|
||||
'platform/drivers/GPS/gps_stm32.cpp',
|
||||
'platform/drivers/GPS/nmea_rbuf.c',
|
||||
'platform/drivers/keyboard/keyboard_MD3x.c',
|
||||
'platform/drivers/display/HX8353_MD3x.cpp',
|
||||
'platform/drivers/backlight/backlight_MDx.c',
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
#include <pinmap.h>
|
||||
#include <spi_stm32.h>
|
||||
#include <adc_stm32.h>
|
||||
|
||||
#include <gps_stm32.h>
|
||||
#include <gps.h>
|
||||
|
||||
static pthread_mutex_t c6000_mutex;
|
||||
static pthread_mutex_t adcMutex;
|
||||
|
@ -73,6 +74,26 @@ static uint8_t spiC6000_func(const void *priv, uint8_t value)
|
|||
return incoming;
|
||||
}
|
||||
|
||||
static void gpsEnable(void *priv)
|
||||
{
|
||||
gpio_setPin(GPS_EN);
|
||||
gpsStm32_enable(priv);
|
||||
}
|
||||
|
||||
static void gpsDisable(void *priv)
|
||||
{
|
||||
gpio_clearPin(GPS_EN);
|
||||
gpsStm32_disable(priv);
|
||||
}
|
||||
|
||||
SPI_CUSTOM_DEVICE_DEFINE(c6000_spi, spiC6000_func, NULL, &c6000_mutex)
|
||||
SPI_STM32_DEVICE_DEFINE(nvm_spi, SPI1, NULL)
|
||||
ADC_STM32_DEVICE_DEFINE(adc1, ADC1, &adcMutex, ADC_COUNTS_TO_UV(3300000, 12))
|
||||
|
||||
const struct gpsDevice gps =
|
||||
{
|
||||
.priv = NULL,
|
||||
.enable = gpsEnable,
|
||||
.disable = gpsDisable,
|
||||
.getSentence = gpsStm32_getNmeaSentence
|
||||
};
|
||||
|
|
|
@ -40,6 +40,7 @@ enum AdcChannel
|
|||
ADC_MIC_CH = 3,
|
||||
};
|
||||
|
||||
extern const struct gpsDevice gps;
|
||||
extern const struct spiCustomDevice c6000_spi;
|
||||
extern const struct spiDevice nvm_spi;
|
||||
extern const struct Adc adc1;
|
||||
|
@ -49,6 +50,8 @@ extern const struct Adc adc1;
|
|||
|
||||
/* Device supports an optional GPS chip */
|
||||
#define CONFIG_GPS
|
||||
#define CONFIG_GPS_STM32_USART1
|
||||
#define CONFIG_NMEA_RBUF_SIZE 128
|
||||
|
||||
/* Screen dimensions */
|
||||
#define CONFIG_SCREEN_WIDTH 160
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include <interfaces/platform.h>
|
||||
#include <interfaces/delays.h>
|
||||
#include <peripherals/gpio.h>
|
||||
#include <hwconfig.h>
|
||||
#include <string.h>
|
||||
|
@ -29,6 +30,8 @@
|
|||
#include <interfaces/audio.h>
|
||||
#include <chSelector.h>
|
||||
#include <Cx000_dac.h>
|
||||
#include <gps_stm32.h>
|
||||
#include <gps.h>
|
||||
|
||||
#ifdef CONFIG_SCREEN_BRIGHTNESS
|
||||
#include <backlight.h>
|
||||
|
@ -72,6 +75,7 @@ void platform_terminate()
|
|||
|
||||
/* Shut down all the modules */
|
||||
adcStm32_terminate(&adc1);
|
||||
gpsStm32_terminate();
|
||||
nvm_terminate();
|
||||
toneGen_terminate();
|
||||
chSelector_terminate();
|
||||
|
@ -209,6 +213,31 @@ 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: implementation of this API function is provided in
|
||||
* platform/drivers/chSelector/chSelector_MDUV3x0.c
|
||||
|
|
Ładowanie…
Reference in New Issue