A bunch of improvements that make playback of the first track work
[Rockbox.git] / firmware / drivers / tsc2100.c
blob22cdcca13de135849f00d8beb59e38f7721fc5c1
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
10 * Copyright (C) 2007 by Jonathan Gordon
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
21 #include "cpu.h"
22 #include "system.h"
23 #include "spi.h"
24 #include "tsc2100.h"
26 /* Read X, Y, Z1, Z2 touchscreen coordinates. */
27 void tsc2100_read_values(short *x, short* y, short *z1, short *z2)
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(SPI_target_TSC2100,
34 out, sizeof(out), in, sizeof(in));
36 *x = (in[0]<<8)|in[1];
37 *y = (in[2]<<8)|in[3];
38 *z1 = (in[4]<<8)|in[5];
39 *z2 = (in[6]<<8)|in[7];
42 short tsc2100_readreg(int page, int address)
44 unsigned short command = 0x8000|(page << 11)|(address << 5);
45 unsigned char out[] = {command >> 8, command & 0xff};
46 unsigned char in[2];
47 spi_block_transfer(SPI_target_TSC2100,
48 out, sizeof(out), in, sizeof(in));
49 return (in[0]<<8)|in[1];
53 void tsc2100_writereg(int page, int address, short value)
55 unsigned short command = (page << 11)|(address << 5);
56 unsigned char out[4] = {command >> 8, command & 0xff,
57 value >> 8, value & 0xff};
58 spi_block_transfer(SPI_target_TSC2100,
59 out, sizeof(out), NULL, 0);
62 void tsc2100_keyclick(void)
64 // 1100 0100 0001 0000
65 short val = 0xC410;
66 tsc2100_writereg(TSAC2_PAGE, TSAC2_ADDRESS, tsc2100_readreg(TSAC2_PAGE, TSAC2_ADDRESS)&0x8000);