[X9D] Some more drivers added (keys / power).
[ACT] Splash. Simu working. All screens need to be reworked!
This commit is contained in:
+42
-168
@@ -33,184 +33,58 @@
|
||||
|
||||
#include "../open9x.h"
|
||||
|
||||
#if 0
|
||||
// TODO code from FrSky
|
||||
void detect_buttons()
|
||||
{
|
||||
short t_pin; short t_pin1;
|
||||
static short key_down_interval;
|
||||
key_down_interval++;
|
||||
|
||||
t_pin = (~(GPIOC->IDR))
|
||||
& (PIN_BUTTON_UP | PIN_BUTTON_ENTER | PIN_BUTTON_DOWN);
|
||||
t_pin1 = (~(GPIOB->IDR)) & (PIN_POWER | PIN_BIND);
|
||||
|
||||
if ((t_pin1 & PIN_BIND) && (!(pin_status1 & PIN_BIND))
|
||||
&& (!(t_pin1 & PIN_POWER))) {
|
||||
}
|
||||
if ((t_pin1 & PIN_POWER) && (!(pin_status1 & PIN_POWER))) {
|
||||
|
||||
}
|
||||
if ((pin_status1 & PIN_BIND) && (pin_status1 & PIN_POWER)) {
|
||||
static char t_pin_bind;
|
||||
t_pin_bind++; //Õâ¸ö±äÁ¿
|
||||
if ((t_pin_bind == 39) || (t_pin_bind == 69)) {
|
||||
t_pin_bind = 40;
|
||||
//SetIDProc(0,0,0,t_pin_bind);
|
||||
}
|
||||
}
|
||||
|
||||
if ((t_pin & PIN_BUTTON_UP) && (!(pin_status & PIN_BUTTON_UP))) {
|
||||
|
||||
}
|
||||
if ((t_pin & PIN_BUTTON_ENTER) && (!(pin_status & PIN_BUTTON_ENTER))) {
|
||||
|
||||
}
|
||||
if ((t_pin & PIN_BUTTON_DOWN) && (!(pin_status & PIN_BUTTON_DOWN))) {
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
if ((pin_status & PIN_BUTTON_UP)) {
|
||||
static char t_pin_up;
|
||||
t_pin_up++; //Õâ¸ö±äÁ¿
|
||||
if ((t_pin_up == 9) || (t_pin_up == 22)) {
|
||||
t_pin_up = 10;
|
||||
|
||||
}
|
||||
else if ((!(t_pin & PIN_BUTTON_UP))) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((pin_status & PIN_BUTTON_ENTER)) {
|
||||
static char t_pin_enter;
|
||||
t_pin_enter++;
|
||||
if ((t_pin_enter == 9) || (t_pin_enter == 22)) {
|
||||
t_pin_enter = 10;
|
||||
|
||||
}
|
||||
else if ((!(t_pin & PIN_BUTTON_ENTER))) {
|
||||
if (t_pin_enter < 9)
|
||||
|
||||
t_pin_enter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pin_status & PIN_BUTTON_DOWN)) {
|
||||
static char t_pin_down;
|
||||
t_pin_down++;
|
||||
if ((t_pin_down == 9) || (t_pin_down == 22)) {
|
||||
t_pin_down = 10;
|
||||
|
||||
}
|
||||
else if ((!(t_pin & PIN_BUTTON_DOWN))) {
|
||||
if (t_pin_down < 9)
|
||||
|
||||
t_pin_down = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pin_status = t_pin;
|
||||
pin_status1 = t_pin1;
|
||||
}
|
||||
#endif
|
||||
// TODO FrSky code included PIN_BIND and PIN_POWER
|
||||
|
||||
uint32_t readKeys()
|
||||
{
|
||||
register uint32_t x = GPIOC->IDR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP
|
||||
register uint32_t y = 0;
|
||||
register uint32_t d = GPIOD->IDR;
|
||||
register uint32_t e = GPIOE->IDR;
|
||||
register uint32_t result = 0;
|
||||
|
||||
if (x & 0x00000020)
|
||||
y |= 0x02 << KEY_ENTER;
|
||||
if (x & 0x00000010)
|
||||
y |= 0x02 << KEY_PLUS;
|
||||
if (x & 0x00000008)
|
||||
y |= 0x02 << KEY_MINUS;
|
||||
if (x & 0x00000002)
|
||||
y |= 0x02 << KEY_MENU;
|
||||
if (x & 0x00000040)
|
||||
y |= 0x02 << KEY_PAGE;
|
||||
if (x & 0x01000000)
|
||||
y |= 0x02 << KEY_EXIT;
|
||||
if (e & PIN_BUTTON_ENTER)
|
||||
result |= 0x02 << KEY_ENTER;
|
||||
if (e & PIN_BUTTON_PLUS)
|
||||
result |= 0x02 << KEY_PLUS;
|
||||
if (e & PIN_BUTTON_MINUS)
|
||||
result |= 0x02 << KEY_MINUS;
|
||||
|
||||
// printf("readKeys(): %x => %x\n", x, y); fflush(stdout);
|
||||
if (d & PIN_BUTTON_MENU)
|
||||
result |= 0x02 << KEY_MENU;
|
||||
if (d & PIN_BUTTON_PAGE)
|
||||
result |= 0x02 << KEY_PAGE;
|
||||
if (d & PIN_BUTTON_EXIT)
|
||||
result |= 0x02 << KEY_EXIT;
|
||||
|
||||
return y ;
|
||||
// printf("readKeys(): %x %x => %x\n", d, e, result); fflush(stdout);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t readTrims()
|
||||
{
|
||||
#if 0
|
||||
register uint32_t c = GPIOC->IDR;
|
||||
register uint32_t e = GPIOE->IDR;
|
||||
register uint32_t result = 0;
|
||||
|
||||
uint32_t trims;
|
||||
uint32_t trima;
|
||||
if (c & PIN_TRIM1_UP)
|
||||
result |= 0x02;
|
||||
if (c & PIN_TRIM1_DN)
|
||||
result |= 0x01;
|
||||
if (c & PIN_TRIM2_UP)
|
||||
result |= 0x04;
|
||||
if (c & PIN_TRIM2_DN)
|
||||
result |= 0x03;
|
||||
|
||||
trims = 0;
|
||||
if (e & PIN_TRIM3_UP)
|
||||
result |= 0x06;
|
||||
if (e & PIN_TRIM3_DN)
|
||||
result |= 0x05;
|
||||
if (e & PIN_TRIM4_UP)
|
||||
result |= 0x08;
|
||||
if (e & PIN_TRIM4_DN)
|
||||
result |= 0x07;
|
||||
|
||||
trima = PIOA->PIO_PDSR;
|
||||
|
||||
// TRIM_LH_DOWN PA7 (PA23)
|
||||
#if defined(REVA)
|
||||
if ( ( trima & 0x0080 ) == 0 )
|
||||
#else
|
||||
if ((trima & 0x00800000) == 0)
|
||||
#endif
|
||||
{
|
||||
trims |= 1;
|
||||
}
|
||||
|
||||
// TRIM_LV_DOWN PA27 (PA24)
|
||||
#if defined(REVA)
|
||||
if ( ( trima & 0x08000000 ) == 0 )
|
||||
#else
|
||||
if ((trima & 0x01000000) == 0)
|
||||
#endif
|
||||
{
|
||||
trims |= 4;
|
||||
}
|
||||
|
||||
// TRIM_RV_UP PA30 (PA1)
|
||||
#if defined(REVA)
|
||||
if ( ( trima & 0x40000000 ) == 0 )
|
||||
#else
|
||||
if ((trima & 0x00000002) == 0)
|
||||
#endif
|
||||
{
|
||||
trims |= 0x20;
|
||||
}
|
||||
|
||||
// TRIM_RH_DOWN PA29 (PA0)
|
||||
#if defined(REVA)
|
||||
if ( ( trima & 0x20000000 ) == 0 )
|
||||
#else
|
||||
if ((trima & 0x00000001) == 0)
|
||||
#endif
|
||||
{
|
||||
trims |= 0x40;
|
||||
}
|
||||
|
||||
// TRIM_LH_UP PB4
|
||||
if ((PIOB->PIO_PDSR & 0x10) == 0) {
|
||||
trims |= 2;
|
||||
}
|
||||
|
||||
trima = PIOC->PIO_PDSR;
|
||||
// TRIM_LV_UP PC28
|
||||
if ((trima & 0x10000000) == 0) {
|
||||
trims |= 8;
|
||||
}
|
||||
|
||||
// TRIM_RV_DOWN PC10
|
||||
if ((trima & 0x00000400) == 0) {
|
||||
trims |= 0x10;
|
||||
}
|
||||
|
||||
// TRIM_RH_UP PC9
|
||||
if ((trima & 0x00000200) == 0) {
|
||||
trims |= 0x80;
|
||||
}
|
||||
|
||||
return trims;
|
||||
#endif
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t keyDown()
|
||||
@@ -246,16 +120,16 @@ void keysInit()
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBUTTON, ENABLE);
|
||||
|
||||
/* GPIO Configuration*/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_UP | PIN_BUTTON_ENTER | PIN_BUTTON_DOWN | PIN_TRIM3_UP | PIN_TRIM3_DN
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM3_UP | PIN_TRIM3_DN
|
||||
| PIN_TRIM4_UP |PIN_TRIM4_DN | PIN_SW_A_L | PIN_SW_D_L | PIN_SW_F_H | PIN_SW_G_H
|
||||
| PIN_SW_G_L | PIN_SW_H_L;
|
||||
| PIN_SW_G_L | PIN_SW_H_L;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_HOME | PIN_ESC | PIN_PAGE;
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
|
||||
Reference in New Issue
Block a user