Renamed define to GHOSTING_MATRIX. Deleted unused files from CK3.ICPad
Config Matrix_type = Config_Pulldown; | Config Matrix_type = Config_Pulldown; | ||||
// define this if your matrix has ghosting (i.e. regular keyboard without diodes) | |||||
#define GHOST | |||||
// Define this if your matrix has ghosting (i.e. regular keyboard without diodes) | |||||
// this will enable the anti-ghosting code | |||||
#define GHOSTING_MATRIX |
Pin Usage | |||||
========= | |||||
mk20dx128vlf5 | |||||
---- | |||||
|Keys| | |||||
---- | |||||
* Strobe (Columns) | |||||
PTB0 | |||||
PTB1 | |||||
PTB2 | |||||
PTB3 | |||||
PTB16 | |||||
PTB17 | |||||
PTC4 | |||||
PTC5 | |||||
PTD0 | |||||
* Sense (Rows) | |||||
PTD1 | |||||
PTD2 | |||||
PTD3 | |||||
PTD4 | |||||
PTD5 | |||||
PTD6 | |||||
PTD7 | |||||
----- | |||||
|Debug| | |||||
----- | |||||
* SWD | |||||
PTA0 (Pull-down) | |||||
PTA3 (Pull-up) | |||||
* LEDs | |||||
PTA19 (LED only for PCB, not McHCK) (XTAL) | |||||
* UARTs | |||||
PTA1 - RX0 | |||||
PTA2 - TX0 | |||||
* Tag Connect | |||||
1 - Vdd +5 | |||||
2 - PTA3 / SWD_IO | |||||
3 - Vss / Gnd | |||||
4 - PTA0 / SWD_CLK | |||||
5 - +5V | |||||
6 - PTA2 / TRACE_SWO | |||||
7 - N/C | |||||
8 - PTA1 / JTAG_TDI | |||||
9 - N/C | |||||
10 - Reset_b | |||||
------ | |||||
|Unused| | |||||
------ | |||||
* GPIO | |||||
PTA1 (Not broken out on PCB, available on McHCK) (Pull-up) | |||||
PTA2 (") | |||||
PTA4 (Pull-up) | |||||
PTA18 (EXTAL) | |||||
PTC0 | |||||
PTC1 | |||||
PTC2 | |||||
PTC3 | |||||
PTC6 | |||||
PTC7 | |||||
* Analog | |||||
ADC0_DP0 | |||||
ADC0_DM0 | |||||
Name = MD1; | |||||
Version = 0.2; | |||||
Author = "HaaTa (Jacob Alexander) 2014"; | |||||
KLL = 0.3; | |||||
# Modified Date | |||||
Date = 2014-09-14; | |||||
S0x00 : U"Esc"; | |||||
S0x01 : U"1"; | |||||
S0x02 : U"2"; | |||||
S0x03 : U"3"; | |||||
S0x04 : U"4"; | |||||
S0x05 : U"5"; | |||||
S0x06 : U"6"; | |||||
S0x07 : U"7"; | |||||
S0x08 : U"8"; | |||||
S0x09 : U"9"; | |||||
S0x0A : U"0"; | |||||
S0x0B : U"Minus"; | |||||
S0x0C : U"Equal"; | |||||
S0x0D : U"Backslash"; | |||||
S0x0E : U"Tab"; | |||||
S0x0F : U"Q"; | |||||
S0x10 : U"W"; | |||||
S0x11 : U"E"; | |||||
S0x12 : U"R"; | |||||
S0x13 : U"T"; | |||||
S0x14 : U"Y"; | |||||
S0x15 : U"U"; | |||||
S0x16 : U"I"; | |||||
S0x17 : U"O"; | |||||
S0x18 : U"P"; | |||||
S0x19 : U"LBrace"; | |||||
S0x1A : U"RBrace"; | |||||
S0x1B : U"Backspace"; | |||||
S0x1C : U"Ctrl"; | |||||
S0x1D : U"A"; | |||||
S0x1E : U"S"; | |||||
S0x1F : U"D"; | |||||
S0x20 : U"F"; | |||||
S0x21 : U"G"; | |||||
S0x22 : U"H"; | |||||
S0x23 : U"J"; | |||||
S0x24 : U"K"; | |||||
S0x25 : U"L"; | |||||
S0x26 : U"Semicolon"; | |||||
S0x27 : U"Quote"; | |||||
S0x28 : U"Enter"; | |||||
S0x29 : U"LShift"; | |||||
S0x2A : U"Z"; | |||||
S0x2B : U"X"; | |||||
S0x2C : U"C"; | |||||
S0x2D : U"V"; | |||||
S0x2E : U"B"; | |||||
S0x2F : U"N"; | |||||
S0x30 : U"M"; | |||||
S0x31 : U"Comma"; | |||||
S0x32 : U"Period"; | |||||
S0x33 : U"Slash"; | |||||
S0x34 : U"RShift"; | |||||
S0x35 : U"Function1"; # Fun key | |||||
S0x36 : U"Function2"; # Left Blank Key | |||||
S0x37 : U"LAlt"; | |||||
S0x38 : U"LGui"; | |||||
S0x39 : U"Space"; | |||||
S0x3A : U"RGui"; | |||||
S0x3B : U"RAlt"; | |||||
S0x3C : U"Function3"; # Right Blank Key 1 | |||||
S0x3D : U"Function4"; # Right Blank Key 2 | |||||
S0x3E : U"BackTick"; | |||||
KeyState Matrix_scanArray[ Matrix_colsNum * Matrix_rowsNum ]; | KeyState Matrix_scanArray[ Matrix_colsNum * Matrix_rowsNum ]; | ||||
// Ghost Arrays | // Ghost Arrays | ||||
#ifdef GHOST | |||||
#ifdef GHOSTING_MATRIX | |||||
KeyGhost Matrix_ghostArray[ Matrix_colsNum * Matrix_rowsNum ]; | KeyGhost Matrix_ghostArray[ Matrix_colsNum * Matrix_rowsNum ]; | ||||
uint8_t col_use[Matrix_colsNum], row_use[Matrix_rowsNum]; // used count | uint8_t col_use[Matrix_colsNum], row_use[Matrix_rowsNum]; // used count | ||||
{ | { | ||||
case Type_StrobeOn: | case Type_StrobeOn: | ||||
*GPIO_PSOR |= (1 << gpio.pin); | *GPIO_PSOR |= (1 << gpio.pin); | ||||
#ifdef GHOST | |||||
#ifdef GHOSTING_MATRIX | |||||
*GPIO_PDDR |= (1 << gpio.pin); // output | *GPIO_PDDR |= (1 << gpio.pin); // output | ||||
#endif | #endif | ||||
break; | break; | ||||
case Type_StrobeOff: | case Type_StrobeOff: | ||||
*GPIO_PCOR |= (1 << gpio.pin); | *GPIO_PCOR |= (1 << gpio.pin); | ||||
#ifdef GHOST | |||||
#ifdef GHOSTING_MATRIX | |||||
// Ghosting martix needs to put not used (off) strobes in high impedance state | // Ghosting martix needs to put not used (off) strobes in high impedance state | ||||
*GPIO_PDDR &= ~(1 << gpio.pin); // input, high Z state | *GPIO_PDDR &= ~(1 << gpio.pin); // input, high Z state | ||||
#endif | #endif | ||||
Matrix_scanArray[ item ].activeCount = 0; | Matrix_scanArray[ item ].activeCount = 0; | ||||
Matrix_scanArray[ item ].inactiveCount = DebounceDivThreshold_define; // Start at 'off' steady state | Matrix_scanArray[ item ].inactiveCount = DebounceDivThreshold_define; // Start at 'off' steady state | ||||
Matrix_scanArray[ item ].prevDecisionTime = 0; | Matrix_scanArray[ item ].prevDecisionTime = 0; | ||||
#ifdef GHOST | |||||
#ifdef GHOSTING_MATRIX | |||||
Matrix_ghostArray[ item ].prev = KeyState_Off; | Matrix_ghostArray[ item ].prev = KeyState_Off; | ||||
Matrix_ghostArray[ item ].cur = KeyState_Off; | Matrix_ghostArray[ item ].cur = KeyState_Off; | ||||
Matrix_ghostArray[ item ].saved = KeyState_Off; | Matrix_ghostArray[ item ].saved = KeyState_Off; | ||||
erro_print("Matrix scan bug!! Report me!"); | erro_print("Matrix scan bug!! Report me!"); | ||||
break; | break; | ||||
} | } | ||||
// Update decision time | // Update decision time | ||||
state->prevDecisionTime = currentTime; | state->prevDecisionTime = currentTime; | ||||
// Send keystate to macro module | // Send keystate to macro module | ||||
#ifndef GHOST | |||||
#ifndef GHOSTING_MATRIX | |||||
Macro_keyState( key, state->curState ); | Macro_keyState( key, state->curState ); | ||||
#endif | #endif | ||||
// Matrix ghosting check and elimination | // Matrix ghosting check and elimination | ||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||
#ifdef GHOST | |||||
#ifdef GHOSTING_MATRIX | |||||
// strobe = column, sense = row | // strobe = column, sense = row | ||||
// Count (rows) use for columns | // Count (rows) use for columns |
KeyPosition saved; // state before ghosting | KeyPosition saved; // state before ghosting | ||||
} __attribute__((packed)) KeyGhost; | } __attribute__((packed)) KeyGhost; | ||||
// utility | |||||
// utility | |||||
inline uint8_t keyOn(/*KeyPosition*/uint8_t st) | inline uint8_t keyOn(/*KeyPosition*/uint8_t st) | ||||
{ return (st == KeyState_Press || st == KeyState_Hold) ? 1 : 0; } | |||||
{ | |||||
return (st == KeyState_Press || st == KeyState_Hold) ? 1 : 0; | |||||
} | |||||
// ----- Functions ----- | // ----- Functions ----- |