mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 08:45:24 +03:00
[Horus] Mouse analogs
This commit is contained in:
parent
80291c73c4
commit
f69295b8f9
8 changed files with 55 additions and 161 deletions
|
@ -487,7 +487,6 @@ if(CPU_FAMILY STREQUAL STM32)
|
|||
${FIRMWARE_SRC}
|
||||
serial.cpp
|
||||
syscalls.c
|
||||
targets/taranis/configure_pins.cpp
|
||||
)
|
||||
foreach(FILE ${STM32LIB_SRC})
|
||||
set(FIRMWARE_SRC
|
||||
|
|
|
@ -217,10 +217,7 @@ enum CurveType {
|
|||
|
||||
#define XPOTS_MULTIPOS_COUNT 6
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define MAX_ROTARY_ENCODERS 0
|
||||
#define NUM_ROTARY_ENCODERS 0
|
||||
#elif defined(REVX)
|
||||
#if defined(PCBSKY9X) && defined(REVX)
|
||||
#define MAX_ROTARY_ENCODERS 1
|
||||
#define NUM_ROTARY_ENCODERS 0
|
||||
#elif defined(PCBSKY9X)
|
||||
|
@ -236,8 +233,10 @@ enum CurveType {
|
|||
|
||||
#if defined(PCBHORUS)
|
||||
#define NUM_AUX_TRIMS 2
|
||||
#define NUM_MOUSE_ANALOGS 2
|
||||
#else
|
||||
#define NUM_AUX_TRIMS 0
|
||||
#define NUM_MOUSE_ANALOGS 0
|
||||
#endif
|
||||
|
||||
#if defined(COLORLCD)
|
||||
|
@ -794,6 +793,11 @@ enum MixSources {
|
|||
MIXSRC_LAST_POT = MIXSRC_P3,
|
||||
#endif
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
MIXSRC_MOUSE1,
|
||||
MIXSRC_MOUSE2,
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
MIXSRC_REa,
|
||||
MIXSRC_LAST_ROTARY_ENCODER = MIXSRC_REa,
|
||||
|
|
|
@ -150,7 +150,7 @@ bool menuStatsAnalogs(evt_t event)
|
|||
{
|
||||
MENU("Analogs", STATS_ICONS, menuTabStats, e_StatsAnalogs, 0, { 0 });
|
||||
|
||||
for (int i=0; i<NUM_STICKS+NUM_POTS; i++) {
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS; i++) {
|
||||
coord_t y = MENU_CONTENT_TOP + (i/2)*FH;
|
||||
coord_t x = MENUS_MARGIN_LEFT + (i & 1 ? LCD_W/2 : 0);
|
||||
lcdDrawNumber(x, y, i+1, LEADING0|LEFT, 2, NULL, ":");
|
||||
|
@ -165,8 +165,8 @@ bool menuStatsAnalogs(evt_t event)
|
|||
}
|
||||
|
||||
// SWR
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+6*FH, "RAS");
|
||||
lcdDrawNumber(MENUS_MARGIN_LEFT+100, MENU_CONTENT_TOP+6*FH, telemetryData.swr.value);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+7*FH, "RAS");
|
||||
lcdDrawNumber(MENUS_MARGIN_LEFT+100, MENU_CONTENT_TOP+7*FH, telemetryData.swr.value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -253,11 +253,11 @@ getvalue_t getValue(mixsrc_t i)
|
|||
#endif
|
||||
|
||||
#if defined(LUAINPUTS)
|
||||
else if (i <= MIXSRC_LAST_POT) {
|
||||
else if (i <= MIXSRC_LAST_POT+NUM_MOUSE_ANALOGS) {
|
||||
return calibratedStick[i-MIXSRC_Rud];
|
||||
}
|
||||
#else
|
||||
else if (i>=MIXSRC_FIRST_STICK && i<=MIXSRC_LAST_POT) {
|
||||
else if (i>=MIXSRC_FIRST_STICK && i<=MIXSRC_LAST_POT+NUM_MOUSE_ANALOGS) {
|
||||
return calibratedStick[i-MIXSRC_Rud];
|
||||
}
|
||||
#endif
|
||||
|
@ -424,13 +424,13 @@ void evalInputs(uint8_t mode)
|
|||
}
|
||||
#endif
|
||||
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS; i++) {
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS+NUM_ROTARY_ENCODERS; i++) {
|
||||
|
||||
// normalization [0..2048] -> [-1024..1024]
|
||||
uint8_t ch = (i < NUM_STICKS ? CONVERT_MODE(i) : i);
|
||||
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
int16_t v = ((i < NUM_STICKS+NUM_POTS) ? anaIn(i) : getRotaryEncoder(i-(NUM_STICKS+NUM_POTS)));
|
||||
int16_t v = ((i < NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS) ? anaIn(i) : getRotaryEncoder(i-(NUM_STICKS+NUM_POTS)));
|
||||
#else
|
||||
int16_t v = anaIn(i);
|
||||
#endif
|
||||
|
@ -484,10 +484,12 @@ void evalInputs(uint8_t mode)
|
|||
if (tmp <= 1) anaCenter |= (tmp==0 ? mask : (bpanaCenter & mask));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
else if (i >= NUM_STICKS+NUM_POTS+NUM_MOUSE_ANALOGS) {
|
||||
// rotary encoders
|
||||
if (v == 0) anaCenter |= mask;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ch < NUM_STICKS) { //only do this for sticks
|
||||
#if defined(VIRTUALINPUTS)
|
||||
|
|
|
@ -105,23 +105,29 @@ void adcInit()
|
|||
{
|
||||
ADS7952_Init();
|
||||
|
||||
configure_pins(ADC_GPIO_PIN_MOUSE1 | ADC_GPIO_PIN_MOUSE2, PIN_ANALOG | PIN_PORTF);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = ADC_GPIO_PIN_MOUSE1 | ADC_GPIO_PIN_MOUSE2;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(ADC_GPIO_MOUSE, &GPIO_InitStructure);
|
||||
|
||||
ADC3->CR1 = ADC_CR1_SCAN;
|
||||
ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
||||
ADC3->SQR1 = (2-1) << 20; // NUMBER_ANALOG Channels
|
||||
ADC3->SQR2 = 0;
|
||||
ADC3->SQR3 = ADC_IN_MOUSE1 + (ADC_IN_MOUSE2<<5);
|
||||
ADC3->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12)
|
||||
+ (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24);
|
||||
ADC3->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12)
|
||||
+ (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27);
|
||||
ADC3->SMPR1 = 0;
|
||||
ADC3->SMPR2 = 3 + (3<<3); // TODO SAMPTIME constant
|
||||
ADC->CCR = 0; // ADC_CCR_ADCPRE_0; Clock div 2
|
||||
|
||||
// Enable the DMA channel here, DMA2 stream 1, channel 2
|
||||
DMA2_Stream1->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;
|
||||
DMA2_Stream1->PAR = CONVERT_PTR_UINT(&ADC3->DR);
|
||||
DMA2_Stream1->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]);
|
||||
DMA2_Stream1->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
||||
ADC_DMA_Stream->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;
|
||||
ADC_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC3->DR);
|
||||
ADC_DMA_Stream->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]);
|
||||
ADC_DMA_Stream->NDTR = 2;
|
||||
ADC_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
||||
}
|
||||
|
||||
const uint16_t adcCommands[MOUSE1+2] =
|
||||
|
@ -190,18 +196,18 @@ uint32_t adcReadNextSPIChannel(uint8_t index)
|
|||
|
||||
void adcOnChipReadStart()
|
||||
{
|
||||
DMA2_Stream1->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
ADC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
ADC3->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR );
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF1 | DMA_LIFCR_CHTIF1 |DMA_LIFCR_CTEIF1 | DMA_LIFCR_CDMEIF1 | DMA_LIFCR_CFEIF1; // Write ones to clear bits
|
||||
DMA2_Stream1->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]);
|
||||
DMA2_Stream1->NDTR = 2;
|
||||
DMA2_Stream1->CR |= DMA_SxCR_EN; // Enable DMA
|
||||
ADC_DMA->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 |DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0 ; // Write ones to clear bits
|
||||
ADC_DMA_Stream->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]);
|
||||
ADC_DMA_Stream->NDTR = 2;
|
||||
ADC_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
||||
ADC3->CR2 |= (uint32_t)ADC_CR2_SWSTART;
|
||||
}
|
||||
|
||||
bool adcOnChipReadFinished()
|
||||
{
|
||||
return (DMA2->LISR & DMA_LISR_TCIF1);
|
||||
return (ADC_DMA->LISR & DMA_LISR_TCIF0);
|
||||
}
|
||||
|
||||
void adcRead()
|
||||
|
|
|
@ -123,10 +123,13 @@
|
|||
#define ADC_SPI_PinSource_SCK GPIO_PinSource2
|
||||
#define ADC_SPI_PinSource_MISO GPIO_PinSource5
|
||||
#define ADC_SPI_PinSource_MOSI GPIO_PinSource6
|
||||
#define ADC_GPIO_PIN_MOUSE1 GPIO_Pin_8 // PF.8 ADC3_IN6 J5 MOUSE_X
|
||||
#define ADC_GPIO_PIN_MOUSE2 GPIO_Pin_9 // PF.9 ADC3_IN7 J6 MOUSE_Y
|
||||
#define ADC_GPIO_PIN_MOUSE1 GPIO_Pin_8 // PF.08 ADC3_IN6 J5 MOUSE_X
|
||||
#define ADC_GPIO_PIN_MOUSE2 GPIO_Pin_9 // PF.09 ADC3_IN7 J6 MOUSE_Y
|
||||
#define ADC_GPIO_MOUSE GPIOF
|
||||
#define ADC_IN_MOUSE1 6
|
||||
#define ADC_IN_MOUSE2 7
|
||||
#define ADC_DMA DMA2
|
||||
#define ADC_DMA_Stream DMA2_Stream0
|
||||
|
||||
// Power
|
||||
#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOJ
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_desc.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 19-March-2012
|
||||
* @brief header file for the usbd_desc.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
|
||||
#ifndef __USB_DESC_H
|
||||
#define __USB_DESC_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_def.h"
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_DESC
|
||||
* @brief general defines for the usb device library file
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_DESC_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
|
||||
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
|
||||
#define USB_STRING_DESCRIPTOR_TYPE 0x03
|
||||
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
|
||||
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
|
||||
#define USB_SIZ_DEVICE_DESC 18
|
||||
#define USB_SIZ_STRING_LANGID 4
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_DESC_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup USBD_DESC_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_DESC_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern const uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC];
|
||||
extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ];
|
||||
extern const uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC];
|
||||
extern const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC];
|
||||
extern const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID];
|
||||
extern const USBD_DEVICE USR_desc;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_DESC_Exported_FunctionsPrototype
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length);
|
||||
uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length);
|
||||
uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length);
|
||||
uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length);
|
||||
uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length);
|
||||
uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length);
|
||||
uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length);
|
||||
|
||||
#ifdef USB_SUPPORT_USER_STRING_DESC
|
||||
uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length);
|
||||
#endif /* USB_SUPPORT_USER_STRING_DESC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USBD_DESC_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -514,7 +514,7 @@
|
|||
#endif
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
#define TR_POTS_VSRCRAW "\310S1\0""\3106P\0""\310S2\0""\313L1\0""\313L2\0""\311LS\0""\311RS\0"
|
||||
#define TR_POTS_VSRCRAW "\310S1\0""\3106P\0""\310S2\0""\313L1\0""\313L2\0""\311LS\0""\311RS\0""\310MO1""\310MO2"
|
||||
#define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0"
|
||||
#elif defined(PCBFLAMENCO)
|
||||
#define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue