]> jspc29.x-matter.uni-frankfurt.de Git - coral.git/commitdiff
own module for Touchpad
authorMichael Wiebusch <m.wiebusch@gsi.de>
Thu, 11 Dec 2014 10:34:10 +0000 (11:34 +0100)
committerMichael Wiebusch <m.wiebusch@gsi.de>
Thu, 11 Dec 2014 10:34:10 +0000 (11:34 +0100)
firmware/TM1001A.c
firmware/TM1001A.h [new file with mode: 0644]
firmware/USBtoSerial.c
firmware/makefile

index 7250b69645be8e83400dab5a59b05f0382cf4893..48a1f35a1bb78c0fd0b4a3d86494e025777f4018 100644 (file)
@@ -1,3 +1,11 @@
+
+
+
+#include <avr/io.h> 
+#include <stdlib.h>
+#include <util/delay.h>
+#include "TM1001A.h"
+
 // This code is based on the work of Frank H. (franky1969) from the
 // Mikrocontroller.net forum.
 // I modified the code thusly that it runs on an ATMega8 with more than 8 MHz
 // June 2013
 
 
-// define here the port and the pin where you cave connected
-// the ADB (I/O) line from your TM1001A touchpad
-#define ADB_BIT (1<<1)
-#define ADB_PIN PINB
-#define ADB_POUT PORTB
-#define ADB_PDIR DDRB
-
-// when touchpad is in keypad mode the next two defines set the number
-// of rows and columns of the
-#define PAD_ROWS 2
-#define PAD_COLS 3
-
-
-
-
-
-
-
-
-
-
-
 #define TAKT F_CPU
 
 //Bits Makro
 #define BITS(H,L)  (0b##H ##L)
 
-#define MIN_ABS_X 150
-#define MAX_ABS_X 1450
-#define MIN_ABS_Y 210
-#define MAX_ABS_Y 1130
-
-#define PAD_WIDTH (MAX_ABS_X-MIN_ABS_X)
-#define PAD_HEIGHT (MAX_ABS_Y-MIN_ABS_Y)
-#define PAD_COL_WIDTH (PAD_WIDTH/PAD_COLS)
-#define PAD_ROW_HEIGHT (PAD_HEIGHT/PAD_ROWS)
-
 //Vorteiler Timer 0 und 1 bei 2313, 8515, Mega8 (nicht Timer 2)
 #define TIMER_VT_1_B BITS(0000,0001)  
 #define TIMER_VT_8_B BITS(0000,0010)  
@@ -65,8 +41,6 @@
 
 
 
-typedef unsigned char u08;
-typedef unsigned short int u16;
 
 #define COM_TALK0 BITS(0011,1100) //Adresse 3, Talk, Register0
 #define COM_TALK1 BITS(0011,1101) //Adresse 3, Talk, Register1
diff --git a/firmware/TM1001A.h b/firmware/TM1001A.h
new file mode 100644 (file)
index 0000000..ba5de09
--- /dev/null
@@ -0,0 +1,71 @@
+// This code is based on the work of Frank H. (franky1969) from the
+// Mikrocontroller.net forum.
+// I modified the code thusly that it runs on an ATMega8 with more than 8 MHz
+// (make use of the counter 0 overflow interrupt to count to numbers greater
+// than 255) and added a set of functions that make your life easy,
+// i.e. spare you the work of crawling through the ADB register documentation yourself.
+//
+// You cannot use counter 0 for any other thing when using the touchpad!
+//
+// Have fun! - Michael W. (acidbourbon)
+//
+// acidbourbon.wordpress.com
+// June 2013
+
+
+// define here the port and the pin where you cave connected
+// the ADB (I/O) line from your TM1001A touchpad
+#define ADB_BIT (1<<1)
+#define ADB_PIN PINB
+#define ADB_POUT PORTB
+#define ADB_PDIR DDRB
+
+// when touchpad is in keypad mode the next two defines set the number
+// of rows and columns of the
+#define PAD_ROWS 2
+#define PAD_COLS 3
+
+
+#define MIN_ABS_X 150
+#define MAX_ABS_X 1450
+#define MIN_ABS_Y 210
+#define MAX_ABS_Y 1130
+
+#define PAD_WIDTH (MAX_ABS_X-MIN_ABS_X)
+#define PAD_HEIGHT (MAX_ABS_Y-MIN_ABS_Y)
+#define PAD_COL_WIDTH (PAD_WIDTH/PAD_COLS)
+#define PAD_ROW_HEIGHT (PAD_HEIGHT/PAD_ROWS)
+
+typedef unsigned char u08;
+typedef unsigned short int u16;
+
+
+ISR( TIMER0_OVF_vect);
+
+uint16_t t0ext(void);
+
+void t0rst(void);
+
+u08 adb(void);
+
+void touchpad_init(void);
+
+uint8_t touchpad_read(void);
+
+void touchpad_set_abs_mode(void);
+
+void touchpad_set_rel_mode_100dpi(void);
+
+void touchpad_set_rel_mode_200dpi(void);
+
+uint8_t z_pressure(void);
+
+uint16_t x_abs(void);
+
+uint16_t y_abs(void);
+
+int8_t delta_y(void);
+
+int8_t delta_x(void);
+
+uint8_t decode_field(void);
index a334ba076c9e6214e2c3550e54b404251d824391..685511fe13fd695fb735976ff3ed3863a843256e 100644 (file)
  *  Main source file for the USBtoSerial project. This file contains the main tasks of\r
  *  the project and is responsible for the initial application hardware configuration.\r
  */\r
-#define F_CPU 16e6\r
+// #define F_CPU 16e6\r
 \r
 #include <avr/io.h> \r
 #include <stdlib.h>\r
 #include "USBtoSerial.h"\r
 #include <util/delay.h>\r
-#include "TM1001A.c"\r
+#include "TM1001A.h"\r
 // #include "rfm70.c"\r
 #include "pins.h"\r
 #include "leds.c"\r
index 6a9fd09c9b9d696e85bb29d82e3eb5adba028ac4..0bbdfba09612836d543fde01dc4d39df64d960dc 100644 (file)
@@ -18,7 +18,7 @@ F_CPU        = 16000000
 F_USB        = $(F_CPU)\r
 OPTIMIZATION = s\r
 TARGET       = USBtoSerial\r
-SRC          = $(TARGET).c Descriptors.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)\r
+SRC          = $(TARGET).c Descriptors.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) TM1001A.c\r
 LUFA_PATH    = ../LUFA/LUFA-130303/LUFA\r
 CC_FLAGS     = -DUSE_LUFA_CONFIG_HEADER -IConfig/\r
 LD_FLAGS     =\r