Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
darwin_stm32_fw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
humanoides
darwin
darwin_stm32_fw
Commits
caa35aef
Commit
caa35aef
authored
10 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Solved a problem in the ADC module.
parent
66824a92
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/adc_dma.c
+18
-20
18 additions, 20 deletions
src/adc_dma.c
src/cm730_fw.c
+1
-1
1 addition, 1 deletion
src/cm730_fw.c
with
19 additions
and
21 deletions
src/adc_dma.c
+
18
−
20
View file @
caa35aef
...
...
@@ -99,28 +99,11 @@ void adc_init(void)
RCC_AHBPeriphClockCmd
(
RCC_AHBPeriph_DMA1
,
ENABLE
);
RCC_APB2PeriphClockCmd
(
RCC_APB2Periph_ADC1
,
ENABLE
);
RCC_APB2PeriphClockCmd
(
RCC_APB2Periph_ADC2
,
ENABLE
);
RCC_APB2PeriphClockCmd
(
ADC1_CH2_PORT_CLK
|
ADC1_CH3_PORT_CLK
|
ADC1_CH4_PORT_CLK
|
RCC_APB2PeriphClockCmd
(
ADC1_CH1_PORT_CLK
|
ADC1_CH2_PORT_CLK
|
ADC1_CH3_PORT_CLK
|
ADC1_CH4_PORT_CLK
|
ADC1_CH5_PORT_CLK
|
ADC1_CH6_PORT_CLK
|
ADC1_CH7_PORT_CLK
|
ADC1_CH8_PORT_CLK
,
ENABLE
);
RCC_APB2PeriphClockCmd
(
ADC2_CH1_PORT_CLK
|
ADC2_CH2_PORT_CLK
|
ADC2_CH3_PORT_CLK
|
ADC2_CH4_PORT_CLK
|
ADC2_CH5_PORT_CLK
|
ADC2_CH6_PORT_CLK
|
ADC2_CH7_PORT_CLK
|
ADC2_CH8_PORT_CLK
,
ENABLE
);
/* DMA Config */
DMA_InitStructure
.
DMA_MemoryBaseAddr
=
(
uint32_t
)
&
ram_data
[
DARWIN_MIC1_L
];
DMA_InitStructure
.
DMA_PeripheralBaseAddr
=
(
uint32_t
)
ADC_CCR_ADDRESS
;
DMA_InitStructure
.
DMA_DIR
=
DMA_DIR_PeripheralSRC
;
DMA_InitStructure
.
DMA_BufferSize
=
30
;
DMA_InitStructure
.
DMA_PeripheralInc
=
DMA_PeripheralInc_Disable
;
DMA_InitStructure
.
DMA_MemoryInc
=
DMA_MemoryInc_Enable
;
DMA_InitStructure
.
DMA_PeripheralDataSize
=
DMA_PeripheralDataSize_Word
;
DMA_InitStructure
.
DMA_MemoryDataSize
=
DMA_MemoryDataSize_Byte
;
DMA_InitStructure
.
DMA_Mode
=
DMA_Mode_Circular
;
DMA_InitStructure
.
DMA_Priority
=
DMA_Priority_High
;
DMA_InitStructure
.
DMA_M2M
=
DMA_M2M_Disable
;
DMA_Init
(
ADC_DMA_CHANNEL
,
&
DMA_InitStructure
);
/* DMA2_Stream0 enable */
DMA_Cmd
(
ADC_DMA_CHANNEL
,
ENABLE
);
/* configure GPIO */
GPIO_InitStructure
.
GPIO_Pin
=
ADC1_CH1_PIN
;
GPIO_InitStructure
.
GPIO_Mode
=
GPIO_Mode_AIN
;
...
...
@@ -198,8 +181,6 @@ void adc_init(void)
ADC_RegularChannelConfig
(
ADC2
,
ADC2_CH8
,
8
,
ADC_SampleTime_239Cycles5
);
/* Enable ADC2 external trigger conversion */
ADC_ExternalTrigConvCmd
(
ADC2
,
ENABLE
);
/* Enable ADC1 DMA */
ADC_DMACmd
(
ADC2
,
ENABLE
);
/* Enable ADC1 */
ADC_Cmd
(
ADC1
,
ENABLE
);
...
...
@@ -223,6 +204,23 @@ void adc_init(void)
/* Check the end of ADC2 calibration */
while
(
ADC_GetCalibrationStatus
(
ADC2
));
/* DMA Config */
DMA_InitStructure
.
DMA_MemoryBaseAddr
=
(
uint32_t
)
&
ram_data
[
DARWIN_MIC1_L
];
DMA_InitStructure
.
DMA_PeripheralBaseAddr
=
(
uint32_t
)
ADC_CCR_ADDRESS
;
DMA_InitStructure
.
DMA_DIR
=
DMA_DIR_PeripheralSRC
;
DMA_InitStructure
.
DMA_BufferSize
=
8
;
DMA_InitStructure
.
DMA_PeripheralInc
=
DMA_PeripheralInc_Disable
;
DMA_InitStructure
.
DMA_MemoryInc
=
DMA_MemoryInc_Enable
;
DMA_InitStructure
.
DMA_PeripheralDataSize
=
DMA_PeripheralDataSize_Word
;
DMA_InitStructure
.
DMA_MemoryDataSize
=
DMA_MemoryDataSize_Word
;
DMA_InitStructure
.
DMA_Mode
=
DMA_Mode_Circular
;
DMA_InitStructure
.
DMA_Priority
=
DMA_Priority_High
;
DMA_InitStructure
.
DMA_M2M
=
DMA_M2M_Disable
;
DMA_Init
(
ADC_DMA_CHANNEL
,
&
DMA_InitStructure
);
/* DMA2_Stream0 enable */
DMA_Cmd
(
ADC_DMA_CHANNEL
,
ENABLE
);
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConvCmd
(
ADC1
,
ENABLE
);
}
This diff is collapsed.
Click to expand it.
src/cm730_fw.c
+
1
−
1
View file @
caa35aef
...
...
@@ -50,7 +50,7 @@ int main(void)
// initialize imu
// imu_init();
// initialize adc
//
adc_init();
adc_init
();
gpio_blink_led
(
LED_5_R
,
1000
);
comm_init
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment