mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 22:35:12 +03:00
Horus internal GPS: settable baudrate, misc fixes, new cmake options, cosmetics, cli
This commit is contained in:
parent
f0c2f10e27
commit
1ef91597ca
8 changed files with 75 additions and 21 deletions
|
@ -708,6 +708,20 @@ int cliShowJitter(const char ** argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(INTERNAL_GPS)
|
||||||
|
int cliGps(const char ** argv)
|
||||||
|
{
|
||||||
|
int baudrate = 0;
|
||||||
|
if (toInt(argv, 1, &baudrate) > 0 && baudrate > 0) {
|
||||||
|
gpsInit(baudrate);
|
||||||
|
serialPrint("GPS baudrate set to %d", baudrate);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
serialPrint("%s: Invalid arguments", argv[0]);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const CliCommand cliCommands[] = {
|
const CliCommand cliCommands[] = {
|
||||||
{ "beep", cliBeep, "[<frequency>] [<duration>]" },
|
{ "beep", cliBeep, "[<frequency>] [<duration>]" },
|
||||||
|
@ -731,6 +745,9 @@ const CliCommand cliCommands[] = {
|
||||||
{ "repeat", cliRepeat, "<interval> <command>" },
|
{ "repeat", cliRepeat, "<interval> <command>" },
|
||||||
#if defined(JITTER_MEASURE)
|
#if defined(JITTER_MEASURE)
|
||||||
{ "jitter", cliShowJitter, "" },
|
{ "jitter", cliShowJitter, "" },
|
||||||
|
#endif
|
||||||
|
#if defined(INTERNAL_GPS)
|
||||||
|
{ "gps", cliGps, "<baudrate>" },
|
||||||
#endif
|
#endif
|
||||||
{ NULL, NULL, NULL } /* sentinel */
|
{ NULL, NULL, NULL } /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,26 @@
|
||||||
/*
|
/*
|
||||||
* This file is part of Cleanflight.
|
* Copyright (C) OpenTX
|
||||||
|
*
|
||||||
|
* Based on code named
|
||||||
|
* th9x - http://code.google.com/p/th9x
|
||||||
|
* er9x - http://code.google.com/p/er9x
|
||||||
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
|
*
|
||||||
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is based on code from Cleanflight project
|
||||||
|
* https://github.com/cleanflight/cleanflight
|
||||||
*
|
*
|
||||||
* Cleanflight is free software: you can redistribute it and/or modify
|
* Cleanflight is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -134,11 +155,11 @@ bool gpsNewFrameNMEA(char c)
|
||||||
case '*':
|
case '*':
|
||||||
string[offset] = 0;
|
string[offset] = 0;
|
||||||
if (param == 0) {
|
if (param == 0) {
|
||||||
// Frame identification
|
// Frame identification (accept all GPS talkers (GP: GPS, GL:Glonass, GN:combination, etc...))
|
||||||
gps_frame = NO_FRAME;
|
gps_frame = NO_FRAME;
|
||||||
if (string[0] == 'G' && string[1] == 'P' && string[2] == 'G' && string[3] == 'G' && string[4] == 'A')
|
if (string[0] == 'G' && string[2] == 'G' && string[3] == 'G' && string[4] == 'A')
|
||||||
gps_frame = FRAME_GGA;
|
gps_frame = FRAME_GGA;
|
||||||
if (string[0] == 'G' && string[1] == 'P' && string[2] == 'R' && string[3] == 'M' && string[4] == 'C')
|
if (string[0] == 'G' && string[2] == 'R' && string[3] == 'M' && string[4] == 'C')
|
||||||
gps_frame = FRAME_RMC;
|
gps_frame = FRAME_RMC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,12 +228,14 @@ bool gpsNewFrameNMEA(char c)
|
||||||
switch (gps_frame) {
|
switch (gps_frame) {
|
||||||
case FRAME_GGA:
|
case FRAME_GGA:
|
||||||
frameOK = 1;
|
frameOK = 1;
|
||||||
|
gpsData.fix = gps_Msg.fix;
|
||||||
|
gpsData.numSat = gps_Msg.numSat;
|
||||||
if (gps_Msg.fix) {
|
if (gps_Msg.fix) {
|
||||||
gpsData.fix = 1;
|
__disable_irq(); // do the atomic update of lat/lon
|
||||||
gpsData.latitude = gps_Msg.latitude;
|
gpsData.latitude = gps_Msg.latitude;
|
||||||
gpsData.longitude = gps_Msg.longitude;
|
gpsData.longitude = gps_Msg.longitude;
|
||||||
gpsData.numSat = gps_Msg.numSat;
|
|
||||||
gpsData.altitude = gps_Msg.altitude;
|
gpsData.altitude = gps_Msg.altitude;
|
||||||
|
__enable_irq();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FRAME_RMC:
|
case FRAME_RMC:
|
||||||
|
@ -252,6 +275,7 @@ void gpsWakeup()
|
||||||
{
|
{
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
while (gpsGetByte(&byte)) {
|
while (gpsGetByte(&byte)) {
|
||||||
|
TRACE_PING("%c", (char)byte);
|
||||||
gpsNewData(byte);
|
gpsNewData(byte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,10 @@ void drawSourceCustomValue(coord_t x, coord_t y, source_t source, int32_t value,
|
||||||
if (gpsData.fix) {
|
if (gpsData.fix) {
|
||||||
drawGPSPosition(x, y, gpsData.longitude, gpsData.latitude, flags);
|
drawGPSPosition(x, y, gpsData.longitude, gpsData.latitude, flags);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
lcdDrawText(x, y, "sats: ", flags);
|
||||||
|
lcdDrawNumber(lcdNextPos, y, gpsData.numSat, flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (source < MIXSRC_FIRST_CH) {
|
else if (source < MIXSRC_FIRST_CH) {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
set(PCBREV "13" CACHE STRING "PCB Revision")
|
set(PCBREV "13" CACHE STRING "PCB Revision")
|
||||||
|
set(INTERNAL_GPS_BAUDRATE "9600" CACHE STRING "Baud rate for internal GPS")
|
||||||
|
option(INTERNAL_GPS_INSTALLED "Internal GPS installed in beta hardware version" NO)
|
||||||
option(DISK_CACHE "Enable SD card disk cache" YES)
|
option(DISK_CACHE "Enable SD card disk cache" YES)
|
||||||
|
|
||||||
set(CPU_TYPE STM32F4)
|
set(CPU_TYPE STM32F4)
|
||||||
|
@ -16,6 +18,7 @@ set(RAMBACKUP YES)
|
||||||
|
|
||||||
add_definitions(-DPCBHORUS -DPCBREV=${PCBREV} -DSTM32F429_439xx -DSDRAM -DCOLORLCD -DPPM_PIN_UART -DPPM_PIN_TIMER)
|
add_definitions(-DPCBHORUS -DPCBREV=${PCBREV} -DSTM32F429_439xx -DSDRAM -DCOLORLCD -DPPM_PIN_UART -DPPM_PIN_TIMER)
|
||||||
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
|
add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK)
|
||||||
|
add_definitions(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE})
|
||||||
|
|
||||||
include_directories(${RADIO_SRC_DIRECTORY}/fonts/480x272 gui/${GUI_DIR} gui/${GUI_DIR}/layouts)
|
include_directories(${RADIO_SRC_DIRECTORY}/fonts/480x272 gui/${GUI_DIR} gui/${GUI_DIR}/layouts)
|
||||||
|
|
||||||
|
@ -49,6 +52,9 @@ if(DISK_CACHE)
|
||||||
set(SRC ${SRC} disk_cache.cpp)
|
set(SRC ${SRC} disk_cache.cpp)
|
||||||
add_definitions(-DDISK_CACHE)
|
add_definitions(-DDISK_CACHE)
|
||||||
endif()
|
endif()
|
||||||
|
if(INTERNAL_GPS_INSTALLED)
|
||||||
|
add_definitions(-DINTERNAL_GPS_INSTALLED)
|
||||||
|
endif()
|
||||||
set(SERIAL2_DRIVER serial2_driver.cpp)
|
set(SERIAL2_DRIVER serial2_driver.cpp)
|
||||||
set(TARGET_SRC
|
set(TARGET_SRC
|
||||||
${TARGET_SRC}
|
${TARGET_SRC}
|
||||||
|
|
|
@ -177,7 +177,7 @@ void boardInit()
|
||||||
|
|
||||||
// bt_open();
|
// bt_open();
|
||||||
|
|
||||||
gpsInit();
|
gpsInit(GPS_USART_BAUDRATE);
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM4_STOP|DBGMCU_TIM5_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM7_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM9_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM11_STOP|DBGMCU_TIM12_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
|
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM4_STOP|DBGMCU_TIM5_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM7_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM9_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM11_STOP|DBGMCU_TIM12_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
|
||||||
|
|
|
@ -389,12 +389,12 @@ void hapticOff(void);
|
||||||
void hapticOn(uint32_t pwmPercent);
|
void hapticOn(uint32_t pwmPercent);
|
||||||
|
|
||||||
// GPS driver
|
// GPS driver
|
||||||
#if PCBREV >= 13
|
#if PCBREV >= 13 || defined(INTERNAL_GPS_INSTALLED)
|
||||||
#define INTERNAL_GPS 1
|
#define INTERNAL_GPS 1
|
||||||
#else
|
#else
|
||||||
#define INTERNAL_GPS 0
|
#define INTERNAL_GPS 0
|
||||||
#endif
|
#endif
|
||||||
void gpsInit(void);
|
void gpsInit(uint32_t baudrate);
|
||||||
uint8_t gpsGetByte(uint8_t * byte);
|
uint8_t gpsGetByte(uint8_t * byte);
|
||||||
|
|
||||||
// Second serial port driver
|
// Second serial port driver
|
||||||
|
|
|
@ -20,9 +20,13 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
|
#if GPS_USART_BAUDRATE > 9600
|
||||||
|
Fifo<uint8_t, 256> gpsRxFifo;
|
||||||
|
#else
|
||||||
Fifo<uint8_t, 64> gpsRxFifo;
|
Fifo<uint8_t, 64> gpsRxFifo;
|
||||||
|
#endif
|
||||||
|
|
||||||
void gpsInit()
|
void gpsInit(uint32_t baudrate)
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
USART_InitTypeDef USART_InitStructure;
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
@ -39,7 +43,7 @@ void gpsInit()
|
||||||
GPIO_Init(GPS_UART_GPIO, &GPIO_InitStructure);
|
GPIO_Init(GPS_UART_GPIO, &GPIO_InitStructure);
|
||||||
|
|
||||||
// UART config
|
// UART config
|
||||||
USART_InitStructure.USART_BaudRate = GPS_USART_BAUDRATE;
|
USART_InitStructure.USART_BaudRate = baudrate;
|
||||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
|
|
|
@ -439,6 +439,5 @@
|
||||||
#define GPS_RX_GPIO_PIN GPIO_Pin_1 // PA.01
|
#define GPS_RX_GPIO_PIN GPIO_Pin_1 // PA.01
|
||||||
#define GPS_TX_GPIO_PinSource GPIO_PinSource0
|
#define GPS_TX_GPIO_PinSource GPIO_PinSource0
|
||||||
#define GPS_RX_GPIO_PinSource GPIO_PinSource1
|
#define GPS_RX_GPIO_PinSource GPIO_PinSource1
|
||||||
#define GPS_USART_BAUDRATE 9600
|
|
||||||
|
|
||||||
#endif // _HAL_H_
|
#endif // _HAL_H_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue