Fix include problem
[kugel-rb.git] / firmware / export / tsc2100.h
bloba0be067409ba0177a3a6a329c296fb4ad203c991
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #ifndef __TSC2100_H_
22 #define __TSC2100_H_
24 void tsc2100_read_data(void);
25 bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2);
26 bool tsc2100_read_volt(short *bat1, short *bat2, short *aux);
27 void tsc2100_set_mode(bool poweron, unsigned char scan_mode);
28 void tsc2100_adc_init(void);
30 /* read a register */
31 short tsc2100_readreg(int page, int address);
32 /* write a value to the register */
33 void tsc2100_writereg(int page, int address, short value);
34 /* produce a key click (doesn't work?) */
35 void tsc2100_keyclick(void);
37 /* ts adc page defines (page 1, 00h ) (refer to page 40 of the datasheet) */
38 #define TSADC_PAGE 1
39 #define TSADC_ADDRESS 0x00
40 #define TSADC_PSTCM (1<<15)
41 #define TSADC_ADST (1<<14)
42 #define TSADC_ADSCM_MASK (0x3C00)
43 #define TSADC_ADSCM_SHIFT 10
44 #define TSADC_RESOL_MASK (0x0300)
45 #define TSADC_RESOL_SHIFT 8
46 #define TSADC_ADAVG_MASK (0x00C0)
47 #define TSADC_ADAVG_SHIFT 6
48 #define TSADC_ADCR_MASK (0x0030)
49 #define TSADC_ADCR_SHIFT 4
50 #define TSADC_PVSTC_MASK (0x000E)
51 #define TSADC_PVSTC_SHIFT 1
52 #define TSADC_AVGFS (1<<0)
54 /* ts status page defines (page 1, 01h ) (refer to page 41 of the datasheet) */
55 #define TSSTAT_PAGE 1
56 #define TSSTAT_ADDRESS 0x01
57 #define TSSTAT_PINTDAV_MASK 0xC000 /* controls the !PINTDAV pin */
58 #define TSSTAT_PINTDAV_SHIFT 14
59 /* these are all read only */
60 #define TSSTAT_PWRDN (1<<13)
61 #define TSSTAT_HCTLM (1<<12)
62 #define TSSTAT_DAVAIL (1<<11)
63 #define TSSTAT_XSTAT (1<<10)
64 #define TSSTAT_YSTAT (1<<9)
65 #define TSSTAT_Z1STAT (1<<8)
66 #define TSSTAT_Z2STAT (1<<7)
67 #define TSSTAT_B1STAT (1<<6)
68 #define TSSTAT_B2STAT (1<<5)
69 #define TSSTAT_AXSTAT (1<<4)
70 // Bit 3 is reserved (1<<3)
71 #define TSSTAT_T1STAT (1<<2)
72 #define TSSTAT_T2STAT (1<<1)
73 // Bit 0 is reserved (1<<0)
75 /* ts Reference Control */
76 #define TSREF_PAGE 1
77 #define TSREF_ADDRESS 0x03
78 #define TSREF_VREFM (1<<4)
79 #define TSREF_RPWUDL_SHIFT 2
80 #define TSREF_RPWDN (1<<1)
81 #define TSREF_IREFV (1<<0)
83 /* ts Reset Control */
84 #define TSRESET_PAGE 1
85 #define TSRESET_ADDRESS 0x04
86 #define TSRESET_VALUE 0xBB00
88 /* ts codec dac gain control */
89 #define TSDACGAIN_PAGE 2
90 #define TSDACGAIN_ADDRESS 0x02
91 #define VOLUME_MAX 0
92 #define VOLUME_MIN -630
94 /* ts audio control 1*/
95 #define TSAC1_PAGE 2
96 #define TSAC1_ADDRESS 0x00
98 /* ts audio control 2 */
99 #define TSAC2_PAGE 2
100 #define TSAC2_ADDRESS 0x04
101 #define TSAC2_KCLEN (1<<15)
102 #define TSAC2_KCLAC_MASK 0x7000
103 #define TSAC2_KCLSC_SHIFT 12
104 #define TSAC2_APGASS (1<<11)
105 #define TSAC2_KCLFRQ_MASK 0x0700
106 #define TSAC2_KCLFRQ_SHIFT 8
107 #define TSAC2_KCLLN_MASK 0x00F0
108 #define TSAC2_KCLLN_SHIFT 4
109 #define TSAC2_DLGAF (1<<3) /* r only */
110 #define TSAC2_DRGAF (1<<2) /* r only */
111 #define TSAC2_DASTC (1<<1)
112 #define TSAC2_ADGAF (1<<0) /* r only */
114 /* ts codec power control */
115 #define TSCPC_PAGE 2
116 #define TSCPC_ADDRESS 0x05
118 /* ts audio control 3 */
119 #define TSAC3_PAGE 2
120 #define TSAC3_ADDRESS 0x06
122 /* ts audio control 4 */
123 #define TSAC4_PAGE 2
124 #define TSAC4_ADDRESS 0x1d
125 #define TSAC4_ASTDP (1<<15)
126 #define TSAC4_DASTDP (1<<14)
127 #define TSAC4_ASSTDP (1<<13)
128 #define TSAC4_DSTDP (1<<12)
129 #define TSAC4_RESERVEDD11 (1<<11)
130 #define TSAC4_AGC_HYST_MASK 0x0c00
131 #define TSAC4_AGC_HYST_SHIFT 10
132 #define TSAC4_SHCKT_DIS (1<<8)
133 #define TSAC4_SHCKT_PD (1<<7)
134 #define TSAC4_SHCKT_FLAG (1<<6)
135 #define TSAC4_DAC_POP_RED (1<<5)
136 #define TSAC4_DAC_POP_RED_SET1 (1<<4)
137 #define TSAC4_DAC_POP_RED_SET2_MASK 0x000c
138 #define TSAC4_DAC_POP_RED_SET2_SHIFT 3
139 #define TSAC4_PGID_MASK 0x0003
140 #define TSAC4_PGID_SHIFT 0
142 /* ts audio control 5 */
143 #define TSAC5_PAGE 2
144 #define TSAC5_ADDRESS 0x1e
146 extern int tenthdb2master(int db);
147 extern void audiohw_set_master_vol(int vol_l, int vol_r);
149 #endif