summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbootloader/mrobe500.c30
-rw-r--r--firmware/SOURCES5
-rw-r--r--firmware/drivers/tsc2100.c64
-rw-r--r--firmware/export/config-mrobe500.h3
-rw-r--r--firmware/export/spi.h26
-rw-r--r--firmware/export/tsc2100.h104
-rw-r--r--firmware/target/arm/olympus/mrobe-500/spi-mr500.c6
-rw-r--r--firmware/target/arm/olympus/mrobe-500/spi-target.h6
8 files changed, 221 insertions, 23 deletions
diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c
index 1bfadd4769..3c98ae25f3 100755
--- a/bootloader/mrobe500.c
+++ b/bootloader/mrobe500.c
@@ -38,8 +38,9 @@
38#include "common.h" 38#include "common.h"
39#include "rbunicode.h" 39#include "rbunicode.h"
40#include "usb.h" 40#include "usb.h"
41#include "spi-target.h" 41#include "spi.h"
42#include "uart-target.h" 42#include "uart-target.h"
43#include "tsc2100.h"
43 44
44extern int line; 45extern int line;
45 46
@@ -59,7 +60,7 @@ void main(void)
59 uartSetup(); 60 uartSetup();
60 lcd_init(); 61 lcd_init();
61 font_init(); 62 font_init();
62 dm320_spi_init(); 63 spi_init();
63 64
64 lcd_setfont(FONT_SYSFIXED); 65 lcd_setfont(FONT_SYSFIXED);
65 66
@@ -102,7 +103,7 @@ void main(void)
102 103
103 printf("ATA"); 104 printf("ATA");
104 105
105 outw(inw(IO_GIO_DIR1)&~(1<<10), IO_GIO_DIR1); // set GIO26 to output 106 outw(inw(IO_GIO_DIR1)&~(1<<10), IO_GIO_DIR1); // set GIO26 (reset pin) to output
106 while(true) 107 while(true)
107 { 108 {
108 if (button_read_device() == BUTTON_POWER) 109 if (button_read_device() == BUTTON_POWER)
@@ -110,20 +111,15 @@ void main(void)
110 printf("reset"); 111 printf("reset");
111 outw(1<<10, IO_GIO_BITSET1); 112 outw(1<<10, IO_GIO_BITSET1);
112 } 113 }
113 114 // if ((inw(IO_GIO_BITSET0)&(1<<14)) == 0)
114 // Read X, Y, Z1, Z2 touchscreen coordinates. 115 {
115 int page = 0, address = 0; 116 short x,y,z1,z2, reg;
116 unsigned short command = 0x8000|(page << 11)|(address << 5); 117 tsc2100_read_values(&x, &y, &z1, &z2);
117 unsigned char out[] = {command >> 8, command & 0xff}; 118 printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2);
118 unsigned char in[8]; 119 printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff);
119 dm320_spi_block_transfer(out, sizeof(out), in, sizeof(in)); 120 tsc2100_keyclick(); /* doesnt work :( */
120 121 line -= 2;
121 printf("%02x%02x %02x%02x %02x%02x %02x%02x\n", 122 }
122 in[0], in[1],
123 in[2], in[3],
124 in[4], in[5],
125 in[6], in[7]);
126 line--;
127 123
128 } 124 }
129#if 0 125#if 0
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 454f9e1fe2..c98b44d433 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -253,6 +253,11 @@ drivers/usb/arcotg_udc.c
253#endif /* !defined(BOOTLOADER) */ 253#endif /* !defined(BOOTLOADER) */
254#endif /* !defined(SIMULATOR) */ 254#endif /* !defined(SIMULATOR) */
255 255
256/* Other Random Hardware */
257#ifdef HAVE_TSC2100
258drivers/tsc2100.c
259#endif
260
256/* CPU Specific - By class then particular chip if applicable */ 261/* CPU Specific - By class then particular chip if applicable */
257#if defined(CPU_SH) 262#if defined(CPU_SH)
258 263
diff --git a/firmware/drivers/tsc2100.c b/firmware/drivers/tsc2100.c
new file mode 100644
index 0000000000..19da33e377
--- /dev/null
+++ b/firmware/drivers/tsc2100.c
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2007 by Jonathan Gordon
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "cpu.h"
22#include "system.h"
23#include "spi.h"
24#include "tsc2100.h"
25
26/* Read X, Y, Z1, Z2 touchscreen coordinates. */
27void tsc2100_read_values(short *x, short* y, short *z1, short *z2)
28{
29 int page = 0, address = 0;
30 unsigned short command = 0x8000|(page << 11)|(address << 5);
31 unsigned char out[] = {command >> 8, command & 0xff};
32 unsigned char in[8];
33 spi_block_transfer(out, sizeof(out), in, sizeof(in));
34
35 *x = (in[0]<<8)|in[1];
36 *y = (in[2]<<8)|in[3];
37 *z1 = (in[4]<<8)|in[5];
38 *z2 = (in[6]<<8)|in[7];
39}
40
41short tsc2100_readreg(int page, int address)
42{
43 unsigned short command = 0x8000|(page << 11)|(address << 5);
44 unsigned char out[] = {command >> 8, command & 0xff};
45 unsigned char in[2];
46 spi_block_transfer(out, sizeof(out), in, sizeof(in));
47 return (in[0]<<8)|in[1];
48}
49
50
51void tsc2100_writereg(int page, int address, short value)
52{
53 unsigned short command = 0x8000|(page << 11)|(address << 5);
54 unsigned char out[4] = {command >> 8, command & 0xff,
55 value >> 8, value & 0xff};
56 spi_block_transfer(out, sizeof(out), NULL, 0);
57}
58
59void tsc2100_keyclick(void)
60{
61 // 1100 0100 0001 0000
62 short val = 0xC410;
63 tsc2100_writereg(TSAC2_PAGE, TSAC2_ADDRESS, val);
64}
diff --git a/firmware/export/config-mrobe500.h b/firmware/export/config-mrobe500.h
index 3e74db68b4..a9c610f3d7 100644
--- a/firmware/export/config-mrobe500.h
+++ b/firmware/export/config-mrobe500.h
@@ -89,6 +89,9 @@
89/* Define this if you have a Motorola SCF5249 */ 89/* Define this if you have a Motorola SCF5249 */
90#define CONFIG_CPU DM320 90#define CONFIG_CPU DM320
91 91
92/* Define this if you have a Texas Instruments TSC2100 touch screen */
93#define HAVE_TSC2100
94
92/* Define this if you want to use coldfire's i2c interface */ 95/* Define this if you want to use coldfire's i2c interface */
93//#define CONFIG_I2C I2C_S3C2440 96//#define CONFIG_I2C I2C_S3C2440
94 97
diff --git a/firmware/export/spi.h b/firmware/export/spi.h
new file mode 100644
index 0000000000..aafc367855
--- /dev/null
+++ b/firmware/export/spi.h
@@ -0,0 +1,26 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2007 by Catalin Patulea
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef __SPI_H__
20#define __SPI_H__
21
22int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
23 uint8_t *rx_bytes, unsigned int rx_size);
24void spi_init(void);
25
26#endif
diff --git a/firmware/export/tsc2100.h b/firmware/export/tsc2100.h
new file mode 100644
index 0000000000..ff30c64559
--- /dev/null
+++ b/firmware/export/tsc2100.h
@@ -0,0 +1,104 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2007 by Jonathan Gordon
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef __TSC2100_H_
20#define __TSC2100_H_
21
22/* Read X, Y, Z1, Z2 touchscreen coordinates. */
23void tsc2100_read_values(short *x, short* y, short *z1, short *z2);
24
25/* read a register */
26short tsc2100_readreg(int page, int address);
27/* write a value to the register */
28void tsc2100_writereg(int page, int address, short value);
29
30/* ts adc page defines (page 1, 00h ) (refer to page 40 of the datasheet) */
31#define TSADC_PAGE 1
32#define TSADC_ADDRESS 0x00
33#define TSADC_PSTCM (1<<15)
34#define TSADC_ADST (1<<14)
35#define TSADC_ADSCM_MASK (0x3C00)
36#define TSADC_ADSCM_SHIFT 10
37#define TSADC_RESOL_MASK (0x0300)
38#define TSADC_RESOL_SHIFT 8
39#define TSADC_ADAVG_MASK (0x00C0)
40#define TSADC_ADAVG_SHIFT 6
41#define TSADC_ADCR_MASK (0x0030)
42#define TSADC_ADCR_SHIFT 4
43#define TSADC_PVSTC_MASK (0x000E)
44#define TSADC_PVSTC_SHIFT 1
45#define TSADC_AVGFS (1<<0)
46
47/* ts status page defines (page 1, 01h ) (refer to page 41 of the datasheet) */
48#define TSSTAT_PAGE 1
49#define TSSTAT_ADDRESS 0x01
50#define TSSTAT_PINTDAV_MASK 0xC000 /* controls the !PINTDAV pin */
51#define TSSTAT_PINTDAV_SHIFT 14
52/* these are all read only */
53#define TSSTAT_PWRDN (1<<13)
54#define TSSTAT_HCTLM (1<<12)
55#define TSSTAT_DAVAIL (1<<11)
56#define TSSTAT_XSTAT (1<<10)
57#define TSSTAT_YSTAT (1<<9)
58#define TSSTAT_Z1STAT (1<<8)
59#define TSSTAT_Z2STAT (1<<7)
60#define TSSTAT_B1STAT (1<<6)
61#define TSSTAT_B2STAT (1<<5)
62#define TSSTAT_AXSTAT (1<<4)
63// Bit 3 is reserved (1<<3)
64#define TSSTAT_T1STAT (1<<2)
65#define TSSTAT_T2STAT (1<<1)
66// Bit 0 is reserved (1<<0)
67
68/* ts Reset Control */
69#define TSRESET_PAGE 1
70#define TSRESET_ADDRESS 0x04
71#define TSRESET_VALUE 0xBB00
72
73
74
75/* ts audio control 2 */
76#define TSAC2_PAGE 2
77#define TSAC2_ADDRESS 0x04
78#define TSAC2_KCLEN (1<<15)
79#define TSAC2_KCLAC_MASK 0x7000
80#define TSAC2_KCLSC_SHIFT 12
81#define TSAC2_APGASS (1<<11)
82#define TSAC2_KCLFRQ_MASK 0x0700
83#define TSAC2_KCLFRQ_SHIFT 8
84#define TSAC2_KCLLN_MASK 0x00F0
85#define TSAC2_KCLLN_SHIFT 4
86#define TSAC2_DLGAF (1<<3) /* r only */
87#define TSAC2_DRGAF (1<<2) /* r only */
88#define TSAC2_DASTC (1<<1)
89#define TSAC2_ADGAF (1<<0) /* r only */
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104#endif
diff --git a/firmware/target/arm/olympus/mrobe-500/spi-mr500.c b/firmware/target/arm/olympus/mrobe-500/spi-mr500.c
index 6c0d4b5990..8aeecd97f2 100644
--- a/firmware/target/arm/olympus/mrobe-500/spi-mr500.c
+++ b/firmware/target/arm/olympus/mrobe-500/spi-mr500.c
@@ -31,8 +31,8 @@
31#define clr_gio_enable() outw(GIO_TS_ENABLE, IO_GIO_BITSET1) 31#define clr_gio_enable() outw(GIO_TS_ENABLE, IO_GIO_BITSET1)
32#define set_gio_enable() outw(GIO_TS_ENABLE, IO_GIO_BITCLR1) 32#define set_gio_enable() outw(GIO_TS_ENABLE, IO_GIO_BITCLR1)
33 33
34int dm320_spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size, 34int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
35 uint8_t *rx_bytes, unsigned int rx_size) 35 uint8_t *rx_bytes, unsigned int rx_size)
36{ 36{
37 /* Activate the slave select pin */ 37 /* Activate the slave select pin */
38 set_gio_enable(); 38 set_gio_enable();
@@ -63,7 +63,7 @@ int dm320_spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
63 return 0; 63 return 0;
64} 64}
65 65
66void dm320_spi_init(void) 66void spi_init(void)
67{ 67{
68 /* Set SCLK idle level = 0 */ 68 /* Set SCLK idle level = 0 */
69 IO_SERIAL0_MODE |= (1<<10); 69 IO_SERIAL0_MODE |= (1<<10);
diff --git a/firmware/target/arm/olympus/mrobe-500/spi-target.h b/firmware/target/arm/olympus/mrobe-500/spi-target.h
index ebaacb45a0..29aff47903 100644
--- a/firmware/target/arm/olympus/mrobe-500/spi-target.h
+++ b/firmware/target/arm/olympus/mrobe-500/spi-target.h
@@ -22,8 +22,8 @@
22 22
23#include <inttypes.h> 23#include <inttypes.h>
24 24
25void dm320_spi_init(void); 25void spi_init(void);
26int dm320_spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size, 26int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
27 uint8_t *rx_bytes, unsigned int rx_size); 27 uint8_t *rx_bytes, unsigned int rx_size);
28 28
29#endif 29#endif