Constants renamed (so that Taranis hal is now nice)

This commit is contained in:
bsongis
2015-06-09 21:15:10 +02:00
parent bab4168ac4
commit 8365a8dbaf
39 changed files with 998 additions and 1005 deletions
+65 -65
View File
@@ -48,80 +48,80 @@ extern uint16_t ResetReason;
#define FIRMWARE_ADDRESS 0x00400000
#if defined(REVA)
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
#define GPIO_BUTTON_EXIT PIOA->PIO_PDSR
#define GPIO_BUTTON_UP PIOC->PIO_PDSR
#define GPIO_BUTTON_DOWN PIOC->PIO_PDSR
#define GPIO_BUTTON_RIGHT PIOC->PIO_PDSR
#define GPIO_BUTTON_LEFT PIOC->PIO_PDSR
#define PIN_BUTTON_MENU 0x00000040
#define PIN_BUTTON_EXIT 0x80000000
#define PIN_BUTTON_UP 0x00000004
#define PIN_BUTTON_DOWN 0x00000008
#define PIN_BUTTON_RIGHT 0x00000010
#define PIN_BUTTON_LEFT 0x00000020
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
#define KEYS_GPIO_REG_EXIT PIOA->PIO_PDSR
#define KEYS_GPIO_REG_UP PIOC->PIO_PDSR
#define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR
#define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR
#define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR
#define KEYS_GPIO_PIN_MENU 0x00000040
#define KEYS_GPIO_PIN_EXIT 0x80000000
#define KEYS_GPIO_PIN_UP 0x00000004
#define KEYS_GPIO_PIN_DOWN 0x00000008
#define KEYS_GPIO_PIN_RIGHT 0x00000010
#define KEYS_GPIO_PIN_LEFT 0x00000020
#else
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
#define GPIO_BUTTON_EXIT PIOC->PIO_PDSR
#define GPIO_BUTTON_UP PIOC->PIO_PDSR
#define GPIO_BUTTON_DOWN PIOC->PIO_PDSR
#define GPIO_BUTTON_RIGHT PIOC->PIO_PDSR
#define GPIO_BUTTON_LEFT PIOC->PIO_PDSR
#define PIN_BUTTON_MENU 0x00000020
#define PIN_BUTTON_EXIT 0x01000000
#define PIN_BUTTON_UP 0x00000002
#define PIN_BUTTON_DOWN 0x00000020
#define PIN_BUTTON_RIGHT 0x00000010
#define PIN_BUTTON_LEFT 0x00000008
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
#define KEYS_GPIO_REG_EXIT PIOC->PIO_PDSR
#define KEYS_GPIO_REG_UP PIOC->PIO_PDSR
#define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR
#define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR
#define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR
#define KEYS_GPIO_PIN_MENU 0x00000020
#define KEYS_GPIO_PIN_EXIT 0x01000000
#define KEYS_GPIO_PIN_UP 0x00000002
#define KEYS_GPIO_PIN_DOWN 0x00000020
#define KEYS_GPIO_PIN_RIGHT 0x00000010
#define KEYS_GPIO_PIN_LEFT 0x00000008
#endif
#if defined(REVX)
#define GPIO_TRIM_LH_L PIOB->PIO_PDSR
#define GPIO_TRIM_LV_DN PIOA->PIO_PDSR
#define GPIO_TRIM_RV_UP PIOC->PIO_PDSR
#define GPIO_TRIM_RH_L PIOA->PIO_PDSR
#define GPIO_TRIM_LH_R PIOA->PIO_PDSR
#define GPIO_TRIM_LV_UP PIOC->PIO_PDSR
#define GPIO_TRIM_RV_DN PIOA->PIO_PDSR
#define GPIO_TRIM_RH_R PIOC->PIO_PDSR
#define TRIMS_GPIO_REG_LHL PIOB->PIO_PDSR
#define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR
#define TRIMS_GPIO_REG_RVU PIOC->PIO_PDSR
#define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR
#define TRIMS_GPIO_REG_LHR PIOA->PIO_PDSR
#define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR
#define TRIMS_GPIO_REG_RVD PIOA->PIO_PDSR
#define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR
#else
#define GPIO_TRIM_LH_L PIOA->PIO_PDSR
#define GPIO_TRIM_LV_DN PIOA->PIO_PDSR
#define GPIO_TRIM_RV_UP PIOA->PIO_PDSR
#define GPIO_TRIM_RH_L PIOA->PIO_PDSR
#define GPIO_TRIM_LH_R PIOB->PIO_PDSR
#define GPIO_TRIM_LV_UP PIOC->PIO_PDSR
#define GPIO_TRIM_RV_DN PIOC->PIO_PDSR
#define GPIO_TRIM_RH_R PIOC->PIO_PDSR
#define TRIMS_GPIO_REG_LHL PIOA->PIO_PDSR
#define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR
#define TRIMS_GPIO_REG_RVU PIOA->PIO_PDSR
#define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR
#define TRIMS_GPIO_REG_LHR PIOB->PIO_PDSR
#define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR
#define TRIMS_GPIO_REG_RVD PIOC->PIO_PDSR
#define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR
#endif
#if defined(REVX)
#define PIN_TRIM_LH_L 0x00000010
#define PIN_TRIM_LV_DN 0x01000000
#define PIN_TRIM_RV_UP 0x00000400
#define PIN_TRIM_RH_L 0x00000001
#define PIN_TRIM_LH_R 0x00800000
#define PIN_TRIM_LV_UP 0x10000000
#define PIN_TRIM_RV_DN 0x00000002
#define PIN_TRIM_RH_R 0x00000200
#define TRIMS_GPIO_PIN_LHL 0x00000010
#define TRIMS_GPIO_PIN_LVD 0x01000000
#define TRIMS_GPIO_PIN_RVU 0x00000400
#define TRIMS_GPIO_PIN_RHL 0x00000001
#define TRIMS_GPIO_PIN_LHR 0x00800000
#define TRIMS_GPIO_PIN_LVU 0x10000000
#define TRIMS_GPIO_PIN_RVD 0x00000002
#define TRIMS_GPIO_PIN_RHR 0x00000200
#elif defined(REVA)
#define PIN_TRIM_LH_L 0x00000080
#define PIN_TRIM_LV_DN 0x08000000
#define PIN_TRIM_RV_UP 0x40000000
#define PIN_TRIM_RH_L 0x20000000
#define PIN_TRIM_LH_R 0x00000010
#define PIN_TRIM_LV_UP 0x10000000
#define PIN_TRIM_RV_DN 0x00000400
#define PIN_TRIM_RH_R 0x00000200
#define TRIMS_GPIO_PIN_LHL 0x00000080
#define TRIMS_GPIO_PIN_LVD 0x08000000
#define TRIMS_GPIO_PIN_RVU 0x40000000
#define TRIMS_GPIO_PIN_RHL 0x20000000
#define TRIMS_GPIO_PIN_LHR 0x00000010
#define TRIMS_GPIO_PIN_LVU 0x10000000
#define TRIMS_GPIO_PIN_RVD 0x00000400
#define TRIMS_GPIO_PIN_RHR 0x00000200
#else
#define PIN_TRIM_LH_L 0x00800000
#define PIN_TRIM_LV_DN 0x01000000
#define PIN_TRIM_RV_UP 0x00000002
#define PIN_TRIM_RH_L 0x00000001
#define PIN_TRIM_LH_R 0x00000010
#define PIN_TRIM_LV_UP 0x10000000
#define PIN_TRIM_RV_DN 0x00000400
#define PIN_TRIM_RH_R 0x00000200
#define TRIMS_GPIO_PIN_LHL 0x00800000
#define TRIMS_GPIO_PIN_LVD 0x01000000
#define TRIMS_GPIO_PIN_RVU 0x00000002
#define TRIMS_GPIO_PIN_RHL 0x00000001
#define TRIMS_GPIO_PIN_LHR 0x00000010
#define TRIMS_GPIO_PIN_LVU 0x10000000
#define TRIMS_GPIO_PIN_RVD 0x00000400
#define TRIMS_GPIO_PIN_RHR 0x00000200
#endif
void usbMassStorage();
@@ -187,7 +187,7 @@ void writeFlash(uint32_t * address, uint32_t * buffer);
extern uint32_t readKeys();
extern uint32_t readTrims();
#define TRIMS_PRESSED() (readTrims())
#define KEYS_PRESSED() (~readKeys())
#define KEYS_PRESSED() (readKeys())
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & (0x20 + 0x40)) == (0x20 + 0x40))
#define DBLKEYS_PRESSED_UP_DWN(i) ((in & (0x10 + 0x08)) == (0x10 + 0x08))
#define DBLKEYS_PRESSED_RGT_UP(i) ((in & (0x20 + 0x10)) == (0x20 + 0x10))
+22 -21
View File
@@ -52,32 +52,33 @@ uint32_t readKeys()
register uint32_t result = 0;
x = lcdLock ? lcdInputs : PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
x = ~x;
#if defined(REVA)
if (x & PIN_BUTTON_RIGHT)
if (x & KEYS_GPIO_PIN_RIGHT)
result |= 0x02 << KEY_RIGHT;
if (x & PIN_BUTTON_LEFT)
if (x & KEYS_GPIO_PIN_LEFT)
result |= 0x02 << KEY_LEFT;
if (x & PIN_BUTTON_UP)
if (x & KEYS_GPIO_PIN_UP)
result |= 0x02 << KEY_UP;
if (x & PIN_BUTTON_DOWN)
if (x & KEYS_GPIO_PIN_DOWN)
result |= 0x02 << KEY_DOWN;
if (GPIO_BUTTON_EXIT & PIN_BUTTON_EXIT)
if (KEYS_GPIO_REG_EXIT & KEYS_GPIO_PIN_EXIT)
result |= 0x02 << KEY_EXIT;
if (GPIO_BUTTON_MENU & 0x000000040)
if (KEYS_GPIO_REG_MENU & 0x000000040)
result |= 0x02 << KEY_MENU;
#else
if (x & PIN_BUTTON_RIGHT)
if (x & KEYS_GPIO_PIN_RIGHT)
result |= 0x02 << KEY_RIGHT;
if (x & PIN_BUTTON_UP)
if (x & KEYS_GPIO_PIN_UP)
result |= 0x02 << KEY_UP;
if (x & PIN_BUTTON_LEFT)
if (x & KEYS_GPIO_PIN_LEFT)
result |= 0x02 << KEY_LEFT;
if (x & PIN_BUTTON_DOWN)
if (x & KEYS_GPIO_PIN_DOWN)
result |= 0x02 << KEY_DOWN;
if (x & PIN_BUTTON_EXIT)
if (x & KEYS_GPIO_PIN_EXIT)
result |= 0x02 << KEY_EXIT;
if (GPIO_BUTTON_MENU & PIN_BUTTON_MENU)
if (KEYS_GPIO_REG_MENU & KEYS_GPIO_PIN_MENU)
result |= 0x02 << KEY_MENU;
#endif
@@ -90,21 +91,21 @@ uint32_t readTrims()
{
register uint32_t result = 0;
if (~GPIO_TRIM_LH_L & PIN_TRIM_LH_L)
if (~TRIMS_GPIO_REG_LHL & TRIMS_GPIO_PIN_LHL)
result |= 0x01;
if (~GPIO_TRIM_LV_DN & PIN_TRIM_LV_DN)
if (~TRIMS_GPIO_REG_LVD & TRIMS_GPIO_PIN_LVD)
result |= 0x04;
if (~GPIO_TRIM_RV_UP & PIN_TRIM_RV_UP)
if (~TRIMS_GPIO_REG_RVU & TRIMS_GPIO_PIN_RVU)
result |= 0x20;
if (~GPIO_TRIM_RH_L & PIN_TRIM_RH_L)
if (~TRIMS_GPIO_REG_RHL & TRIMS_GPIO_PIN_RHL)
result |= 0x40;
if (~GPIO_TRIM_LH_R & PIN_TRIM_LH_R)
if (~TRIMS_GPIO_REG_LHR & TRIMS_GPIO_PIN_LHR)
result |= 0x02;
if (~GPIO_TRIM_LV_UP & PIN_TRIM_LV_UP)
if (~TRIMS_GPIO_REG_LVU & TRIMS_GPIO_PIN_LVU)
result |= 0x08;
if (~GPIO_TRIM_RV_DN & PIN_TRIM_RV_DN)
if (~TRIMS_GPIO_REG_RVD & TRIMS_GPIO_PIN_RVD)
result |= 0x10;
if (~GPIO_TRIM_RH_R & PIN_TRIM_RH_R)
if (~TRIMS_GPIO_REG_RHR & TRIMS_GPIO_PIN_RHR)
result |= 0x80;
return result;
@@ -117,7 +118,7 @@ uint8_t trimDown(uint8_t idx)
uint8_t keyDown()
{
return (~readKeys() & 0x7E) || REA_DOWN();
return readKeys() || REA_DOWN();
}
void readKeysAndTrims()