9G-STM32 EWARM开发进程简介之二
六,移植STM32 LCCD工程
1,移植GPIO的IOToggle使用
A,挑选Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:workslccd-1.0.0Driversgpio.c”增加到工程;
D:workslccd-1.0.0Driversgpio.c的源码如下:
(参阅GPIO/IOToggle/main.c)
B,修正D:workslccd-1.0.0Sourcemain.c的int main(void) 的while (1)前加上:
/* Configure the GPIO ports */
GPIO_Configuration();
while (1)里边加上:
{
printf(“*** LCCD V1.0 running %d “,i++);
GPIO_Test();
}
并在文件前增加:
extern void GPIO_Configuration(void);
extern void GPIO_Test(void);
2,移植SYSTICK的使用
A,在D:workslccd-1.0.0Sourcemain.c的int main(void)增加:
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(SystemFrequency / 1000))
{
/* Capture error */
while (1);
}
B,在D:workslccd-1.0.0Sourcestm32f10x_it.c 的 void SysTick_Handler(void) 加上:
TimingDelay_Decrement(); 文件前加上:
extern void TimingDelay_Decrement(void);
C,挑选Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:workslccd-1.0.0Drivers ime.c”增加到工程;
D:workslccd-1.0.0Drivers ime.c的源码如下:
(参阅SysTick/main.c)
3,移植DMA的ADC1的使用
A,修正D:workslccd-1.0.0Sourcemain.c的int main(void) 的while (1)前加上:
/* ADC1 Configuration */
ADC_Configuration();
while (1)里边加上:
printf(“*** LCCD V1.0 running %d adc =%d mv “,i++,(unsigned int)ADC_read());
并在文件前增加:
extern void ADC_Configuration(void);
extern unsigned int ADC_read(void);
B,在D:workslccd-1.0.0Sourcestm32f10x_it.c 的 void SysTick_Handler(void) 加上:
ADC_filter();
文件前加上:
extern unsigned int ADC_filter(void);
C,在D:workslccd-1.0.0Includestm32f10x_conf.h 中,翻开注释:
#include “stm32f10x_adc.h”
#include “stm32f10x_dma.h”
D,挑选Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:workslccd-1.0.0Driversadc.c”增加到工程;
D:workslccd-1.0.0Driversadc.c的源码如下:
(参阅ADC/ADC1_DMA/main.c)
4,移植TIM的PWM使用
A,修正D:workslccd-1.0.0Sourcemain.c的int main(void) 的while (1)前加上:
/* TIM1 Configuration */
TIM2_Configuration();
/* TIM1 Configuration */
TIM2_Configuration();
并在文件前增加:
extern void TIM1_Configuration(void);
extern void TIM2_Configuration(void);
B,挑选Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:workslccd-1.0.0Drivers im.c”增加到工程;
D:workslccd-1.0.0Drivers im.c的源码如下:
(参阅TIM/PWM_Output/main.c)
5,移植EXTI的外部中止使用
A,修正D:workslccd-1.0.0Sourcemain.c的int main(void) 的while (1)前加上:
/* EXTI Configuration */
EXTI_Configuration();
并在文件前增加:
extern void EXTI_Configuration(void);
B,在D:workslccd-1.0.0Sourcestm32f10x_it.c 的 void SysTick_Handler(void) 后边加上:
void EXTI0_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line0) != RESET)
{
EXTI_PA0_IRQHandler();
/* Clear the EXTI_Line9 pending bit */
EXTI_ClearITPendingBit(EXTI_Line0);
}
}
在文件前加上:
extern void EXTI_PA0_IRQHandler(void);
C,在D:workslccd-1.0.0Includestm32f10x_it.h 的 void SysTick_Handler(void) 后边加上
void EXTI0_IRQHandler(void);
D,在D:workslccd-1.0.0Includestm32f10x_conf.h 中,翻开注释:
#include “stm32f10x_exti.h”
#include “misc.h”
E,挑选Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:workslccd-1.0.0Driversexti.c”增加到工程;
D:workslccd-1.0.0Driversexti.c的源码如下:
(NVIC/Priority/main.c)