9G-STM32 EWARM開發(fā)過程簡(jiǎn)介之二
六,移植STM32 LCCD工程
1,移植GPIO的IOToggle應(yīng)用
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的應(yīng)用
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的應(yīng)用
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應(yīng)用
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的外部中斷應(yīng)用
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)
評(píng)論