689 lines
21 KiB
C++
689 lines
21 KiB
C++
#include "Arduino.h"
|
||
|
||
//Arduino 1.8.3
|
||
//STM32F103C, 64k flash
|
||
//upload method: serial (A9 to RX, A10 to TX)
|
||
//To upload set Boot0 jumper to 1 (the one further away from reset btn) and press reset (stm will boot from flash wich contains uart to flash uploader)
|
||
//To boot program after restart set Boot0 jumper to 0
|
||
|
||
//#define DEBUG
|
||
|
||
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
|
||
|
||
void checkSerial();
|
||
bool textAvailable();
|
||
bool checkTextbuffer();
|
||
void sendChar(char c,char c2);
|
||
void coilInterrupt();
|
||
|
||
//pins die nicht gehn als output:
|
||
/* PA15
|
||
* PB3
|
||
* PB4
|
||
* PA12
|
||
*/
|
||
|
||
#define SCAN_0 PA1
|
||
#define SCAN_1 PA2
|
||
#define SCAN_2 PA3
|
||
#define SCAN_3 PA4
|
||
#define SCAN_4 PA5
|
||
#define SCAN_5 PA6
|
||
#define SCAN_6 PA7
|
||
#define SCAN_7 PB0
|
||
#define SCAN_8 PB1
|
||
#define IN_A PB13 //geht
|
||
#define IN_B PB14 //geht
|
||
#define IN_C PB15 //geht
|
||
#define IN_D PB5 //geht
|
||
#define IN_E PB6 //geht
|
||
#define IN_F PB7 //geht
|
||
#define IN_G PB8 //geht
|
||
#define IN_H PB9 //geht
|
||
|
||
#define PIN_LED PC13
|
||
|
||
#define PIN_COIL_SENSE PB11
|
||
|
||
#define LEDON LOW
|
||
#define LEDOFF HIGH
|
||
|
||
|
||
#define NUM_SCANPINS 9
|
||
|
||
|
||
|
||
|
||
int scanaddress[]={SCAN_0,SCAN_1,SCAN_2,SCAN_3,SCAN_4,SCAN_5,SCAN_6,SCAN_7,SCAN_8};
|
||
int inaddress[]={IN_A,IN_B,IN_C,IN_D,IN_E,IN_F,IN_G,IN_H};
|
||
|
||
byte keymatrix[128][NUM_SCANPINS]={
|
||
//0 1 2 3 4 5 6 7 8 <- see rows (left side) in docs/brotherax240_keyboard.JPG
|
||
//content at this array position is pressed keys 2^0 - 2^7=A-H. If Column 0(A) and 7(H) should be used, 2^0+2^7=1+128=129 is entered
|
||
{0,0,0,0,0,0,0,0,0}, //0 = |