mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
parent
993e543162
commit
8e7e036591
13 changed files with 54 additions and 53 deletions
|
@ -136,7 +136,7 @@ class DarkblueTheme: public Theme
|
||||||
|
|
||||||
delete calibHorus;
|
delete calibHorus;
|
||||||
#if defined(PCBX10)
|
#if defined(PCBX10)
|
||||||
if(ANALOGS_PWM_ENABLED()) {
|
if(STICKS_PWM_ENABLED()) {
|
||||||
calibHorus = BitmapBuffer::load(getThemePath("X10S.bmp"));
|
calibHorus = BitmapBuffer::load(getThemePath("X10S.bmp"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -175,7 +175,7 @@ class DefaultTheme: public Theme
|
||||||
|
|
||||||
delete calibHorus;
|
delete calibHorus;
|
||||||
#if defined(PCBX10)
|
#if defined(PCBX10)
|
||||||
if(ANALOGS_PWM_ENABLED()) {
|
if(STICKS_PWM_ENABLED()) {
|
||||||
calibHorus = BitmapBuffer::load(getThemePath("X10S.bmp"));
|
calibHorus = BitmapBuffer::load(getThemePath("X10S.bmp"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -2627,10 +2627,6 @@ void opentxInit(OPENTX_INIT_ARGS)
|
||||||
backlightOn();
|
backlightOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NUM_PWMANALOGS > 0
|
|
||||||
analogPwmCheck();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!unexpectedShutdown) {
|
if (!unexpectedShutdown) {
|
||||||
opentxStart();
|
opentxStart();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@
|
||||||
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, 1,1,0, 1,1, 1};
|
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, 1,1,0, 1,1, 1};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NUM_PWMANALOGS > 0
|
#if NUM_PWMSTICKS > 0
|
||||||
#define FIRST_ANALOG_ADC (ANALOGS_PWM_ENABLED() ? NUM_PWMANALOGS : 0)
|
#define FIRST_ANALOG_ADC (STICKS_PWM_ENABLED() ? NUM_PWMSTICKS : 0)
|
||||||
#define NUM_ANALOGS_ADC (ANALOGS_PWM_ENABLED() ? (NUM_ANALOGS - NUM_PWMANALOGS) : NUM_ANALOGS)
|
#define NUM_ANALOGS_ADC (STICKS_PWM_ENABLED() ? (NUM_ANALOGS - NUM_PWMSTICKS) : NUM_ANALOGS)
|
||||||
#elif defined(PCBX9E)
|
#elif defined(PCBX9E)
|
||||||
#define FIRST_ANALOG_ADC 0
|
#define FIRST_ANALOG_ADC 0
|
||||||
#define NUM_ANALOGS_ADC 10
|
#define NUM_ANALOGS_ADC 10
|
||||||
|
@ -93,7 +93,7 @@ void adcInit()
|
||||||
ADC_MAIN->SQR1 = (NUM_ANALOGS_ADC-1) << 20; // bits 23:20 = number of conversions
|
ADC_MAIN->SQR1 = (NUM_ANALOGS_ADC-1) << 20; // bits 23:20 = number of conversions
|
||||||
|
|
||||||
#if defined(PCBX10)
|
#if defined(PCBX10)
|
||||||
if (ANALOGS_PWM_ENABLED()) {
|
if (STICKS_PWM_ENABLED()) {
|
||||||
ADC_MAIN->SQR2 = (ADC_CHANNEL_EXT1<<0) + (ADC_CHANNEL_EXT2<<5); // conversions 7 and more
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_EXT1<<0) + (ADC_CHANNEL_EXT2<<5); // conversions 7 and more
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_POT2<<5) + (ADC_CHANNEL_POT3<<10) + (ADC_CHANNEL_SLIDER1<<15) + (ADC_CHANNEL_SLIDER2<<20) + (ADC_CHANNEL_BATT<<25); // conversions 1 to 6
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_POT2<<5) + (ADC_CHANNEL_POT3<<10) + (ADC_CHANNEL_SLIDER1<<15) + (ADC_CHANNEL_SLIDER2<<20) + (ADC_CHANNEL_BATT<<25); // conversions 1 to 6
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ void adcInit()
|
||||||
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT4<<0) + (ADC_CHANNEL_SLIDER3<<5) + (ADC_CHANNEL_SLIDER4<<10) + (ADC_CHANNEL_BATT<<15); // conversions 7 and more
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT4<<0) + (ADC_CHANNEL_SLIDER3<<5) + (ADC_CHANNEL_SLIDER4<<10) + (ADC_CHANNEL_BATT<<15); // conversions 7 and more
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT2<<20) + (ADC_CHANNEL_POT3<<25); // conversions 1 to 6
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT2<<20) + (ADC_CHANNEL_POT3<<25); // conversions 1 to 6
|
||||||
#elif defined(PCBXLITE)
|
#elif defined(PCBXLITE)
|
||||||
if (ANALOGS_PWM_ENABLED()) {
|
if (STICKS_PWM_ENABLED()) {
|
||||||
ADC_MAIN->SQR2 = 0;
|
ADC_MAIN->SQR2 = 0;
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_POT2<<5) + (ADC_CHANNEL_BATT<<10);
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_POT2<<5) + (ADC_CHANNEL_BATT<<10);
|
||||||
}
|
}
|
||||||
|
@ -149,9 +149,9 @@ void adcInit()
|
||||||
ADC_EXT_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
ADC_EXT_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NUM_PWMANALOGS > 0
|
#if NUM_PWMSTICKS > 0
|
||||||
if (ANALOGS_PWM_ENABLED()) {
|
if (STICKS_PWM_ENABLED()) {
|
||||||
analogPwmInit();
|
sticksPwmInit();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -211,9 +211,9 @@ void adcRead()
|
||||||
adcValues[x] = temp[x] >> 2;
|
adcValues[x] = temp[x] >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NUM_PWMANALOGS > 0
|
#if NUM_PWMSTICKS > 0
|
||||||
if (ANALOGS_PWM_ENABLED()) {
|
if (STICKS_PWM_ENABLED()) {
|
||||||
analogPwmRead(adcValues);
|
sticksPwmRead(adcValues);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
|
@ -22,14 +22,14 @@
|
||||||
|
|
||||||
#define TIMESAMPLE_COUNT 6
|
#define TIMESAMPLE_COUNT 6
|
||||||
|
|
||||||
uint8_t analogs_pwm_disabled = 0;
|
uint8_t sticks_pwm_disabled = 0;
|
||||||
volatile uint32_t pwm_interrupt_count;
|
volatile uint32_t pwm_interrupt_count;
|
||||||
volatile uint8_t timer_capture_states[4];
|
volatile uint8_t timer_capture_states[4];
|
||||||
volatile uint32_t timer_capture_rising_time[4];
|
volatile uint32_t timer_capture_rising_time[4];
|
||||||
volatile uint32_t timer_capture_values[4][TIMESAMPLE_COUNT];
|
volatile uint32_t timer_capture_values[4][TIMESAMPLE_COUNT];
|
||||||
volatile uint8_t timer_capture_indexes[4];
|
volatile uint8_t timer_capture_indexes[4];
|
||||||
|
|
||||||
void analogPwmInit()
|
void sticksPwmInit()
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
GPIO_InitStructure.GPIO_Pin = PWM_GPIOA_PINS;
|
GPIO_InitStructure.GPIO_Pin = PWM_GPIOA_PINS;
|
||||||
|
@ -101,10 +101,10 @@ extern "C" void PWM_IRQHandler(void)
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
if (PWM_TIMER->SR & (TIM_DIER_CC1IE << i)) {
|
if (PWM_TIMER->SR & (TIM_DIER_CC1IE << i)) {
|
||||||
uint32_t capture = TIM_GetCapture(i);
|
uint32_t capture = TIM_GetCapture(i);
|
||||||
|
pwm_interrupt_count++; // overflow may happen but we only use this to detect PWM / ADC on radio startup
|
||||||
if (timer_capture_states[i] != 0) {
|
if (timer_capture_states[i] != 0) {
|
||||||
uint32_t value = diff_with_16bits_overflow(timer_capture_rising_time[i], capture);
|
uint32_t value = diff_with_16bits_overflow(timer_capture_rising_time[i], capture);
|
||||||
if (value < 10000) {
|
if (value < 10000) {
|
||||||
pwm_interrupt_count++;
|
|
||||||
timer_capture_values[i][timer_capture_indexes[i]++] = value;
|
timer_capture_values[i][timer_capture_indexes[i]++] = value;
|
||||||
timer_capture_indexes[i] %= TIMESAMPLE_COUNT;
|
timer_capture_indexes[i] %= TIMESAMPLE_COUNT;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ extern "C" void PWM_IRQHandler(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void analogPwmRead(uint16_t * values)
|
void sticksPwmRead(uint16_t * values)
|
||||||
{
|
{
|
||||||
uint32_t tmp[4];
|
uint32_t tmp[4];
|
||||||
|
|
||||||
|
@ -146,14 +146,3 @@ void analogPwmRead(uint16_t * values)
|
||||||
values[2] = tmp[3];
|
values[2] = tmp[3];
|
||||||
values[3] = tmp[2];
|
values[3] = tmp[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
void analogPwmCheck()
|
|
||||||
{
|
|
||||||
// I have ~1860 interrupts with only one stick
|
|
||||||
if (pwm_interrupt_count < 1000) {
|
|
||||||
analogs_pwm_disabled = true;
|
|
||||||
#if !defined(SIMU)
|
|
||||||
adcInit();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,8 +28,8 @@ if (PCB STREQUAL X10)
|
||||||
set(TARGET_SRC
|
set(TARGET_SRC
|
||||||
${TARGET_SRC}
|
${TARGET_SRC}
|
||||||
../common/arm/stm32/audio_dac_driver.cpp
|
../common/arm/stm32/audio_dac_driver.cpp
|
||||||
../common/arm/stm32/analog_adc_driver.cpp
|
../common/arm/stm32/adc_driver.cpp
|
||||||
../common/arm/stm32/analog_pwm_driver.cpp
|
../common/arm/stm32/sticks_pwm_driver.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(BITMAPS_TARGET x10_bitmaps)
|
set(BITMAPS_TARGET x10_bitmaps)
|
||||||
|
|
|
@ -197,6 +197,15 @@ void boardInit()
|
||||||
memset(&g_FATFS_Obj, 0, sizeof(g_FATFS_Obj));
|
memset(&g_FATFS_Obj, 0, sizeof(g_FATFS_Obj));
|
||||||
|
|
||||||
keysInit();
|
keysInit();
|
||||||
|
|
||||||
|
#if NUM_PWMSTICKS > 0
|
||||||
|
sticksPwmInit();
|
||||||
|
delay_ms(20);
|
||||||
|
if (pwm_interrupt_count < 32) {
|
||||||
|
sticks_pwm_disabled = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
adcInit();
|
adcInit();
|
||||||
lcdInit();
|
lcdInit();
|
||||||
backlightInit();
|
backlightInit();
|
||||||
|
|
|
@ -339,10 +339,10 @@ void watchdogInit(unsigned int duration);
|
||||||
#define NUM_XPOTS NUM_POTS
|
#define NUM_XPOTS NUM_POTS
|
||||||
#if defined(PCBX10)
|
#if defined(PCBX10)
|
||||||
#define NUM_SLIDERS 2
|
#define NUM_SLIDERS 2
|
||||||
#define NUM_PWMANALOGS 4
|
#define NUM_PWMSTICKS 4
|
||||||
#else
|
#else
|
||||||
#define NUM_SLIDERS 4
|
#define NUM_SLIDERS 4
|
||||||
#define NUM_PWMANALOGS 0
|
#define NUM_PWMSTICKS 0
|
||||||
#endif
|
#endif
|
||||||
enum Analogs {
|
enum Analogs {
|
||||||
STICK1,
|
STICK1,
|
||||||
|
@ -408,12 +408,11 @@ uint16_t getAnalogValue(uint8_t index);
|
||||||
#define NUM_DUMMY_ANAS 0
|
#define NUM_DUMMY_ANAS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NUM_PWMANALOGS > 0
|
#if NUM_PWMSTICKS > 0
|
||||||
extern uint8_t analogs_pwm_disabled;
|
extern uint8_t sticks_pwm_disabled;
|
||||||
#define ANALOGS_PWM_ENABLED() (analogs_pwm_disabled == false)
|
#define STICKS_PWM_ENABLED() (sticks_pwm_disabled == false)
|
||||||
void analogPwmInit(void);
|
void sticksPwmInit(void);
|
||||||
void analogPwmRead(uint16_t * values);
|
void sticksPwmRead(uint16_t * values);
|
||||||
void analogPwmCheck();
|
|
||||||
extern volatile uint32_t pwm_interrupt_count;
|
extern volatile uint32_t pwm_interrupt_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@
|
||||||
#define PWM_IRQHandler TIM5_IRQHandler
|
#define PWM_IRQHandler TIM5_IRQHandler
|
||||||
#define PWM_IRQn TIM5_IRQn
|
#define PWM_IRQn TIM5_IRQn
|
||||||
#define PWM_GPIOA_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
|
#define PWM_GPIOA_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
|
||||||
#define ADC_GPIOA_PINS (ANALOGS_PWM_ENABLED() ? 0 : (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3))
|
#define ADC_GPIOA_PINS (STICKS_PWM_ENABLED() ? 0 : (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3))
|
||||||
#define ADC_GPIOC_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
|
#define ADC_GPIOC_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
|
||||||
#define ADC_GPIOF_PINS (GPIO_Pin_6 | GPIO_Pin_7) // | GPIO_Pin_8 | GPIO_Pin_9)
|
#define ADC_GPIOF_PINS (GPIO_Pin_6 | GPIO_Pin_7) // | GPIO_Pin_8 | GPIO_Pin_9)
|
||||||
#define ADC_CHANNEL_STICK_LH ADC_Channel_0 // ADC3_IN0
|
#define ADC_CHANNEL_STICK_LH ADC_Channel_0 // ADC3_IN0
|
||||||
|
|
|
@ -169,13 +169,13 @@ set(TARGET_SRC
|
||||||
extmodule_driver.cpp
|
extmodule_driver.cpp
|
||||||
trainer_driver.cpp
|
trainer_driver.cpp
|
||||||
../common/arm/stm32/audio_dac_driver.cpp
|
../common/arm/stm32/audio_dac_driver.cpp
|
||||||
../common/arm/stm32/analog_adc_driver.cpp
|
../common/arm/stm32/adc_driver.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(PCB STREQUAL XLITE)
|
if(PCB STREQUAL XLITE)
|
||||||
set(TARGET_SRC
|
set(TARGET_SRC
|
||||||
${TARGET_SRC}
|
${TARGET_SRC}
|
||||||
../common/arm/stm32/analog_pwm_driver.cpp
|
../common/arm/stm32/sticks_pwm_driver.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -174,8 +174,17 @@ void boardInit()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
keysInit();
|
keysInit();
|
||||||
adcInit();
|
|
||||||
delaysInit();
|
delaysInit();
|
||||||
|
|
||||||
|
#if NUM_PWMSTICKS > 0
|
||||||
|
sticksPwmInit();
|
||||||
|
delay_ms(20);
|
||||||
|
if (pwm_interrupt_count < 32) {
|
||||||
|
sticks_pwm_disabled = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
adcInit();
|
||||||
lcdInit(); // delaysInit() must be called before
|
lcdInit(); // delaysInit() must be called before
|
||||||
audioInit();
|
audioInit();
|
||||||
init2MhzTimer();
|
init2MhzTimer();
|
||||||
|
|
|
@ -450,12 +450,11 @@ enum Analogs {
|
||||||
#define NUM_DUMMY_ANAS 0
|
#define NUM_DUMMY_ANAS 0
|
||||||
|
|
||||||
#if defined(PCBXLITE)
|
#if defined(PCBXLITE)
|
||||||
#define NUM_PWMANALOGS 4
|
#define NUM_PWMSTICKS 4
|
||||||
extern uint8_t analogs_pwm_disabled;
|
extern uint8_t sticks_pwm_disabled;
|
||||||
#define ANALOGS_PWM_ENABLED() (analogs_pwm_disabled == false)
|
#define STICKS_PWM_ENABLED() (sticks_pwm_disabled == false)
|
||||||
void analogPwmInit(void);
|
void sticksPwmInit(void);
|
||||||
void analogPwmRead(uint16_t * values);
|
void sticksPwmRead(uint16_t * values);
|
||||||
void analogPwmCheck();
|
|
||||||
extern volatile uint32_t pwm_interrupt_count;
|
extern volatile uint32_t pwm_interrupt_count;
|
||||||
#define NUM_TRIMS_KEYS 4
|
#define NUM_TRIMS_KEYS 4
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -477,7 +477,7 @@
|
||||||
#define PWM_IRQHandler TIM5_IRQHandler
|
#define PWM_IRQHandler TIM5_IRQHandler
|
||||||
#define PWM_IRQn TIM5_IRQn
|
#define PWM_IRQn TIM5_IRQn
|
||||||
#define PWM_GPIOA_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
|
#define PWM_GPIOA_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3)
|
||||||
#define ADC_GPIOA_PINS (ANALOGS_PWM_ENABLED() ? 0 : (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3))
|
#define ADC_GPIOA_PINS (STICKS_PWM_ENABLED() ? 0 : (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3))
|
||||||
#define ADC_GPIOC_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2)
|
#define ADC_GPIOC_PINS (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2)
|
||||||
#define ADC_CHANNEL_STICK_RV ADC_Channel_0 // ADC1_IN0
|
#define ADC_CHANNEL_STICK_RV ADC_Channel_0 // ADC1_IN0
|
||||||
#define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1
|
#define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue