summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c')
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
index 0a1389a226..da3e2e9f44 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
@@ -23,27 +23,38 @@
23#include "adc.h" 23#include "adc.h"
24#include "adc-target.h" 24#include "adc-target.h"
25#include "kernel.h" 25#include "kernel.h"
26#include "tsc2100.h"
27#include "button-target.h"
26 28
27/* prototypes */ 29void read_battery_inputs(void);
28static void adc_tick(void);
29 30
30void adc_init(void) 31void adc_init(void)
31{ 32{
32 /* attach the adc reading to the tick */ 33 /* Initialize the touchscreen and the battery readout */
33 tick_add_task(adc_tick); 34 tsc2100_adc_init();
35
36 /* Enable the tsc2100 interrupt */
37 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
34} 38}
35 39
36/* Called to get the recent ADC reading */ 40/* Touchscreen data available interupt */
37inline unsigned short adc_read(int channel) 41void GIO14(void)
38{ 42{
39 return (short)channel; 43 short tsadc = tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
44 short adscm = (tsadc&TSADC_ADSCM_MASK)>>TSADC_ADSCM_SHIFT;
45
46 /* Always read all registers in one go to clear any missed flags */
47 tsc2100_read_data();
48
49 switch (adscm)
50 {
51 case 1:
52 case 2:
53 touch_read_coord();
54 break;
55 case 0x0B:
56 read_battery_inputs();
57 break;
58 }
59 IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */
40} 60}
41
42/* add this to the tick so that the ADC converts are done in the background */
43static void adc_tick(void)
44{
45}
46
47
48
49