1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 /* Read X, Y, Z1, Z2 touchscreen coordinates. */
29 void tsc2100_read_values(short *x
, short* y
, short *z1
, short *z2
)
31 int page
= 0, address
= 0;
32 unsigned short command
= 0x8000|(page
<< 11)|(address
<< 5);
33 unsigned char out
[] = {command
>> 8, command
& 0xff};
35 spi_block_transfer(SPI_target_TSC2100
,
36 out
, sizeof(out
), in
, sizeof(in
));
38 *x
= (in
[0]<<8)|in
[1];
39 *y
= (in
[2]<<8)|in
[3];
40 *z1
= (in
[4]<<8)|in
[5];
41 *z2
= (in
[6]<<8)|in
[7];
44 short tsc2100_readreg(int page
, int address
)
46 unsigned short command
= 0x8000|(page
<< 11)|(address
<< 5);
47 unsigned char out
[] = {command
>> 8, command
& 0xff};
49 spi_block_transfer(SPI_target_TSC2100
,
50 out
, sizeof(out
), in
, sizeof(in
));
51 return (in
[0]<<8)|in
[1];
55 void tsc2100_writereg(int page
, int address
, short value
)
57 unsigned short command
= (page
<< 11)|(address
<< 5);
58 unsigned char out
[4] = {command
>> 8, command
& 0xff,
59 value
>> 8, value
& 0xff};
60 spi_block_transfer(SPI_target_TSC2100
,
61 out
, sizeof(out
), NULL
, 0);
64 void tsc2100_keyclick(void)
66 // 1100 0100 0001 0000
68 tsc2100_writereg(TSAC2_PAGE
, TSAC2_ADDRESS
, tsc2100_readreg(TSAC2_PAGE
, TSAC2_ADDRESS
)&0x8000);