Merge with latest 2.3
This commit is contained in:
@@ -236,12 +236,8 @@ set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
keys_driver.cpp
|
||||
diskio.cpp
|
||||
)
|
||||
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
telemetry_driver.cpp
|
||||
)
|
||||
)
|
||||
|
||||
set(FIRMWARE_SRC
|
||||
${FIRMWARE_SRC}
|
||||
|
||||
@@ -150,7 +150,7 @@ void auxSerialInit(unsigned int mode, unsigned int protocol)
|
||||
break;
|
||||
|
||||
case UART_MODE_SBUS_TRAINER:
|
||||
auxSerialSetup(SBUS_BAUDRATE, false, USART_WordLength_9b, USART_Parity_Even, USART_StopBits_2); // 2 stop bits requires USART_WordLength_9b
|
||||
auxSerialSetup(SBUS_BAUDRATE, true, USART_WordLength_9b, USART_Parity_Even, USART_StopBits_2); // 2 stop bits requires USART_WordLength_9b
|
||||
AUX_SERIAL_POWER_ON();
|
||||
break;
|
||||
|
||||
@@ -238,10 +238,6 @@ extern "C" void AUX_SERIAL_USART_IRQHandler(void)
|
||||
#if defined(LUA) & !defined(CLI)
|
||||
if (luaRxFifo && auxSerialMode == UART_MODE_LUA)
|
||||
luaRxFifo->push(data);
|
||||
#endif
|
||||
#if !defined(BOOT)
|
||||
if (auxSerialMode == UART_MODE_SBUS_TRAINER)
|
||||
trainerSbusFifo.push(data);
|
||||
#endif
|
||||
}
|
||||
status = AUX_SERIAL_USART->SR;
|
||||
@@ -352,7 +348,7 @@ void aux2SerialInit(unsigned int mode, unsigned int protocol)
|
||||
break;
|
||||
|
||||
case UART_MODE_SBUS_TRAINER:
|
||||
aux2SerialSetup(SBUS_BAUDRATE, false, USART_WordLength_9b, USART_Parity_Even, USART_StopBits_2); // 2 stop bits requires USART_WordLength_9b
|
||||
aux2SerialSetup(SBUS_BAUDRATE, true, USART_WordLength_9b, USART_Parity_Even, USART_StopBits_2); // 2 stop bits requires USART_WordLength_9b
|
||||
AUX2_SERIAL_POWER_ON();
|
||||
break;
|
||||
|
||||
@@ -438,11 +434,6 @@ extern "C" void AUX2_SERIAL_USART_IRQHandler(void)
|
||||
if (luaRxFifo && aux2SerialMode == UART_MODE_LUA) {
|
||||
luaRxFifo->push(data);
|
||||
}
|
||||
#endif
|
||||
#if !defined(BOOT)
|
||||
if (aux2SerialMode == UART_MODE_SBUS_TRAINER) {
|
||||
trainerSbusFifo.push(data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
status = AUX2_SERIAL_USART->SR;
|
||||
|
||||
@@ -54,28 +54,32 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define USBD_VID 0x0483
|
||||
#define USBD_VID_STM 0x0483 // STM Vendor ID
|
||||
#define USBD_VID_PID_CODES 0x1209 // https://pid.codes
|
||||
|
||||
#define USBD_LANGID_STRING 0x409
|
||||
#define USBD_MANUFACTURER_STRING "OpenTX"
|
||||
#define USBD_SERIALNUMBER_FS_STRING "00000000001B"
|
||||
|
||||
|
||||
#if defined(BOOT)
|
||||
#define USBD_MSC_PRODUCT_FS_STRING USB_NAME " Bootloader"
|
||||
#else
|
||||
#define USBD_MSC_PRODUCT_FS_STRING USB_NAME " Mass Storage"
|
||||
#endif
|
||||
|
||||
#define USBD_MSC_VID USBD_VID_STM
|
||||
#define USBD_MSC_PID 0x5720
|
||||
#define USBD_MSC_CONFIGURATION_FS_STRING "MSC Config"
|
||||
#define USBD_MSC_INTERFACE_FS_STRING "MSC Interface"
|
||||
|
||||
#define USBD_HID_PID 0x5710
|
||||
#define USBD_HID_VID USBD_VID_PID_CODES
|
||||
#define USBD_HID_PID 0x4F54 // OpenTX assigned PID
|
||||
#define USBD_HID_PRODUCT_FS_STRING USB_NAME " Joystick"
|
||||
#define USBD_HID_CONFIGURATION_FS_STRING "HID Config"
|
||||
#define USBD_HID_INTERFACE_FS_STRING "HID Interface"
|
||||
|
||||
#define USBD_CDC_PID 0x5740 // do not change, this ID is used by the ST USB driver for Windows
|
||||
#define USBD_CDC_VID USBD_VID_STM
|
||||
#define USBD_CDC_PID 0x5740 // do not change, this ID is used by the ST USB driver for Windows
|
||||
#define USBD_CDC_PRODUCT_FS_STRING USB_NAME " Serial Port"
|
||||
#define USBD_CDC_CONFIGURATION_FS_STRING "VSP Config"
|
||||
#define USBD_CDC_INTERFACE_FS_STRING "VSP Interface"
|
||||
@@ -125,20 +129,29 @@ __ALIGN_BEGIN uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ] __ALIGN_END ; // modifi
|
||||
* @param length : pointer to data length variable
|
||||
* @retval pointer to descriptor buffer
|
||||
*/
|
||||
uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length)
|
||||
uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length)
|
||||
{
|
||||
int pid=0;
|
||||
int vid, pid;
|
||||
|
||||
switch (getSelectedUsbMode()) {
|
||||
case USB_JOYSTICK_MODE:
|
||||
vid = USBD_HID_VID;
|
||||
pid = USBD_HID_PID;
|
||||
break;
|
||||
|
||||
case USB_SERIAL_MODE:
|
||||
vid = USBD_CDC_VID;
|
||||
pid = USBD_CDC_PID;
|
||||
break;
|
||||
|
||||
case USB_MASS_STORAGE_MODE:
|
||||
vid = USBD_MSC_VID;
|
||||
pid = USBD_MSC_PID;
|
||||
break;
|
||||
|
||||
default:
|
||||
vid = 0;
|
||||
pid = 0;
|
||||
}
|
||||
|
||||
/* USB Standard Device Descriptor */
|
||||
@@ -152,10 +165,10 @@ uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length)
|
||||
0x00, /*bDeviceSubClass*/
|
||||
0x00, /*bDeviceProtocol*/
|
||||
USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/
|
||||
LOBYTE(USBD_VID), /*idVendor*/
|
||||
HIBYTE(USBD_VID), /*idVendor*/
|
||||
LOBYTE(pid), /*idVendor*/
|
||||
HIBYTE(pid), /*idVendor*/
|
||||
LOBYTE(vid), /*idVendor*/
|
||||
HIBYTE(vid), /*idVendor*/
|
||||
LOBYTE(pid), /*idVendor*/
|
||||
HIBYTE(pid), /*idVendor*/
|
||||
0x00, /*bcdDevice rel. 2.00*/
|
||||
0x02,
|
||||
USBD_IDX_MFC_STR, /*Index of manufacturer string*/
|
||||
|
||||
@@ -637,7 +637,11 @@ void sportUpdatePowerInit();
|
||||
#endif
|
||||
|
||||
// Aux serial port driver
|
||||
#define DEBUG_BAUDRATE 115200
|
||||
#if defined(RADIO_TX16S)
|
||||
#define DEBUG_BAUDRATE 400000
|
||||
#else
|
||||
#define DEBUG_BAUDRATE 115200
|
||||
#endif
|
||||
#if defined(AUX_SERIAL_GPIO)
|
||||
extern uint8_t auxSerialMode;
|
||||
void auxSerialInit(unsigned int mode, unsigned int protocol);
|
||||
@@ -711,6 +715,7 @@ void bluetoothDisable();
|
||||
extern DMAFifo<512> telemetryFifo;
|
||||
typedef DMAFifo<32> AuxSerialRxFifo;
|
||||
extern AuxSerialRxFifo auxSerialRxFifo;
|
||||
extern AuxSerialRxFifo aux2SerialRxFifo;
|
||||
extern volatile uint32_t externalModulePort;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -160,9 +160,16 @@ extern "C" void TRAINER_TIMER_IRQHandler()
|
||||
int sbusGetByte(uint8_t * byte)
|
||||
{
|
||||
switch (currentTrainerMode) {
|
||||
#if defined(AUX_SERIAL)
|
||||
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL)
|
||||
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
|
||||
return trainerSbusFifo.pop(*byte);
|
||||
#if defined(AUX_SERIAL)
|
||||
if (auxSerialMode == UART_MODE_SBUS_TRAINER)
|
||||
return auxSerialRxFifo.pop(*byte);
|
||||
#endif
|
||||
#if defined(AUX2_SERIAL)
|
||||
if (aux2SerialMode == UART_MODE_SBUS_TRAINER)
|
||||
return aux2SerialRxFifo.pop(*byte);
|
||||
#endif
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -42,6 +42,8 @@ char * main_thread_error = nullptr;
|
||||
bool simu_shutdown = false;
|
||||
bool simu_running = false;
|
||||
|
||||
uint32_t telemetryErrors = 0;
|
||||
|
||||
#if defined(STM32)
|
||||
GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpioi, gpioj;
|
||||
TIM_TypeDef tim1, tim2, tim3, tim4, tim5, tim6, tim7, tim8, tim9, tim10;
|
||||
@@ -470,6 +472,47 @@ void sportUpdatePowerInit()
|
||||
{
|
||||
}
|
||||
|
||||
void telemetryPortSetDirectionInput()
|
||||
{
|
||||
}
|
||||
|
||||
void telemetryPortSetDirectionOutput()
|
||||
{
|
||||
}
|
||||
|
||||
void rxPdcUsart( void (*pChProcess)(uint8_t x) )
|
||||
{
|
||||
}
|
||||
|
||||
void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||
{
|
||||
}
|
||||
|
||||
bool telemetryGetByte(uint8_t * byte)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void telemetryClearFifo()
|
||||
{
|
||||
}
|
||||
|
||||
void telemetryPortInvertedInit(uint32_t baudrate)
|
||||
{
|
||||
}
|
||||
|
||||
void sportSendByte(uint8_t byte)
|
||||
{
|
||||
}
|
||||
|
||||
void sportSendBuffer(const uint8_t * buffer, uint32_t count)
|
||||
{
|
||||
}
|
||||
|
||||
void check_telemetry_exti()
|
||||
{
|
||||
}
|
||||
|
||||
void boardInit()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -125,9 +125,13 @@ set(FIRMWARE_TARGET_SRC
|
||||
MEDSdcard.c
|
||||
)
|
||||
|
||||
set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
telemetry_driver.cpp
|
||||
)
|
||||
|
||||
set(TARGET_SRC
|
||||
${TARGET_SRC}
|
||||
telemetry_driver.cpp
|
||||
adc_driver.cpp
|
||||
pulses_driver.cpp
|
||||
audio_driver.cpp
|
||||
|
||||
@@ -399,10 +399,8 @@ void debugPutc(const char c);
|
||||
|
||||
// Telemetry driver
|
||||
void telemetryPortInit(uint32_t baudrate, uint8_t mode);
|
||||
inline void telemetryPortSetDirectionOutput()
|
||||
{
|
||||
}
|
||||
uint32_t telemetryTransmitPending();
|
||||
void telemetryPortSetDirectionOutput();
|
||||
void telemetryPortSetDirectionInput();
|
||||
void telemetryTransmitBuffer(const uint8_t * buffer, uint32_t size);
|
||||
void rxPdcUsart( void (*pChProcess)(uint8_t x) );
|
||||
void sportSendBuffer(const uint8_t * buffer, uint32_t size);
|
||||
|
||||
@@ -93,10 +93,8 @@ void startPdcUsartReceive()
|
||||
{
|
||||
Usart *pUsart = SECOND_USART;
|
||||
TelemetryInBuffer.outPtr = TelemetryInBuffer.fifo ;
|
||||
#ifndef SIMU
|
||||
pUsart->US_RPR = (uint32_t)TelemetryInBuffer.fifo ;
|
||||
pUsart->US_RNPR = (uint32_t)TelemetryInBuffer.fifo ;
|
||||
#endif
|
||||
pUsart->US_RCR = RX_UART_BUFFER_SIZE ;
|
||||
pUsart->US_RNCR = RX_UART_BUFFER_SIZE ;
|
||||
pUsart->US_PTCR = US_PTCR_RXTEN ;
|
||||
@@ -104,7 +102,6 @@ void startPdcUsartReceive()
|
||||
|
||||
void rxPdcUsart( void (*pChProcess)(uint8_t x) )
|
||||
{
|
||||
#if !defined(SIMU)
|
||||
Usart *pUsart = SECOND_USART;
|
||||
uint8_t *ptr ;
|
||||
uint8_t *endPtr ;
|
||||
@@ -132,7 +129,6 @@ void rxPdcUsart( void (*pChProcess)(uint8_t x) )
|
||||
pUsart->US_RNPR = (uint32_t)TelemetryInBuffer.fifo ;
|
||||
pUsart->US_RNCR = RX_UART_BUFFER_SIZE ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t txPdcUsart(const uint8_t * buffer, uint32_t size)
|
||||
@@ -140,9 +136,7 @@ uint32_t txPdcUsart(const uint8_t * buffer, uint32_t size)
|
||||
Usart * pUsart = SECOND_USART;
|
||||
|
||||
if (pUsart->US_TNCR == 0) {
|
||||
#ifndef SIMU
|
||||
pUsart->US_TNPR = (uint32_t)buffer ;
|
||||
#endif
|
||||
pUsart->US_TNCR = size ;
|
||||
pUsart->US_PTCR = US_PTCR_TXTEN ;
|
||||
return 1 ;
|
||||
@@ -150,6 +144,7 @@ uint32_t txPdcUsart(const uint8_t * buffer, uint32_t size)
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/*
|
||||
uint32_t telemetryTransmitPending()
|
||||
{
|
||||
Usart *pUsart = SECOND_USART;
|
||||
@@ -164,13 +159,20 @@ uint32_t telemetryTransmitPending()
|
||||
|
||||
return x ;
|
||||
}
|
||||
*/
|
||||
|
||||
void telemetryPortSetDirectionOutput()
|
||||
{
|
||||
}
|
||||
|
||||
void telemetryPortSetDirectionInput()
|
||||
{
|
||||
}
|
||||
|
||||
void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||
{
|
||||
#if !defined(SIMU)
|
||||
UART2_Configure(baudrate, Master_frequency, mode);
|
||||
startPdcUsartReceive();
|
||||
#endif
|
||||
}
|
||||
|
||||
void sportSendBuffer(const uint8_t * buffer, uint32_t size)
|
||||
|
||||
@@ -135,7 +135,6 @@ elseif(PCB STREQUAL X7)
|
||||
set(LUA_EXPORT lua_export_t12)
|
||||
add_definitions(-DRADIO_T12)
|
||||
add_definitions(-DEEPROM_VARIANT=0x4001)
|
||||
add_definitions(-DMANUFACTURER_JUMPER)
|
||||
elseif(PCBREV STREQUAL TX12)
|
||||
option(INTERNAL_MODULE_MULTI "Support for MULTI internal module" ON)
|
||||
set(FLAVOUR tx12)
|
||||
@@ -146,6 +145,7 @@ elseif(PCB STREQUAL X7)
|
||||
set(ROTARY_ENCODER YES)
|
||||
set(LUA_EXPORT lua_export_tx12)
|
||||
set(BLUETOOTH NO)
|
||||
set(USB_CHARGER YES)
|
||||
add_definitions(-DRADIO_TX12)
|
||||
add_definitions(-DEEPROM_VARIANT=0x4002)
|
||||
add_definitions(-DMANUFACTURER_RADIOMASTER)
|
||||
@@ -347,6 +347,11 @@ if(ROTARY_ENCODER)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(USB_CHARGER)
|
||||
set(TARGET_SRC ${TARGET_SRC} usb_charger_driver.cpp)
|
||||
add_definitions(-DUSB_CHARGER)
|
||||
endif()
|
||||
|
||||
if(BLUETOOTH)
|
||||
add_definitions(-DBLUETOOTH)
|
||||
set(TARGET_SRC
|
||||
|
||||
@@ -92,7 +92,8 @@ void boardInit()
|
||||
TRAINER_RCC_AHB1Periph |
|
||||
TRAINER_MODULE_RCC_AHB1Periph |
|
||||
BT_RCC_AHB1Periph |
|
||||
GYRO_RCC_AHB1Periph,
|
||||
GYRO_RCC_AHB1Periph |
|
||||
USB_CHARGER_RCC_AHB1Periph,
|
||||
ENABLE);
|
||||
|
||||
RCC_APB1PeriphClockCmd(ROTARY_ENCODER_RCC_APB1Periph |
|
||||
@@ -193,6 +194,10 @@ void boardInit()
|
||||
toplcdInit();
|
||||
#endif
|
||||
|
||||
#if defined(USB_CHARGER)
|
||||
usbChargerInit();
|
||||
#endif
|
||||
|
||||
if (HAS_SPORT_UPDATE_CONNECTOR()) {
|
||||
sportUpdateInit();
|
||||
}
|
||||
|
||||
@@ -863,6 +863,10 @@ void bluetoothDisable();
|
||||
#define IS_BLUETOOTH_CHIP_PRESENT() (true)
|
||||
#endif
|
||||
|
||||
// USB Charger
|
||||
void usbChargerInit();
|
||||
bool usbChargerLed();
|
||||
|
||||
// LED driver
|
||||
void ledInit();
|
||||
void ledOff();
|
||||
|
||||
@@ -1431,6 +1431,16 @@
|
||||
#define PCBREV_RCC_AHB1Periph 0
|
||||
#endif
|
||||
|
||||
|
||||
// USB Charger
|
||||
#if defined(USB_CHARGER)
|
||||
#define USB_CHARGER_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||
#define USB_CHARGER_GPIO GPIOB
|
||||
#define USB_CHARGER_GPIO_PIN GPIO_Pin_5 // PB.05
|
||||
#else
|
||||
#define USB_CHARGER_RCC_AHB1Periph 0
|
||||
#endif
|
||||
|
||||
// S.Port update connector
|
||||
#if defined(PCBXLITE)
|
||||
#define SPORT_MAX_BAUDRATE 250000 // not tested
|
||||
@@ -1446,7 +1456,7 @@
|
||||
#define SPORT_UPDATE_PWR_GPIO_PIN GPIO_Pin_3 // PB.03
|
||||
#define GPIO_SPORT_UPDATE_PWR_GPIO_ON GPIO_SetBits
|
||||
#define GPIO_SPORT_UPDATE_PWR_GPIO_OFF GPIO_ResetBits
|
||||
#elif defined(PCBX7)
|
||||
#elif defined(RADIO_X7)
|
||||
#define SPORT_MAX_BAUDRATE 250000 // < 400000
|
||||
#define SPORT_UPDATE_RCC_AHB1Periph RCC_AHB1Periph_GPIOB
|
||||
#define SPORT_UPDATE_PWR_GPIO GPIOB
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
void usbChargerInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = USB_CHARGER_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(USB_CHARGER_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
bool usbChargerLed()
|
||||
{
|
||||
return (GPIO_ReadInputDataBit(USB_CHARGER_GPIO, USB_CHARGER_GPIO_PIN) == Bit_RESET && usbPlugged());
|
||||
}
|
||||
Reference in New Issue
Block a user