1 /* -------------------------------- Arctic Core ------------------------------
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
6 * This source code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by the
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * -------------------------------- Arctic Core ------------------------------*/
25 #include "mpc5516.h"
\r
27 const struct tcd_t AdcGroupDMACommandConfig [ADC_NBR_OF_GROUPS];
\r
28 const struct tcd_t AdcGroupDMAResultConfig [ADC_NBR_OF_GROUPS];
\r
30 Adc_GroupStatus AdcGroupStatus[ADC_NBR_OF_GROUPS];
\r
32 /* Configuration goes here. */
\r
33 void Adc_Group0Notification (void)
\r
37 void Adc_Group1Notification (void)
\r
41 const Adc_HWConfigurationType AdcHWUnitConfiguration =
\r
44 .adcPrescale = ADC_SYSTEM_CLOCK_DIVIDE_FACTOR_8,
\r
45 .clockSource = ADC_SYSTEM_CLOCK,
\r
48 const Adc_ChannelConfigurationType AdcChannelConfiguration [ADC_NBR_OF_CHANNELS] =
\r
50 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
51 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
52 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
53 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
54 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_DISABLED},
\r
55 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
56 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
57 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
58 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
59 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
60 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
61 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
62 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
63 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
64 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
65 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
66 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
67 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
68 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
69 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
70 { ADC_CONVERSION_TIME_8_CLOCKS, 10, 0, ADC_RESOLUTION_12BITS, ADC_CALIBRATION_ENABLED},
\r
73 const Adc_ChannelType Adc_Group0ChannelList[ADC_NBR_OF_GROUP0_CHANNELS] =
\r
75 ADC_CH1, ADC_CH2, ADC_CH3, ADC_CH4, ADC_CH5, ADC_CH6, ADC_CH7
\r
78 const Adc_ChannelType Adc_Group1ChannelList[ADC_NBR_OF_GROUP1_CHANNELS] =
\r
80 ADC_CH0, ADC_CH2, ADC_CH3, ADC_CH4
\r
83 const Adc_ChannelType Adc_Group2ChannelList[ADC_NBR_OF_GROUP2_CHANNELS] =
\r
85 ADC_CH0, ADC_CH1, ADC_CH2
\r
88 const Adc_ChannelType Adc_Group3ChannelList[ADC_NBR_OF_GROUP3_CHANNELS] =
\r
90 ADC_CH0, ADC_CH1, ADC_CH2
\r
93 /* Ram buffers for command and result queues. These are located here in the
\r
94 configuration to be able to reconfigure system without recompiling the
\r
96 Adc_ValueGroupType Adc_Group0Buffer [sizeof(Adc_Group0ChannelList)/sizeof(Adc_Group0ChannelList[0])];
\r
97 Adc_CommandType Adc_Group0Commands [sizeof(Adc_Group0ChannelList)/sizeof(Adc_Group0ChannelList[0])];
\r
99 Adc_ValueGroupType Adc_Group1Buffer [sizeof(Adc_Group1ChannelList)/sizeof(Adc_Group1ChannelList[0])];
\r
100 Adc_CommandType Adc_Group1Commands [sizeof(Adc_Group1ChannelList)/sizeof(Adc_Group1ChannelList[0])];
\r
102 Adc_ValueGroupType Adc_Group2Buffer [sizeof(Adc_Group2ChannelList)/sizeof(Adc_Group2ChannelList[0])];
\r
103 Adc_CommandType Adc_Group2Commands [sizeof(Adc_Group2ChannelList)/sizeof(Adc_Group2ChannelList[0])];
\r
105 Adc_ValueGroupType Adc_Group3Buffer [sizeof(Adc_Group3ChannelList)/sizeof(Adc_Group3ChannelList[0])];
\r
106 Adc_CommandType Adc_Group3Commands [sizeof(Adc_Group3ChannelList)/sizeof(Adc_Group3ChannelList[0])];
\r
109 const Adc_GroupDefType AdcGroupConfiguration [] =
\r
111 { .accessMode = ADC_ACCESS_MODE_SINGLE, .conversionMode = ADC_CONV_MODE_ONESHOT,
\r
112 .triggerSrc = ADC_TRIGG_SRC_SW, .hwTriggerSignal = ADC_NO_HW_TRIG,
\r
113 .hwTriggerTimer = ADC_NO_TIMER,
\r
114 .groupCallback = Adc_Group0Notification,
\r
115 .streamBufferMode = ADC_NO_STREAMING, .streamNumSamples = 0,
\r
116 .channelList = Adc_Group0ChannelList,
\r
117 .resultBuffer = Adc_Group0Buffer,
\r
118 .commandBuffer = Adc_Group0Commands,
\r
119 .numberOfChannels = sizeof(Adc_Group0Commands)/sizeof(Adc_Group0Commands[0]),
\r
120 .status = &AdcGroupStatus[ADC_GROUP0],
\r
121 .dmaCommandChannel = DMA_ADC_GROUP0_COMMAND_CHANNEL,
\r
122 .dmaResultChannel = DMA_ADC_GROUP0_RESULT_CHANNEL,
\r
123 .groupDMACommands = &AdcGroupDMACommandConfig[ADC_GROUP0],
\r
124 .groupDMAResults = &AdcGroupDMAResultConfig[ADC_GROUP0]},
\r
126 { .accessMode = ADC_ACCESS_MODE_SINGLE, .conversionMode = ADC_CONV_MODE_CONTINOUS,
\r
127 .triggerSrc = ADC_TRIGG_SRC_SW, .hwTriggerSignal = ADC_NO_HW_TRIG,
\r
128 .hwTriggerTimer = ADC_NO_TIMER,
\r
129 .groupCallback = Adc_Group1Notification,
\r
130 .streamBufferMode = ADC_NO_STREAMING, .streamNumSamples = 0,
\r
131 .channelList = Adc_Group1ChannelList,
\r
132 .resultBuffer = Adc_Group1Buffer,
\r
133 .commandBuffer = Adc_Group1Commands,
\r
134 .numberOfChannels = sizeof(Adc_Group1Commands)/sizeof(Adc_Group1Commands[0]),
\r
135 .status = &AdcGroupStatus[ADC_GROUP1],
\r
136 .dmaCommandChannel = DMA_ADC_GROUP1_COMMAND_CHANNEL,
\r
137 .dmaResultChannel = DMA_ADC_GROUP1_RESULT_CHANNEL,
\r
138 .groupDMACommands = &AdcGroupDMACommandConfig[ADC_GROUP1],
\r
139 .groupDMAResults = &AdcGroupDMAResultConfig[ADC_GROUP1]}
\r
143 /******************************************************************/
\r
145 /* End of user configuration area. DO NOT modify the code below!! */
\r
147 /******************************************************************/
\r
148 const Adc_ConfigType AdcConfig [] =
\r
151 .hwConfigPtr = &AdcHWUnitConfiguration,
\r
152 .channelConfigPtr = AdcChannelConfiguration,
\r
153 .nbrOfChannels = sizeof(AdcChannelConfiguration)/sizeof(AdcChannelConfiguration[0]),
\r
154 .groupConfigPtr = AdcGroupConfiguration,
\r
155 .nbrOfGroups = sizeof(AdcGroupConfiguration)/sizeof(AdcGroupConfiguration[0])}
\r
158 /* DMA configuration. */
\r
159 const struct tcd_t AdcGroupDMACommandConfig [ADC_NBR_OF_GROUPS] =
\r
162 .SADDR = (uint32_t)Adc_Group0Commands,
\r
164 .SSIZE = DMA_TRANSFER_SIZE_32BITS,
\r
166 .DSIZE = DMA_TRANSFER_SIZE_32BITS,
\r
167 .SOFF = sizeof(Adc_CommandType),
\r
168 .NBYTES = sizeof(Adc_CommandType),
\r
169 .SLAST = -sizeof(Adc_Group0Commands),
\r
170 .DADDR = (vint32_t)&EQADC.CFPR[ADC_GROUP0].R,
\r
172 .CITER = sizeof(Adc_Group0Commands)/sizeof(Adc_Group0Commands[0]),
\r
176 .BITER = sizeof(Adc_Group0Commands)/sizeof(Adc_Group0Commands[0]),
\r
189 .SADDR = (uint32_t)Adc_Group1Commands,
\r
191 .SSIZE = DMA_TRANSFER_SIZE_32BITS,
\r
193 .DSIZE = DMA_TRANSFER_SIZE_32BITS,
\r
194 .SOFF = sizeof(Adc_CommandType),
\r
195 .NBYTES = sizeof(Adc_CommandType),
\r
196 .SLAST = -sizeof(Adc_Group1Commands),
\r
197 .DADDR = (vint32_t)&EQADC.CFPR[ADC_GROUP1].R,
\r
199 .CITER = sizeof(Adc_Group1Commands)/sizeof(Adc_Group1Commands[0]),
\r
203 .BITER = sizeof(Adc_Group1Commands)/sizeof(Adc_Group1Commands[0]),
\r
217 const struct tcd_t AdcGroupDMAResultConfig [ADC_NBR_OF_GROUPS]=
\r
220 .SADDR = (vint32_t)&EQADC.RFPR[ADC_GROUP0].R + 2,
\r
222 .SSIZE = DMA_TRANSFER_SIZE_16BITS,
\r
224 .DSIZE = DMA_TRANSFER_SIZE_16BITS,
\r
226 .NBYTES = sizeof(Adc_ValueGroupType),
\r
228 .DADDR = (uint32_t)Adc_Group0Buffer,
\r
230 .CITER = sizeof(Adc_Group0Buffer)/sizeof(Adc_Group0Buffer[0]),
\r
231 .DOFF = sizeof(Adc_ValueGroupType),
\r
232 .DLAST_SGA = -sizeof(Adc_Group0Buffer),
\r
234 .BITER = sizeof(Adc_Group0Buffer)/sizeof(Adc_Group0Buffer[0]),
\r
247 .SADDR = (vint32_t)&EQADC.RFPR[ADC_GROUP1].R + 2,
\r
249 .SSIZE = DMA_TRANSFER_SIZE_16BITS,
\r
251 .DSIZE = DMA_TRANSFER_SIZE_16BITS,
\r
253 .NBYTES = sizeof(Adc_ValueGroupType),
\r
255 .DADDR = (uint32_t)Adc_Group1Buffer,
\r
257 .CITER = sizeof(Adc_Group1Buffer)/sizeof(Adc_Group1Buffer[0]),
\r
258 .DOFF = sizeof(Adc_ValueGroupType),
\r
259 .DLAST_SGA = -sizeof(Adc_Group1Buffer),
\r
261 .BITER = sizeof(Adc_Group1Buffer)/sizeof(Adc_Group1Buffer[0]),
\r