Subversion Repositories NaviCtrl

Rev

Rev 141 | Rev 147 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 141 Rev 146
Line 58... Line 58...
58
#include "uart1.h"
58
#include "uart1.h"
59
#include "analog.h"
59
#include "analog.h"
60
#include "config.h"
60
#include "config.h"
Line 61... Line 61...
61
 
61
 
-
 
62
AnalogData_t AnalogData;
Line 62... Line 63...
62
AnalogData_t AnalogData;
63
u8 ADReady = 0;
63
 
64
 
64
void ADC_IRQHandler(void)
65
void ADC_IRQHandler(void)
65
{
66
{
Line 72... Line 73...
72
                AnalogData.Ch5 = ADC_GetConversionValue(ADC_Channel_5);
73
                AnalogData.Ch5 = ADC_GetConversionValue(ADC_Channel_5);
73
                AnalogData.Ch6 = ADC_GetConversionValue(ADC_Channel_6);
74
                AnalogData.Ch6 = ADC_GetConversionValue(ADC_Channel_6);
74
                AnalogData.Ch7 = ADC_GetConversionValue(ADC_Channel_7);
75
                AnalogData.Ch7 = ADC_GetConversionValue(ADC_Channel_7);
75
                DebugOut.Analog[4] = AnalogData.Ch1;
76
                DebugOut.Analog[4] = AnalogData.Ch1;
76
                ADC_ClearFlag(ADC_FLAG_ECV);
77
                ADC_ClearFlag(ADC_FLAG_ECV);
-
 
78
                ADReady = 1;
77
        }
79
        }
78
        VIC0->VAR = 0xFF;
80
        VIC0->VAR = 0xFF;
79
}
81
}
Line 80... Line 82...
80
 
82
 
Line 113... Line 115...
113
        ADC_Init(&ADC_InitStructure);
115
        ADC_Init(&ADC_InitStructure);
Line 114... Line 116...
114
 
116
 
115
        ADC_PrescalerConfig(255);  // PCLK/255  (24MHz/255 = 94.1kHZ )
117
        ADC_PrescalerConfig(255);  // PCLK/255  (24MHz/255 = 94.1kHZ )
Line -... Line 118...
-
 
118
        ADC_ITConfig(ADC_IT_ECV, ENABLE); // enable end of conversion IRQ
-
 
119
 
116
        ADC_ITConfig(ADC_IT_ECV, ENABLE); // enable end of conversion IRQ
120
        // initiate first update
Line 117... Line 121...
117
 
121
        ADReady = 0;
118
        //ADC_ConversionCmd(ADC_Conversion_Start);
122
        ADC_ConversionCmd(ADC_Conversion_Start);
Line 119... Line 123...
119
 
123
 
Line 129... Line 133...
129
        ADC_ConversionCmd(ADC_Conversion_Stop);
133
        ADC_ConversionCmd(ADC_Conversion_Stop);
130
        ADC_ITConfig(ADC_IT_ECV, DISABLE); // disable end of conversion IRQ
134
        ADC_ITConfig(ADC_IT_ECV, DISABLE); // disable end of conversion IRQ
131
        ADC_Cmd(DISABLE); // power down the ADC
135
        ADC_Cmd(DISABLE); // power down the ADC
132
        ADC_DeInit(); // reset register to default values
136
        ADC_DeInit(); // reset register to default values
133
}
137
}
-
 
138
 
-
 
139
void Analog_Update(void)
-
 
140
{
-
 
141
        if(!ADReady) return;
-
 
142
        ADReady = 0;
-
 
143
        ADC_ConversionCmd(ADC_Conversion_Start);
-
 
144
}