Rev 426 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 426 | Rev 434 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | 1 | ||
2 | #include <stdlib.h> |
2 | #include <stdlib.h> |
3 | #include <avr/io.h> |
3 | #include <avr/io.h> |
4 | #include <avr/interrupt.h> |
- | |
5 | 4 | #include <avr/interrupt.h> |
|
- | 5 | #include "analog.h" |
|
Line 6... | Line 6... | ||
6 | #include "analog.h" |
6 | #include "printf_P.h" |
7 | 7 | ||
Line 8... | Line 8... | ||
8 | volatile uint16_t Adc0, Adc1, Adc2, Adc3, Adc4, Adc5, Adc6, Adc7; |
8 | volatile uint16_t Adc0, Adc1, Adc2, Adc3, Adc4, Adc5, Adc6, Adc7; |
9 | volatile uint8_t ADReady = 1; |
9 | volatile uint8_t ADReady = 1; |
10 | 10 | ||
11 | /*****************************************************/ |
11 | /*****************************************************/ |
12 | /* Initialize Analog Digital Converter */ |
12 | /* Initialize Analog Digital Converter */ |
13 | /*****************************************************/ |
13 | /*****************************************************/ |
- | 14 | void ADC_Init(void) |
|
14 | void ADC_Init(void) |
15 | { |
15 | { |
16 | uint8_t sreg = SREG; |
16 | uint8_t sreg = SREG; |
17 | printf("\r\n ADC init..."); |
17 | // disable all interrupts before reconfiguration |
18 | // disable all interrupts before reconfiguration |
18 | cli(); |
19 | cli(); |
Line 34... | Line 35... | ||
34 | ADCSRB &= ~((1 << ADTS2)|(1 << ADTS1)|(1 << ADTS0)); |
35 | ADCSRB &= ~((1 << ADTS2)|(1 << ADTS1)|(1 << ADTS0)); |
35 | // Start AD conversion |
36 | // Start AD conversion |
36 | ADC_Enable(); |
37 | ADC_Enable(); |
37 | // restore global interrupt flags |
38 | // restore global interrupt flags |
38 | SREG = sreg; |
39 | SREG = sreg; |
- | 40 | sei(); |
|
- | 41 | printf("ok"); |
|
39 | } |
42 | } |
Line 40... | Line 43... | ||
40 | 43 | ||
41 | /*****************************************************/ |
44 | /*****************************************************/ |
42 | /* Interrupt Service Routine for ADC */ |
45 | /* Interrupt Service Routine for ADC */ |