summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2009-05-02 23:25:55 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2009-05-02 23:25:55 +0000
commitfe2319372abd6b1f96bdc3ca45e5f6fa3165d6ed (patch)
tree0b8c5e2543615640981b14a14de7bd651665b629 /firmware/drivers
parentd5f7dab2308859d98837f76f3b2374645130e082 (diff)
downloadrockbox-fe2319372abd6b1f96bdc3ca45e5f6fa3165d6ed.zip
rockbox-fe2319372abd6b1f96bdc3ca45e5f6fa3165d6ed.tar.gz
rockbox-fe2319372abd6b1f96bdc3ca45e5f6fa3165d6ed.tar.bz2
rockbox-fe2319372abd6b1f96bdc3ca45e5f6fa3165d6ed.tar.xz
M:Robe 500 - Fix some of the Keymaps, touchscreen improvements to decrease inacurate reads, add support for dynamic frequency (was running at 87.5 MHz, now it runs at 175 MHz when boosted), disable clock to unneded modules (decreased power by 20 mA), LCD turnoff now works without graphic glitches, battery ADC read now returns scaled voltage, define backlight fading
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20846 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/rtc/rtc_rx5x348ab.c4
-rw-r--r--firmware/drivers/tsc2100.c78
2 files changed, 64 insertions, 18 deletions
diff --git a/firmware/drivers/rtc/rtc_rx5x348ab.c b/firmware/drivers/rtc/rtc_rx5x348ab.c
index 286cd77..2b4e17c 100644
--- a/firmware/drivers/rtc/rtc_rx5x348ab.c
+++ b/firmware/drivers/rtc/rtc_rx5x348ab.c
@@ -36,7 +36,7 @@ void rtc_init(void)
int rtc_read_datetime(unsigned char* buf)
{
char command = ADDR_READ|ADDR_BURST; /* burst read from the start of the time/date reg */
- spi_block_transfer(SPI_target_RX5X348AB,
+ spi_block_transfer(SPI_target_RX5X348AB, true,
&command, 1, buf, 7);
return 1;
}
@@ -48,7 +48,7 @@ int rtc_write_datetime(unsigned char* buf)
data[0] = command;
for (i=1;i<8;i++)
data[i] = buf[i-1];
- spi_block_transfer(SPI_target_RX5X348AB,
+ spi_block_transfer(SPI_target_RX5X348AB, true,
data, 8, NULL, 0);
return 1;
}
diff --git a/firmware/drivers/tsc2100.c b/firmware/drivers/tsc2100.c
index 14b56b7..271a557 100644
--- a/firmware/drivers/tsc2100.c
+++ b/firmware/drivers/tsc2100.c
@@ -27,6 +27,10 @@
/* adc_data contains the last readings from the tsc2100 */
static short adc_data[10];
+static short adc_status;
+static long adc_last_read=0;
+static long adc_last_touch_read=0;
+static long adc_last_volt_read=0;
void tsc2100_read_data(void)
{
@@ -36,7 +40,11 @@ void tsc2100_read_data(void)
unsigned char out[] = {command >> 8, command & 0xff};
unsigned char *p_adc_data=(unsigned char *)&adc_data;
- spi_block_transfer(SPI_target_TSC2100,
+ adc_status|=tsc2100_readreg(TSSTAT_PAGE, TSSTAT_ADDRESS);
+
+ adc_last_read=current_tick;
+
+ spi_block_transfer(SPI_target_TSC2100, false,
out, sizeof(out), (char *)adc_data, sizeof(adc_data));
for(i=0; i<sizeof(adc_data); i+=2)
@@ -44,28 +52,55 @@ void tsc2100_read_data(void)
}
/* Read X, Y, Z1, Z2 touchscreen coordinates. */
-void tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
+bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
{
- *x = adc_data[0];
- *y = adc_data[1];
- *z1 = adc_data[2];
- *z2 = adc_data[3];
+ /* Note: This could cause problems if the current tick is not reset in ~1.3
+ * years. Noting this in the event that a suspend/resume function
+ * is added.
+ */
+ if( (adc_status&(3<<9)) && (adc_last_read - adc_last_touch_read>=0) ) {
+ *x = adc_data[0];
+ *y = adc_data[1];
+ *z1 = adc_data[2];
+ *z2 = adc_data[3];
+
+ adc_status&=~(3<<9);
+
+ adc_last_touch_read=current_tick;
+
+ return true;
+ } else {
+ return false;
+ }
}
-void tsc2100_read_volt(short *bat1, short *bat2, short *aux)
+bool tsc2100_read_volt(short *bat1, short *bat2, short *aux)
{
- *bat1 = adc_data[5];
- *bat2 = adc_data[6];
- *aux = adc_data[7];
+ if( (adc_status&(7<<4)) && TIME_BEFORE(adc_last_volt_read, adc_last_read)) {
+ *bat1 = adc_data[5];
+ *bat2 = adc_data[6];
+ *aux = adc_data[7];
+
+ adc_status&=~(7<<4);
+ adc_last_volt_read=current_tick;
+ return true;
+ } else {
+ return false;
+ }
}
-void tsc2100_set_mode(unsigned char scan_mode)
+void tsc2100_set_mode(bool poweron, unsigned char scan_mode)
{
short tsadc=(scan_mode<<TSADC_ADSCM_SHIFT)| /* mode */
(0x3<<TSADC_RESOL_SHIFT)| /* 12 bit resolution */
(0x2<<TSADC_ADCR_SHIFT )| /* 2 MHz internal clock */
(0x2<<TSADC_PVSTC_SHIFT);
+ if(!poweron)
+ {
+ tsadc|=TSADC_ADST;
+ }
+
if(scan_mode<6)
tsadc|=TSADC_PSTCM;
@@ -75,12 +110,15 @@ void tsc2100_set_mode(unsigned char scan_mode)
void tsc2100_adc_init(void)
{
/* Set the TSC2100 to read touchscreen */
- tsc2100_set_mode(0x01);
-
+ tsc2100_set_mode(true, 0x01);
+
tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS,
(0x1<<TSSTAT_PINTDAV_SHIFT) /* Data available only */
);
-
+
+ /* An additional 2 mA can be saved here by powering down vref between
+ * conversions, but it adds a click to the audio on the M:Robe 500
+ */
tsc2100_writereg(TSREF_PAGE, TSREF_ADDRESS,
TSREF_VREFM|TSREF_IREFV);
}
@@ -90,7 +128,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(SPI_target_TSC2100,
+ spi_block_transfer(SPI_target_TSC2100, false,
out, sizeof(out), in, sizeof(in));
return (in[0]<<8)|in[1];
}
@@ -101,7 +139,7 @@ void tsc2100_writereg(int page, int address, short value)
unsigned short command = (page << 11)|(address << 5);
unsigned char out[4] = {command >> 8, command & 0xff,
value >> 8, value & 0xff};
- spi_block_transfer(SPI_target_TSC2100,
+ spi_block_transfer(SPI_target_TSC2100, false,
out, sizeof(out), NULL, 0);
}
@@ -111,3 +149,11 @@ void tsc2100_keyclick(void)
//short val = 0xC410;
tsc2100_writereg(TSAC2_PAGE, TSAC2_ADDRESS, tsc2100_readreg(TSAC2_PAGE, TSAC2_ADDRESS)&0x8000);
}
+
+#ifdef HAVE_HARDWARE_BEEP
+
+void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude)
+{
+ tsc2100_keyclick();
+}
+#endif