2007-09-20 04:46:41 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2007-09-22 06:04:14 +00:00
|
|
|
* $Id$
|
2007-09-20 04:46:41 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Karl Kurbjun
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-09-20 04:46:41 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "cpu.h"
|
2008-09-10 20:14:22 +00:00
|
|
|
#include "adc.h"
|
2007-09-20 04:46:41 +00:00
|
|
|
#include "adc-target.h"
|
|
|
|
#include "kernel.h"
|
2009-04-28 05:07:25 +00:00
|
|
|
#include "tsc2100.h"
|
2009-12-14 07:18:55 +00:00
|
|
|
#include "system-target.h"
|
2009-04-28 05:07:25 +00:00
|
|
|
#include "button-target.h"
|
2007-09-20 04:46:41 +00:00
|
|
|
|
|
|
|
void adc_init(void)
|
|
|
|
{
|
2009-10-11 06:08:14 +00:00
|
|
|
/* Pin 15 appears to be the nPWD pin - make sure it is high otherwise the
|
|
|
|
* touchscreen does not work, audio has not been tested, but it is
|
|
|
|
* expected that is will also not work when low.
|
|
|
|
*/
|
2011-02-06 20:41:49 +00:00
|
|
|
|
2009-12-14 07:18:55 +00:00
|
|
|
IO_GIO_BITSET0 = (1<<15); /* Turn on TSC2100 */
|
2009-10-11 06:08:14 +00:00
|
|
|
|
2009-04-28 05:07:25 +00:00
|
|
|
/* Initialize the touchscreen and the battery readout */
|
|
|
|
tsc2100_adc_init();
|
|
|
|
|
|
|
|
/* Enable the tsc2100 interrupt */
|
|
|
|
IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
|
2009-12-12 18:36:52 +00:00
|
|
|
|
|
|
|
/* Read all registers to make sure they are clear */
|
|
|
|
tsc2100_read_data();
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|
|
|
|
|
2009-04-28 05:07:25 +00:00
|
|
|
/* Touchscreen data available interupt */
|
|
|
|
void GIO14(void)
|
2007-09-20 04:46:41 +00:00
|
|
|
{
|
2009-06-24 04:17:15 +00:00
|
|
|
/* Interrupts work properly when cleared first */
|
|
|
|
IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */
|
2009-12-12 18:36:52 +00:00
|
|
|
|
2009-04-28 05:07:25 +00:00
|
|
|
/* Always read all registers in one go to clear any missed flags */
|
|
|
|
tsc2100_read_data();
|
|
|
|
|
2009-12-12 18:36:52 +00:00
|
|
|
/* Stop the scan, firmware will initiate another scan with a mode set */
|
2011-02-06 20:41:49 +00:00
|
|
|
tsc2100_set_mode(true, 0x00);
|
2007-09-20 04:46:41 +00:00
|
|
|
}
|
2009-05-02 23:25:55 +00:00
|
|
|
|