kopia lustrzana https://github.com/OpenRTX/OpenRTX
Add GD77 keyboard driver
rodzic
c096e946a4
commit
41ecb11d3a
|
@ -18,17 +18,71 @@
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "gpio.h"
|
||||
#include "delays.h"
|
||||
#include "keyboard.h"
|
||||
#include "hwconfig.h"
|
||||
|
||||
void kbd_init()
|
||||
{
|
||||
/* TODO */
|
||||
gpio_setMode(KB_ROW0, INPUT_PULL_UP);
|
||||
gpio_setMode(KB_ROW1, INPUT_PULL_UP);
|
||||
gpio_setMode(KB_ROW2, INPUT_PULL_UP);
|
||||
gpio_setMode(KB_ROW3, INPUT_PULL_UP);
|
||||
gpio_setMode(KB_ROW4, INPUT_PULL_UP);
|
||||
gpio_setMode(KB_COL0, OUTPUT);
|
||||
gpio_setMode(KB_COL1, OUTPUT);
|
||||
gpio_setMode(KB_COL2, OUTPUT);
|
||||
gpio_setMode(KB_COL3, OUTPUT);
|
||||
|
||||
gpio_setMode(FUNC_SW, INPUT);
|
||||
gpio_setMode(FUNC2_SW, INPUT);
|
||||
gpio_setMode(MONI_SW, INPUT);
|
||||
|
||||
}
|
||||
|
||||
keyboard_t kbd_getKeys()
|
||||
{
|
||||
/* TODO */
|
||||
return 0;
|
||||
keyboard_t keys = 0;
|
||||
|
||||
gpio_clearPin(KB_COL0);
|
||||
delayUs(1);
|
||||
if(gpio_readPin(KB_ROW0) == 0) keys |= KEY_1;
|
||||
if(gpio_readPin(KB_ROW1) == 0) keys |= KEY_2;
|
||||
if(gpio_readPin(KB_ROW2) == 0) keys |= KEY_3;
|
||||
if(gpio_readPin(KB_ROW3) == 0) keys |= KEY_ENTER;
|
||||
if(gpio_readPin(KB_ROW4) == 0) keys |= KEY_RIGHT;
|
||||
gpio_setPin(KB_COL0);
|
||||
|
||||
gpio_clearPin(KB_COL1);
|
||||
delayUs(1);
|
||||
if(gpio_readPin(KB_ROW0) == 0) keys |= KEY_4;
|
||||
if(gpio_readPin(KB_ROW1) == 0) keys |= KEY_5;
|
||||
if(gpio_readPin(KB_ROW2) == 0) keys |= KEY_6;
|
||||
if(gpio_readPin(KB_ROW3) == 0) keys |= KEY_UP;
|
||||
if(gpio_readPin(KB_ROW4) == 0) keys |= KEY_LEFT;
|
||||
gpio_setPin(KB_COL1);
|
||||
|
||||
gpio_clearPin(KB_COL2);
|
||||
delayUs(1);
|
||||
if(gpio_readPin(KB_ROW0) == 0) keys |= KEY_7;
|
||||
if(gpio_readPin(KB_ROW1) == 0) keys |= KEY_8;
|
||||
if(gpio_readPin(KB_ROW2) == 0) keys |= KEY_9;
|
||||
if(gpio_readPin(KB_ROW3) == 0) keys |= KEY_DOWN;
|
||||
gpio_setPin(KB_COL2);
|
||||
|
||||
gpio_clearPin(KB_COL3);
|
||||
delayUs(1);
|
||||
if(gpio_readPin(KB_ROW0) == 0) keys |= KEY_STAR;
|
||||
if(gpio_readPin(KB_ROW1) == 0) keys |= KEY_0;
|
||||
if(gpio_readPin(KB_ROW2) == 0) keys |= KEY_HASH;
|
||||
if(gpio_readPin(KB_ROW3) == 0) keys |= KEY_ESC;
|
||||
gpio_setPin(KB_COL3);
|
||||
|
||||
if(gpio_readPin(FUNC_SW) == 0) keys |= KEY_F1;
|
||||
if(gpio_readPin(FUNC2_SW) == 0) keys |= KEY_F2;
|
||||
if(gpio_readPin(MONI_SW) == 0) keys |= KEY_MONI;
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,4 +39,21 @@
|
|||
#define LCD_CLK GPIOC,11
|
||||
#define LCD_DAT GPIOC,12
|
||||
|
||||
#endif
|
||||
/* Keyboard */
|
||||
#define KB_ROW0 GPIOB,19
|
||||
#define KB_ROW1 GPIOB,20
|
||||
#define KB_ROW2 GPIOB,21
|
||||
#define KB_ROW3 GPIOB,22
|
||||
#define KB_ROW4 GPIOB,23
|
||||
|
||||
#define KB_COL0 GPIOC,0
|
||||
#define KB_COL1 GPIOC,1
|
||||
#define KB_COL2 GPIOC,2
|
||||
#define KB_COL3 GPIOC,3
|
||||
|
||||
#define PTT_SW GPIOA,1
|
||||
#define FUNC_SW GPIOA,2
|
||||
#define FUNC2_SW GPIOB,1
|
||||
#define MONI_SW GPIOB,9
|
||||
|
||||
#endif
|
Ładowanie…
Reference in New Issue