[X9D] Switches now OK on both HW and simu

This commit is contained in:
bernet.andre@gmail.com
2013-01-07 08:42:12 +00:00
parent 5e940e56f4
commit 97595efa83
6 changed files with 24 additions and 17 deletions
+10 -5
View File
@@ -438,17 +438,22 @@ void menuMainView(uint8_t event)
// Switches // Switches
for (uint8_t i=0; i<8; i++) { for (uint8_t i=0; i<8; i++) {
uint8_t sw; uint8_t sw;
int16_t val;
switch(i) { switch(i) {
case 0: case 5:
sw = getValue(MIXSRC_SA-1) > 0 ? 2 : 1; sw = getValue(MIXSRC_SF-1) > 0 ? 3*i+2 : 3*i+1;
break;
case 6:
val = getValue(MIXSRC_SG-1);
sw = ((val < 0) ? 3*i : ((val == 0) ? 3*i+1 : 3*i+2));
break; break;
case 7: case 7:
sw = getValue(MIXSRC_SH-1) > 0 ? 2+2+3*6 : 1+2+3*6; sw = getValue(MIXSRC_SH-1) > 0 ? 3*i+1 : 3*i;
break; break;
default: default:
{ {
int16_t val = getValue(MIXSRC_SA+i-1); val = getValue(MIXSRC_SA+i-1);
sw = ((val < 0) ? 3*i : ((val == 0) ? 3*i+1 : 3*i+2)); sw = ((val < 0) ? 3*i+1 : ((val == 0) ? 3*i+2 : 3*i+3));
break; break;
} }
} }
+5 -5
View File
@@ -103,8 +103,8 @@ void setSwitch(int8_t swtch)
GPIOB->IDR &= ~PIN_SW_A_H; GPIOB->IDR &= ~PIN_SW_A_H;
break; break;
case DSW(SW_SA1): case DSW(SW_SA1):
GPIOE->IDR |= PIN_SW_A_H; GPIOB->IDR |= PIN_SW_A_H;
GPIOB->IDR |= PIN_SW_A_L; GPIOE->IDR |= PIN_SW_A_L;
break; break;
case DSW(SW_SA2): case DSW(SW_SA2):
GPIOE->IDR &= ~PIN_SW_A_L; GPIOE->IDR &= ~PIN_SW_A_L;
@@ -165,15 +165,15 @@ void setSwitch(int8_t swtch)
GPIOE->IDR |= PIN_SW_F; GPIOE->IDR |= PIN_SW_F;
break; break;
case DSW(SW_SG0): case DSW(SW_SG0):
GPIOE->IDR |= PIN_SW_G_L; GPIOB->IDR |= PIN_SW_G_L;
GPIOA->IDR &= ~PIN_SW_G_H; GPIOA->IDR &= ~PIN_SW_G_H;
break; break;
case DSW(SW_SG1): case DSW(SW_SG1):
GPIOA->IDR |= PIN_SW_G_H; GPIOA->IDR |= PIN_SW_G_H;
GPIOE->IDR |= PIN_SW_G_L; GPIOB->IDR |= PIN_SW_G_L;
break; break;
case DSW(SW_SG2): case DSW(SW_SG2):
GPIOE->IDR &= ~PIN_SW_G_L; GPIOB->IDR &= ~PIN_SW_G_L;
GPIOA->IDR |= PIN_SW_G_H; GPIOA->IDR |= PIN_SW_G_H;
break; break;
case DSW(SW_SH0): case DSW(SW_SH0):
+2 -2
View File
@@ -444,12 +444,12 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
#endif #endif
#if defined(PCBX9D) #if defined(PCBX9D)
SWITCH_KEY(A, SA0, 2); SWITCH_KEY(A, SA0, 3);
SWITCH_KEY(B, SB0, 3); SWITCH_KEY(B, SB0, 3);
SWITCH_KEY(C, SC0, 3); SWITCH_KEY(C, SC0, 3);
SWITCH_KEY(D, SD0, 3); SWITCH_KEY(D, SD0, 3);
SWITCH_KEY(E, SE0, 3); SWITCH_KEY(E, SE0, 3);
SWITCH_KEY(F, SF0, 3); SWITCH_KEY(F, SF0, 2);
SWITCH_KEY(G, SG0, 3); SWITCH_KEY(G, SG0, 3);
SWITCH_KEY(H, SH0, 2); SWITCH_KEY(H, SH0, 2);
#else #else
+3 -1
View File
@@ -48,5 +48,7 @@ void delaysInit(void) {
void delay_01us(uint16_t nb){ void delay_01us(uint16_t nb){
TIM13->CNT = 0; TIM13->CNT = 0;
while(TIM13->CNT < nb); TIM13->EGR = 1;
while(((uint16_t)TIM13->CNT) < nb);
TIM13->EGR = 0;
} }
+1 -1
View File
@@ -12,7 +12,7 @@
#include "../open9x.h" #include "../open9x.h"
#define I2C_delay() delay_01us(15); #define I2C_delay() delay_01us(30);
/** /**
* @brief Configure the used I/O ports pin * @brief Configure the used I/O ports pin
+3 -3
View File
@@ -124,13 +124,13 @@ uint32_t keyState(EnumKeys enuk)
switch ((uint8_t) enuk) { switch ((uint8_t) enuk) {
case SW_SA0: case SW_SA0:
xxx = (~b & PIN_SW_A_H) && (b & PIN_SW_A_L); xxx = (~b & PIN_SW_A_H) && (e & PIN_SW_A_L);
break; break;
case SW_SA1: case SW_SA1:
xxx = (b & PIN_SW_A_H) && (b & PIN_SW_A_L); xxx = (b & PIN_SW_A_H) && (e & PIN_SW_A_L);
break; break;
case SW_SA2: case SW_SA2:
xxx = (b & PIN_SW_A_H) && (~b & PIN_SW_A_L); xxx = (b & PIN_SW_A_H) && (~e & PIN_SW_A_L);
break; break;
case SW_SB0: case SW_SB0: