Subversion Repositories NaviCtrl

Rev

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

Rev 181 Rev 182
Line 57... Line 57...
57
#include "91x_lib.h"
57
#include "91x_lib.h"
58
#include "uart1.h"
58
#include "uart1.h"
59
#include "analog.h"
59
#include "analog.h"
60
#include "timer1.h"
60
#include "timer1.h"
61
#include "config.h"
61
#include "config.h"
62
#include "led.h"
-
 
Line 63... Line 62...
63
 
62
 
Line 64... Line 63...
64
AnalogData_t AnalogData;
63
AnalogData_t AnalogData;
65
 
64
 
Line 80... Line 79...
80
        VIC0->VAR = 0xFF;
79
        VIC0->VAR = 0xFF;
81
}
80
}
Line 82... Line 81...
82
 
81
 
83
void Analog_Init(void)
82
void Analog_Init(void)
84
{
83
{
Line 85... Line 84...
85
        ADC_InitTypeDef   ADC_InitStructure;   
84
        ADC_InitTypeDef   ADC_InitStructure;
86
 
85
 
87
        UART1_PutString("\r\n ADC init...");
86
        UART1_PutString("\r\n ADC init...");
88
       
87
 
89
        SCU_APBPeriphClockConfig(__GPIO4, ENABLE); // Enable the GPIO4 Clock
88
        SCU_APBPeriphClockConfig(__GPIO4, ENABLE); // Enable the GPIO4 Clock
90
       
89
 
91
        ADC_DeInit(); // reset register to default values
90
        ADC_DeInit(); // reset register to default values
92
       
91
 
93
        // configure port 4 pins as analog inputs
92
        // configure port 4 pins as analog inputs
94
        GPIO_ANAPinConfig(GPIO_ANAChannel1, ENABLE);
93
        GPIO_ANAPinConfig(GPIO_ANAChannel1, ENABLE);
95
        GPIO_ANAPinConfig(GPIO_ANAChannel2, ENABLE);
94
        GPIO_ANAPinConfig(GPIO_ANAChannel2, ENABLE);
Line 99... Line 98...
99
        GPIO_ANAPinConfig(GPIO_ANAChannel6, ENABLE);
98
        GPIO_ANAPinConfig(GPIO_ANAChannel6, ENABLE);
100
        GPIO_ANAPinConfig(GPIO_ANAChannel7, ENABLE);
99
        GPIO_ANAPinConfig(GPIO_ANAChannel7, ENABLE);
Line 101... Line 100...
101
 
100
 
102
        ADC_Cmd(ENABLE); // power on the ADC
101
        ADC_Cmd(ENABLE); // power on the ADC
103
        ADC_StandbyModeCmd(DISABLE); // disable Standby Mode
102
        ADC_StandbyModeCmd(DISABLE); // disable Standby Mode
104
        ADC_StructInit(&ADC_InitStructure);    
103
        ADC_StructInit(&ADC_InitStructure);
105
        ADC_InitStructure.ADC_Channel_1_Mode = ADC_NoThreshold_Conversion;
104
        ADC_InitStructure.ADC_Channel_1_Mode = ADC_NoThreshold_Conversion;
106
        ADC_InitStructure.ADC_Channel_2_Mode = ADC_NoThreshold_Conversion;
105
        ADC_InitStructure.ADC_Channel_2_Mode = ADC_NoThreshold_Conversion;
107
        ADC_InitStructure.ADC_Channel_3_Mode = ADC_NoThreshold_Conversion;
106
        ADC_InitStructure.ADC_Channel_3_Mode = ADC_NoThreshold_Conversion;
108
        ADC_InitStructure.ADC_Channel_4_Mode = ADC_NoThreshold_Conversion;
107
        ADC_InitStructure.ADC_Channel_4_Mode = ADC_NoThreshold_Conversion;
Line 114... Line 113...
114
        ADC_InitStructure.ADC_Conversion_Mode = ADC_Single_Mode;
113
        ADC_InitStructure.ADC_Conversion_Mode = ADC_Single_Mode;
115
        ADC_Init(&ADC_InitStructure);
114
        ADC_Init(&ADC_InitStructure);
Line 116... Line 115...
116
 
115
 
117
        ADC_PrescalerConfig(255);  // PCLK/255  (24MHz/255 = 94.1kHZ )
116
        ADC_PrescalerConfig(255);  // PCLK/255  (24MHz/255 = 94.1kHZ )
118
        ADC_ITConfig(ADC_IT_ECV, ENABLE); // enable end of conversion IRQ
117
        ADC_ITConfig(ADC_IT_ECV, ENABLE); // enable end of conversion IRQ
119
       
118
 
120
        VIC_Config(ADC_ITLine, VIC_IRQ, PRIORITY_ADC);
119
        VIC_Config(ADC_ITLine, VIC_IRQ, PRIORITY_ADC);
Line 121... Line 120...
121
        VIC_ITCmd(ADC_ITLine, ENABLE);
120
        VIC_ITCmd(ADC_ITLine, ENABLE);
122
 
121