summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-09-22 14:21:07 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-09-22 14:21:07 +0000
commitd331d00a2d18654ff5ea493adb194fc4a8aa5976 (patch)
tree1a83be2570035f6fc926433a487a2522223998c0 /firmware
parent376169ab957b38902f58e4e531c4600f79bd4424 (diff)
downloadrockbox-d331d00a2d18654ff5ea493adb194fc4a8aa5976.tar.gz
rockbox-d331d00a2d18654ff5ea493adb194fc4a8aa5976.zip
start of the tsc2100 driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14816 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-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
7 files changed, 208 insertions, 6 deletions
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