Merge remote-tracking branch 'origin/next' into bsongis/9XR-PRO_port
Conflicts: companion/src/avroutputdialog.cpp companion/src/burnconfigdialog.cpp companion/src/eeprominterface.cpp companion/src/eeprominterface.h companion/src/firmwares/opentx/opentxinterface.cpp companion/src/helpers.cpp radio/src/gui/menu_general.cpp radio/src/opentx.cpp
This commit is contained in:
@@ -182,12 +182,6 @@ void pwrOff()
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ROTARY_ENCODERS <= 2
|
||||
#define ROTENC_DOWN() ((~PIND & 0x20) || (~PIND & 0x10))
|
||||
#else
|
||||
#define ROTENC_DOWN() (0)
|
||||
#endif
|
||||
|
||||
FORCEINLINE uint8_t keyDown()
|
||||
{
|
||||
return ((~PINL) & 0x3F) || ROTENC_DOWN();
|
||||
@@ -261,59 +255,50 @@ bool switchState(EnumKeys enuk)
|
||||
return result;
|
||||
}
|
||||
|
||||
static const pm_uchar crossTrim[] PROGMEM = {
|
||||
1<<INP_J_TRM_LH_DWN,
|
||||
1<<INP_J_TRM_LH_UP,
|
||||
1<<INP_J_TRM_LV_DWN,
|
||||
1<<INP_J_TRM_LV_UP,
|
||||
1<<INP_J_TRM_RV_DWN,
|
||||
1<<INP_J_TRM_RV_UP,
|
||||
1<<INP_J_TRM_RH_DWN,
|
||||
1<<INP_J_TRM_RH_UP
|
||||
};
|
||||
|
||||
uint8_t trimDown(uint8_t idx)
|
||||
{
|
||||
uint8_t in = ~PIND;
|
||||
return (in & pgm_read_byte(crossTrim+idx));
|
||||
}
|
||||
|
||||
FORCEINLINE void readKeysAndTrims()
|
||||
{
|
||||
/* Original keys were connected to PORTB as follows:
|
||||
|
||||
Bit Key
|
||||
7 other use
|
||||
6 LEFT
|
||||
5 RIGHT
|
||||
4 UP
|
||||
3 DOWN
|
||||
2 EXIT
|
||||
1 MENU
|
||||
0 other use
|
||||
*/
|
||||
|
||||
uint8_t enuk = KEY_MENU;
|
||||
|
||||
#if ROTARY_ENCODERS <= 2
|
||||
keys[BTN_REa].input(~PIND & 0x20, BTN_REa);
|
||||
#endif
|
||||
keys[BTN_REb].input(~PIND & 0x10, BTN_REb);
|
||||
|
||||
// User buttons ...
|
||||
uint8_t tin = ~PINL;
|
||||
uint8_t in;
|
||||
in = (tin & 0x0f) << 3;
|
||||
in |= (tin & 0x30) >> 3;
|
||||
|
||||
for (int i=1; i<7; i++)
|
||||
{
|
||||
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
||||
keys[enuk].input(in & (1<<i),(EnumKeys)enuk);
|
||||
for (int i=1; i<7; i++) {
|
||||
// INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
||||
keys[enuk].input(in & (1<<i), (EnumKeys)enuk);
|
||||
++enuk;
|
||||
}
|
||||
|
||||
// Trim switches ...
|
||||
static const pm_uchar crossTrim[] PROGMEM ={
|
||||
1<<INP_J_TRM_LH_DWN,
|
||||
1<<INP_J_TRM_LH_UP,
|
||||
1<<INP_J_TRM_LV_DWN,
|
||||
1<<INP_J_TRM_LV_UP,
|
||||
1<<INP_J_TRM_RV_DWN,
|
||||
1<<INP_J_TRM_RV_UP,
|
||||
1<<INP_J_TRM_RH_DWN,
|
||||
1<<INP_J_TRM_RH_UP
|
||||
};
|
||||
|
||||
// Trims ...
|
||||
in = ~PINJ;
|
||||
|
||||
for (int i=0; i<8; i++) {
|
||||
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
||||
keys[enuk].input(in & pgm_read_byte(crossTrim+i),(EnumKeys)enuk);
|
||||
keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk);
|
||||
++enuk;
|
||||
}
|
||||
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
keys[BTN_REa].input(REA_DOWN(), BTN_REa);
|
||||
keys[BTN_REb].input(REB_DOWN(), BTN_REb);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ROTARY_ENCODERS <= 2
|
||||
|
||||
@@ -100,63 +100,63 @@ void sdPoll10ms();
|
||||
#define IS_BACKLIGHT_ON() (PORTC & (1<<OUT_C_LIGHT))
|
||||
|
||||
|
||||
# define INP_L_SPARE6 7
|
||||
# define INP_L_SPARE5 6
|
||||
# define INP_L_KEY_EXT 5
|
||||
# define INP_L_KEY_MEN 4
|
||||
# define INP_L_KEY_LFT 3
|
||||
# define INP_L_KEY_RGT 2
|
||||
# define INP_L_KEY_UP 1
|
||||
# define INP_L_KEY_DWN 0
|
||||
#define INP_L_SPARE6 7
|
||||
#define INP_L_SPARE5 6
|
||||
#define INP_L_KEY_EXT 5
|
||||
#define INP_L_KEY_MEN 4
|
||||
#define INP_L_KEY_LFT 3
|
||||
#define INP_L_KEY_RGT 2
|
||||
#define INP_L_KEY_UP 1
|
||||
#define INP_L_KEY_DWN 0
|
||||
|
||||
# define INP_J_TRM_RH_UP 7
|
||||
# define INP_J_TRM_RH_DWN 6
|
||||
# define INP_J_TRM_RV_UP 5
|
||||
# define INP_J_TRM_RV_DWN 4
|
||||
# define INP_J_TRM_LV_UP 3
|
||||
# define INP_J_TRM_LV_DWN 2
|
||||
# define INP_J_TRM_LH_UP 1
|
||||
# define INP_J_TRM_LH_DWN 0
|
||||
#define INP_J_TRM_RH_UP 7
|
||||
#define INP_J_TRM_RH_DWN 6
|
||||
#define INP_J_TRM_RV_UP 5
|
||||
#define INP_J_TRM_RV_DWN 4
|
||||
#define INP_J_TRM_LV_UP 3
|
||||
#define INP_J_TRM_LV_DWN 2
|
||||
#define INP_J_TRM_LH_UP 1
|
||||
#define INP_J_TRM_LH_DWN 0
|
||||
|
||||
# define INP_E_PPM_IN 7
|
||||
# define INP_E_ROT_ENC_1_B 6
|
||||
# define INP_E_ROT_ENC_1_A 5
|
||||
# define INP_E_USB_D_PLS 4
|
||||
# define OUT_E_BUZZER 3
|
||||
# define INP_E_USB_D_NEG 2
|
||||
# define INP_E_TELEM_RX 1
|
||||
# define OUT_E_TELEM_TX 0
|
||||
#define INP_E_PPM_IN 7
|
||||
#define INP_E_ROT_ENC_1_B 6
|
||||
#define INP_E_ROT_ENC_1_A 5
|
||||
#define INP_E_USB_D_PLS 4
|
||||
#define OUT_E_BUZZER 3
|
||||
#define INP_E_USB_D_NEG 2
|
||||
#define INP_E_TELEM_RX 1
|
||||
#define OUT_E_TELEM_TX 0
|
||||
|
||||
# define OUT_D_HAPTIC 7
|
||||
# define INP_D_SPARE4 6
|
||||
# define INP_D_ROT_ENC_2_PUSH 5
|
||||
# define INP_D_ROT_ENC_1_PUSH 4
|
||||
# define OUT_D_ROT_ENC_2_B 3
|
||||
# define INP_D_ROT_ENC_2_A 2
|
||||
# define INP_D_I2C_SCL 1
|
||||
# define INP_D_I2C_SDA 0
|
||||
#define OUT_D_HAPTIC 7
|
||||
#define INP_D_SPARE4 6
|
||||
#define INP_D_ROT_ENC_2_PUSH 5
|
||||
#define INP_D_ROT_ENC_1_PUSH 4
|
||||
#define OUT_D_ROT_ENC_2_B 3
|
||||
#define INP_D_ROT_ENC_2_A 2
|
||||
#define INP_D_I2C_SCL 1
|
||||
#define INP_D_I2C_SDA 0
|
||||
|
||||
# define INP_G_Gear 5
|
||||
# define INP_G_ThrCt 2
|
||||
# define OUT_G_SIM_CTL 4 //1 : phone-jack=ppm_in
|
||||
# define INP_G_ID1 3
|
||||
# define INP_G_RF_POW 1
|
||||
# define INP_G_RuddDR 0
|
||||
#define INP_G_Gear 5
|
||||
#define INP_G_ThrCt 2
|
||||
#define OUT_G_SIM_CTL 4 //1 : phone-jack=ppm_in
|
||||
#define INP_G_ID1 3
|
||||
#define INP_G_RF_POW 1
|
||||
#define INP_G_RuddDR 0
|
||||
|
||||
# define INP_C_AileDR 7
|
||||
# define INP_C_ElevDR 6
|
||||
# define OUT_C_LIGHT 0
|
||||
#define INP_C_AileDR 7
|
||||
#define INP_C_ElevDR 6
|
||||
#define OUT_C_LIGHT 0
|
||||
|
||||
# define OUT_B_Speaker 7
|
||||
# define OUT_B_PPM 6 // will be switched by TCNT1==OCR1B in hardware
|
||||
# define INP_B_Trainer 5
|
||||
# define INP_B_ID2 4
|
||||
#define OUT_B_Speaker 7
|
||||
#define OUT_B_PPM 6 // will be switched by TCNT1==OCR1B in hardware
|
||||
#define INP_B_Trainer 5
|
||||
#define INP_B_ID2 4
|
||||
|
||||
#if defined(VOICE)
|
||||
# define OUT_H_14DRESET 3
|
||||
# define OUT_H_14DCLK 4
|
||||
# define OUT_H_14DDATA 5
|
||||
# define INP_H_14DBUSY 6
|
||||
#define OUT_H_14DRESET 3
|
||||
#define OUT_H_14DCLK 4
|
||||
#define OUT_H_14DDATA 5
|
||||
#define INP_H_14DBUSY 6
|
||||
#endif
|
||||
|
||||
// Keys driver
|
||||
@@ -187,4 +187,14 @@ void pwrOff();
|
||||
// Haptic driver
|
||||
#define hapticOff() // TODO hapticOn() cleaner ...
|
||||
|
||||
// Rotary encoder driver
|
||||
#if ROTARY_ENCODERS <= 2
|
||||
#define REA_DOWN() (~PIND & 0x20)
|
||||
#define REB_DOWN() (~PIND & 0x10)
|
||||
#else
|
||||
#define REA_DOWN() (0)
|
||||
#define REB_DOWN() (0)
|
||||
#endif
|
||||
#define ROTENC_DOWN() (REA_DOWN() || REB_DOWN())
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,12 +45,12 @@ const char ana_direction[NUMBER_ANALOG] = {1, 1, 0, 1 ,0 ,1 ,0, 0, 0};
|
||||
|
||||
// Settings for mode register ADC_MR
|
||||
// USEQ off - silicon problem, doesn't work
|
||||
// TRANSFER = 1
|
||||
// TRACKTIM = 4 (5 clock periods)
|
||||
// ANACH = 0
|
||||
// SETTLING = 1 (not used if ANACH = 0)
|
||||
// STARTUP = 1 (8 clock periods)
|
||||
// PRESCAL = 3.6 MHz clock (between 1 and 20MHz)
|
||||
// TRANSFER = 3
|
||||
// TRACKTIM = 15 (16 clock periods)
|
||||
// ANACH = 1
|
||||
// SETTLING = 6 (not used if ANACH = 0)
|
||||
// STARTUP = 6 (96 clock periods)
|
||||
// PRESCAL = 9.0 MHz clock (between 1 and 20MHz)
|
||||
// FREERUN = 0
|
||||
// FWUP = 0
|
||||
// SLEEP = 0
|
||||
@@ -66,7 +66,7 @@ void adcInit()
|
||||
// Enable peripheral clock ADC = bit 29
|
||||
PMC->PMC_PCER0 |= 0x20000000L ; // Enable peripheral clock to ADC
|
||||
padc = ADC ;
|
||||
padc->ADC_MR = 0x14110000 | timer ; // 0001 0100 0001 0001 xxxx xxxx 0000 0000
|
||||
padc->ADC_MR = 0x3FB60000 | timer ; // 0011 1111 1011 0110 xxxx xxxx 0000 0000
|
||||
padc->ADC_ACR = ADC_ACR_TSON ; // Turn on temp sensor
|
||||
#if defined(REVA)
|
||||
padc->ADC_CHER = 0x0000E23E ; // channels 1,2,3,4,5,9,13,14,15
|
||||
|
||||
@@ -310,11 +310,11 @@ extern "C" void TC3_IRQHandler() //capture ppm in at 2MHz
|
||||
|
||||
// G: We process g_ppmIns immediately here, to make servo movement as smooth as possible
|
||||
// while under trainee control
|
||||
if (val>4000 && val<19000) { // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
|
||||
if (val>4000 && val<19000) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
|
||||
ppmInState = 1; // triggered
|
||||
}
|
||||
else {
|
||||
if (ppmInState && ppmInState<=8)
|
||||
if (ppmInState && ppmInState<=16)
|
||||
{
|
||||
if (val>800 && val<2200) // if valid pulse-width range
|
||||
{
|
||||
|
||||
@@ -254,9 +254,12 @@ void rotencInit();
|
||||
void rotencEnd();
|
||||
|
||||
#if ROTARY_ENCODERS > 0
|
||||
#define rotencDown() (!(PIOB->PIO_PDSR & 0x40))
|
||||
#define REA_DOWN() (!(PIOB->PIO_PDSR & 0x40))
|
||||
#else
|
||||
#define rotencDown() 0
|
||||
#define REA_DOWN() (0)
|
||||
#endif
|
||||
|
||||
// Debug driver
|
||||
void debugPutc(const char c);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1014,7 +1014,7 @@ void sdMountPoll()
|
||||
|
||||
case SD_ST_DATA:
|
||||
if (!usbPlugged() && f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
refreshSystemAudioFiles();
|
||||
referenceSystemAudioFiles();
|
||||
Card_state = SD_ST_MOUNTED;
|
||||
}
|
||||
break;
|
||||
@@ -1082,7 +1082,7 @@ void sdInit()
|
||||
Card_state = SD_ST_DATA;
|
||||
|
||||
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
refreshSystemAudioFiles();
|
||||
referenceSystemAudioFiles();
|
||||
Card_state = SD_ST_MOUNTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,9 +113,14 @@ uint32_t readTrims()
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t trimDown(uint8_t idx)
|
||||
{
|
||||
return readTrims() & (1 << idx);
|
||||
}
|
||||
|
||||
uint8_t keyDown()
|
||||
{
|
||||
return (~readKeys() & 0x7E) || rotencDown();
|
||||
return (~readKeys() & 0x7E) || REA_DOWN();
|
||||
}
|
||||
|
||||
void readKeysAndTrims()
|
||||
@@ -123,7 +128,7 @@ void readKeysAndTrims()
|
||||
register uint32_t i;
|
||||
|
||||
#if ROTARY_ENCODERS > 0
|
||||
keys[BTN_REa].input(rotencDown(), BTN_REa);
|
||||
keys[BTN_REa].input(REA_DOWN(), BTN_REa);
|
||||
#endif
|
||||
|
||||
uint8_t enuk = KEY_MENU;
|
||||
|
||||
@@ -234,37 +234,38 @@ bool switchState(EnumKeys enuk)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef SIMU
|
||||
FORCEINLINE
|
||||
#endif
|
||||
void readKeysAndTrims()
|
||||
// Trim switches ...
|
||||
static const pm_uchar crossTrim[] PROGMEM ={
|
||||
1<<INP_D_TRM_LH_DWN, // bit 7
|
||||
1<<INP_D_TRM_LH_UP,
|
||||
1<<INP_D_TRM_LV_DWN,
|
||||
1<<INP_D_TRM_LV_UP,
|
||||
1<<INP_D_TRM_RV_DWN,
|
||||
1<<INP_D_TRM_RV_UP,
|
||||
1<<INP_D_TRM_RH_DWN,
|
||||
1<<INP_D_TRM_RH_UP // bit 0
|
||||
};
|
||||
|
||||
uint8_t trimDown(uint8_t idx)
|
||||
{
|
||||
uint8_t in = ~PIND;
|
||||
return (in & pgm_read_byte(crossTrim+idx));
|
||||
}
|
||||
|
||||
FORCEINLINE void readKeysAndTrims()
|
||||
{
|
||||
uint8_t enuk = KEY_MENU;
|
||||
|
||||
// User buttons ...
|
||||
uint8_t in = ~PINB;
|
||||
|
||||
for(int i=1; i<7; i++)
|
||||
{
|
||||
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
||||
keys[enuk].input(in & (1<<i),(EnumKeys)enuk);
|
||||
for (int i=1; i<7; i++) {
|
||||
// INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
|
||||
keys[enuk].input(in & (1<<i), (EnumKeys)enuk);
|
||||
++enuk;
|
||||
}
|
||||
|
||||
// Trim switches ...
|
||||
static const pm_uchar crossTrim[] PROGMEM ={
|
||||
1<<INP_D_TRM_LH_DWN, // bit 7
|
||||
1<<INP_D_TRM_LH_UP,
|
||||
1<<INP_D_TRM_LV_DWN,
|
||||
1<<INP_D_TRM_LV_UP,
|
||||
1<<INP_D_TRM_RV_DWN,
|
||||
1<<INP_D_TRM_RV_UP,
|
||||
1<<INP_D_TRM_RH_DWN,
|
||||
1<<INP_D_TRM_RH_UP // bit 0
|
||||
};
|
||||
|
||||
// Trims ...
|
||||
in = ~PIND;
|
||||
|
||||
for (int i=0; i<8; i++) {
|
||||
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
|
||||
keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk);
|
||||
|
||||
+14
-14
@@ -3,7 +3,7 @@
|
||||
* @file system_stm32f2xx.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 09-January-2013
|
||||
* @date 05-January-2014
|
||||
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
|
||||
* This file contains the system clock configuration for STM32F2xx devices,
|
||||
* and is generated by the clock configuration tool
|
||||
@@ -46,15 +46,15 @@
|
||||
*-----------------------------------------------------------------------------
|
||||
* System Clock source | PLL (HSE)
|
||||
*-----------------------------------------------------------------------------
|
||||
* SYSCLK(Hz) | 60000000
|
||||
* SYSCLK(Hz) | 120000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* HCLK(Hz) | 60000000
|
||||
* HCLK(Hz) | 120000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* AHB Prescaler | 1
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB1 Prescaler | 2
|
||||
* APB1 Prescaler | 4
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB2 Prescaler | 1
|
||||
* APB2 Prescaler | 2
|
||||
*-----------------------------------------------------------------------------
|
||||
* HSE Frequency(Hz) | 12000000
|
||||
*-----------------------------------------------------------------------------
|
||||
@@ -62,7 +62,7 @@
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_N | 240
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_P | 4
|
||||
* PLL_P | 2
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_Q | 5
|
||||
*-----------------------------------------------------------------------------
|
||||
@@ -74,7 +74,7 @@
|
||||
*-----------------------------------------------------------------------------
|
||||
* VDD(V) | 3.3
|
||||
*-----------------------------------------------------------------------------
|
||||
* Flash Latency(WS) | 2
|
||||
* Flash Latency(WS) | 3
|
||||
*-----------------------------------------------------------------------------
|
||||
* Prefetch Buffer | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
@@ -146,7 +146,7 @@
|
||||
#define PLL_N 240
|
||||
|
||||
/* SYSCLK = PLL_VCO / PLL_P */
|
||||
#define PLL_P 4
|
||||
#define PLL_P 2
|
||||
|
||||
/* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */
|
||||
#define PLL_Q 5
|
||||
@@ -167,7 +167,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint32_t SystemCoreClock = 60000000;
|
||||
uint32_t SystemCoreClock = 120000000;
|
||||
|
||||
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
@@ -359,11 +359,11 @@ static void SetSysClock(void)
|
||||
/* HCLK = SYSCLK / 1*/
|
||||
RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
|
||||
|
||||
/* PCLK2 = HCLK / 1*/
|
||||
RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
|
||||
/* PCLK2 = HCLK / 2*/
|
||||
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
|
||||
|
||||
/* PCLK1 = HCLK / 2*/
|
||||
RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
|
||||
/* PCLK1 = HCLK / 4*/
|
||||
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
|
||||
|
||||
/* Configure the main PLL */
|
||||
RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
|
||||
@@ -378,7 +378,7 @@ static void SetSysClock(void)
|
||||
}
|
||||
|
||||
/* Configure Flash prefetch, Instruction cache, Data cache and wait state */
|
||||
FLASH->ACR = FLASH_ACR_PRFTEN |FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_2WS;
|
||||
FLASH->ACR = FLASH_ACR_PRFTEN |FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_3WS;
|
||||
|
||||
/* Select the main PLL as system clock source */
|
||||
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
|
||||
|
||||
@@ -60,9 +60,9 @@
|
||||
|
||||
volatile uint16_t Analog_values[NUMBER_ANALOG];
|
||||
#if defined(REV4a)
|
||||
const char ana_direction[NUMBER_ANALOG] = {0,1,0,1, 1,1,1,0, 0};
|
||||
const char ana_direction[NUMBER_ANALOG] = {0,1,0,1, 1,1,0,1,0, 0};
|
||||
#elif !defined(REV3)
|
||||
const char ana_direction[NUMBER_ANALOG] = {0,1,0,1, 1,0,1,0, 0};
|
||||
const char ana_direction[NUMBER_ANALOG] = {0,1,0,1, 1,0,0,1,0, 0};
|
||||
#endif
|
||||
|
||||
void adcInit()
|
||||
@@ -88,7 +88,7 @@ void adcInit()
|
||||
ADC1->CR1 = ADC_CR1_SCAN ;
|
||||
ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS ;
|
||||
ADC1->SQR1 = (NUMBER_ANALOG-1) << 20 ; // NUMBER_ANALOG Channels
|
||||
ADC1->SQR2 = SLIDE_L + (SLIDE_R<<5) + (BATTERY<<10) ;
|
||||
ADC1->SQR2 = (SLIDE_L<<5) + (SLIDE_R<<10) + (BATTERY<<15) ;
|
||||
ADC1->SQR3 = STICK_LH + (STICK_LV<<5) + (STICK_RV<<10) + (STICK_RH<<15) + (POT_L<<20) + (POT_R<<25) ;
|
||||
ADC1->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12)
|
||||
+ (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) ;
|
||||
@@ -120,7 +120,6 @@ void adcRead()
|
||||
}
|
||||
}
|
||||
DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
// return ( i < 10000 ) ? 1 : 0 ;
|
||||
|
||||
#if !defined(REV3)
|
||||
// adc direction correct
|
||||
@@ -136,9 +135,3 @@ void adcRead()
|
||||
void adcStop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -88,7 +88,9 @@ void dacInit()
|
||||
DAC->CR = DAC_CR_TEN1 | DAC_CR_EN1 ; // Enable DAC
|
||||
NVIC_SetPriority(DMA1_Stream5_IRQn, 2) ; // High priority interrupt
|
||||
NVIC_EnableIRQ(TIM6_DAC_IRQn) ; // TODO needed?
|
||||
NVIC_SetPriority(TIM6_DAC_IRQn, 7);
|
||||
NVIC_EnableIRQ(DMA1_Stream5_IRQn) ;
|
||||
NVIC_SetPriority(DMA1_Stream5_IRQn, 7);
|
||||
}
|
||||
|
||||
bool dacQueue(AudioBuffer *buffer)
|
||||
|
||||
@@ -155,6 +155,7 @@ void init5msTimer()
|
||||
TIM14->CR1 = 5 ;
|
||||
TIM14->DIER |= 1 ;
|
||||
NVIC_EnableIRQ(TIM8_TRG_COM_TIM14_IRQn) ;
|
||||
NVIC_SetPriority(TIM8_TRG_COM_TIM14_IRQn, 7);
|
||||
}
|
||||
|
||||
void stop5msTimer( void )
|
||||
@@ -191,9 +192,6 @@ void boardInit()
|
||||
adcInit();
|
||||
delaysInit();
|
||||
audioInit();
|
||||
#if defined(DEBUG)
|
||||
uartInit(DEBUG_UART_BAUDRATE);
|
||||
#endif
|
||||
init5msTimer();
|
||||
__enable_irq();
|
||||
eepromInit();
|
||||
|
||||
@@ -60,7 +60,7 @@ extern "C" {
|
||||
#define PERI1_FREQUENCY 30000000
|
||||
#define PERI2_FREQUENCY 60000000
|
||||
#define TIMER_MULT_APB1 2
|
||||
#define TIMER_MULT_APB2 1
|
||||
#define TIMER_MULT_APB2 2
|
||||
|
||||
#define JACK_PPM_OUT()
|
||||
#define JACK_PPM_IN()
|
||||
@@ -77,11 +77,11 @@ extern uint16_t sessionTimer;
|
||||
|
||||
void delaysInit();
|
||||
|
||||
#define DEBUG_UART_BAUDRATE 115200
|
||||
#define DEBUG_BAUDRATE 115200
|
||||
#define SPORT_BAUDRATE 57600
|
||||
|
||||
void uartInit(uint32_t baudrate);
|
||||
void uartPutc(const char c);
|
||||
void uart3Init(unsigned int mode);
|
||||
void uart3Putc(const char c);
|
||||
|
||||
void sportInit(void);
|
||||
|
||||
@@ -183,6 +183,8 @@ bool usbPlugged(void);
|
||||
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
||||
#endif
|
||||
|
||||
// Debug driver
|
||||
void debugPutc(const char c);
|
||||
|
||||
extern uint8_t currentTrainerMode;
|
||||
|
||||
|
||||
@@ -969,7 +969,7 @@ FIL g_telemetryFile = {0};
|
||||
void sdInit()
|
||||
{
|
||||
if (f_mount(0, &g_FATFS_Obj) == FR_OK) {
|
||||
refreshSystemAudioFiles();
|
||||
referenceSystemAudioFiles();
|
||||
|
||||
#if defined(DEBUG)
|
||||
f_open(&g_telemetryFile, LOGS_PATH "/sport.log", FA_OPEN_ALWAYS | FA_WRITE);
|
||||
|
||||
@@ -92,6 +92,11 @@ uint32_t readTrims()
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t trimDown(uint8_t idx)
|
||||
{
|
||||
return readTrims() & (1 << idx);
|
||||
}
|
||||
|
||||
uint8_t keyDown()
|
||||
{
|
||||
return ~readKeys() & 0x7E ;
|
||||
|
||||
@@ -160,6 +160,7 @@ static void init_pa10_none()
|
||||
TIM1->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
TIM1->CR1 |= TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM1_CC_IRQn) ;
|
||||
NVIC_SetPriority(TIM1_CC_IRQn, 7);
|
||||
}
|
||||
|
||||
static void disable_pa10_none()
|
||||
@@ -202,6 +203,7 @@ static void init_pa7_none()
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
TIM8->CR1 |= TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM8_CC_IRQn) ;
|
||||
NVIC_SetPriority(TIM8_CC_IRQn, 7);
|
||||
}
|
||||
|
||||
static void disable_pa7_none()
|
||||
@@ -267,7 +269,8 @@ static void init_pa10_pxx()
|
||||
TIM1->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM1->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
TIM1->CR1 |= TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM1_CC_IRQn) ;
|
||||
NVIC_EnableIRQ(TIM1_CC_IRQn);
|
||||
NVIC_SetPriority(TIM1_CC_IRQn, 7);
|
||||
}
|
||||
|
||||
static void disable_pa10_pxx()
|
||||
@@ -316,7 +319,9 @@ static void init_pa10_ppm()
|
||||
|
||||
TIM1->CR1 = TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM1_CC_IRQn) ;
|
||||
NVIC_SetPriority(TIM1_CC_IRQn, 7);
|
||||
NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn) ;
|
||||
NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 7);
|
||||
}
|
||||
|
||||
static void disable_pa10_ppm()
|
||||
@@ -428,6 +433,7 @@ static void init_pa7_pxx()
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
TIM8->CR1 |= TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM8_CC_IRQn) ;
|
||||
NVIC_SetPriority(TIM8_CC_IRQn, 7);
|
||||
}
|
||||
|
||||
static void disable_pa7_pxx()
|
||||
@@ -501,6 +507,7 @@ static void init_pa7_dsm2()
|
||||
TIM8->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
TIM8->CR1 |= TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM8_CC_IRQn) ;
|
||||
NVIC_SetPriority(TIM8_CC_IRQn, 7);
|
||||
}
|
||||
|
||||
static void disable_pa7_dsm2()
|
||||
@@ -555,7 +562,9 @@ static void init_pa7_ppm()
|
||||
|
||||
TIM8->CR1 = TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM8_CC_IRQn) ;
|
||||
NVIC_SetPriority(TIM8_CC_IRQn, 7);
|
||||
NVIC_EnableIRQ(TIM8_UP_TIM13_IRQn) ;
|
||||
NVIC_SetPriority(TIM8_UP_TIM13_IRQn, 7);
|
||||
}
|
||||
|
||||
static void disable_pa7_ppm()
|
||||
|
||||
@@ -78,6 +78,7 @@ void sportInit(void)
|
||||
|
||||
USART_ITConfig(SPORT, USART_IT_RXNE, ENABLE);
|
||||
NVIC_EnableIRQ(USART2_IRQn);
|
||||
NVIC_SetPriority(USART2_IRQn, 6);
|
||||
}
|
||||
|
||||
void sportPutc(const char c)
|
||||
|
||||
@@ -71,6 +71,7 @@ void init_trainer_ppm()
|
||||
|
||||
TIM3->CR1 = TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM3_IRQn) ;
|
||||
NVIC_SetPriority(TIM3_IRQn, 7);
|
||||
}
|
||||
|
||||
// TODO - testing
|
||||
@@ -99,6 +100,7 @@ void init_trainer_capture()
|
||||
TIM3->DIER |= TIM_DIER_CC3IE ;
|
||||
TIM3->CR1 = TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(TIM3_IRQn) ;
|
||||
NVIC_SetPriority(TIM3_IRQn, 7);
|
||||
}
|
||||
|
||||
void stop_trainer_capture()
|
||||
@@ -122,13 +124,13 @@ extern "C" void TIM3_IRQHandler()
|
||||
val = (uint16_t)(capture - lastCapt) / 2 ;
|
||||
lastCapt = capture;
|
||||
|
||||
// We prcoess g_ppmInsright here to make servo movement as smooth as possible
|
||||
// We process g_ppmInsright here to make servo movement as smooth as possible
|
||||
// while under trainee control
|
||||
if ((val>4000) && (val < 19000)) { // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
|
||||
if ((val>4000) && (val < 19000)) { // G: Prioritize reset pulse. (Needed when less than 16 incoming pulses)
|
||||
ppmInState = 1; // triggered
|
||||
}
|
||||
else {
|
||||
if (ppmInState && (ppmInState<=8)) {
|
||||
if (ppmInState && (ppmInState<=16)) {
|
||||
if ((val>800) && (val<2200)) {
|
||||
g_ppmIns[ppmInState++ - 1] = (int16_t)(val - 1500)*(g_eeGeneral.PPM_Multiplier+10)/10; //+-500 != 512, but close enough.
|
||||
}
|
||||
|
||||
+31
-6
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
void uartInit(uint32_t baudrate)
|
||||
void uart3Setup(unsigned int baudrate)
|
||||
{
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
@@ -69,21 +69,47 @@ void uartInit(uint32_t baudrate)
|
||||
USART_ITConfig(UART3, USART_IT_TXE, DISABLE);
|
||||
|
||||
NVIC_EnableIRQ(USART3_IRQn);
|
||||
NVIC_SetPriority(USART3_IRQn, 7);
|
||||
}
|
||||
|
||||
void uart3Init(unsigned int mode)
|
||||
{
|
||||
USART_DeInit(USART3);
|
||||
|
||||
switch(mode) {
|
||||
case UART_MODE_SPORT:
|
||||
uart3Setup(SPORT_BAUDRATE);
|
||||
break;
|
||||
#if defined(DEBUG)
|
||||
case UART_MODE_DEBUG:
|
||||
uart3Setup(DEBUG_BAUDRATE);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Fifo<512> uart3TxFifo;
|
||||
|
||||
void uart3Putc(const char c)
|
||||
{
|
||||
uart3TxFifo.push(c);
|
||||
USART_ITConfig(UART3, USART_IT_TXE, ENABLE);
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
Fifo<512> debugTxFifo;
|
||||
void debugPutc(const char c)
|
||||
{
|
||||
debugTxFifo.push(c);
|
||||
USART_ITConfig(UART3, USART_IT_TXE, ENABLE);
|
||||
if (g_eeGeneral.uart3Mode == UART_MODE_DEBUG) {
|
||||
uart3Putc(c);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" void USART3_IRQHandler(void)
|
||||
{
|
||||
if (USART_GetITStatus(UART3, USART_IT_TXE) != RESET) {
|
||||
uint8_t txchar;
|
||||
if (debugTxFifo.pop(txchar)) {
|
||||
if (uart3TxFifo.pop(txchar)) {
|
||||
/* Write one byte to the transmit data register */
|
||||
USART_SendData(UART3, txchar);
|
||||
}
|
||||
@@ -92,4 +118,3 @@ extern "C" void USART3_IRQHandler(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user