19
小灯闪烁工程(实际程序): 为什么用宏定义? 为什么用闪烁? 不直接用亮?
20
工程文件的组织 形式
21
#ifndef GPIO_H //防止重复定义 #define GPIO_H GPIO.H #include “mcf52233.h” #include “sysinit.h” #include “GeneralFun.h ” void GPIO_Init(uint8 port,uint8 pin,uint8 direction,uint8 state); uint8 GPIO_Get(uint8 port,uint8 pin); void GPIO_Set(uint8 port,uint8 pin,uint8 state); #define PORT_NQ 0 //1.4.7 #define PORT_AN 2 //0~7 #define PORT_AS 3 //0.1.2.3 #define PORT_QS 4 //0.1.2.3 ……………………
6
扩展板
7
MCF52233核心板 (带以太网口)
8
MCF52235核心板 (带CAN接口)
9
MCF52223核心板 (带USB口)
10
写入器
11
写入程序运行界面
12
Freescale CodeWarrior 开发环境运行界面
13
二、入门导引-硬件体系
14
最小系统
15
最小系统
16
三、入门导引-编程结构
#ifndef Light_H Light.h #define Light_H #include “GPIO.h” //包含GPIO头文件 #define Light_Run_PORT PORT_TC //灯使用的端口 #define Light_Run 1 //灯使用的引脚 #define Light_Error_PORT PORT_TC //灯使用的端口 #define Light_Error 2 //灯使用的引脚 #define Light_Link_PORT PORT_LD //灯使用的端口 #define Light_Link 1 //灯使用的引脚 #define Light_ON 1 //灯暗(对应高电平) #define Light_OFF 0 //灯亮(对应低电平) void Light_Init(uint8 port,uint8 name,uint8 state); void Light_Control(uint8 port,uint8 name,uint8 state); void Light_Change(uint8 port,uint8 name); 24