M:Robe 500: Fix FIQ's and make the audio DMA a FIQ, simplify the ADC code and make it more reliable. Fix ADC problems on initial boot.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23948 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2009-12-12 18:36:52 +00:00
parent de159ceb3d
commit e087751b10
7 changed files with 33 additions and 63 deletions

View file

@ -28,9 +28,6 @@
/* 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)
{
@ -42,8 +39,6 @@ void tsc2100_read_data(void)
adc_status|=tsc2100_readreg(TSSTAT_PAGE, TSSTAT_ADDRESS);
adc_last_read=current_tick;
spi_block_transfer(SPI_target_TSC2100,
out, sizeof(out), (char *)adc_data, sizeof(adc_data));
@ -54,11 +49,7 @@ void tsc2100_read_data(void)
/* Read X, Y, Z1, Z2 touchscreen coordinates. */
bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
{
/* 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) ) {
if( adc_status&(3<<9) ) {
*x = adc_data[0];
*y = adc_data[1];
*z1 = adc_data[2];
@ -66,8 +57,6 @@ bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
adc_status&=~(3<<9);
adc_last_touch_read=current_tick;
return true;
} else {
return false;
@ -76,13 +65,12 @@ bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
bool tsc2100_read_volt(short *bat1, short *bat2, short *aux)
{
if( (adc_status&(7<<4)) && TIME_BEFORE(adc_last_volt_read, adc_last_read)) {
if( adc_status&(7<<4) ) {
*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;
@ -110,7 +98,7 @@ void tsc2100_set_mode(bool poweron, unsigned char scan_mode)
void tsc2100_adc_init(void)
{
/* Set the TSC2100 to read touchscreen */
tsc2100_set_mode(true, 0x01);
tsc2100_set_mode(true, 0x02);
tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS,
(0x1<<TSSTAT_PINTDAV_SHIFT) /* Data available only */
@ -132,7 +120,6 @@ short tsc2100_readreg(int page, int address)
return (in[0]<<8)|in[1];
}
void tsc2100_writereg(int page, int address, short value)
{
unsigned short command = (page << 11)|(address << 5);

View file

@ -126,7 +126,7 @@ SECTIONS
.fiqstack (NOLOAD) :
{
*(.stack)
. += 0x100;
. += 0x400;
fiq_stack = .;
} > IRAM

View file

@ -42,6 +42,9 @@ void adc_init(void)
/* Enable the tsc2100 interrupt */
IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
/* Read all registers to make sure they are clear */
tsc2100_read_data();
}
/* Touchscreen data available interupt */
@ -49,31 +52,11 @@ void GIO14(void)
{
/* Interrupts work properly when cleared first */
IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */
short tsadc = tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
short adscm = (tsadc&TSADC_ADSCM_MASK)>>TSADC_ADSCM_SHIFT;
/* Always read all registers in one go to clear any missed flags */
tsc2100_read_data();
switch (adscm)
{
case 0x01:
case 0x02:
case 0x03:
case 0x04:
case 0x05:
/* do a battery read - this will shutdown the adc till the next tick
*/
// tsc2100_set_mode(true, 0x0B);
break;
case 0x06:
case 0x07:
case 0x08:
case 0x09:
case 0x0B:
tsc2100_set_mode(true, 0x01);
break;
}
/* Stop the scan, firmware will initiate another scan with a mode set */
tsc2100_set_mode(true, 0x00);
}

View file

@ -128,7 +128,7 @@ int button_read_device(int *data)
button_read |= touchscreen_to_pixels(touch_x, touch_y, data);
}
tsc2100_set_mode(true, 0x01);
tsc2100_set_mode(true, 0x02);
/* Handle power button */
if ((IO_GIO_BITSET0&0x01) == 0) {

View file

@ -61,6 +61,9 @@ void pcm_play_dma_init(void)
IO_INTC_IRQ0 = 1 << 11;
IO_INTC_EINT0 |= 1 << 11;
/* Set this as a FIQ */
IO_INTC_FISEL0 |= 1 << 11;
IO_DSPC_HPIB_CONTROL = 1 << 10 | 1 << 9 | 1 << 8 | 1 << 7 | 1 << 3 | 1 << 0;
dsp_reset();
@ -133,7 +136,7 @@ void DSPHINT(void)
unsigned int i;
IO_INTC_IRQ0 = 1 << 11;
IO_INTC_FIQ0 = 1 << 11;
switch (dsp_message.msg)
{

View file

@ -68,17 +68,14 @@ unsigned int battery_adc_voltage(void)
current_bat2=((short)((int)(bat2<<10)/4096*6*2.5));
current_aux=((short)((int)(aux<<10)/4096*6*2.5));
}
if (TIME_BEFORE(last_tick+2*HZ, current_tick) || last_tick==0)
tsadc=tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
/* Set the TSC2100 to read voltages if not busy with pen */
if(!(tsadc & TSADC_PSTCM))
{
tsadc=tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
/* Set the TSC2100 to read voltages if not busy with pen */
if(!(tsadc & TSADC_PSTCM))
{
tsc2100_set_mode(true, 0x0B);
last_tick = current_tick;
}
tsc2100_set_mode(true, 0x0B);
last_tick = current_tick;
}
return current_voltage;

View file

@ -155,17 +155,17 @@ void fiq_handler(void)
* Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c
*/
asm volatile (
"sub lr, lr, #4 \r\n"
"stmfd sp!, {r0-r3, ip, lr} \r\n"
"mov r0, #0x00030000 \r\n"
"ldr r0, [r0, #0x510] \r\n" /* Fetch value from IO_INTC_FIQENTRY0 */
"sub r0, r0, #1 \r\n"
"ldr r1, =irqvector \r\n"
"ldr r1, [r1, r0, lsl #2] \r\n" /* Divide value by 4 (TBA0/TBA1 is set to 0) and load appropriate pointer from the vector list */
"blx r1 \r\n" /* Jump to handler */
"ldmfd sp!, {r0-r3, ip, pc}^ \r\n" /* Return from FIQ */
);
asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */
"sub sp, sp, #8 \n"); /* Reserve stack */
unsigned short addr = IO_INTC_FIQENTRY0>>2;
if(addr != 0)
{
addr--;
irqvector[addr]();
}
asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */
"ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */
"subs pc, lr, #4 \n"); /* Return from FIQ */
}
void system_reboot(void)