All X9E switches now working

This commit is contained in:
bsongis
2014-11-27 23:09:14 +01:00
parent 18a1006d4b
commit d64989baac
15 changed files with 520 additions and 295 deletions
+11 -2
View File
@@ -55,7 +55,7 @@ FILE *fp = NULL;
#if defined(PCBTARANIS)
uint32_t Peri1_frequency, Peri2_frequency;
GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe;
GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog;
TIM_TypeDef tim1, tim2, tim3, tim4, tim8, tim10;
RCC_TypeDef rcc;
DMA_Stream_TypeDef dma2_stream2, dma2_stream6;
@@ -178,7 +178,16 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
{
// printf("swtch=%d state=%d\n", swtch, state); fflush(stdout);
switch (swtch) {
#if defined(PCBTARANIS)
#if defined(PCBTARANIS) && defined(REV9E)
SWITCH_3_CASE(0, GPIO_PIN_SW_A_L, GPIO_PIN_SW_A_H, PIN_SW_A_L, PIN_SW_A_H)
SWITCH_3_CASE(1, GPIO_PIN_SW_B_L, GPIO_PIN_SW_B_H, PIN_SW_B_L, PIN_SW_B_H)
SWITCH_3_CASE(2, GPIO_PIN_SW_C_L, GPIO_PIN_SW_C_H, PIN_SW_C_L, PIN_SW_C_H)
SWITCH_3_CASE(3, GPIO_PIN_SW_D_L, GPIO_PIN_SW_D_H, PIN_SW_D_L, PIN_SW_D_H)
SWITCH_3_CASE(4, GPIO_PIN_SW_E_H, GPIO_PIN_SW_E_L, PIN_SW_E_H, PIN_SW_E_L)
SWITCH_3_CASE(5, GPIO_PIN_SW_F_H, GPIO_PIN_SW_F_L, PIN_SW_F_H, PIN_SW_F_L)
SWITCH_3_CASE(6, GPIO_PIN_SW_G_L, GPIO_PIN_SW_G_H, PIN_SW_G_L, PIN_SW_G_H)
SWITCH_3_CASE(7, GPIO_PIN_SW_H_L, GPIO_PIN_SW_H_H, PIN_SW_H_H, PIN_SW_H_L)
#elif defined(PCBTARANIS)
SWITCH_3_CASE(0, GPIO_PIN_SW_A_L, GPIO_PIN_SW_A_H, PIN_SW_A_L, PIN_SW_A_H)
SWITCH_3_CASE(1, GPIO_PIN_SW_B_L, GPIO_PIN_SW_B_H, PIN_SW_B_L, PIN_SW_B_H)
SWITCH_3_CASE(2, GPIO_PIN_SW_C_L, GPIO_PIN_SW_C_H, PIN_SW_C_L, PIN_SW_C_H)
+9 -5
View File
@@ -56,14 +56,14 @@ extern char * main_thread_error;
#include <execinfo.h>
inline void write_backtrace(char *output)
{
void *buf[16];
char **s;
int n = backtrace(buf,16);
int n = backtrace(buf, 16);
s = backtrace_symbols(buf, n);
if (s) {
for(int i=0; i<n; i++)
sprintf(output+strlen(output), "%02i: %s\n",i,s[i]);
for (int i=0; i<n; ++i) {
sprintf(output+strlen(output), "%02i: %s\n", i, s[i]);
}
}
}
#endif
@@ -99,7 +99,7 @@ typedef const int16_t pm_int16_t;
typedef const int8_t pm_int8_t;
#if defined(PCBTARANIS)
extern GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe;
extern GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog;
extern TIM_TypeDef tim1, tim3, tim4, tim8, tim10;
extern USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4;
extern RCC_TypeDef rcc;
@@ -110,11 +110,15 @@ extern DMA_TypeDef dma2;
#undef GPIOC
#undef GPIOD
#undef GPIOE
#undef GPIOF
#undef GPIOG
#define GPIOA (&gpioa)
#define GPIOB (&gpiob)
#define GPIOC (&gpioc)
#define GPIOD (&gpiod)
#define GPIOE (&gpioe)
#define GPIOF (&gpiof)
#define GPIOG (&gpiog)
#undef TIM1
#undef TIM3
#undef TIM4
+130 -72
View File
@@ -12,7 +12,6 @@
#endif
// Keys
#define GPIO_BUTTON_ENTER GPIOE->IDR
#define GPIO_BUTTON_PLUS GPIOE->IDR
#define GPIO_BUTTON_MINUS GPIOE->IDR
#define GPIO_BUTTON_MENU GPIOD->IDR
@@ -21,8 +20,10 @@
#define PIN_BUTTON_PLUS GPIO_Pin_10 // PE.10
#define PIN_BUTTON_MINUS GPIO_Pin_11 // PE.11
#if defined(REV9E)
#define GPIO_BUTTON_ENTER GPIOF->IDR
#define PIN_BUTTON_ENTER GPIO_Pin_0 // PF.00
#else
#define GPIO_BUTTON_ENTER GPIOE->IDR
#define PIN_BUTTON_ENTER GPIO_Pin_12 // PE.12
#endif
#define PIN_BUTTON_MENU GPIO_Pin_7 // PD.07
@@ -30,35 +31,102 @@
#define PIN_BUTTON_EXIT GPIO_Pin_2 // PD.03
// Trims
#define GPIO_TRIM_LH_L GPIOE->IDR
#define GPIO_TRIM_LV_DN GPIOE->IDR
#define GPIO_TRIM_RV_UP GPIOC->IDR
#define GPIO_TRIM_RH_L GPIOC->IDR
#define GPIO_TRIM_LH_R GPIOE->IDR
#define GPIO_TRIM_LV_UP GPIOE->IDR
#define GPIO_TRIM_RV_DN GPIOC->IDR
#define GPIO_TRIM_RH_R GPIOC->IDR
#define PIN_TRIM_RV_DN GPIO_Pin_3 // PC.03
#define GPIO_TRIM_RV_UP GPIOC->IDR
#define PIN_TRIM_RV_UP GPIO_Pin_2 // PC.02
#define GPIO_TRIM_RH_L GPIOC->IDR
#define PIN_TRIM_RH_L GPIO_Pin_1 // PC.01
#define GPIO_TRIM_RH_R GPIOC->IDR
#define PIN_TRIM_RH_R GPIO_Pin_13 // PC.13
#if defined(REV3)
#define PIN_TRIM_LH_R GPIO_Pin_4 // PE.04
#define GPIO_TRIM_LH_L GPIOE->IDR
#define PIN_TRIM_LH_L GPIO_Pin_3 // PE.03
#define GPIO_TRIM_LH_R GPIOE->IDR
#define PIN_TRIM_LH_R GPIO_Pin_4 // PE.04
#else
#define GPIO_TRIM_LH_L GPIOE->IDR
#define PIN_TRIM_LH_L GPIO_Pin_4 // PE.04
#define GPIO_TRIM_LH_R GPIOE->IDR
#define PIN_TRIM_LH_R GPIO_Pin_3 // PE.03
#endif
#if defined(REV9E)
#define GPIO_TRIM_LV_DN GPIOG->IDR
#define PIN_TRIM_LV_DN GPIO_Pin_1 // PG.01
#define GPIO_TRIM_LV_UP GPIOG->IDR
#define PIN_TRIM_LV_UP GPIO_Pin_0 // PG.00
#else
#define GPIO_TRIM_LV_DN GPIOE->IDR
#define PIN_TRIM_LV_DN GPIO_Pin_6 // PE.06
#define GPIO_TRIM_LV_UP GPIOE->IDR
#define PIN_TRIM_LV_UP GPIO_Pin_5 // PE.05
#endif
// Switchs
#if defined(REV3)
#define GPIO_PIN_SW_A_H (~GPIOB->IDR)
#define PIN_SW_A_H GPIO_Pin_7 // PB.07
#define GPIO_PIN_SW_A_L (~GPIOE->IDR)
#define PIN_SW_A_L GPIO_Pin_2 // PE.02
#else
#define GPIO_PIN_SW_A_H GPIOB->IDR
#define PIN_SW_A_H GPIO_Pin_5 // PB.05
#define GPIO_PIN_SW_A_L GPIOE->IDR
#define PIN_SW_A_L GPIO_Pin_0 // PE.00
#endif
#if defined(REV3)
#define GPIO_PIN_SW_B_L GPIOB->IDR
#define PIN_SW_B_L GPIO_Pin_5 // PB.05
#define GPIO_PIN_SW_B_H GPIOB->IDR
#define PIN_SW_B_H GPIO_Pin_6 // PB.06
#else
#define GPIO_PIN_SW_B_H GPIOE->IDR
#define PIN_SW_B_H GPIO_Pin_1 // PE.01
#define GPIO_PIN_SW_B_L GPIOE->IDR
#define PIN_SW_B_L GPIO_Pin_2 // PE.02
#endif
#if defined(REV3)
#define GPIO_PIN_SW_C_H (~GPIOB->IDR)
#define PIN_SW_C_H GPIO_Pin_1 // PB.01
#define GPIO_PIN_SW_C_L (~GPIOE->IDR)
#define PIN_SW_C_L GPIO_Pin_7 // PE.07
#else
#define GPIO_PIN_SW_C_H GPIOE->IDR
#define PIN_SW_C_H GPIO_Pin_15 // PE.15
#define GPIO_PIN_SW_C_L GPIOA->IDR
#define PIN_SW_C_L GPIO_Pin_5 // PA.05
#endif
#if defined(REV3)
#define GPIO_PIN_SW_D_H (~GPIOE->IDR)
#define PIN_SW_D_H GPIO_Pin_9 // PE.09
#define GPIO_PIN_SW_D_L (~GPIOE->IDR)
#define PIN_SW_D_L GPIO_Pin_8 // PE.08
#elif defined(REVPLUS)
#define GPIO_PIN_SW_D_H (GPIOE->IDR)
#define PIN_SW_D_H GPIO_Pin_7 // PE.07
#define GPIO_PIN_SW_D_L (GPIOE->IDR)
#define PIN_SW_D_L GPIO_Pin_13 // PE.13
#else
#define GPIO_PIN_SW_D_H GPIOE->IDR
#define PIN_SW_D_H GPIO_Pin_7 // PE.07
#define GPIO_PIN_SW_D_L GPIOB->IDR
#define PIN_SW_D_L GPIO_Pin_1 // PB.01
#endif
#define GPIO_PIN_SW_E_L GPIOB->IDR
#define PIN_SW_E_L GPIO_Pin_3 // PB.03
#define GPIO_PIN_SW_E_H GPIOB->IDR
#define PIN_SW_E_H GPIO_Pin_4 // PB.04
#if defined(REV9E)
#define GPIO_PIN_SW_F_L GPIOF->IDR
#define PIN_SW_F_L GPIO_Pin_15 // PF.15
#define GPIO_PIN_SW_F_H GPIOE->IDR
#define PIN_SW_F_H GPIO_Pin_14 // PE.14
#elif defined(REV3)
#define GPIO_PIN_SW_F (~GPIOE->IDR)
#define PIN_SW_F GPIO_Pin_14 // PE.14
#else
@@ -66,87 +134,77 @@
#define PIN_SW_F GPIO_Pin_14 // PE.14
#endif
#define GPIO_PIN_SW_E_L GPIOB->IDR
#define GPIO_PIN_SW_E_H GPIOB->IDR
#define PIN_SW_E_L GPIO_Pin_3 // PB.03
#define PIN_SW_E_H GPIO_Pin_4 // PB.04
#if defined(REV3)
#define GPIO_PIN_SW_B_L GPIOB->IDR
#define GPIO_PIN_SW_B_H GPIOB->IDR
#define PIN_SW_B_L GPIO_Pin_5 // PB.05
#define PIN_SW_B_H GPIO_Pin_6 // PB.06
#else
#define GPIO_PIN_SW_B_H GPIOE->IDR
#define GPIO_PIN_SW_B_L GPIOE->IDR
#define PIN_SW_B_H GPIO_Pin_1 // PE.01
#define PIN_SW_B_L GPIO_Pin_2 // PE.02
#endif
#if defined(REV3)
#define GPIO_PIN_SW_A_H (~GPIOB->IDR)
#define GPIO_PIN_SW_A_L (~GPIOE->IDR)
#define PIN_SW_A_H GPIO_Pin_7 // PB.07
#define PIN_SW_A_L GPIO_Pin_2 // PE.02
#else
#define GPIO_PIN_SW_A_H GPIOB->IDR
#define GPIO_PIN_SW_A_L GPIOE->IDR
#define PIN_SW_A_H GPIO_Pin_5 // PB.05
#define PIN_SW_A_L GPIO_Pin_0 // PE.00
#endif
#if defined(REV3)
#define GPIO_PIN_SW_G_H (~GPIOA->IDR)
#define GPIO_PIN_SW_G_L (~GPIOB->IDR)
#define PIN_SW_G_H GPIO_Pin_5 // PA.05
#define GPIO_PIN_SW_G_L (~GPIOB->IDR)
#define PIN_SW_G_L GPIO_Pin_0 // PB.00
#else
#define GPIO_PIN_SW_G_H GPIOE->IDR
#define GPIO_PIN_SW_G_L GPIOE->IDR
#define PIN_SW_G_H GPIO_Pin_9 // PE.09
#define GPIO_PIN_SW_G_L GPIOE->IDR
#define PIN_SW_G_L GPIO_Pin_8 // PE.08
#endif
#if defined(REV3)
#define GPIO_PIN_SW_C_H (~GPIOB->IDR)
#define GPIO_PIN_SW_C_L (~GPIOE->IDR)
#define PIN_SW_C_H GPIO_Pin_1 // PB.01
#define PIN_SW_C_L GPIO_Pin_7 // PE.07
#else
#define GPIO_PIN_SW_C_H GPIOE->IDR
#define GPIO_PIN_SW_C_L GPIOA->IDR
#define PIN_SW_C_H GPIO_Pin_15 // PE.15
#define PIN_SW_C_L GPIO_Pin_5 // PA.05
#endif
#if defined(REV3)
#define GPIO_PIN_SW_D_H (~GPIOE->IDR)
#define GPIO_PIN_SW_D_L (~GPIOE->IDR)
#define PIN_SW_D_H GPIO_Pin_9 // PE.09
#define PIN_SW_D_L GPIO_Pin_8 // PE.08
#elif defined(REVPLUS)
#define GPIO_PIN_SW_D_H (GPIOE->IDR)
#define GPIO_PIN_SW_D_L (GPIOE->IDR)
#define PIN_SW_D_H GPIO_Pin_7 // PE.07
#define PIN_SW_D_L GPIO_Pin_13 // PE.13
#else
#define GPIO_PIN_SW_D_H GPIOE->IDR
#define GPIO_PIN_SW_D_L GPIOB->IDR
#define PIN_SW_D_H GPIO_Pin_7 // PE.07
#define PIN_SW_D_L GPIO_Pin_1 // PB.01
#endif
#if defined(REV3)
#define GPIO_PIN_SW_H (~GPIOE->IDR)
#define PIN_SW_H GPIO_Pin_13 // PE.13
#if defined(REV9E)
#define GPIO_PIN_SW_H_H GPIOD->IDR
#define PIN_SW_H_H GPIO_Pin_10 // PD.10
#define GPIO_PIN_SW_H_L GPIOD->IDR
#define PIN_SW_H_L GPIO_Pin_14 // PD.14
#elif defined(REVPLUS)
#define GPIO_PIN_SW_H GPIOD->IDR
#define PIN_SW_H GPIO_Pin_14 // PD.14
#elif defined(REV3)
#define GPIO_PIN_SW_H (~GPIOE->IDR)
#define PIN_SW_H GPIO_Pin_13 // PE.13
#else
#define GPIO_PIN_SW_H GPIOE->IDR
#define PIN_SW_H GPIO_Pin_13 // PE.13
#endif
#if defined(REV9E)
#define GPIO_PIN_SW_I_H GPIOF->IDR
#define PIN_SW_I_H GPIO_Pin_1 // PF.01
#define GPIO_PIN_SW_I_L GPIOF->IDR
#define PIN_SW_I_L GPIO_Pin_2 // PF.02
#define GPIO_PIN_SW_J_H GPIOF->IDR
#define PIN_SW_J_H GPIO_Pin_3 // PF.03
#define GPIO_PIN_SW_J_L GPIOF->IDR
#define PIN_SW_J_L GPIO_Pin_4 // PF.04
#define GPIO_PIN_SW_K_H GPIOF->IDR
#define PIN_SW_K_H GPIO_Pin_5 // PF.05
#define GPIO_PIN_SW_K_L GPIOF->IDR
#define PIN_SW_K_L GPIO_Pin_6 // PF.06
#define GPIO_PIN_SW_L_H GPIOF->IDR
#define PIN_SW_L_H GPIO_Pin_7 // PF.07
#define GPIO_PIN_SW_L_L GPIOE->IDR
#define PIN_SW_L_L GPIO_Pin_10 // PE.10
#define GPIO_PIN_SW_M_H GPIOF->IDR
#define PIN_SW_M_H GPIO_Pin_11 // PF.11
#define GPIO_PIN_SW_M_L GPIOF->IDR
#define PIN_SW_M_L GPIO_Pin_12 // PF.12
#define GPIO_PIN_SW_N_H GPIOF->IDR
#define PIN_SW_N_H GPIO_Pin_13 // PF.13
#define GPIO_PIN_SW_N_L GPIOF->IDR
#define PIN_SW_N_L GPIO_Pin_14 // PF.14
#define GPIO_PIN_SW_O_H GPIOG->IDR
#define PIN_SW_O_H GPIO_Pin_13 // PG.13
#define GPIO_PIN_SW_O_L GPIOG->IDR
#define PIN_SW_O_L GPIO_Pin_12 // PG.12
#define GPIO_PIN_SW_P_H GPIOG->IDR
#define PIN_SW_P_H GPIO_Pin_11 // PG.11
#define GPIO_PIN_SW_P_L GPIOG->IDR
#define PIN_SW_P_L GPIO_Pin_10 // PG.10
#define GPIO_PIN_SW_Q_H GPIOE->IDR
#define PIN_SW_Q_H GPIO_Pin_11 // PE.11
#define GPIO_PIN_SW_Q_L GPIOE->IDR
#define PIN_SW_Q_L GPIO_Pin_12 // PE.12
#define GPIO_PIN_SW_R_H GPIOG->IDR
#define PIN_SW_R_H GPIO_Pin_7 // PG.07
#define GPIO_PIN_SW_R_L GPIOG->IDR
#define PIN_SW_R_L GPIO_Pin_8 // PG.08
#endif
// ADC
#define PIN_STK_J1 GPIO_Pin_0 // PA.00
#define PIN_STK_J2 GPIO_Pin_1 // PA.01
+124 -163
View File
@@ -142,6 +142,90 @@ void readKeysAndTrims()
}
#if !defined(BOOT)
#if defined(REV9E)
#define ADD_3POS_CASE(x, i) \
case SW_S ## x ## 0: \
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
break; \
case SW_S ## x ## 1: \
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
break; \
case SW_S ## x ## 2: \
xxx = (~GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
break
#define ADD_3POS_INVERTED_CASE(x, i) ADD_3POS_CASE(x, i)
#define ADD_XTRA_2POS_CASE(...)
#else
#define ADD_2POS_CASE(x) \
case SW_S ## x ## 0: \
xxx = GPIO_PIN_SW_ ## x & PIN_SW_ ## x ; \
break; \
case SW_S ## x ## 2: \
xxx = ~GPIO_PIN_SW_ ## x & PIN_SW_ ## x ; \
break
#define ADD_3POS_CASE(x, i) \
case SW_S ## x ## 0: \
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
if (IS_3POS(i)) { \
xxx = xxx && (~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
} \
break; \
case SW_S ## x ## 1: \
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
break; \
case SW_S ## x ## 2: \
xxx = (~GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
if (IS_3POS(i)) { \
xxx = xxx && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
} \
break
#define ADD_3POS_INVERTED_CASE(x, i) \
case SW_S ## x ## 0: \
xxx = (~GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
if (IS_3POS(i)) { \
xxx = xxx && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
} \
break; \
case SW_S ## x ## 1: \
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
break; \
case SW_S ## x ## 2: \
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
if (IS_3POS(i)) { \
xxx = xxx && (~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
} \
break
#define ADD_XTRA_2POS_CASE(x, y) \
case SW_S ## y ## 0: \
xxx = GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L; \
break; \
case SW_S ## y ## 2: \
xxx = ~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L; \
break
#endif
#if defined(REV3)
#define ADD_3POS_INVERTED_REV3_CASE(x, i) \
case SW_S ## x ## 0: \
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
if (IS_3POS(i)) { \
xxx = xxx && (~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
} \
break; \
case SW_S ## x ## 1: \
xxx = (~GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
break; \
case SW_S ## x ## 2: \
xxx = (~GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
if (IS_3POS(i)) { \
xxx = xxx && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
} \
break
#else
#define ADD_3POS_INVERTED_REV3_CASE(x, i) ADD_3POS_CASE(x, i)
#endif
bool switchState(EnumKeys enuk)
{
register uint32_t xxx = 0;
@@ -149,173 +233,48 @@ bool switchState(EnumKeys enuk)
if (enuk < (int) DIM(keys)) return keys[enuk].state() ? 1 : 0;
switch ((uint8_t) enuk) {
case SW_SA0:
xxx = (GPIO_PIN_SW_A_H & PIN_SW_A_H);
if (IS_3POS(0)) {
xxx = xxx && (~GPIO_PIN_SW_A_L & PIN_SW_A_L);
}
break;
case SW_SA1:
#if defined(REV3)
xxx = (~GPIO_PIN_SW_A_H & PIN_SW_A_H) && (~GPIO_PIN_SW_A_L & PIN_SW_A_L);
ADD_3POS_INVERTED_REV3_CASE(A, 0);
ADD_XTRA_2POS_CASE(A, I);
ADD_3POS_CASE(B, 1);
ADD_XTRA_2POS_CASE(B, J);
ADD_3POS_INVERTED_REV3_CASE(C, 2);
ADD_XTRA_2POS_CASE(C, K);
ADD_3POS_INVERTED_REV3_CASE(D, 3);
ADD_XTRA_2POS_CASE(D, L);
ADD_3POS_INVERTED_CASE(E, 4);
ADD_XTRA_2POS_CASE(E, M);
#if defined(REV9E)
ADD_3POS_CASE(F, 5);
#else
xxx = (GPIO_PIN_SW_A_H & PIN_SW_A_H) && (GPIO_PIN_SW_A_L & PIN_SW_A_L);
ADD_2POS_CASE(F);
#endif
break;
case SW_SA2:
xxx = (~GPIO_PIN_SW_A_H & PIN_SW_A_H);
if (IS_3POS(0)) {
xxx = xxx && (GPIO_PIN_SW_A_L & PIN_SW_A_L);
}
break;
case SW_SI0:
xxx = GPIO_PIN_SW_A_L & PIN_SW_A_L;
break;
case SW_SI2:
xxx = ~GPIO_PIN_SW_A_L & PIN_SW_A_L;
break;
ADD_3POS_INVERTED_REV3_CASE(G, 6);
ADD_XTRA_2POS_CASE(G, N);
case SW_SB0:
xxx = (GPIO_PIN_SW_B_H & PIN_SW_B_H);
if (IS_3POS(1)) {
xxx = xxx && (~GPIO_PIN_SW_B_L & PIN_SW_B_L);
}
break;
case SW_SB1:
xxx = (GPIO_PIN_SW_B_H & PIN_SW_B_H) && (GPIO_PIN_SW_B_L & PIN_SW_B_L);
break;
case SW_SB2:
xxx = (~GPIO_PIN_SW_B_H & PIN_SW_B_H);
if (IS_3POS(1)) {
xxx = xxx && (GPIO_PIN_SW_B_L & PIN_SW_B_L);
}
break;
case SW_SJ0:
xxx = GPIO_PIN_SW_B_L & PIN_SW_B_L;
break;
case SW_SJ2:
xxx = ~GPIO_PIN_SW_B_L & PIN_SW_B_L;
break;
case SW_SC0:
xxx = (GPIO_PIN_SW_C_H & PIN_SW_C_H);
if (IS_3POS(2)) {
xxx = xxx && (~GPIO_PIN_SW_C_L & PIN_SW_C_L);
}
break;
case SW_SC1:
#if defined(REV3)
xxx = (~GPIO_PIN_SW_C_H & PIN_SW_C_H) && (~GPIO_PIN_SW_C_L & PIN_SW_C_L);
#if defined(REV9E)
ADD_3POS_CASE(H, 7);
#else
xxx = (GPIO_PIN_SW_C_H & PIN_SW_C_H) && (GPIO_PIN_SW_C_L & PIN_SW_C_L);
ADD_2POS_CASE(H);
#endif
break;
case SW_SC2:
xxx = (~GPIO_PIN_SW_C_H & PIN_SW_C_H);
if (IS_3POS(2)) {
xxx = xxx && (GPIO_PIN_SW_C_L & PIN_SW_C_L);
}
break;
case SW_SK0:
xxx = GPIO_PIN_SW_C_L & PIN_SW_C_L;
break;
case SW_SK2:
xxx = ~GPIO_PIN_SW_C_L & PIN_SW_C_L;
break;
case SW_SD0:
xxx = (GPIO_PIN_SW_D_H & PIN_SW_D_H);
if (IS_3POS(3)) {
xxx = xxx && (~GPIO_PIN_SW_D_L & PIN_SW_D_L);
}
break;
case SW_SD1:
#if defined(REV3)
xxx = (~GPIO_PIN_SW_D_H & PIN_SW_D_H) && (~GPIO_PIN_SW_D_L & PIN_SW_D_L);
#else
xxx = (GPIO_PIN_SW_D_H & PIN_SW_D_H) && (GPIO_PIN_SW_D_L & PIN_SW_D_L);
#if defined(REV9E)
ADD_3POS_CASE(I, 8);
ADD_3POS_CASE(J, 9);
ADD_3POS_CASE(K, 10);
ADD_3POS_CASE(L, 11);
ADD_3POS_CASE(M, 12);
ADD_3POS_CASE(N, 13);
ADD_3POS_CASE(O, 14);
ADD_3POS_CASE(P, 15);
ADD_3POS_CASE(Q, 16);
ADD_3POS_CASE(R, 17);
#endif
break;
case SW_SD2:
xxx = (~GPIO_PIN_SW_D_H & PIN_SW_D_H);
if (IS_3POS(3)) {
xxx = xxx && (GPIO_PIN_SW_D_L & PIN_SW_D_L);
}
break;
case SW_SL0:
xxx = GPIO_PIN_SW_D_L & PIN_SW_D_L;
break;
case SW_SL2:
xxx = ~GPIO_PIN_SW_D_L & PIN_SW_D_L;
break;
case SW_SE0:
xxx = (~GPIO_PIN_SW_E_H & PIN_SW_E_H);
if (IS_3POS(4)) {
xxx = xxx && (GPIO_PIN_SW_E_L & PIN_SW_E_L);
}
break;
case SW_SE1:
xxx = (GPIO_PIN_SW_E_H & PIN_SW_E_H) && (GPIO_PIN_SW_E_L & PIN_SW_E_L);
break;
case SW_SE2:
xxx = (GPIO_PIN_SW_E_H & PIN_SW_E_H);
if (IS_3POS(4)) {
xxx = xxx && (~GPIO_PIN_SW_E_L & PIN_SW_E_L);
}
break;
case SW_SM0:
xxx = GPIO_PIN_SW_E_L & PIN_SW_E_L;
break;
case SW_SM2:
xxx = ~GPIO_PIN_SW_E_L & PIN_SW_E_L;
break;
case SW_SF0:
xxx = GPIO_PIN_SW_F & PIN_SW_F;
break;
case SW_SF2:
xxx = ~GPIO_PIN_SW_F & PIN_SW_F;
break;
case SW_SG0:
xxx = (GPIO_PIN_SW_G_H & PIN_SW_G_H);
if (IS_3POS(6)) {
xxx = xxx && (~GPIO_PIN_SW_G_L & PIN_SW_G_L);
}
break;
case SW_SG1:
#if defined(REV3)
xxx = (~GPIO_PIN_SW_G_H & PIN_SW_G_H) && (~GPIO_PIN_SW_G_L & PIN_SW_G_L);
#else
xxx = (GPIO_PIN_SW_G_H & PIN_SW_G_H) && (GPIO_PIN_SW_G_L & PIN_SW_G_L);
#endif
break;
case SW_SG2:
xxx = (~GPIO_PIN_SW_G_H & PIN_SW_G_H);
if (IS_3POS(6)) {
xxx = xxx && (GPIO_PIN_SW_G_L & PIN_SW_G_L);
}
break;
case SW_SN0:
xxx = GPIO_PIN_SW_G_L & PIN_SW_G_L;
break;
case SW_SN2:
xxx = ~GPIO_PIN_SW_G_L & PIN_SW_G_L;
break;
case SW_SH0:
xxx = GPIO_PIN_SW_H & PIN_SW_H;
break;
case SW_SH2:
xxx = ~GPIO_PIN_SW_H & PIN_SW_H;
break;
default:
break;
@@ -338,7 +297,7 @@ void keysInit()
| PIN_SW_A_L | PIN_SW_D_L | PIN_SW_F | PIN_SW_C_L | PIN_SW_D_H | PIN_SW_H;
#elif defined(REV9E)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
| PIN_SW_F | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_D_L | PIN_SW_G_H | PIN_SW_G_L;
| PIN_SW_F_H | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_D_L | PIN_SW_G_H | PIN_SW_G_L | PIN_SW_L_L | PIN_SW_Q_H | PIN_SW_Q_L;
#elif defined(REVPLUS)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
@@ -355,14 +314,16 @@ void keysInit()
GPIO_Init(GPIOE, &GPIO_InitStructure);
#if defined(REV9E)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_ENTER;
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_ENTER | PIN_SW_F_L | PIN_SW_I_H | PIN_SW_I_L | PIN_SW_J_H | PIN_SW_J_L | PIN_SW_K_H | PIN_SW_K_L | PIN_SW_L_H | PIN_SW_M_H | PIN_SW_M_L | PIN_SW_N_H | PIN_SW_N_L;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIN_TRIM_LV_DN | PIN_TRIM_LV_UP;
GPIO_InitStructure.GPIO_Pin = PIN_TRIM_LV_DN | PIN_TRIM_LV_UP | PIN_SW_O_H | PIN_SW_O_L | PIN_SW_P_H | PIN_SW_P_L | PIN_SW_R_H | PIN_SW_R_L;
GPIO_Init(GPIOG, &GPIO_InitStructure);
#endif
#if defined(REVPLUS)
#if defined(REV9E)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE | PIN_SW_H_H | PIN_SW_H_L;
#elif defined(REVPLUS)
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE | PIN_SW_H;
#else
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE;