- /****************************************Copyright (c)****************************************************
- ** Copyright ?2003~2009 Shenzhen uCdragon Technology Co.,Ltd. All Rights Reserved
- **
- ** http://www.ucdragon.com
- **
- ** 深圳市优龙科技有限公司所提供的所有服务内容旨在协助客户加速产品的研发进度,在服务过程中所提供
- ** 的任何程序、文档、测试结果、方案、支持等资料和信息,都仅供参考,客户有权不使用或自行参考修改,本公司不
- ** 提供任何的完整性、可靠性等保证,若在客户使用过程中因任何原因造成的特别的、偶然的或间接的损失,本公司不
- ** 承担任何责任。
- ** —深圳市优龙科技有限公司
- **
- **--------------File Info---------------------------------------------------------------------------------
- ** File Name: Main.c
- ** Last modified date:
- ** Last version: V1.0
- ** Description: 主函数文件
- **
- ** Modified date:
- ** Version:
- ** Descriptions:
- *********************************************************************************************************/
- #include "includes.h"
- /*********************************************************************************************************
- ** Function name: myDelay
- ** Descriptions: 驱动GPIO 翻转Demo
- ** input parameters: ulTime:延时时间
- ** output parameters: none
- ** Returned value: none
- ** Created by:
- ** Created Date:
- **--------------------------------------------------------------------------------------------------------
- ** Modified by:
- ** Modified date:
- *********************************************************************************************************/
- void myDelay (INT32U ulTime)
- {
- INT32U i;
- i = 0;
- while (ulTime--) {
- for (i = 0; i < 5000; i++);
- }
- }
- /*********************************************************************************************************
- ** Function name: main
- ** Descriptions: 驱动GPIO 翻转Demo
- ** input parameters: none
- ** output parameters: none
- ** Returned value: none
- ** Created by:
- ** Created Date
- **--------------------------------------------------------------------------------------------------------
- ** Modified by:
- ** Modified date:
- *********************************************************************************************************/
- int main (void)
- {
- SystemCoreClockUpdate();
- SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK
- | SIM_SCGC5_PORTB_MASK
- | SIM_SCGC5_PORTC_MASK
- | SIM_SCGC5_PORTD_MASK
- | SIM_SCGC5_PORTE_MASK );
-
- uart0Init(9600,0,0,8,1);
- printf("YL-KL25Z128 KEY Test start\r\n");
- PORT_ENABLE_CLK(MKL_PORTA);
- PORT_ENABLE_CLK(MKL_PORTB);
- PORT_ENABLE_CLK(MKL_PORTB); /* 使能PORT时钟 */
- PORT_ENABLE_CLK(MKL_PORTD);
-
- IO_FUN_SEL(MKL_PORTB,18,1); /* D5,D6,D7的IO配置 */
- IO_FUN_SEL(MKL_PORTB,19,1);
- IO_FUN_SEL(MKL_PORTD,1,1);
- IO_FUN_SEL(MKL_PORTD,6,1); /*K3*/
- IO_FUN_SEL(MKL_PORTA,4,1); /*K4*/
-
- GPIO_DDR_OUTPUT(MKL_PORTB,18); /* IO设置为输出模式 */
- GPIO_DDR_OUTPUT(MKL_PORTB,19);
- GPIO_DDR_OUTPUT(MKL_PORTD,1);
- GPIO_DDR_INPUT(MKL_PORTD,6);
-
- GPIO_SET(MKL_PORTB,18); /* IO设置为高电平,LED熄灭 */
- GPIO_SET(MKL_PORTB,19);
- GPIO_SET(MKL_PORTD,1);
-
- while(1)
- {
- /* 分别按下K3,K4使得D6,D5亮灭交替循环,D7闪烁 */
- if(!GPIO_GET_VALUE(MKL_PORTD,6))
- {
- GPIO_TOGGLE(MKL_PORTB,19);
- myDelay(500); //去抖
- }
- if(!GPIO_GET_VALUE(MKL_PORTA,4))
- {
- GPIO_TOGGLE(MKL_PORTB,18);
- myDelay(500); //去抖
- }
- GPIO_TOGGLE(MKL_PORTD,1);
- myDelay(200);
- }
- }
- /*********************************************************************************************************
- END FILE
- *********************************************************************************************************/
按下按键K4 , TSL1闪亮 TSL3常亮 ;