Rev 136 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
135 | killagreg | 1 | /*#######################################################################################*/ |
2 | /* !!! THIS IS NOT FREE SOFTWARE !!! */ |
||
3 | /*#######################################################################################*/ |
||
4 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
5 | // + Copyright (c) 2008 Ingo Busker, Holger Buss |
||
6 | // + Nur für den privaten Gebrauch |
||
7 | // + FOR NON COMMERCIAL USE ONLY |
||
8 | // + www.MikroKopter.com |
||
9 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
10 | // + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation), |
||
11 | // + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist. |
||
12 | // + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt |
||
13 | // + bzgl. der Nutzungsbedingungen aufzunehmen. |
||
14 | // + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen, |
||
15 | // + Verkauf von Luftbildaufnahmen, usw. |
||
16 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
17 | // + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht, |
||
18 | // + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen |
||
19 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
20 | // + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts |
||
21 | // + auf anderen Webseiten oder sonstigen Medien veröffentlicht werden, muss unsere Webseite "http://www.mikrokopter.de" |
||
22 | // + eindeutig als Ursprung verlinkt werden |
||
23 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
24 | // + Keine Gewähr auf Fehlerfreiheit, Vollständigkeit oder Funktion |
||
25 | // + Benutzung auf eigene Gefahr |
||
26 | // + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden |
||
27 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
28 | // + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur |
||
29 | // + mit unserer Zustimmung zulässig |
||
30 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
31 | // + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen |
||
32 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
33 | // + Redistributions of source code (with or without modifications) must retain the above copyright notice, |
||
34 | // + this list of conditions and the following disclaimer. |
||
35 | // + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived |
||
36 | // + from this software without specific prior written permission. |
||
37 | // + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted |
||
38 | // + for non-commercial use (directly or indirectly) |
||
39 | // + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted |
||
40 | // + with our written permission |
||
41 | // + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be |
||
42 | // + clearly linked as origin |
||
43 | // + * PORTING this software (or part of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed |
||
44 | // |
||
45 | // + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
46 | // + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
47 | // + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
48 | // + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
49 | // + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
50 | // + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
51 | // + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
52 | // + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
53 | // + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
54 | // + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
55 | // + POSSIBILITY OF SUCH DAMAGE. |
||
56 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
57 | #include "91x_lib.h" |
||
58 | #include "uart1.h" |
||
59 | #include "analog.h" |
||
60 | |||
61 | AnalogData_t AnalogData; |
||
62 | |||
63 | void ADC_IRQHandler(void) |
||
64 | { |
||
65 | if(ADC_GetFlagStatus(ADC_FLAG_ECV) == SET) |
||
66 | { |
||
67 | AnalogData.Ch1 = ADC_GetConversionValue(ADC_Channel_1); |
||
68 | AnalogData.Ch2 = ADC_GetConversionValue(ADC_Channel_2); |
||
69 | AnalogData.Ch3 = ADC_GetConversionValue(ADC_Channel_3); |
||
70 | AnalogData.Ch4 = ADC_GetConversionValue(ADC_Channel_4); |
||
71 | AnalogData.Ch5 = ADC_GetConversionValue(ADC_Channel_5); |
||
72 | AnalogData.Ch6 = ADC_GetConversionValue(ADC_Channel_6); |
||
73 | AnalogData.Ch7 = ADC_GetConversionValue(ADC_Channel_7); |
||
74 | DebugOut.Analog[4] = AnalogData.Ch1; |
||
75 | ADC_ClearFlag(ADC_FLAG_ECV); |
||
76 | } |
||
77 | VIC0->VAR = 0xFF; |
||
78 | } |
||
79 | |||
80 | void Analog_Init(void) |
||
81 | { |
||
82 | ADC_InitTypeDef ADC_InitStructure; |
||
83 | |||
84 | UART1_PutString("\r\n ADC init..."); |
||
85 | |||
86 | SCU_APBPeriphClockConfig(__GPIO4, ENABLE); // Enable the GPIO4 Clock |
||
87 | |||
88 | ADC_DeInit(); // reset register to default values |
||
89 | |||
90 | // configure port 4 pins as analog inputs |
||
91 | GPIO_ANAPinConfig(GPIO_ANAChannel1, ENABLE); |
||
92 | GPIO_ANAPinConfig(GPIO_ANAChannel2, ENABLE); |
||
93 | GPIO_ANAPinConfig(GPIO_ANAChannel3, ENABLE); |
||
94 | GPIO_ANAPinConfig(GPIO_ANAChannel4, ENABLE); |
||
95 | GPIO_ANAPinConfig(GPIO_ANAChannel5, ENABLE); |
||
96 | GPIO_ANAPinConfig(GPIO_ANAChannel6, ENABLE); |
||
97 | GPIO_ANAPinConfig(GPIO_ANAChannel7, ENABLE); |
||
98 | |||
99 | ADC_Cmd(ENABLE); // power on the ADC |
||
100 | ADC_StandbyModeCmd(DISABLE); // disable Standby Mode |
||
101 | ADC_StructInit(&ADC_InitStructure); |
||
102 | ADC_InitStructure.ADC_Channel_1_Mode = ADC_NoThreshold_Conversion; |
||
103 | ADC_InitStructure.ADC_Channel_2_Mode = ADC_NoThreshold_Conversion; |
||
104 | ADC_InitStructure.ADC_Channel_3_Mode = ADC_NoThreshold_Conversion; |
||
105 | ADC_InitStructure.ADC_Channel_4_Mode = ADC_NoThreshold_Conversion; |
||
106 | ADC_InitStructure.ADC_Channel_5_Mode = ADC_NoThreshold_Conversion; |
||
107 | ADC_InitStructure.ADC_Channel_6_Mode = ADC_NoThreshold_Conversion; |
||
108 | ADC_InitStructure.ADC_Channel_7_Mode = ADC_NoThreshold_Conversion; |
||
109 | ADC_InitStructure.ADC_Select_Channel = ADC_Channel_0; |
||
110 | ADC_InitStructure.ADC_Scan_Mode = ENABLE; // convert all selected channels |
||
111 | ADC_InitStructure.ADC_Conversion_Mode = ADC_Continuous_Mode; |
||
112 | ADC_Init(&ADC_InitStructure); |
||
113 | |||
114 | ADC_PrescalerConfig(255); // PCLK/255 (24MHz/255 = 94.1kHZ ) |
||
115 | ADC_ITConfig(ADC_IT_ECV, ENABLE); // enable end of conversion IRQ |
||
116 | |||
117 | ADC_ConversionCmd(ADC_Conversion_Start); |
||
118 | |||
119 | VIC_Config(ADC_ITLine, VIC_IRQ, 14); //low priority |
||
120 | VIC_ITCmd(ADC_ITLine, ENABLE); |
||
121 | |||
122 | UART1_PutString("ok"); |
||
123 | } |