Horus internal GPS: settable baudrate, misc fixes, new cmake options,… (#3736)
* Horus internal GPS: settable baudrate, misc fixes, new cmake options, cosmetics, cli * Horus internal GPS: cmake changes, more CLI options, ability to send commands to the module * Compilation fixes
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
set(PCBREV "13" CACHE STRING "PCB Revision")
|
||||
set(INTERNAL_GPS_BAUDRATE "9600" CACHE STRING "Baud rate for internal GPS")
|
||||
option(DISK_CACHE "Enable SD card disk cache" YES)
|
||||
if(${PCBREV} GREATER 10)
|
||||
option(INTERNAL_GPS "Internal GPS installed" YES)
|
||||
else()
|
||||
option(INTERNAL_GPS "Internal GPS installed" NO)
|
||||
if(NOT INTERNAL_GPS)
|
||||
message("Internal GPS is optional, use INTERNAL_GPS=YES option to enable it")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPU_TYPE STM32F4)
|
||||
set(HSE_VALUE 12000000)
|
||||
@@ -16,6 +25,7 @@ set(RAMBACKUP YES)
|
||||
|
||||
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(-DGPS_USART_BAUDRATE=${INTERNAL_GPS_BAUDRATE})
|
||||
|
||||
include_directories(${RADIO_SRC_DIRECTORY}/fonts/480x272 gui/${GUI_DIR} gui/${GUI_DIR}/layouts)
|
||||
|
||||
@@ -44,11 +54,15 @@ set(GUI_SRC
|
||||
${LAYOUTS_SRC}
|
||||
${WIDGETS_SRC}
|
||||
)
|
||||
set(SRC ${SRC} gps.cpp)
|
||||
if(DISK_CACHE)
|
||||
set(SRC ${SRC} disk_cache.cpp)
|
||||
add_definitions(-DDISK_CACHE)
|
||||
endif()
|
||||
if(INTERNAL_GPS)
|
||||
set(SRC ${SRC} gps.cpp)
|
||||
add_definitions(-DINTERNAL_GPS)
|
||||
message("Internal GPS enabled")
|
||||
endif()
|
||||
set(SERIAL2_DRIVER serial2_driver.cpp)
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
|
||||
@@ -162,7 +162,7 @@ void boardInit()
|
||||
lcdInit();
|
||||
backlightInit();
|
||||
// TODO ? backlightEnable(100);
|
||||
|
||||
|
||||
audioInit();
|
||||
init2MhzTimer();
|
||||
init1msTimer();
|
||||
@@ -171,8 +171,8 @@ void boardInit()
|
||||
|
||||
// bt_open();
|
||||
|
||||
gpsInit();
|
||||
|
||||
gpsInit(GPS_USART_BAUDRATE);
|
||||
|
||||
#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);
|
||||
#endif
|
||||
|
||||
@@ -399,13 +399,12 @@ void hapticOff(void);
|
||||
void hapticOn(uint32_t pwmPercent);
|
||||
|
||||
// GPS driver
|
||||
#if PCBREV >= 13
|
||||
#define INTERNAL_GPS 1
|
||||
#else
|
||||
#define INTERNAL_GPS 0
|
||||
#endif
|
||||
void gpsInit(void);
|
||||
void gpsInit(uint32_t baudrate);
|
||||
uint8_t gpsGetByte(uint8_t * byte);
|
||||
#if defined(DEBUG)
|
||||
extern uint8_t gpsTraceEnabled;
|
||||
void gpsSendByte(uint8_t byte);
|
||||
#endif
|
||||
|
||||
// Second serial port driver
|
||||
#define SERIAL2
|
||||
|
||||
@@ -20,9 +20,13 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
Fifo<uint8_t, 64> gpsRxFifo;
|
||||
#if GPS_USART_BAUDRATE > 9600
|
||||
Fifo<uint8_t, 256> gpsRxFifo;
|
||||
#else
|
||||
Fifo<uint8_t, 64> gpsRxFifo;
|
||||
#endif
|
||||
|
||||
void gpsInit()
|
||||
void gpsInit(uint32_t baudrate)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
@@ -39,7 +43,7 @@ void gpsInit()
|
||||
GPIO_Init(GPS_UART_GPIO, &GPIO_InitStructure);
|
||||
|
||||
// UART config
|
||||
USART_InitStructure.USART_BaudRate = GPS_USART_BAUDRATE;
|
||||
USART_InitStructure.USART_BaudRate = baudrate;
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
@@ -56,9 +60,23 @@ void gpsInit()
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
uint8_t gpsTraceEnabled = false;
|
||||
Fifo<uint8_t, 64> gpsTxFifo;
|
||||
|
||||
void gpsSendByte(uint8_t byte)
|
||||
{
|
||||
while (gpsTxFifo.isFull());
|
||||
gpsTxFifo.push(byte);
|
||||
USART_ITConfig(GPS_USART, USART_IT_TXE, ENABLE);
|
||||
}
|
||||
|
||||
#endif // #if defined(DEBUG)
|
||||
|
||||
|
||||
extern "C" void GPS_USART_IRQHandler(void)
|
||||
{
|
||||
#if 0
|
||||
#if defined(DEBUG)
|
||||
// Send
|
||||
if (USART_GetITStatus(GPS_USART, USART_IT_TXE) != RESET) {
|
||||
uint8_t txchar;
|
||||
@@ -85,5 +103,11 @@ extern "C" void GPS_USART_IRQHandler(void)
|
||||
|
||||
uint8_t gpsGetByte(uint8_t * byte)
|
||||
{
|
||||
return gpsRxFifo.pop(*byte);
|
||||
uint8_t result = gpsRxFifo.pop(*byte);
|
||||
#if defined(DEBUG)
|
||||
if (gpsTraceEnabled) {
|
||||
serialPutc(*byte);
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
@@ -443,6 +443,5 @@
|
||||
#define GPS_RX_GPIO_PIN GPIO_Pin_1 // PA.01
|
||||
#define GPS_TX_GPIO_PinSource GPIO_PinSource0
|
||||
#define GPS_RX_GPIO_PinSource GPIO_PinSource1
|
||||
#define GPS_USART_BAUDRATE 9600
|
||||
|
||||
#endif // _HAL_H_
|
||||
|
||||
Reference in New Issue
Block a user