mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
start of the tsc2100 driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14816 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
376169ab95
commit
d331d00a2d
8 changed files with 221 additions and 23 deletions
|
@ -38,8 +38,9 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "rbunicode.h"
|
#include "rbunicode.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
#include "spi-target.h"
|
#include "spi.h"
|
||||||
#include "uart-target.h"
|
#include "uart-target.h"
|
||||||
|
#include "tsc2100.h"
|
||||||
|
|
||||||
extern int line;
|
extern int line;
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ void main(void)
|
||||||
uartSetup();
|
uartSetup();
|
||||||
lcd_init();
|
lcd_init();
|
||||||
font_init();
|
font_init();
|
||||||
dm320_spi_init();
|
spi_init();
|
||||||
|
|
||||||
lcd_setfont(FONT_SYSFIXED);
|
lcd_setfont(FONT_SYSFIXED);
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ void main(void)
|
||||||
|
|
||||||
printf("ATA");
|
printf("ATA");
|
||||||
|
|
||||||
outw(inw(IO_GIO_DIR1)&~(1<<10), IO_GIO_DIR1); // set GIO26 to output
|
outw(inw(IO_GIO_DIR1)&~(1<<10), IO_GIO_DIR1); // set GIO26 (reset pin) to output
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
if (button_read_device() == BUTTON_POWER)
|
if (button_read_device() == BUTTON_POWER)
|
||||||
|
@ -110,20 +111,15 @@ void main(void)
|
||||||
printf("reset");
|
printf("reset");
|
||||||
outw(1<<10, IO_GIO_BITSET1);
|
outw(1<<10, IO_GIO_BITSET1);
|
||||||
}
|
}
|
||||||
|
// if ((inw(IO_GIO_BITSET0)&(1<<14)) == 0)
|
||||||
// Read X, Y, Z1, Z2 touchscreen coordinates.
|
{
|
||||||
int page = 0, address = 0;
|
short x,y,z1,z2, reg;
|
||||||
unsigned short command = 0x8000|(page << 11)|(address << 5);
|
tsc2100_read_values(&x, &y, &z1, &z2);
|
||||||
unsigned char out[] = {command >> 8, command & 0xff};
|
printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2);
|
||||||
unsigned char in[8];
|
printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff);
|
||||||
dm320_spi_block_transfer(out, sizeof(out), in, sizeof(in));
|
tsc2100_keyclick(); /* doesnt work :( */
|
||||||
|
line -= 2;
|
||||||
printf("%02x%02x %02x%02x %02x%02x %02x%02x\n",
|
}
|
||||||
in[0], in[1],
|
|
||||||
in[2], in[3],
|
|
||||||
in[4], in[5],
|
|
||||||
in[6], in[7]);
|
|
||||||
line--;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -253,6 +253,11 @@ drivers/usb/arcotg_udc.c
|
||||||
#endif /* !defined(BOOTLOADER) */
|
#endif /* !defined(BOOTLOADER) */
|
||||||
#endif /* !defined(SIMULATOR) */
|
#endif /* !defined(SIMULATOR) */
|
||||||
|
|
||||||
|
/* Other Random Hardware */
|
||||||
|
#ifdef HAVE_TSC2100
|
||||||
|
drivers/tsc2100.c
|
||||||
|
#endif
|
||||||
|
|
||||||
/* CPU Specific - By class then particular chip if applicable */
|
/* CPU Specific - By class then particular chip if applicable */
|
||||||
#if defined(CPU_SH)
|
#if defined(CPU_SH)
|
||||||
|
|
||||||
|
|
64
firmware/drivers/tsc2100.c
Normal file
64
firmware/drivers/tsc2100.c
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id: $
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Jonathan Gordon
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "cpu.h"
|
||||||
|
#include "system.h"
|
||||||
|
#include "spi.h"
|
||||||
|
#include "tsc2100.h"
|
||||||
|
|
||||||
|
/* Read X, Y, Z1, Z2 touchscreen coordinates. */
|
||||||
|
void tsc2100_read_values(short *x, short* y, short *z1, short *z2)
|
||||||
|
{
|
||||||
|
int page = 0, address = 0;
|
||||||
|
unsigned short command = 0x8000|(page << 11)|(address << 5);
|
||||||
|
unsigned char out[] = {command >> 8, command & 0xff};
|
||||||
|
unsigned char in[8];
|
||||||
|
spi_block_transfer(out, sizeof(out), in, sizeof(in));
|
||||||
|
|
||||||
|
*x = (in[0]<<8)|in[1];
|
||||||
|
*y = (in[2]<<8)|in[3];
|
||||||
|
*z1 = (in[4]<<8)|in[5];
|
||||||
|
*z2 = (in[6]<<8)|in[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
short tsc2100_readreg(int page, int address)
|
||||||
|
{
|
||||||
|
unsigned short command = 0x8000|(page << 11)|(address << 5);
|
||||||
|
unsigned char out[] = {command >> 8, command & 0xff};
|
||||||
|
unsigned char in[2];
|
||||||
|
spi_block_transfer(out, sizeof(out), in, sizeof(in));
|
||||||
|
return (in[0]<<8)|in[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void tsc2100_writereg(int page, int address, short value)
|
||||||
|
{
|
||||||
|
unsigned short command = 0x8000|(page << 11)|(address << 5);
|
||||||
|
unsigned char out[4] = {command >> 8, command & 0xff,
|
||||||
|
value >> 8, value & 0xff};
|
||||||
|
spi_block_transfer(out, sizeof(out), NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsc2100_keyclick(void)
|
||||||
|
{
|
||||||
|
// 1100 0100 0001 0000
|
||||||
|
short val = 0xC410;
|
||||||
|
tsc2100_writereg(TSAC2_PAGE, TSAC2_ADDRESS, val);
|
||||||
|
}
|
|
@ -89,6 +89,9 @@
|
||||||
/* Define this if you have a Motorola SCF5249 */
|
/* Define this if you have a Motorola SCF5249 */
|
||||||
#define CONFIG_CPU DM320
|
#define CONFIG_CPU DM320
|
||||||
|
|
||||||
|
/* Define this if you have a Texas Instruments TSC2100 touch screen */
|
||||||
|
#define HAVE_TSC2100
|
||||||
|
|
||||||
/* Define this if you want to use coldfire's i2c interface */
|
/* Define this if you want to use coldfire's i2c interface */
|
||||||
//#define CONFIG_I2C I2C_S3C2440
|
//#define CONFIG_I2C I2C_S3C2440
|
||||||
|
|
||||||
|
|
26
firmware/export/spi.h
Normal file
26
firmware/export/spi.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id: $
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Catalin Patulea
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __SPI_H__
|
||||||
|
#define __SPI_H__
|
||||||
|
|
||||||
|
int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
|
||||||
|
uint8_t *rx_bytes, unsigned int rx_size);
|
||||||
|
void spi_init(void);
|
||||||
|
|
||||||
|
#endif
|
104
firmware/export/tsc2100.h
Normal file
104
firmware/export/tsc2100.h
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id: $
|
||||||
|
*
|
||||||
|
* Copyright (C) 2007 by Jonathan Gordon
|
||||||
|
*
|
||||||
|
* All files in this archive are subject to the GNU General Public License.
|
||||||
|
* See the file COPYING in the source tree root for full license agreement.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __TSC2100_H_
|
||||||
|
#define __TSC2100_H_
|
||||||
|
|
||||||
|
/* Read X, Y, Z1, Z2 touchscreen coordinates. */
|
||||||
|
void tsc2100_read_values(short *x, short* y, short *z1, short *z2);
|
||||||
|
|
||||||
|
/* read a register */
|
||||||
|
short tsc2100_readreg(int page, int address);
|
||||||
|
/* write a value to the register */
|
||||||
|
void tsc2100_writereg(int page, int address, short value);
|
||||||
|
|
||||||
|
/* ts adc page defines (page 1, 00h ) (refer to page 40 of the datasheet) */
|
||||||
|
#define TSADC_PAGE 1
|
||||||
|
#define TSADC_ADDRESS 0x00
|
||||||
|
#define TSADC_PSTCM (1<<15)
|
||||||
|
#define TSADC_ADST (1<<14)
|
||||||
|
#define TSADC_ADSCM_MASK (0x3C00)
|
||||||
|
#define TSADC_ADSCM_SHIFT 10
|
||||||
|
#define TSADC_RESOL_MASK (0x0300)
|
||||||
|
#define TSADC_RESOL_SHIFT 8
|
||||||
|
#define TSADC_ADAVG_MASK (0x00C0)
|
||||||
|
#define TSADC_ADAVG_SHIFT 6
|
||||||
|
#define TSADC_ADCR_MASK (0x0030)
|
||||||
|
#define TSADC_ADCR_SHIFT 4
|
||||||
|
#define TSADC_PVSTC_MASK (0x000E)
|
||||||
|
#define TSADC_PVSTC_SHIFT 1
|
||||||
|
#define TSADC_AVGFS (1<<0)
|
||||||
|
|
||||||
|
/* ts status page defines (page 1, 01h ) (refer to page 41 of the datasheet) */
|
||||||
|
#define TSSTAT_PAGE 1
|
||||||
|
#define TSSTAT_ADDRESS 0x01
|
||||||
|
#define TSSTAT_PINTDAV_MASK 0xC000 /* controls the !PINTDAV pin */
|
||||||
|
#define TSSTAT_PINTDAV_SHIFT 14
|
||||||
|
/* these are all read only */
|
||||||
|
#define TSSTAT_PWRDN (1<<13)
|
||||||
|
#define TSSTAT_HCTLM (1<<12)
|
||||||
|
#define TSSTAT_DAVAIL (1<<11)
|
||||||
|
#define TSSTAT_XSTAT (1<<10)
|
||||||
|
#define TSSTAT_YSTAT (1<<9)
|
||||||
|
#define TSSTAT_Z1STAT (1<<8)
|
||||||
|
#define TSSTAT_Z2STAT (1<<7)
|
||||||
|
#define TSSTAT_B1STAT (1<<6)
|
||||||
|
#define TSSTAT_B2STAT (1<<5)
|
||||||
|
#define TSSTAT_AXSTAT (1<<4)
|
||||||
|
// Bit 3 is reserved (1<<3)
|
||||||
|
#define TSSTAT_T1STAT (1<<2)
|
||||||
|
#define TSSTAT_T2STAT (1<<1)
|
||||||
|
// Bit 0 is reserved (1<<0)
|
||||||
|
|
||||||
|
/* ts Reset Control */
|
||||||
|
#define TSRESET_PAGE 1
|
||||||
|
#define TSRESET_ADDRESS 0x04
|
||||||
|
#define TSRESET_VALUE 0xBB00
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ts audio control 2 */
|
||||||
|
#define TSAC2_PAGE 2
|
||||||
|
#define TSAC2_ADDRESS 0x04
|
||||||
|
#define TSAC2_KCLEN (1<<15)
|
||||||
|
#define TSAC2_KCLAC_MASK 0x7000
|
||||||
|
#define TSAC2_KCLSC_SHIFT 12
|
||||||
|
#define TSAC2_APGASS (1<<11)
|
||||||
|
#define TSAC2_KCLFRQ_MASK 0x0700
|
||||||
|
#define TSAC2_KCLFRQ_SHIFT 8
|
||||||
|
#define TSAC2_KCLLN_MASK 0x00F0
|
||||||
|
#define TSAC2_KCLLN_SHIFT 4
|
||||||
|
#define TSAC2_DLGAF (1<<3) /* r only */
|
||||||
|
#define TSAC2_DRGAF (1<<2) /* r only */
|
||||||
|
#define TSAC2_DASTC (1<<1)
|
||||||
|
#define TSAC2_ADGAF (1<<0) /* r only */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -31,8 +31,8 @@
|
||||||
#define clr_gio_enable() outw(GIO_TS_ENABLE, IO_GIO_BITSET1)
|
#define clr_gio_enable() outw(GIO_TS_ENABLE, IO_GIO_BITSET1)
|
||||||
#define set_gio_enable() outw(GIO_TS_ENABLE, IO_GIO_BITCLR1)
|
#define set_gio_enable() outw(GIO_TS_ENABLE, IO_GIO_BITCLR1)
|
||||||
|
|
||||||
int dm320_spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
|
int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
|
||||||
uint8_t *rx_bytes, unsigned int rx_size)
|
uint8_t *rx_bytes, unsigned int rx_size)
|
||||||
{
|
{
|
||||||
/* Activate the slave select pin */
|
/* Activate the slave select pin */
|
||||||
set_gio_enable();
|
set_gio_enable();
|
||||||
|
@ -63,7 +63,7 @@ int dm320_spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dm320_spi_init(void)
|
void spi_init(void)
|
||||||
{
|
{
|
||||||
/* Set SCLK idle level = 0 */
|
/* Set SCLK idle level = 0 */
|
||||||
IO_SERIAL0_MODE |= (1<<10);
|
IO_SERIAL0_MODE |= (1<<10);
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
void dm320_spi_init(void);
|
void spi_init(void);
|
||||||
int dm320_spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
|
int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
|
||||||
uint8_t *rx_bytes, unsigned int rx_size);
|
uint8_t *rx_bytes, unsigned int rx_size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue