9G-STM32 EWARM开发过程简介之二
六,移植STM32 LCCD工程
1,移植GPIO的IOToggle应用
A,选择Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:\works\lccd-1.0.0\Drivers\gpio.c”添加到工程;
D:\works\lccd-1.0.0\Drivers\gpio.c的源码如下:
(参考GPIO/IOToggle/main.c)
B,修改D:\works\lccd-1.0.0\Source\main.c的int main(void) 的while (1)前加上:
/* Configure the GPIO ports */
GPIO_Configuration();
while (1)里面加上:
{
printf("*** LCCD V1.0 running %d \n\r",i++);
GPIO_Test();
}
并在文件前添加:
extern void GPIO_Configuration(void);
extern void GPIO_Test(void);
2,移植SYSTICK的应用
A,在D:\works\lccd-1.0.0\Source\main.c的int main(void)添加:
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(SystemFrequency / 1000))
{
/* Capture error */
while (1);
}
B,在D:\works\lccd-1.0.0\Source\stm32f10x_it.c 的 void SysTick_Handler(void) 加上:
TimingDelay_Decrement(); 文件前加上:
extern void TimingDelay_Decrement(void);
C,选择Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:\works\lccd-1.0.0\Drivers\time.c”添加到工程;
D:\works\lccd-1.0.0\Drivers\time.c的源码如下:
(参考SysTick/main.c)
3,移植DMA的ADC1的应用
A,修改D:\works\lccd-1.0.0\Source\main.c的int main(void) 的while (1)前加上:
/* ADC1 Configuration */
ADC_Configuration();
while (1)里面加上:
printf("*** LCCD V1.0 running %d adc =%d mv \n\r",i++,(unsigned int)ADC_read());
并在文件前添加:
extern void ADC_Configuration(void);
extern unsigned int ADC_read(void);
B,在D:\works\lccd-1.0.0\Source\stm32f10x_it.c 的 void SysTick_Handler(void) 加上:
ADC_filter();
文件前加上:
extern unsigned int ADC_filter(void);
C,在D:\works\lccd-1.0.0\Include\stm32f10x_conf.h 中,打开注释:
#include "stm32f10x_adc.h"
#include "stm32f10x_dma.h"
D,选择Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:\works\lccd-1.0.0\Drivers\adc.c”添加到工程;
D:\works\lccd-1.0.0\Drivers\adc.c的源码如下:
(参考ADC/ADC1_DMA/main.c)
4,移植TIM的PWM应用
A,修改D:\works\lccd-1.0.0\Source\main.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:\works\lccd-1.0.0\Drivers\tim.c”添加到工程;
D:\works\lccd-1.0.0\Drivers\tim.c的源码如下:
(参考TIM/PWM_Output/main.c)
5,移植EXTI的外部中断应用
A,修改D:\works\lccd-1.0.0\Source\main.c的int main(void) 的while (1)前加上:
/* EXTI Configuration */
EXTI_Configuration();
并在文件前添加:
extern void EXTI_Configuration(void);
B,在D:\works\lccd-1.0.0\Source\stm32f10x_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:\works\lccd-1.0.0\Include\stm32f10x_it.h 的 void SysTick_Handler(void) 后面加上
void EXTI0_IRQHandler(void);
D,在D:\works\lccd-1.0.0\Include\stm32f10x_conf.h 中,打开注释:
#include "stm32f10x_exti.h"
#include "misc.h"
E,选择Workspace”窗口下的“DRV”用“Project”->“Add Files”把“D:\works\lccd-1.0.0\Drivers\exti.c”添加到工程;
D:\works\lccd-1.0.0\Drivers\exti.c的源码如下:
(NVIC/Priority/main.c)
离线