summaryrefslogtreecommitdiff
path: root/firmware/drivers/adc.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/adc.c')
-rw-r--r--firmware/drivers/adc.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c
index adeace005b..f002be96b4 100644
--- a/firmware/drivers/adc.c
+++ b/firmware/drivers/adc.c
@@ -109,50 +109,4 @@ void adc_init(void)
109 sleep(2); /* Ensure valid readings when adc_init returns */ 109 sleep(2); /* Ensure valid readings when adc_init returns */
110} 110}
111 111
112#elif CONFIG_CPU == TCC730
113
114
115/**************************************************************************
116 **
117 ** Each channel will be updated HZ/CHANNEL_ORDER_SIZE times per second.
118 **
119 *************************************************************************/
120
121static int current_channel;
122static int current_channel_idx;
123static unsigned short adcdata[NUM_ADC_CHANNELS];
124
125#define CHANNEL_ORDER_SIZE 2
126static int channel_order[CHANNEL_ORDER_SIZE] = {6,7};
127
128static void adc_tick(void)
129{
130 if (ADCON & (1 << 3)) {
131 /* previous conversion finished? */
132 adcdata[current_channel] = ADDATA >> 6;
133 if (++current_channel_idx >= CHANNEL_ORDER_SIZE)
134 current_channel_idx = 0;
135 current_channel = channel_order[current_channel_idx];
136 int adcon = (current_channel << 4) | 1;
137 ADCON = adcon;
138 }
139}
140
141unsigned short adc_read(int channel)
142{
143 return adcdata[channel];
144}
145
146void adc_init(void)
147{
148 current_channel_idx = 0;
149 current_channel = channel_order[current_channel_idx];
150
151 ADCON = (current_channel << 4) | 1;
152
153 tick_add_task(adc_tick);
154
155 sleep(2); /* Ensure valid readings when adc_init returns */
156}
157
158#endif 112#endif